From fae9b0737730c7d8ad81aa1a05f361704717cbbe Mon Sep 17 00:00:00 2001 From: wSedlacek Date: Sat, 14 Nov 2026 14:48:16 -0800 Subject: [PATCH] fix(mobile): PR details use one native section tab control Reopened from pingdotgg/t3code#32270 and squashed onto current main. Co-Authored-By: Claude Opus 5.5 --- .../src/components/ui/SegmentedControl.tsx | 2 +- .../pull-requests/PullRequestRouteScreen.tsx | 122 ++++++++++++++---- 2 files changed, 96 insertions(+), 28 deletions(-) diff --git a/apps/mobile/src/components/ui/SegmentedControl.tsx b/apps/mobile/src/components/ui/SegmentedControl.tsx index 15883d300da4..7064ad95fc14 100644 --- a/apps/mobile/src/components/ui/SegmentedControl.tsx +++ b/apps/mobile/src/components/ui/SegmentedControl.tsx @@ -48,7 +48,7 @@ export function SegmentedControl( const option = props.options[nativeEvent.index]; if (option) props.onSelect(option.value); }} - style={{ height: props.size === "compact" ? 32 : 36 }} + style={{ height: props.size === "compact" ? 32 : 36, width: "100%" }} /> ); diff --git a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx index 8e33a5bec100..627156dbc3af 100644 --- a/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx +++ b/apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx @@ -19,7 +19,7 @@ import { import { PullRequestActivityFilters } from "./PullRequestActivityFilters"; import type { LegendListRef } from "@legendapp/list/react-native"; import { AnimatedLegendList } from "@legendapp/list/reanimated"; -import Animated from "react-native-reanimated"; +import Animated, { useAnimatedStyle, useSharedValue } from "react-native-reanimated"; import { PR_ROW_LAYOUT, PR_ROW_ENTER, @@ -133,6 +133,9 @@ import { } from "@t3tools/client-runtime/source-control-clients"; const EMPTY_IDS: readonly string[] = []; +// Matches SegmentedControl's default height so the list spacer and overlay stay aligned. +const PR_SECTION_CONTROL_HEIGHT = Platform.OS === "android" ? 40 : 36; +const PR_LIST_CONTENT_TOP_PADDING = 8; function usePullRequestActivityRows(params: PullRequestParams, filter: ActivityFilter) { const navigation = useNavigation(); @@ -399,9 +402,41 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps>>({}); + // One native control stays mounted outside the opacity-hidden tabs (Usage-style), so Liquid + // Glass selection never remounts mid-gesture. Its top tracks the active tab's scroll. + const sectionControlTop = useSharedValue(0); + const sectionControlStyle = useAnimatedStyle(() => ({ + transform: [{ translateY: sectionControlTop.value }], + })); + const syncSectionControlTop = (scrollY: number) => { + sectionControlTop.set( + PR_LIST_CONTENT_TOP_PADDING + + sectionControlReadStatusHeight.current + + sectionControlYInHeader.current - + scrollY, + ); + }; + // guidesEnabled can remap the displayed tab (guide → overview) without selectSection. + // Keep the overlay and currentScrollOffset on that tab's stored offset so spacer onLayout + // callbacks do not restore the previous tab's position. + // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- overlay follows the displayed tab when guides remap without selectSection + useEffect(() => { + const offset = scrollOffsets.current[section] ?? -contentTopInset; + currentScrollOffset.current = { tab: section, offset }; + sectionControlTop.set( + PR_LIST_CONTENT_TOP_PADDING + + sectionControlReadStatusHeight.current + + sectionControlYInHeader.current - + offset, + ); + }, [section, contentTopInset, sectionControlTop]); // AnimatedLegendList re-attaches its handle and sets state whenever its ref changes, // so an inline ref in the tab map loops the screen into "Maximum update depth exceeded". const [listRefs] = useState(() => { @@ -427,6 +462,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps { const offset = event.nativeEvent.contentOffset.y; scrollOffsets.current[tab] = offset; - if (shown(requestedSection.current) === tab) + if (shown(requestedSection.current) === tab) { currentScrollOffset.current = { tab, offset }; + syncSectionControlTop(offset); + } }} + scrollEventThrottle={16} className="flex-1" renderScrollComponent={Platform.OS === "ios" ? NativeScrollView : undefined} contentInsetAdjustmentBehavior="never" @@ -762,7 +801,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps - + { + sectionControlReadStatusHeight.current = event.nativeEvent.layout.height; + syncSectionControlTop(currentScrollOffset.current.offset); + }} + > + + {identity ? ( - {/* UIKit draws the tapped control's glass lens outside the hidden - tab's opacity, so only the visible tab mounts the control. */} - {Platform.OS !== "ios" || section === tab ? ( - - ) : ( - - )} + {/* Spacer only: the real control is overlaid outside opacity:0 tabs so + UIKit's glass lens stays on one always-mounted native control. */} + { + sectionControlYInHeader.current = event.nativeEvent.layout.y; + syncSectionControlTop(currentScrollOffset.current.offset); + setSectionControlReady(true); + }} + /> ) : null} @@ -927,6 +964,37 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps ))} + {identity && sectionControlReady ? ( + + + + + + ) : null}