Skip to content

Commit fc7da9d

Browse files
fix(mobile): Files and ZIP lists scroll their last rows clear of the bottom bar
Legend List 3.7.2 dropped the patched contentInsetStartAdjustment, so these lists moved to a manual top contentInset with contentInsetAdjustmentBehavior "never". That also dropped UIKit's automatic bottom inset (home indicator and the Files search toolbar), leaving the last rows under the search field. Add the column's bottom safe area to the manual inset, as UIKit did. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent abdab20 commit fc7da9d

5 files changed

Lines changed: 21 additions & 6 deletions

File tree

‎apps/mobile/src/components/ui/useBarInset.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ export function useContentTopInset(): number {
4848
return Platform.OS === "ios" ? (columnMetrics?.safeArea.top ?? insets.top) : 0;
4949
}
5050

51+
/** The content's bottom safe area on iOS, which a list with manual insets must add itself. */
52+
export function useContentBottomInset(): number {
53+
const insets = useSafeAreaInsets();
54+
const columnMetrics = useNativeColumnLayoutMetrics();
55+
return Platform.OS === "ios" ? (columnMetrics?.safeArea.bottom ?? insets.bottom) : 0;
56+
}
57+
5158
/** How much of the screen's bottom edge an AppBar `search` covers: iOS's bottom search toolbar. */
5259
export function useSearchToolbarInset(search: AppBarSearch | undefined): number {
5360
const { layout } = useAdaptiveWorkspaceLayout();

‎apps/mobile/src/features/files/FileTreeBrowser.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Pressable, RefreshControl, View } from "react-native";
1010
import { AppText as Text } from "../../components/ui/AppText";
1111
import { PierreEntryIcon } from "../../components/PierreEntryIcon";
1212
import { cn } from "../../lib/cn";
13-
import { useContentTopInset } from "../../components/ui/useBarInset";
13+
import { useContentBottomInset, useContentTopInset } from "../../components/ui/useBarInset";
1414
import {
1515
buildFileTree,
1616
flattenFileTree,
@@ -122,6 +122,7 @@ export function FileTreeBrowser(props: {
122122
readonly selectedPathAtPress: string | null;
123123
} | null>(null);
124124
const headerInset = useContentTopInset();
125+
const bottomInset = useContentBottomInset();
125126
const {
126127
onLoadDirectory,
127128
onPreviewFile,
@@ -214,7 +215,7 @@ export function FileTreeBrowser(props: {
214215
return (
215216
<LegendList
216217
renderScrollComponent={NativeScrollView}
217-
contentInset={{ top: headerInset }}
218+
contentInset={{ top: headerInset, bottom: bottomInset }}
218219
alwaysBounceVertical
219220
className="flex-1"
220221
data={visibleNodes}

‎apps/mobile/src/features/files/ZipArchiveView.test.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ vi.mock("../../components/ui/AppBar", () => {
127127
}) => <div>{props.menus?.map((menu) => renderItems(menu.items))}</div>,
128128
};
129129
});
130-
vi.mock("../../components/ui/useBarInset", () => ({ useContentTopInset: () => 0 }));
130+
vi.mock("../../components/ui/useBarInset", () => ({
131+
useContentTopInset: () => 0,
132+
useContentBottomInset: () => 0,
133+
}));
131134
vi.mock("../../components/ui/AppSymbol", () => ({ SymbolView: () => null }));
132135
vi.mock("../../components/ui/Progress", () => ({ Progress: () => null }));
133136
vi.mock("../../components/PierreEntryIcon", () => ({ PierreEntryIcon: () => null }));

‎apps/mobile/src/features/files/ZipArchiveView.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { Keyboard, Pressable, ScrollView, TextInput, View } from "react-native";
2121

2222
import { PierreEntryIcon } from "../../components/PierreEntryIcon";
2323
import { AppBar } from "../../components/ui/AppBar";
24-
import { useContentTopInset } from "../../components/ui/useBarInset";
24+
import { useContentBottomInset, useContentTopInset } from "../../components/ui/useBarInset";
2525
import { SymbolView } from "../../components/ui/AppSymbol";
2626
import { AppText as Text } from "../../components/ui/AppText";
2727
import { Button } from "../../components/ui/Button";
@@ -395,11 +395,12 @@ function ZipArchiveList(props: {
395395
return next;
396396
});
397397
const fileCount = archive.fileCount;
398+
const bottomInset = useContentBottomInset();
398399
return (
399400
<View className="flex-1 bg-sheet">
400401
<LegendList
401402
renderScrollComponent={NativeScrollView}
402-
contentInset={{ top: props.headerInset }}
403+
contentInset={{ top: props.headerInset, bottom: bottomInset }}
403404
className="flex-1"
404405
data={rows}
405406
keyExtractor={(row) => `${row.node.entry ? "f" : "d"}:${row.node.path}`}

‎apps/mobile/src/features/files/useFileTreeEntries.test.tsx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ vi.mock("react-native", () => ({
141141
vi.mock("react-native-safe-area-context", () => ({ useSafeAreaInsets: () => ({ top: 0 }) }));
142142
vi.mock("../../native/NativeScrollViewMarker", () => ({ NativeScrollView: Nothing }));
143143
vi.mock("../../native/native-layout-metrics", () => ({ useNativeColumnLayoutMetrics: () => null }));
144-
vi.mock("../../components/ui/useBarInset", () => ({ useContentTopInset: () => 0 }));
144+
vi.mock("../../components/ui/useBarInset", () => ({
145+
useContentTopInset: () => 0,
146+
useContentBottomInset: () => 0,
147+
}));
145148
vi.mock("@legendapp/list/react-native", () => ({
146149
LegendList: <T,>(props: {
147150
data: ReadonlyArray<T>;

0 commit comments

Comments
 (0)