Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions apps/mobile/src/features/pull-requests/PullRequestRouteScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
const navigation = useNavigation();
const insets = useSafeAreaInsets();
const [toolbarHeight, setToolbarHeight] = usePullRequestToolbarHeight(insets.bottom);
// Only iOS lists run under the bars; Android lists start below the header.
const barInsets = Platform.OS === "ios" ? insets : { top: 0, bottom: 0 };
const params = route.params;
usePullRequestEnvironmentFallback(params);
const connected = usePullRequestConnected(params.environmentId);
Expand All @@ -362,7 +364,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
// has its own offset, which only its next scroll would record here.
const currentScrollOffset = useRef<{ tab: typeof section; offset: number }>({
tab: "overview",
offset: -insets.top,
offset: -barInsets.top,
});
const bodyY = useRef(0);
const [headerHeight, setHeaderHeight] = useState(0);
Expand All @@ -386,14 +388,15 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
const current =
currentScrollOffset.current.tab === from
? currentScrollOffset.current.offset
: (scrollOffsets.current[from] ?? -insets.top);
: (scrollOffsets.current[from] ?? -barInsets.top);
scrollOffsets.current[section] = current;
const headerEnd = Math.max(-insets.top, bodyY.current - insets.top);
const headerEnd = Math.max(-barInsets.top, bodyY.current - barInsets.top);
const offset = pullRequestTabOffset(current, scrollOffsets.current[next], headerEnd);
requestedSection.current = next;
scrollOffsets.current[next] = offset;
currentScrollOffset.current = { tab: next, offset };
scrollViews.current[next]?.scrollToOffset({ offset, animated: false });
// LegendList clamps to its measured rows, which leave out the short-tab minHeight below.
scrollViews.current[next]?.getNativeScrollRef().scrollTo({ y: offset, animated: false });
setSection(next);
};
const tabContent = activityContent;
Expand Down Expand Up @@ -441,7 +444,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
});
const jumpToFiles = () => {
scrollViews.current.overview?.scrollToOffset({
offset: bodyY.current + filesY.current - insets.top,
offset: bodyY.current + filesY.current - barInsets.top,
animated: true,
});
pendingFilesJump.current = false;
Expand Down Expand Up @@ -675,7 +678,9 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
// UIKit owns the bar's inset, so a minimizing bar and a resized column
// move the list in the same frame as the bar.
contentInsetAdjustmentBehavior="automatic"
contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
contentInsetStartAdjustment={barInsets.top}
// RN scrollTo clamps against raw insets and ignores the automatic bar inset.
scrollToOverflowEnabled
refreshControl={
<RefreshControl
refreshing={section === tab && pullRefresh.refreshing}
Expand All @@ -694,7 +699,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
pendingDescriptionJump.current = false;
// Collapse changes the scroll range; restore the heading after that layout commits.
scrollViews.current.overview?.scrollToOffset({
offset: bodyY.current + descriptionY.current - insets.top,
offset: bodyY.current + descriptionY.current - barInsets.top,
animated: false,
});
}}
Expand All @@ -705,7 +710,7 @@ export function PullRequestRouteScreen({ route }: StaticScreenProps<PullRequestP
// Short tabs must still be tall enough to preserve the collapsed header.
minHeight: Math.max(
0,
viewportHeight + headerHeight - insets.top - insets.bottom,
viewportHeight + headerHeight - barInsets.top - barInsets.bottom,
),
}}
data={[
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
Expand Down
Loading