Skip to content

Commit 468ade3

Browse files
feat(mobile): adopt v5 navigation and native iPad columns (#16733)
1 parent a9fb6a8 commit 468ade3

47 files changed

Lines changed: 1916 additions & 2408 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
750 KB
Binary file not shown.

‎apps/mobile/fingerprint.config.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ if (!majorVersion) {
1414
}
1515

1616
module.exports = {
17+
// Hash the pinned Screens fork's native source, rather than only its version.
18+
nativeModuleSourceType: "files",
1719
extraSources: [{ type: "contents", id: "appMajorVersion", contents: majorVersion }],
1820
};

‎apps/mobile/modules/t3-markdown-text/ios/T3MarkdownText.mm‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ @implementation T3MarkdownText {
287287
UILongPressGestureRecognizer *_longPressGestureRecognizer;
288288
UITapGestureRecognizer *_pressGestureRecognizer;
289289
NSArray *_contextAccessibilityElements;
290+
BOOL _textLayoutNeedsUpdate;
290291
}
291292

292293
+ (ComponentDescriptorProvider)componentDescriptorProvider
@@ -384,16 +385,18 @@ - (void)prepareForRecycle
384385
_textView.frame = CGRectZero;
385386
_textView.attributedText = nil;
386387
_contextAccessibilityElements = nil;
388+
_textLayoutNeedsUpdate = YES;
387389
}
388390

389391
- (void)layoutSubviews
390392
{
391393
[super layoutSubviews];
392-
// _textView's frame is assigned inside drawRect, which only fires when
393-
// state changes. Trigger a redraw whenever the host frame moves out from
394-
// under it (rotation, parent relayout) so the text view resizes and
395-
// onTextLayout re-fires with the new line wrapping.
394+
// Resize during UIKit's layout pass. Doing this in drawRect can leave the
395+
// text view's drawing surface clipped to its previous width after a pane
396+
// expands, even though TextKit has already rewrapped the lines.
396397
if (!CGRectEqualToRect(_textView.frame, _view.frame)) {
398+
_textView.frame = _view.frame;
399+
_textLayoutNeedsUpdate = YES;
397400
[self setNeedsDisplay];
398401
}
399402
}
@@ -455,7 +458,7 @@ - (void)drawRect:(CGRect)rect
455458
// entirely when nothing actually changed so a JS-side state update made in
456459
// response to onSelectionChange doesn't deselect what the user is selecting.
457460
const BOOL textChanged = ![_textView.attributedText isEqualToAttributedString:convertedAttrString];
458-
const BOOL frameChanged = !CGRectEqualToRect(_textView.frame, _view.frame);
461+
const BOOL frameChanged = _textLayoutNeedsUpdate;
459462
if (!textChanged && !frameChanged) {
460463
return;
461464
}
@@ -482,9 +485,9 @@ - (void)drawRect:(CGRect)rect
482485
_suppressSelectionChange = NO;
483486
}
484487
if (frameChanged) {
485-
_textView.frame = _view.frame;
486488
_textView.textContainer.size = CGSizeMake(CGRectGetWidth(_view.frame), CGFLOAT_MAX);
487489
}
490+
_textLayoutNeedsUpdate = NO;
488491

489492
// Text attachments have no native link element. Expose their existing runs
490493
// at the measured glyph bounds, without inserting views into text layout.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import ExpoModulesCore
2+
import UIKit
3+
4+
/// Reports the body geometry of a native navigation column.
5+
final class T3LayoutMetricsView: ExpoView {
6+
let onMetricsChange = EventDispatcher()
7+
private var lastMetrics: NSDictionary?
8+
9+
required init(appContext: AppContext? = nil) {
10+
super.init(appContext: appContext)
11+
isUserInteractionEnabled = false
12+
registerForTraitChanges([UITraitHorizontalSizeClass.self, UITraitVerticalSizeClass.self]) { (view: T3LayoutMetricsView, _: UITraitCollection) in
13+
view.publishMetrics()
14+
}
15+
}
16+
17+
override func didMoveToWindow() {
18+
super.didMoveToWindow()
19+
lastMetrics = nil
20+
publishMetrics()
21+
}
22+
23+
override func layoutSubviews() {
24+
super.layoutSubviews()
25+
publishMetrics()
26+
}
27+
28+
override func safeAreaInsetsDidChange() {
29+
super.safeAreaInsetsDidChange()
30+
publishMetrics()
31+
}
32+
33+
private func publishMetrics() {
34+
guard window != nil, bounds.width > 0, bounds.height > 0 else { return }
35+
let metrics: [String: Any] = [
36+
"width": bounds.width, "height": bounds.height,
37+
"horizontalSizeClass": traitCollection.horizontalSizeClass == .regular ? "regular" : "compact",
38+
"safeArea": [
39+
"top": safeAreaInsets.top, "bottom": safeAreaInsets.bottom,
40+
"left": safeAreaInsets.left, "right": safeAreaInsets.right,
41+
],
42+
]
43+
let next = metrics as NSDictionary
44+
guard lastMetrics?.isEqual(next) != true else { return }
45+
lastMetrics = next
46+
onMetricsChange(metrics)
47+
}
48+
}

‎apps/mobile/modules/t3-native-controls/ios/T3NativeControlsModule.swift‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ public final class T3NativeControlsModule: Module {
1111
private var filePresentation: T3NativeFilePresentation?
1212

1313
public func definition() -> ModuleDefinition {
14+
Constants {
15+
if #available(iOS 26.0, *) {
16+
return ["supportsWorkspaceColumns": NSClassFromString("RNSSplitHostComponentView") != nil]
17+
}
18+
return ["supportsWorkspaceColumns": false]
19+
}
20+
View(T3LayoutMetricsView.self) {
21+
ViewName("LayoutMetrics")
22+
Events("onMetricsChange")
23+
}
24+
1425
AsyncFunction("presentVideo") { (url: URL, title: String, sourceIdentifier: String, identifier: String, promise: Promise) in
1526
try self.presentVideo(
1627
url: url,

‎apps/mobile/package.json‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
"react-native-nitro-modules": "0.35.9",
121121
"react-native-reanimated": "4.7.0",
122122
"react-native-safe-area-context": "~5.9.1",
123-
"react-native-screens": "~4.28.0",
123+
"react-native-screens": "file:deps/react-native-screens-5.0.0-t3.7.tgz",
124124
"react-native-shiki-engine": "^0.3.12",
125125
"react-native-svg": "15.15.5",
126126
"react-native-webview": "14.0.1",
@@ -142,7 +142,8 @@
142142
"install": {
143143
"exclude": [
144144
"react-native-keyboard-controller",
145-
"typescript"
145+
"typescript",
146+
"react-native-screens"
146147
]
147148
},
148149
"autolinking": {

‎apps/mobile/src/Stack.tsx‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import {
2+
createV5StackNavigator as createNativeStackNavigator,
3+
createV5SheetStackNavigator,
4+
} from "./native/createV5StackNavigator";
5+
import { createWorkspaceStackNavigator } from "./features/layout/createWorkspaceStackNavigator";
16
import {
27
createPathConfigForStaticNavigation,
38
getPathFromState,
@@ -6,7 +11,6 @@ import {
611
useNavigation,
712
} from "@react-navigation/native";
813
import {
9-
createNativeStackNavigator,
1014
createNativeStackScreen,
1115
type NativeStackNavigationOptions,
1216
} from "@react-navigation/native-stack";
@@ -189,7 +193,7 @@ const LEGAL_DOCUMENT_HEADER_OPTIONS: AppScreenOptions = {
189193
presentation: "fullScreenModal",
190194
};
191195

192-
const SettingsContentStack = createNativeStackNavigator({
196+
const SettingsContentStack = createV5SheetStackNavigator({
193197
initialRouteName: "Settings",
194198
screenOptions: {
195199
...GLASS_HEADER_OPTIONS,
@@ -399,7 +403,7 @@ const SettingsContentStack = createNativeStackNavigator({
399403
// The outer stack never owns visible chrome. Settings routes render inside a
400404
// nested stack whose native header remains mounted, while Clerk owns auth chrome.
401405
// Keeping bar visibility invariant avoids iOS 26's headerless-to-headered jump.
402-
const SettingsSheetStack = createNativeStackNavigator({
406+
const SettingsSheetStack = createV5SheetStackNavigator({
403407
initialRouteName: "SettingsContent",
404408
screenOptions: {
405409
headerShown: false,
@@ -670,7 +674,7 @@ function NotFoundScreen() {
670674
);
671675
}
672676

673-
const RootStackConfig = createNativeStackNavigator({
677+
const RootStackConfig = createWorkspaceStackNavigator({
674678
initialRouteName: "Home",
675679
layout: RootStackLayout,
676680
screenOptions: {

‎apps/mobile/src/components/CompactBrandTitle.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { NATIVE_WORKSPACE_COLUMNS_SUPPORTED } from "../native/NativeWorkspaceColumns";
12
import Constants from "expo-constants";
23
import type { NativeStackNavigationOptions } from "@react-navigation/native-stack";
34
import { Platform, View } from "react-native";
@@ -14,7 +15,7 @@ import { useAndroidControlSizing } from "./useAndroidControlSizing";
1415
*/
1516
export function brandTitleOffset(): number {
1617
if (Platform.OS !== "ios") return 0;
17-
return Platform.isPad ? IPAD_HOME_TITLE_OFFSET : 0;
18+
return Platform.isPad && !NATIVE_WORKSPACE_COLUMNS_SUPPORTED ? IPAD_HOME_TITLE_OFFSET : 0;
1819
}
1920

2021
/**

‎apps/mobile/src/components/ScreenHeader.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ export function ScreenHeader(props: ScreenHeaderProps) {
5353
]}
5454
options={{
5555
headerShown: true,
56+
headerBackVisible:
57+
!layout.usesSplitView ||
58+
!props.backInSplitView ||
59+
!(props.backInSplitView.onPress || props.onBack),
5660
title: props.title,
5761
unstable_headerSubtitle: props.subtitle || undefined,
5862
...(props.matchSearchSurface

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

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import { LegendList } from "@legendapp/list/react-native";
12
import type { ProjectEntry } from "@t3tools/contracts";
23
import { SymbolView } from "../../components/AppSymbol";
34
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
4-
import { ActivityIndicator, FlatList, Pressable, RefreshControl, View } from "react-native";
5+
import { ActivityIndicator, Platform, Pressable, RefreshControl, View } from "react-native";
56
import { useSafeAreaInsets } from "react-native-safe-area-context";
67

78
import { AppText as Text } from "../../components/AppText";
89
import { PierreEntryIcon } from "../../components/PierreEntryIcon";
910
import { cn } from "../../lib/cn";
1011
import { IOS_NAV_BAR_HEIGHT } from "../../lib/layoutMetrics";
11-
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
1212
import {
1313
buildFileTree,
1414
flattenFileTree,
@@ -17,8 +17,6 @@ import {
1717
} from "./fileTree";
1818

1919
const fileTreeCache = new WeakMap<ReadonlyArray<ProjectEntry>, ReadonlyArray<FileTreeNode>>();
20-
const FILE_TREE_INITIAL_RENDER_COUNT = 20;
21-
const FILE_TREE_RENDER_BATCH_SIZE = 12;
2220
const OPTIMISTIC_SELECTION_TIMEOUT_MS = 1_000;
2321

2422
function cachedFileTree(entries: ReadonlyArray<ProjectEntry>): ReadonlyArray<FileTreeNode> {
@@ -45,7 +43,8 @@ const FileTreeRow = memo(function FileTreeRow(props: {
4543
readonly selected: boolean;
4644
readonly expanded: boolean;
4745
readonly loaded: boolean;
48-
readonly onPressDirectory: (path: string) => void;
46+
readonly loading: boolean;
47+
readonly onPressDirectory: (path: string, expand: boolean) => void;
4948
readonly onPreviewFile?: (path: string) => void;
5049
readonly onPressFile: (path: string) => void;
5150
}) {
@@ -62,7 +61,7 @@ const FileTreeRow = memo(function FileTreeRow(props: {
6261
}}
6362
onPress={() => {
6463
if (node.kind === "directory") {
65-
props.onPressDirectory(node.path);
64+
props.onPressDirectory(node.path, !props.expanded);
6665
return;
6766
}
6867
props.onPressFile(node.path);
@@ -97,7 +96,9 @@ const FileTreeRow = memo(function FileTreeRow(props: {
9796
>
9897
{node.name}
9998
</Text>
100-
{node.kind === "directory" && props.loaded ? (
99+
{node.kind === "directory" && props.expanded && props.loading ? (
100+
<ActivityIndicator size="small" accessibilityLabel={`Loading ${node.name}`} />
101+
) : node.kind === "directory" && props.loaded ? (
101102
<Text className="text-2xs font-t3-medium text-foreground-tertiary">
102103
{node.children.length}
103104
</Text>
@@ -110,10 +111,12 @@ export function FileTreeBrowser(props: {
110111
readonly entries: ReadonlyArray<ProjectEntry>;
111112
readonly error: string | null;
112113
readonly isPending: boolean;
114+
readonly isRefreshing: boolean;
113115
readonly searchQuery: string;
114116
readonly searchTruncated: boolean;
115117
readonly selectedPath: string | null;
116118
readonly loadedDirectories: ReadonlySet<string>;
119+
readonly loadingDirectories: ReadonlySet<string>;
117120
readonly onLoadDirectory: (path: string) => void;
118121
readonly onPreviewFile?: (path: string) => void;
119122
readonly onRefresh: () => void;
@@ -127,12 +130,13 @@ export function FileTreeBrowser(props: {
127130
const insets = useSafeAreaInsets();
128131
// Native transparent-header height ≈ safe-area top + nav bar (~44). Matches the
129132
// observed adjustedContentInset bottom (~102) seen in the native trace.
130-
const headerInset = NATIVE_LIQUID_GLASS_SUPPORTED ? insets.top + IOS_NAV_BAR_HEIGHT : 0;
133+
const headerInset = Platform.OS === "ios" ? insets.top + IOS_NAV_BAR_HEIGHT : 0;
131134
const {
132135
onLoadDirectory,
133136
onPreviewFile,
134137
onSelectFile,
135138
loadedDirectories,
139+
loadingDirectories,
136140
selectedPath: controlledSelectedPath,
137141
} = props;
138142
const controlledSelectedPathRef = useRef(controlledSelectedPath);
@@ -184,17 +188,21 @@ export function FileTreeBrowser(props: {
184188
[],
185189
);
186190

187-
const toggleDirectory = useCallback((path: string) => {
188-
setExpandedPaths((current) => {
189-
const next = new Set(current);
190-
if (next.has(path)) {
191-
next.delete(path);
192-
} else {
193-
next.add(path);
194-
}
195-
return next;
196-
});
197-
}, []);
191+
const toggleDirectory = useCallback(
192+
(path: string, expand: boolean) => {
193+
if (expand) onLoadDirectory(path);
194+
setExpandedPaths((current) => {
195+
const next = new Set(current);
196+
if (next.has(path)) {
197+
next.delete(path);
198+
} else {
199+
next.add(path);
200+
}
201+
return next;
202+
});
203+
},
204+
[onLoadDirectory],
205+
);
198206
const handleSelectFile = useCallback(
199207
(path: string) => {
200208
if (pendingSelectionTimeoutRef.current !== null) {
@@ -219,6 +227,7 @@ export function FileTreeBrowser(props: {
219227
selected={item.node.kind === "file" && item.node.path === selectedPath}
220228
expanded={expandedPaths.has(item.node.path)}
221229
loaded={loadedDirectories.has(item.node.path)}
230+
loading={loadingDirectories.has(item.node.path)}
222231
onPressDirectory={toggleDirectory}
223232
onPreviewFile={onPreviewFile}
224233
onPressFile={handleSelectFile}
@@ -229,36 +238,40 @@ export function FileTreeBrowser(props: {
229238
handleSelectFile,
230239
onPreviewFile,
231240
loadedDirectories,
241+
loadingDirectories,
232242
selectedPath,
233243
toggleDirectory,
234244
],
235245
);
236246

237-
// SPIKE: render the FlatList as the screen's DIRECT content (no wrapping View), and
238-
// mirror the Home ScrollView exactly — `contentInsetAdjustmentBehavior: "automatic"`
239-
// with NO manual contentInset. iOS only applies the nav-bar top inset + scroll-edge
240-
// blur to a scroll view in the screen's primary position; a scroll view buried in
241-
// flex-1 Views is ignored, which is why the tree rendered under the header with no blur.
247+
const extraData = useMemo(
248+
() => ({ expandedPaths, loadedDirectories, loadingDirectories, selectedPath }),
249+
[expandedPaths, loadedDirectories, loadingDirectories, selectedPath],
250+
);
251+
252+
// UIKit owns the header inset on every supported iOS version. Keep the
253+
// list as direct screen content so automatic inset adjustment can find it.
242254
return (
243-
<FlatList
255+
<LegendList
256+
contentInsetStartAdjustment={headerInset}
244257
alwaysBounceVertical
245258
className="flex-1"
246259
data={visibleNodes}
247260
keyExtractor={(item) => item.node.path}
248-
contentInsetAdjustmentBehavior={NATIVE_LIQUID_GLASS_SUPPORTED ? "automatic" : "never"}
261+
contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
249262
scrollIndicatorInsets={
250-
NATIVE_LIQUID_GLASS_SUPPORTED
251-
? { top: headerInset, left: 0, right: 0, bottom: 0 }
252-
: undefined
263+
Platform.OS === "ios" ? { top: headerInset, left: 0, right: 0, bottom: 0 } : undefined
253264
}
254265
keyboardDismissMode="on-drag"
255266
keyboardShouldPersistTaps="handled"
256-
initialNumToRender={FILE_TREE_INITIAL_RENDER_COUNT}
257-
maxToRenderPerBatch={FILE_TREE_RENDER_BATCH_SIZE}
258-
updateCellsBatchingPeriod={16}
259-
windowSize={5}
267+
estimatedItemSize={42}
268+
recycleItems
269+
maintainVisibleContentPosition
270+
extraData={extraData}
260271
contentContainerStyle={{ paddingTop: 8, paddingBottom: 8 }}
261-
refreshControl={<RefreshControl refreshing={props.isPending} onRefresh={props.onRefresh} />}
272+
refreshControl={
273+
<RefreshControl refreshing={props.isRefreshing} onRefresh={props.onRefresh} />
274+
}
262275
renderItem={renderItem}
263276
ListHeaderComponent={
264277
<>

0 commit comments

Comments
 (0)