TypeScript
feat(mobile): thread header minimizes on the Duo while reading back through history (#24235)
Julius Marmingeeeda2cb2cdf7
diff --git a/apps/mobile/deps/react-native-screens-5.0.0-t3.36.tgz b/apps/mobile/deps/react-native-screens-5.0.0-t3.36.tgzdeleted file mode 100644index 071a4022a7b..00000000000Binary files a/apps/mobile/deps/react-native-screens-5.0.0-t3.36.tgz and /dev/null differdiff --git a/apps/mobile/deps/react-native-screens-5.0.0-t3.37.tgz b/apps/mobile/deps/react-native-screens-5.0.0-t3.37.tgznew file mode 100644index 00000000000..0d0076c8a3cBinary files /dev/null and b/apps/mobile/deps/react-native-screens-5.0.0-t3.37.tgz differdiff --git a/apps/mobile/package.json b/apps/mobile/package.jsonindex 87c9d3ad50b..b94b8fc0e8d 100644--- a/apps/mobile/package.json+++ b/apps/mobile/package.json@@ -134,7 +134,7 @@"react-native-pdf-jsi": "5.0.0","react-native-reanimated": "4.7.1","react-native-safe-area-context": "~5.10.1",- "react-native-screens": "file:deps/react-native-screens-5.0.0-t3.36.tgz",+ "react-native-screens": "file:deps/react-native-screens-5.0.0-t3.37.tgz","react-native-shiki-engine": "^0.3.12","react-native-svg": "15.16.0","react-native-webview": "14.0.1",diff --git a/apps/mobile/src/Stack.tsx b/apps/mobile/src/Stack.tsxindex d5a8a038fe4..4a99aca12cf 100644--- a/apps/mobile/src/Stack.tsx+++ b/apps/mobile/src/Stack.tsx@@ -147,6 +147,7 @@ const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Pltype AppScreenOptions = NativeStackNavigationOptions & {readonly unstable_navigationItemStyle?: "editor";+ readonly unstable_headerMinimizationBehavior?: "onScrollUp";};const GLASS_HEADER_OPTIONS: AppScreenOptions = {@@ -169,6 +170,13 @@ const DETAIL_HEADER_OPTIONS: AppScreenOptions = {headerShown: Platform.OS !== "android",};+// Like Messages on the Duo: reading back through history (scrolling up) minimizes the+// header, and reversing toward the latest message restores it. Other devices ignore it.+const THREAD_HEADER_OPTIONS: AppScreenOptions = {+ ...DETAIL_HEADER_OPTIONS,+ unstable_headerMinimizationBehavior: "onScrollUp",+};+const SOLID_HEADER_OPTIONS: AppScreenOptions = {headerBackButtonDisplayMode: "minimal",headerBackTitle: "",@@ -707,7 +715,7 @@ const RootStackConfig = createWorkspaceStackNavigator({Thread: createNativeStackScreen({screen: ThreadRouteScreen,linking: { path: "threads/:environmentId?/:threadId?", alias: ["new/draft"] },- options: DETAIL_HEADER_OPTIONS,+ options: THREAD_HEADER_OPTIONS,}),NewTaskProject: createNativeStackScreen({screen: NewTaskRouteScreen,diff --git a/apps/mobile/src/features/threads/ThreadFeed.tsx b/apps/mobile/src/features/threads/ThreadFeed.tsxindex 9988debe2a0..63526a732bc 100644--- a/apps/mobile/src/features/threads/ThreadFeed.tsx+++ b/apps/mobile/src/features/threads/ThreadFeed.tsx@@ -96,6 +96,7 @@ import {useRef,useState,useId,+ type ComponentPropsWithRef,type ReactNode,type RefObject,} from "react";@@ -124,6 +125,7 @@ import { FilePreviewModal, type FilePreviewSource } from "../../components/FilePimport { isPdfFile } from "../../lib/filePreview";import { flattenThemeColor } from "../../lib/mobileTheme";import { PresentationSource } from "../../components/ui/NativePresentation";+import { NativeScrollViewMarker } from "../../native/NativeScrollViewMarker";import { useSafeAreaInsets } from "react-native-safe-area-context";import Animated, { FadeIn, FadeInUp, type SharedValue } from "react-native-reanimated";import { useUniwindTheme } from "../../lib/useUniwindTheme";@@ -751,6 +753,16 @@ function MessageAttachmentUnknown(props: { readonly name: string }) {// LegendList only computes hook visibility when the list has a viewability config.const THREAD_MEDIA_VIEWABILITY_CONFIG = { itemVisiblePercentThreshold: 0 };+// The composer and overlays beside the feed keep UIKit from finding it on its own, so+// register it with the screen controller. Header minimization observes this scroll view.+function ThreadFeedScrollView(props: ComponentPropsWithRef<typeof Animated.ScrollView>) {+ return (+ <NativeScrollViewMarker style={{ flex: 1 }}>+ <Animated.ScrollView {...props} />+ </NativeScrollViewMarker>+ );+}+function ThreadMediaVisibility(props: { readonly children: ReactNode }) {const [visible, setVisible] = useState(false);useViewabilityAmount<ThreadFeedEntry>(@@ -2977,6 +2989,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {// (facebook/react-native#54123); the anchored end space after a send// is pure inset, so without this the blank region can't be scrolled.applyWorkaroundForContentInsetHitTestBug+ {...(Platform.OS === "ios" ? { ScrollViewComponent: ThreadFeedScrollView } : {})}// Horizontal Duo reservations are already included in the row padding.contentInsetAdjustmentBehavior={usesNativeAutomaticInsetsdiff --git a/apps/mobile/src/native/StackHeader.tsx b/apps/mobile/src/native/StackHeader.tsxindex ae9783f39dd..1b4d3c381a9 100644--- a/apps/mobile/src/native/StackHeader.tsx+++ b/apps/mobile/src/native/StackHeader.tsx@@ -26,6 +26,7 @@ export type AppNativeStackNavigationOptions = Omit<readonly unstable_headerSubtitle?: unknown;readonly unstable_headerToolbarItems?: unknown;readonly unstable_navigationItemStyle?: unknown;+ readonly unstable_headerMinimizationBehavior?: unknown;};function useNativeStackNavigation(): NativeStackNavigationProp<ParamListBase> | null {diff --git a/apps/mobile/src/native/V5StackHeader.ios.tsx b/apps/mobile/src/native/V5StackHeader.ios.tsxindex 13720678c3f..479ad3dce1a 100644--- a/apps/mobile/src/native/V5StackHeader.ios.tsx+++ b/apps/mobile/src/native/V5StackHeader.ios.tsx@@ -5,6 +5,7 @@ import type {} from "@react-navigation/native-stack";import { isValidElement, useEffect, useRef } from "react";import { StyleSheet } from "react-native";+import { isDuoDevice } from "../lib/device-type";import { useMobileNavigationTheme } from "../lib/useMobileNavigationTheme";import { useDeviceType, useNativeLayoutMetrics } from "../native/native-layout-metrics";import {@@ -13,6 +14,7 @@ import {type HeaderBarButtonMailSearchToolbarItem,type SearchBarCommands,type StackHeaderConfigProps,+ type StackHeaderMinimizationBehaviorIOS,type StackHeaderMenuElementIOS,type StackHeaderMenuIOS,type HeaderBarButtonItemWithMenu,@@ -26,6 +28,7 @@ type ToolbarItem =| HeaderBarButtonSearchBarPlacementItem;type Options = NativeStackNavigationOptions & {readonly unstable_navigationItemStyle?: "editor" | "navigator";+ readonly unstable_headerMinimizationBehavior?: StackHeaderMinimizationBehaviorIOS;readonly headerSubtitle?: string;readonly unstable_headerSubtitle?: string;readonly headerSubtitleStyle?: { color?: string; fontSize?: number; fontFamily?: string };@@ -279,6 +282,10 @@ export function V5StackHeader(props: {backButtonHidden={options.headerBackVisible === false}ios={{navigationItemStyle: options.unstable_navigationItemStyle,+ // Opt-ins apply only on the Duo's short display; unset falls back to the system default.+ minimizationBehavior: isDuoDevice(deviceType)+ ? options.unstable_headerMinimizationBehavior+ : undefined,tintColor: options.headerTintColor,searchBar:mailSearch || searchOptions ? (diff --git a/docs/operations/mobile-screens-fork.md b/docs/operations/mobile-screens-fork.mdindex d7d0313a592..3a2b1adf952 100644--- a/docs/operations/mobile-screens-fork.md+++ b/docs/operations/mobile-screens-fork.md@@ -1,7 +1,7 @@# Building the mobile Screens dependencyThe mobile v5 stack uses a committed tarball from the-[T3 Screens fork](https://github.com/pingdotgg/react-native-screens/tree/t3-v5.0.0-t3.36).+[T3 Screens fork](https://github.com/pingdotgg/react-native-screens/tree/t3-v5.0.0-t3.37).The fork owns the integration changes; the app does not patch this package.Each archive includes compiled JavaScript, declarations, native source and`t3-fork.json` recording its version, source commit and upstream base.diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex d440b8830fe..5125b6af46c 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -553,7 +553,7 @@ importers:version: 7.5.1([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])'@react-navigation/native-stack':specifier: 7.21.0- version: 7.21.0(patch_hash=990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42)(717295d9841cbe75b29e7bc95e2e9d14)+ version: 7.21.0(patch_hash=990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42)(110925a0d7a34aa12f32b4b743079ccc)'@shikijs/core':specifier: 4.2.0version: 4.2.0@@ -765,8 +765,8 @@ importers:specifier: ~5.10.1version: 5.10.1([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])react-native-screens:- specifier: file:deps/react-native-screens-5.0.0-t3.36.tgz- version: file:apps/mobile/deps/react-native-screens-5.0.0-t3.36.tgz([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])+ specifier: file:deps/react-native-screens-5.0.0-t3.37.tgz+ version: file:apps/mobile/deps/react-native-screens-5.0.0-t3.37.tgz([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])react-native-shiki-engine:specifier: ^0.3.12version: 0.3.12([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])@@ -10675,9 +10675,9 @@ packages:react: '*'react-native: '*'- react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.36.tgz:- resolution: {integrity: sha512-Fkd/KBWVC8NrGc3sBL7JdK5Zn1+2cw5tU0NxXWlqdkjjar5BntiQNU+NBvALM+NUnB4q7oHykYCQjW4Nk6i67A==, tarball: file:apps/mobile/deps/react-native-screens-5.0.0-t3.36.tgz}- version: 5.0.0-t3.36+ react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.37.tgz:+ resolution: {integrity: sha512-LMm9e8lHseFaUYKF4tFkGkqpJFu36uwp6ZGQgBYksn+pmcx0voaSMkK0tGaZ59LFXXD2TGoBR3K9kAX++72Xig==, tarball: file:apps/mobile/deps/react-native-screens-5.0.0-t3.37.tgz}+ version: 5.0.0-t3.37peerDependencies:react: '*'react-native: '*'@@ -15618,7 +15618,7 @@ snapshots:optionalDependencies:'@react-native-masked-view/masked-view': 0.3.2([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])- '@react-navigation/[email protected](patch_hash=990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42)(717295d9841cbe75b29e7bc95e2e9d14)':+ '@react-navigation/[email protected](patch_hash=990d575444c4af2ce8218b3b7a8280fe244c03abbdb32b822a2e862f791dbf42)(110925a0d7a34aa12f32b4b743079ccc)':dependencies:'@react-navigation/elements': 2.9.45(d8845bac868f4d8a58c8a8f12ad0d4a5)'@react-navigation/native': 7.5.1([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])@@ -15626,7 +15626,7 @@ snapshots:react: 19.3.0react-native: 0.88.0(@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected])react-native-safe-area-context: 5.10.1([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])- react-native-screens: file:apps/mobile/deps/react-native-screens-5.0.0-t3.36.tgz([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])+ react-native-screens: file:apps/mobile/deps/react-native-screens-5.0.0-t3.37.tgz([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected])sf-symbols-typescript: 2.2.0warn-once: 0.1.1transitivePeerDependencies:@@ -21212,7 +21212,7 @@ snapshots:react: 19.3.0react-native: 0.88.0(@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected])- react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.36.tgz([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]):+ react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.37.tgz([email protected](@babel/[email protected]([email protected]))(@react-native/[email protected](@babel/[email protected]([email protected]))([email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]):dependencies:react: 19.3.0react-freeze: 1.0.4([email protected])