Skip to content

Commit eeda2cb

Browse files
feat(mobile): thread header minimizes on the Duo while reading back through history (#24235)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 96ffd7a commit eeda2cb

9 files changed

Lines changed: 41 additions & 12 deletions

File tree

-769 KB
Binary file not shown.
769 KB
Binary file not shown.

‎apps/mobile/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
"react-native-pdf-jsi": "5.0.0",
135135
"react-native-reanimated": "4.7.1",
136136
"react-native-safe-area-context": "~5.10.1",
137-
"react-native-screens": "file:deps/react-native-screens-5.0.0-t3.36.tgz",
137+
"react-native-screens": "file:deps/react-native-screens-5.0.0-t3.37.tgz",
138138
"react-native-shiki-engine": "^0.3.12",
139139
"react-native-svg": "15.16.0",
140140
"react-native-webview": "14.0.1",

‎apps/mobile/src/Stack.tsx‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ const HEADER_SCROLL_EDGE_EFFECTS = nativeHeaderScrollEdgeEffects(Platform.OS, Pl
147147

148148
type AppScreenOptions = NativeStackNavigationOptions & {
149149
readonly unstable_navigationItemStyle?: "editor";
150+
readonly unstable_headerMinimizationBehavior?: "onScrollUp";
150151
};
151152

152153
const GLASS_HEADER_OPTIONS: AppScreenOptions = {
@@ -169,6 +170,13 @@ const DETAIL_HEADER_OPTIONS: AppScreenOptions = {
169170
headerShown: Platform.OS !== "android",
170171
};
171172

173+
// Like Messages on the Duo: reading back through history (scrolling up) minimizes the
174+
// header, and reversing toward the latest message restores it. Other devices ignore it.
175+
const THREAD_HEADER_OPTIONS: AppScreenOptions = {
176+
...DETAIL_HEADER_OPTIONS,
177+
unstable_headerMinimizationBehavior: "onScrollUp",
178+
};
179+
172180
const SOLID_HEADER_OPTIONS: AppScreenOptions = {
173181
headerBackButtonDisplayMode: "minimal",
174182
headerBackTitle: "",
@@ -707,7 +715,7 @@ const RootStackConfig = createWorkspaceStackNavigator({
707715
Thread: createNativeStackScreen({
708716
screen: ThreadRouteScreen,
709717
linking: { path: "threads/:environmentId?/:threadId?", alias: ["new/draft"] },
710-
options: DETAIL_HEADER_OPTIONS,
718+
options: THREAD_HEADER_OPTIONS,
711719
}),
712720
NewTaskProject: createNativeStackScreen({
713721
screen: NewTaskRouteScreen,

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ import {
9696
useRef,
9797
useState,
9898
useId,
99+
type ComponentPropsWithRef,
99100
type ReactNode,
100101
type RefObject,
101102
} from "react";
@@ -124,6 +125,7 @@ import { FilePreviewModal, type FilePreviewSource } from "../../components/FileP
124125
import { isPdfFile } from "../../lib/filePreview";
125126
import { flattenThemeColor } from "../../lib/mobileTheme";
126127
import { PresentationSource } from "../../components/ui/NativePresentation";
128+
import { NativeScrollViewMarker } from "../../native/NativeScrollViewMarker";
127129
import { useSafeAreaInsets } from "react-native-safe-area-context";
128130
import Animated, { FadeIn, FadeInUp, type SharedValue } from "react-native-reanimated";
129131
import { useUniwindTheme } from "../../lib/useUniwindTheme";
@@ -751,6 +753,16 @@ function MessageAttachmentUnknown(props: { readonly name: string }) {
751753
// LegendList only computes hook visibility when the list has a viewability config.
752754
const THREAD_MEDIA_VIEWABILITY_CONFIG = { itemVisiblePercentThreshold: 0 };
753755

756+
// The composer and overlays beside the feed keep UIKit from finding it on its own, so
757+
// register it with the screen controller. Header minimization observes this scroll view.
758+
function ThreadFeedScrollView(props: ComponentPropsWithRef<typeof Animated.ScrollView>) {
759+
return (
760+
<NativeScrollViewMarker style={{ flex: 1 }}>
761+
<Animated.ScrollView {...props} />
762+
</NativeScrollViewMarker>
763+
);
764+
}
765+
754766
function ThreadMediaVisibility(props: { readonly children: ReactNode }) {
755767
const [visible, setVisible] = useState(false);
756768
useViewabilityAmount<ThreadFeedEntry>(
@@ -2977,6 +2989,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
29772989
// (facebook/react-native#54123); the anchored end space after a send
29782990
// is pure inset, so without this the blank region can't be scrolled.
29792991
applyWorkaroundForContentInsetHitTestBug
2992+
{...(Platform.OS === "ios" ? { ScrollViewComponent: ThreadFeedScrollView } : {})}
29802993
// Horizontal Duo reservations are already included in the row padding.
29812994
contentInsetAdjustmentBehavior={
29822995
usesNativeAutomaticInsets

‎apps/mobile/src/native/StackHeader.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export type AppNativeStackNavigationOptions = Omit<
2626
readonly unstable_headerSubtitle?: unknown;
2727
readonly unstable_headerToolbarItems?: unknown;
2828
readonly unstable_navigationItemStyle?: unknown;
29+
readonly unstable_headerMinimizationBehavior?: unknown;
2930
};
3031

3132
function useNativeStackNavigation(): NativeStackNavigationProp<ParamListBase> | null {

‎apps/mobile/src/native/V5StackHeader.ios.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
} from "@react-navigation/native-stack";
66
import { isValidElement, useEffect, useRef } from "react";
77
import { StyleSheet } from "react-native";
8+
import { isDuoDevice } from "../lib/device-type";
89
import { useMobileNavigationTheme } from "../lib/useMobileNavigationTheme";
910
import { useDeviceType, useNativeLayoutMetrics } from "../native/native-layout-metrics";
1011
import {
@@ -13,6 +14,7 @@ import {
1314
type HeaderBarButtonMailSearchToolbarItem,
1415
type SearchBarCommands,
1516
type StackHeaderConfigProps,
17+
type StackHeaderMinimizationBehaviorIOS,
1618
type StackHeaderMenuElementIOS,
1719
type StackHeaderMenuIOS,
1820
type HeaderBarButtonItemWithMenu,
@@ -26,6 +28,7 @@ type ToolbarItem =
2628
| HeaderBarButtonSearchBarPlacementItem;
2729
type Options = NativeStackNavigationOptions & {
2830
readonly unstable_navigationItemStyle?: "editor" | "navigator";
31+
readonly unstable_headerMinimizationBehavior?: StackHeaderMinimizationBehaviorIOS;
2932
readonly headerSubtitle?: string;
3033
readonly unstable_headerSubtitle?: string;
3134
readonly headerSubtitleStyle?: { color?: string; fontSize?: number; fontFamily?: string };
@@ -279,6 +282,10 @@ export function V5StackHeader(props: {
279282
backButtonHidden={options.headerBackVisible === false}
280283
ios={{
281284
navigationItemStyle: options.unstable_navigationItemStyle,
285+
// Opt-ins apply only on the Duo's short display; unset falls back to the system default.
286+
minimizationBehavior: isDuoDevice(deviceType)
287+
? options.unstable_headerMinimizationBehavior
288+
: undefined,
282289
tintColor: options.headerTintColor,
283290
searchBar:
284291
mailSearch || searchOptions ? (

‎docs/operations/mobile-screens-fork.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Building the mobile Screens dependency
22

33
The mobile v5 stack uses a committed tarball from the
4-
[T3 Screens fork](https://github.com/pingdotgg/react-native-screens/tree/t3-v5.0.0-t3.36).
4+
[T3 Screens fork](https://github.com/pingdotgg/react-native-screens/tree/t3-v5.0.0-t3.37).
55
The fork owns the integration changes; the app does not patch this package.
66
Each archive includes compiled JavaScript, declarations, native source and
77
`t3-fork.json` recording its version, source commit and upstream base.

‎pnpm-lock.yaml‎

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)