feat(mobile): adopt v5 navigation and native iPad columns (#16733)
This commit is contained in:
1 parent
a9fb6a8063
commit
468ade3049
47 files changed
+1918
-2410
No files matched your search
Binary file not shown.
@@ -14,5 +14,7 @@ if (!majorVersion) {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
// Hash the pinned Screens fork's native source, rather than only its version.
|
||||
nativeModuleSourceType: "files",
|
||||
extraSources: [{ type: "contents", id: "appMajorVersion", contents: majorVersion }],
|
||||
};
|
||||
@@ -287,6 +287,7 @@ T3MarkdownOutsideTapCoordinatorForWindow(UIWindow *window)
|
||||
UILongPressGestureRecognizer *_longPressGestureRecognizer;
|
||||
UITapGestureRecognizer *_pressGestureRecognizer;
|
||||
NSArray *_contextAccessibilityElements;
|
||||
BOOL _textLayoutNeedsUpdate;
|
||||
}
|
||||
|
||||
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
||||
@@ -384,16 +385,18 @@ T3MarkdownOutsideTapCoordinatorForWindow(UIWindow *window)
|
||||
_textView.frame = CGRectZero;
|
||||
_textView.attributedText = nil;
|
||||
_contextAccessibilityElements = nil;
|
||||
_textLayoutNeedsUpdate = YES;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews
|
||||
{
|
||||
[super layoutSubviews];
|
||||
// _textView's frame is assigned inside drawRect, which only fires when
|
||||
// state changes. Trigger a redraw whenever the host frame moves out from
|
||||
// under it (rotation, parent relayout) so the text view resizes and
|
||||
// onTextLayout re-fires with the new line wrapping.
|
||||
// Resize during UIKit's layout pass. Doing this in drawRect can leave the
|
||||
// text view's drawing surface clipped to its previous width after a pane
|
||||
// expands, even though TextKit has already rewrapped the lines.
|
||||
if (!CGRectEqualToRect(_textView.frame, _view.frame)) {
|
||||
_textView.frame = _view.frame;
|
||||
_textLayoutNeedsUpdate = YES;
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
}
|
||||
@@ -455,7 +458,7 @@ T3MarkdownOutsideTapCoordinatorForWindow(UIWindow *window)
|
||||
// entirely when nothing actually changed so a JS-side state update made in
|
||||
// response to onSelectionChange doesn't deselect what the user is selecting.
|
||||
const BOOL textChanged = ![_textView.attributedText isEqualToAttributedString:convertedAttrString];
|
||||
const BOOL frameChanged = !CGRectEqualToRect(_textView.frame, _view.frame);
|
||||
const BOOL frameChanged = _textLayoutNeedsUpdate;
|
||||
if (!textChanged && !frameChanged) {
|
||||
return;
|
||||
}
|
||||
@@ -482,9 +485,9 @@ T3MarkdownOutsideTapCoordinatorForWindow(UIWindow *window)
|
||||
_suppressSelectionChange = NO;
|
||||
}
|
||||
if (frameChanged) {
|
||||
_textView.frame = _view.frame;
|
||||
_textView.textContainer.size = CGSizeMake(CGRectGetWidth(_view.frame), CGFLOAT_MAX);
|
||||
}
|
||||
_textLayoutNeedsUpdate = NO;
|
||||
|
||||
// Text attachments have no native link element. Expose their existing runs
|
||||
// at the measured glyph bounds, without inserting views into text layout.
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import ExpoModulesCore
|
||||
import UIKit
|
||||
|
||||
/// Reports the body geometry of a native navigation column.
|
||||
final class T3LayoutMetricsView: ExpoView {
|
||||
let onMetricsChange = EventDispatcher()
|
||||
private var lastMetrics: NSDictionary?
|
||||
|
||||
required init(appContext: AppContext? = nil) {
|
||||
super.init(appContext: appContext)
|
||||
isUserInteractionEnabled = false
|
||||
registerForTraitChanges([UITraitHorizontalSizeClass.self, UITraitVerticalSizeClass.self]) { (view: T3LayoutMetricsView, _: UITraitCollection) in
|
||||
view.publishMetrics()
|
||||
}
|
||||
}
|
||||
|
||||
override func didMoveToWindow() {
|
||||
super.didMoveToWindow()
|
||||
lastMetrics = nil
|
||||
publishMetrics()
|
||||
}
|
||||
|
||||
override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
publishMetrics()
|
||||
}
|
||||
|
||||
override func safeAreaInsetsDidChange() {
|
||||
super.safeAreaInsetsDidChange()
|
||||
publishMetrics()
|
||||
}
|
||||
|
||||
private func publishMetrics() {
|
||||
guard window != nil, bounds.width > 0, bounds.height > 0 else { return }
|
||||
let metrics: [String: Any] = [
|
||||
"width": bounds.width, "height": bounds.height,
|
||||
"horizontalSizeClass": traitCollection.horizontalSizeClass == .regular ? "regular" : "compact",
|
||||
"safeArea": [
|
||||
"top": safeAreaInsets.top, "bottom": safeAreaInsets.bottom,
|
||||
"left": safeAreaInsets.left, "right": safeAreaInsets.right,
|
||||
],
|
||||
]
|
||||
let next = metrics as NSDictionary
|
||||
guard lastMetrics?.isEqual(next) != true else { return }
|
||||
lastMetrics = next
|
||||
onMetricsChange(metrics)
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,17 @@ public final class T3NativeControlsModule: Module {
|
||||
private var filePresentation: T3NativeFilePresentation?
|
||||
|
||||
public func definition() -> ModuleDefinition {
|
||||
Constants {
|
||||
if #available(iOS 26.0, *) {
|
||||
return ["supportsWorkspaceColumns": NSClassFromString("RNSSplitHostComponentView") != nil]
|
||||
}
|
||||
return ["supportsWorkspaceColumns": false]
|
||||
}
|
||||
View(T3LayoutMetricsView.self) {
|
||||
ViewName("LayoutMetrics")
|
||||
Events("onMetricsChange")
|
||||
}
|
||||
|
||||
AsyncFunction("presentVideo") { (url: URL, title: String, sourceIdentifier: String, identifier: String, promise: Promise) in
|
||||
try self.presentVideo(
|
||||
url: url,
|
||||
|
||||
@@ -120,7 +120,7 @@
|
||||
"react-native-nitro-modules": "0.35.9",
|
||||
"react-native-reanimated": "4.7.0",
|
||||
"react-native-safe-area-context": "~5.9.1",
|
||||
"react-native-screens": "~4.28.0",
|
||||
"react-native-screens": "file:deps/react-native-screens-5.0.0-t3.7.tgz",
|
||||
"react-native-shiki-engine": "^0.3.12",
|
||||
"react-native-svg": "15.15.5",
|
||||
"react-native-webview": "14.0.1",
|
||||
@@ -142,7 +142,8 @@
|
||||
"install": {
|
||||
"exclude": [
|
||||
"react-native-keyboard-controller",
|
||||
"typescript"
|
||||
"typescript",
|
||||
"react-native-screens"
|
||||
]
|
||||
},
|
||||
"autolinking": {
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import {
|
||||
createV5StackNavigator as createNativeStackNavigator,
|
||||
createV5SheetStackNavigator,
|
||||
} from "./native/createV5StackNavigator";
|
||||
import { createWorkspaceStackNavigator } from "./features/layout/createWorkspaceStackNavigator";
|
||||
import {
|
||||
createPathConfigForStaticNavigation,
|
||||
getPathFromState,
|
||||
@@ -6,7 +11,6 @@ import {
|
||||
useNavigation,
|
||||
} from "@react-navigation/native";
|
||||
import {
|
||||
createNativeStackNavigator,
|
||||
createNativeStackScreen,
|
||||
type NativeStackNavigationOptions,
|
||||
} from "@react-navigation/native-stack";
|
||||
@@ -189,7 +193,7 @@ const LEGAL_DOCUMENT_HEADER_OPTIONS: AppScreenOptions = {
|
||||
presentation: "fullScreenModal",
|
||||
};
|
||||
|
||||
const SettingsContentStack = createNativeStackNavigator({
|
||||
const SettingsContentStack = createV5SheetStackNavigator({
|
||||
initialRouteName: "Settings",
|
||||
screenOptions: {
|
||||
...GLASS_HEADER_OPTIONS,
|
||||
@@ -399,7 +403,7 @@ const SettingsContentStack = createNativeStackNavigator({
|
||||
// The outer stack never owns visible chrome. Settings routes render inside a
|
||||
// nested stack whose native header remains mounted, while Clerk owns auth chrome.
|
||||
// Keeping bar visibility invariant avoids iOS 26's headerless-to-headered jump.
|
||||
const SettingsSheetStack = createNativeStackNavigator({
|
||||
const SettingsSheetStack = createV5SheetStackNavigator({
|
||||
initialRouteName: "SettingsContent",
|
||||
screenOptions: {
|
||||
headerShown: false,
|
||||
@@ -670,7 +674,7 @@ function NotFoundScreen() {
|
||||
);
|
||||
}
|
||||
|
||||
const RootStackConfig = createNativeStackNavigator({
|
||||
const RootStackConfig = createWorkspaceStackNavigator({
|
||||
initialRouteName: "Home",
|
||||
layout: RootStackLayout,
|
||||
screenOptions: {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { NATIVE_WORKSPACE_COLUMNS_SUPPORTED } from "../native/NativeWorkspaceColumns";
|
||||
import Constants from "expo-constants";
|
||||
import type { NativeStackNavigationOptions } from "@react-navigation/native-stack";
|
||||
import { Platform, View } from "react-native";
|
||||
@@ -14,7 +15,7 @@ import { useAndroidControlSizing } from "./useAndroidControlSizing";
|
||||
*/
|
||||
export function brandTitleOffset(): number {
|
||||
if (Platform.OS !== "ios") return 0;
|
||||
return Platform.isPad ? IPAD_HOME_TITLE_OFFSET : 0;
|
||||
return Platform.isPad && !NATIVE_WORKSPACE_COLUMNS_SUPPORTED ? IPAD_HOME_TITLE_OFFSET : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,6 +53,10 @@ export function ScreenHeader(props: ScreenHeaderProps) {
|
||||
]}
|
||||
options={{
|
||||
headerShown: true,
|
||||
headerBackVisible:
|
||||
!layout.usesSplitView ||
|
||||
!props.backInSplitView ||
|
||||
!(props.backInSplitView.onPress || props.onBack),
|
||||
title: props.title,
|
||||
unstable_headerSubtitle: props.subtitle || undefined,
|
||||
...(props.matchSearchSurface
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { LegendList } from "@legendapp/list/react-native";
|
||||
import type { ProjectEntry } from "@t3tools/contracts";
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { ActivityIndicator, FlatList, Pressable, RefreshControl, View } from "react-native";
|
||||
import { ActivityIndicator, Platform, Pressable, RefreshControl, View } from "react-native";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
import { AppText as Text } from "../../components/AppText";
|
||||
import { PierreEntryIcon } from "../../components/PierreEntryIcon";
|
||||
import { cn } from "../../lib/cn";
|
||||
import { IOS_NAV_BAR_HEIGHT } from "../../lib/layoutMetrics";
|
||||
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
|
||||
import {
|
||||
buildFileTree,
|
||||
flattenFileTree,
|
||||
@@ -17,8 +17,6 @@ import {
|
||||
} from "./fileTree";
|
||||
|
||||
const fileTreeCache = new WeakMap<ReadonlyArray<ProjectEntry>, ReadonlyArray<FileTreeNode>>();
|
||||
const FILE_TREE_INITIAL_RENDER_COUNT = 20;
|
||||
const FILE_TREE_RENDER_BATCH_SIZE = 12;
|
||||
const OPTIMISTIC_SELECTION_TIMEOUT_MS = 1_000;
|
||||
|
||||
function cachedFileTree(entries: ReadonlyArray<ProjectEntry>): ReadonlyArray<FileTreeNode> {
|
||||
@@ -45,7 +43,8 @@ const FileTreeRow = memo(function FileTreeRow(props: {
|
||||
readonly selected: boolean;
|
||||
readonly expanded: boolean;
|
||||
readonly loaded: boolean;
|
||||
readonly onPressDirectory: (path: string) => void;
|
||||
readonly loading: boolean;
|
||||
readonly onPressDirectory: (path: string, expand: boolean) => void;
|
||||
readonly onPreviewFile?: (path: string) => void;
|
||||
readonly onPressFile: (path: string) => void;
|
||||
}) {
|
||||
@@ -62,7 +61,7 @@ const FileTreeRow = memo(function FileTreeRow(props: {
|
||||
}}
|
||||
onPress={() => {
|
||||
if (node.kind === "directory") {
|
||||
props.onPressDirectory(node.path);
|
||||
props.onPressDirectory(node.path, !props.expanded);
|
||||
return;
|
||||
}
|
||||
props.onPressFile(node.path);
|
||||
@@ -97,7 +96,9 @@ const FileTreeRow = memo(function FileTreeRow(props: {
|
||||
>
|
||||
{node.name}
|
||||
</Text>
|
||||
{node.kind === "directory" && props.loaded ? (
|
||||
{node.kind === "directory" && props.expanded && props.loading ? (
|
||||
<ActivityIndicator size="small" accessibilityLabel={`Loading ${node.name}`} />
|
||||
) : node.kind === "directory" && props.loaded ? (
|
||||
<Text className="text-2xs font-t3-medium text-foreground-tertiary">
|
||||
{node.children.length}
|
||||
</Text>
|
||||
@@ -110,10 +111,12 @@ export function FileTreeBrowser(props: {
|
||||
readonly entries: ReadonlyArray<ProjectEntry>;
|
||||
readonly error: string | null;
|
||||
readonly isPending: boolean;
|
||||
readonly isRefreshing: boolean;
|
||||
readonly searchQuery: string;
|
||||
readonly searchTruncated: boolean;
|
||||
readonly selectedPath: string | null;
|
||||
readonly loadedDirectories: ReadonlySet<string>;
|
||||
readonly loadingDirectories: ReadonlySet<string>;
|
||||
readonly onLoadDirectory: (path: string) => void;
|
||||
readonly onPreviewFile?: (path: string) => void;
|
||||
readonly onRefresh: () => void;
|
||||
@@ -127,12 +130,13 @@ export function FileTreeBrowser(props: {
|
||||
const insets = useSafeAreaInsets();
|
||||
// Native transparent-header height ≈ safe-area top + nav bar (~44). Matches the
|
||||
// observed adjustedContentInset bottom (~102) seen in the native trace.
|
||||
const headerInset = NATIVE_LIQUID_GLASS_SUPPORTED ? insets.top + IOS_NAV_BAR_HEIGHT : 0;
|
||||
const headerInset = Platform.OS === "ios" ? insets.top + IOS_NAV_BAR_HEIGHT : 0;
|
||||
const {
|
||||
onLoadDirectory,
|
||||
onPreviewFile,
|
||||
onSelectFile,
|
||||
loadedDirectories,
|
||||
loadingDirectories,
|
||||
selectedPath: controlledSelectedPath,
|
||||
} = props;
|
||||
const controlledSelectedPathRef = useRef(controlledSelectedPath);
|
||||
@@ -184,17 +188,21 @@ export function FileTreeBrowser(props: {
|
||||
[],
|
||||
);
|
||||
|
||||
const toggleDirectory = useCallback((path: string) => {
|
||||
setExpandedPaths((current) => {
|
||||
const next = new Set(current);
|
||||
if (next.has(path)) {
|
||||
next.delete(path);
|
||||
} else {
|
||||
next.add(path);
|
||||
}
|
||||
return next;
|
||||
});
|
||||
}, []);
|
||||
const toggleDirectory = useCallback(
|
||||
(path: string, expand: boolean) => {
|
||||
if (expand) onLoadDirectory(path);
|
||||
setExpandedPaths((current) => {
|
||||
const next = new Set(current);
|
||||
if (next.has(path)) {
|
||||
next.delete(path);
|
||||
} else {
|
||||
next.add(path);
|
||||
}
|
||||
return next;
|
||||
});
|
||||
},
|
||||
[onLoadDirectory],
|
||||
);
|
||||
const handleSelectFile = useCallback(
|
||||
(path: string) => {
|
||||
if (pendingSelectionTimeoutRef.current !== null) {
|
||||
@@ -219,6 +227,7 @@ export function FileTreeBrowser(props: {
|
||||
selected={item.node.kind === "file" && item.node.path === selectedPath}
|
||||
expanded={expandedPaths.has(item.node.path)}
|
||||
loaded={loadedDirectories.has(item.node.path)}
|
||||
loading={loadingDirectories.has(item.node.path)}
|
||||
onPressDirectory={toggleDirectory}
|
||||
onPreviewFile={onPreviewFile}
|
||||
onPressFile={handleSelectFile}
|
||||
@@ -229,36 +238,40 @@ export function FileTreeBrowser(props: {
|
||||
handleSelectFile,
|
||||
onPreviewFile,
|
||||
loadedDirectories,
|
||||
loadingDirectories,
|
||||
selectedPath,
|
||||
toggleDirectory,
|
||||
],
|
||||
);
|
||||
|
||||
// SPIKE: render the FlatList as the screen's DIRECT content (no wrapping View), and
|
||||
// mirror the Home ScrollView exactly — `contentInsetAdjustmentBehavior: "automatic"`
|
||||
// with NO manual contentInset. iOS only applies the nav-bar top inset + scroll-edge
|
||||
// blur to a scroll view in the screen's primary position; a scroll view buried in
|
||||
// flex-1 Views is ignored, which is why the tree rendered under the header with no blur.
|
||||
const extraData = useMemo(
|
||||
() => ({ expandedPaths, loadedDirectories, loadingDirectories, selectedPath }),
|
||||
[expandedPaths, loadedDirectories, loadingDirectories, selectedPath],
|
||||
);
|
||||
|
||||
// UIKit owns the header inset on every supported iOS version. Keep the
|
||||
// list as direct screen content so automatic inset adjustment can find it.
|
||||
return (
|
||||
<FlatList
|
||||
<LegendList
|
||||
contentInsetStartAdjustment={headerInset}
|
||||
alwaysBounceVertical
|
||||
className="flex-1"
|
||||
data={visibleNodes}
|
||||
keyExtractor={(item) => item.node.path}
|
||||
contentInsetAdjustmentBehavior={NATIVE_LIQUID_GLASS_SUPPORTED ? "automatic" : "never"}
|
||||
contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
|
||||
scrollIndicatorInsets={
|
||||
NATIVE_LIQUID_GLASS_SUPPORTED
|
||||
? { top: headerInset, left: 0, right: 0, bottom: 0 }
|
||||
: undefined
|
||||
Platform.OS === "ios" ? { top: headerInset, left: 0, right: 0, bottom: 0 } : undefined
|
||||
}
|
||||
keyboardDismissMode="on-drag"
|
||||
keyboardShouldPersistTaps="handled"
|
||||
initialNumToRender={FILE_TREE_INITIAL_RENDER_COUNT}
|
||||
maxToRenderPerBatch={FILE_TREE_RENDER_BATCH_SIZE}
|
||||
updateCellsBatchingPeriod={16}
|
||||
windowSize={5}
|
||||
estimatedItemSize={42}
|
||||
recycleItems
|
||||
maintainVisibleContentPosition
|
||||
extraData={extraData}
|
||||
contentContainerStyle={{ paddingTop: 8, paddingBottom: 8 }}
|
||||
refreshControl={<RefreshControl refreshing={props.isPending} onRefresh={props.onRefresh} />}
|
||||
refreshControl={
|
||||
<RefreshControl refreshing={props.isRefreshing} onRefresh={props.onRefresh} />
|
||||
}
|
||||
renderItem={renderItem}
|
||||
ListHeaderComponent={
|
||||
<>
|
||||
|
||||
@@ -43,6 +43,7 @@ import { useAppearancePreferences } from "../settings/appearance/AppearancePrefe
|
||||
import { ThreadRouteScreen } from "../threads/ThreadRouteScreen";
|
||||
import { FilePreviewLoading, FilePreviewNotice } from "./FilePreviewFeedback";
|
||||
import { FileMarkdownPreview } from "./FileMarkdownPreview";
|
||||
import { ThreadInspectorContentStack } from "../threads/thread-inspector-content-stack";
|
||||
import { FileTreeBrowser } from "./FileTreeBrowser";
|
||||
import { useFileTreeEntries } from "./useFileTreeEntries";
|
||||
import { preloadWorkspaceFileContents } from "./preload-workspace-file";
|
||||
@@ -561,9 +562,11 @@ export function ThreadFilesTreeScreen(props: ThreadFilesRouteScreenProps) {
|
||||
key={JSON.stringify([environmentId, cwd])}
|
||||
entries={entriesQuery.entries}
|
||||
loadedDirectories={entriesQuery.loadedDirectories}
|
||||
loadingDirectories={entriesQuery.loadingDirectories}
|
||||
onLoadDirectory={entriesQuery.loadDirectory}
|
||||
error={entriesQuery.error}
|
||||
isPending={entriesQuery.isPending}
|
||||
isRefreshing={entriesQuery.isRefreshing}
|
||||
searchQuery={searchQuery}
|
||||
searchTruncated={entriesQuery.searchTruncated}
|
||||
selectedPath={null}
|
||||
@@ -751,8 +754,14 @@ export function ThreadFileScreen(props: ThreadFileRouteScreenProps) {
|
||||
// Hand the file navigator to the workspace so it renders beside the
|
||||
// navigator, outside this screen's native header.
|
||||
const renderWorkspaceInspector = useCallback(
|
||||
() => renderInspector(inspectorHeaderInset),
|
||||
[inspectorHeaderInset, renderInspector],
|
||||
() => (
|
||||
<ThreadInspectorContentStack
|
||||
mode="files"
|
||||
resetKeys={[threadId, cwd]}
|
||||
renderFiles={() => renderInspector(inspectorHeaderInset)}
|
||||
/>
|
||||
),
|
||||
[cwd, inspectorHeaderInset, renderInspector, threadId],
|
||||
);
|
||||
useRegisterWorkspaceInspector(fileInspector.supported ? renderWorkspaceInspector : undefined);
|
||||
|
||||
|
||||
@@ -77,6 +77,8 @@ function freezeNode(node: MutableFileTreeNode): FileTreeNode {
|
||||
};
|
||||
}
|
||||
|
||||
const fileNameCollator = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" });
|
||||
|
||||
function compareNodes(
|
||||
left: Pick<FileTreeNode, "kind" | "name">,
|
||||
right: Pick<FileTreeNode, "kind" | "name">,
|
||||
@@ -84,7 +86,7 @@ function compareNodes(
|
||||
if (left.kind !== right.kind) {
|
||||
return left.kind === "directory" ? -1 : 1;
|
||||
}
|
||||
return left.name.localeCompare(right.name, undefined, { numeric: true, sensitivity: "base" });
|
||||
return fileNameCollator.compare(left.name, right.name);
|
||||
}
|
||||
|
||||
export function buildFileTree(entries: ReadonlyArray<ProjectEntry>): ReadonlyArray<FileTreeNode> {
|
||||
|
||||
@@ -78,7 +78,6 @@ export function ThreadFileNavigatorPane(props: {
|
||||
sharesBackground: false,
|
||||
tintColor: foregroundColor,
|
||||
type: "button" as const,
|
||||
width: 44,
|
||||
},
|
||||
] as ComponentProps<typeof ScreenStackHeaderConfig>["headerRightBarButtonItems"],
|
||||
[foregroundColor, toggleAuxiliaryPane],
|
||||
@@ -89,6 +88,7 @@ export function ThreadFileNavigatorPane(props: {
|
||||
key={JSON.stringify([props.environmentId, props.cwd])}
|
||||
entries={entriesQuery.entries}
|
||||
loadedDirectories={entriesQuery.loadedDirectories}
|
||||
loadingDirectories={entriesQuery.loadingDirectories}
|
||||
onLoadDirectory={entriesQuery.loadDirectory}
|
||||
error={
|
||||
canReadFiles
|
||||
@@ -98,6 +98,7 @@ export function ThreadFileNavigatorPane(props: {
|
||||
: (fileAccess.error ?? "This connection cannot read host files.")
|
||||
}
|
||||
isPending={fileAccess.isPending || entriesQuery.isPending}
|
||||
isRefreshing={entriesQuery.isRefreshing}
|
||||
searchQuery={searchQuery}
|
||||
searchTruncated={entriesQuery.searchTruncated}
|
||||
selectedPath={props.selectedPath}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { executeAtomQuery } from "@t3tools/client-runtime/state/runtime";
|
||||
import type { EnvironmentId, ProjectEntry } from "@t3tools/contracts";
|
||||
import * as Cause from "effect/Cause";
|
||||
import { useCallback, useEffect, useMemo, useReducer, useRef } from "react";
|
||||
import { useCallback, useEffect, useMemo, useReducer, useRef, useState } from "react";
|
||||
|
||||
import { appAtomRegistry } from "../../state/atom-registry";
|
||||
import { projectEnvironment } from "../../state/projects";
|
||||
@@ -30,7 +30,8 @@ export function useFileTreeEntries(input: {
|
||||
})
|
||||
: null,
|
||||
);
|
||||
const [revision, render] = useReducer((value: number) => value + 1, 0);
|
||||
const [, render] = useReducer((value: number) => value + 1, 0);
|
||||
const [entriesRevision, entriesChanged] = useReducer((value: number) => value + 1, 0);
|
||||
const refreshVersion = useRef(0);
|
||||
const directories = useMemo(
|
||||
() => ({
|
||||
@@ -43,6 +44,9 @@ export function useFileTreeEntries(input: {
|
||||
}),
|
||||
[cwd, environmentId],
|
||||
);
|
||||
const [refreshingDirectories, setRefreshingDirectories] = useState<typeof directories | null>(
|
||||
null,
|
||||
);
|
||||
useEffect(
|
||||
() => () => {
|
||||
refreshVersion.current++;
|
||||
@@ -83,6 +87,7 @@ export function useFileTreeEntries(input: {
|
||||
entry.path.slice(0, Math.max(0, entry.path.lastIndexOf("/"))) === directoryPath,
|
||||
),
|
||||
);
|
||||
entriesChanged();
|
||||
} else {
|
||||
const error = Cause.squash(result.cause);
|
||||
directories.errors.set(
|
||||
@@ -113,8 +118,8 @@ export function useFileTreeEntries(input: {
|
||||
}
|
||||
};
|
||||
visit((rootData?.entries ?? []).filter((entry) => !entry.path.includes("/")));
|
||||
return { revision, entries: [...merged.values()], reachableDirectories };
|
||||
}, [directories, revision, rootData, searchData, searching]);
|
||||
return { revision: entriesRevision, entries: [...merged.values()], reachableDirectories };
|
||||
}, [directories, entriesRevision, rootData, searchData, searching]);
|
||||
|
||||
const refresh = useCallback(() => {
|
||||
refreshRoot();
|
||||
@@ -126,6 +131,7 @@ export function useFileTreeEntries(input: {
|
||||
directories.pending.clear();
|
||||
directories.errors.clear();
|
||||
const version = ++refreshVersion.current;
|
||||
setRefreshingDirectories(directories);
|
||||
const remaining = paths.values();
|
||||
const worker = async () => {
|
||||
while (version === refreshVersion.current) {
|
||||
@@ -134,9 +140,34 @@ export function useFileTreeEntries(input: {
|
||||
await loadDirectory(next.value, true);
|
||||
}
|
||||
};
|
||||
for (let index = 0; index < Math.min(4, paths.size); index++) void worker();
|
||||
const queries =
|
||||
cwd !== null && environmentId !== null
|
||||
? [
|
||||
projectEnvironment.listEntries({ environmentId, input: { cwd, directoryPath: "" } }),
|
||||
...(searching
|
||||
? [
|
||||
projectEnvironment.searchEntries({
|
||||
environmentId,
|
||||
input: { cwd, query: debouncedQuery, limit: 200 },
|
||||
}),
|
||||
]
|
||||
: []),
|
||||
]
|
||||
: [];
|
||||
const work = [
|
||||
...queries.map((atom) =>
|
||||
executeAtomQuery(appAtomRegistry, atom, { reportFailure: false, reportDefect: false }),
|
||||
),
|
||||
...Array.from({ length: Math.min(4, paths.size) }, () => worker()),
|
||||
];
|
||||
render();
|
||||
return Promise.all(work).finally(() => {
|
||||
if (version === refreshVersion.current) setRefreshingDirectories(null);
|
||||
});
|
||||
}, [
|
||||
cwd,
|
||||
debouncedQuery,
|
||||
environmentId,
|
||||
directories,
|
||||
loadDirectory,
|
||||
refreshRoot,
|
||||
@@ -147,6 +178,7 @@ export function useFileTreeEntries(input: {
|
||||
|
||||
return {
|
||||
entries: snapshot.entries,
|
||||
isRefreshing: refreshingDirectories === directories,
|
||||
error:
|
||||
root.error ??
|
||||
(searching ? search.error : null) ??
|
||||
@@ -158,6 +190,7 @@ export function useFileTreeEntries(input: {
|
||||
(searching && (query !== debouncedQuery || search.isPending)),
|
||||
searchTruncated: searching && (search.data?.truncated ?? false),
|
||||
loadedDirectories: new Set(directories.entries.keys()),
|
||||
loadingDirectories: new Set(directories.pending.keys()),
|
||||
loadDirectory,
|
||||
refresh,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
|
||||
import { useCallback, useRef } from "react";
|
||||
import { use, useCallback, useRef } from "react";
|
||||
import { Platform } from "react-native";
|
||||
import type { SearchBarCommands } from "react-native-screens";
|
||||
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
|
||||
import { useUniwindTheme } from "../../lib/useUniwindTheme";
|
||||
import { useHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
|
||||
import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
|
||||
@@ -9,11 +11,14 @@ import {
|
||||
NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED,
|
||||
} from "../layout/native-mail-search-toolbar";
|
||||
import { buildHomeListFilterMenu } from "./home-list-filter-menu";
|
||||
import { createSidebarHeaderItems } from "../threads/sidebar-native-header-items";
|
||||
import type { HomeHeaderProps } from "./HomeHeader.types";
|
||||
|
||||
export type { HomeHeaderEnvironment } from "./HomeHeader.types";
|
||||
|
||||
export function HomeHeader(props: HomeHeaderProps) {
|
||||
const primaryColumn = use(NativePrimaryColumnContext);
|
||||
const iPadSidebar = Platform.OS === "ios" && Platform.isPad && primaryColumn !== null;
|
||||
const searchBarRef = useRef<SearchBarCommands>(null);
|
||||
const iconColor = useUniwindTheme()["--color-icon"];
|
||||
// The list uses a fixed creation order and ignores sort/group options, so
|
||||
@@ -36,57 +41,87 @@ export function HomeHeader(props: HomeHeaderProps) {
|
||||
// Static header config (glass, title, fonts) lives in Stack.tsx
|
||||
// (GLASS_HEADER_OPTIONS). Only dynamic values are set here.
|
||||
headerTintColor: iconColor,
|
||||
unstable_headerRightItems: () => [
|
||||
withNativeGlassHeaderItem({
|
||||
accessibilityLabel: "Open settings",
|
||||
icon: { name: "ellipsis", type: "sfSymbol" } as const,
|
||||
identifier: "home-settings",
|
||||
label: "",
|
||||
onPress: props.onOpenSettings,
|
||||
type: "button",
|
||||
}),
|
||||
],
|
||||
// The keys below are set per-branch (not `undefined`) so a later
|
||||
// reapply cannot clobber options owned by NativeHeaderToolbar.
|
||||
...(NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED
|
||||
? {
|
||||
unstable_headerToolbarItems: () => [
|
||||
createNativeMailSearchToolbarItem({
|
||||
composeButtonId: "home-new-task",
|
||||
composeSystemImageName: "square.and.pencil",
|
||||
filterMenu,
|
||||
filterButtonId: "home-filter",
|
||||
filterSystemImageName: hasCustomListOptions
|
||||
? "line.3.horizontal.decrease.circle.fill"
|
||||
: "line.3.horizontal.decrease",
|
||||
onComposePress: props.onStartNewTask,
|
||||
onSearchTextChange: props.onSearchQueryChange,
|
||||
placeholder: "Search",
|
||||
searchTextChangeId: "home-search-text",
|
||||
showsSearchDismissButton: true,
|
||||
unstable_headerRightItems: () =>
|
||||
iPadSidebar
|
||||
? createSidebarHeaderItems({
|
||||
filterIcon: hasCustomListOptions
|
||||
? "line.3.horizontal.decrease.circle.fill"
|
||||
: "line.3.horizontal.decrease.circle",
|
||||
filterMenu,
|
||||
onOpenSettings: props.onOpenSettings,
|
||||
})
|
||||
: [
|
||||
withNativeGlassHeaderItem({
|
||||
accessibilityLabel: "Open settings",
|
||||
icon: { name: "ellipsis", type: "sfSymbol" } as const,
|
||||
identifier: "home-settings",
|
||||
label: "",
|
||||
onPress: props.onOpenSettings,
|
||||
type: "button",
|
||||
}),
|
||||
],
|
||||
}
|
||||
: {
|
||||
// Pre-Liquid-Glass iOS: standard pull-down search in the nav
|
||||
// bar; create + sort live in the plain bottom toolbar below.
|
||||
// The keys below are set per-branch (not `undefined`) so a later
|
||||
// reapply cannot clobber options owned by NativeHeaderToolbar.
|
||||
...(iPadSidebar
|
||||
? {
|
||||
headerSearchBarOptions: {
|
||||
ref: searchBarRef,
|
||||
autoCapitalize: "none" as const,
|
||||
hideNavigationBar: false,
|
||||
hideWhenScrolling: false,
|
||||
obscureBackground: false,
|
||||
placement: "stacked" as const,
|
||||
allowToolbarIntegration: false,
|
||||
placeholder: "Search",
|
||||
onCancelButtonPress: () => {
|
||||
props.onSearchQueryChange("");
|
||||
},
|
||||
onChangeText: (event) => {
|
||||
props.onSearchQueryChange(event.nativeEvent.text);
|
||||
},
|
||||
onCancelButtonPress: () => props.onSearchQueryChange(""),
|
||||
onChangeText: (event) => props.onSearchQueryChange(event.nativeEvent.text),
|
||||
},
|
||||
}),
|
||||
unstable_headerToolbarItems: () => [],
|
||||
}
|
||||
: NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED
|
||||
? {
|
||||
headerSearchBarOptions: {
|
||||
ref: searchBarRef,
|
||||
autoCapitalize: "none" as const,
|
||||
onCancelButtonPress: () => props.onSearchQueryChange(""),
|
||||
},
|
||||
unstable_headerToolbarItems: () => [
|
||||
createNativeMailSearchToolbarItem({
|
||||
composeButtonId: "home-new-task",
|
||||
composeSystemImageName: "square.and.pencil",
|
||||
filterMenu,
|
||||
filterButtonId: "home-filter",
|
||||
filterSystemImageName: hasCustomListOptions
|
||||
? "line.3.horizontal.decrease.circle.fill"
|
||||
: "line.3.horizontal.decrease",
|
||||
onComposePress: props.onStartNewTask,
|
||||
onSearchTextChange: props.onSearchQueryChange,
|
||||
placeholder: "Search",
|
||||
searchTextChangeId: "home-search-text",
|
||||
showsSearchDismissButton: true,
|
||||
}),
|
||||
],
|
||||
}
|
||||
: {
|
||||
// Pre-Liquid-Glass iOS: standard pull-down search in the nav
|
||||
// bar; create + sort live in the plain bottom toolbar below.
|
||||
headerSearchBarOptions: {
|
||||
ref: searchBarRef,
|
||||
autoCapitalize: "none" as const,
|
||||
hideNavigationBar: false,
|
||||
placeholder: "Search",
|
||||
onCancelButtonPress: () => {
|
||||
props.onSearchQueryChange("");
|
||||
},
|
||||
onChangeText: (event) => {
|
||||
props.onSearchQueryChange(event.nativeEvent.text);
|
||||
},
|
||||
},
|
||||
}),
|
||||
}}
|
||||
/>
|
||||
|
||||
{NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED ? null : (
|
||||
{iPadSidebar || NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED ? null : (
|
||||
<NativeHeaderToolbar placement="bottom">
|
||||
<NativeHeaderToolbar.Menu
|
||||
accessibilityLabel="Filter threads"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { use } from "react";
|
||||
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
|
||||
import * as Arr from "effect/Array";
|
||||
import * as Order from "effect/Order";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
@@ -12,6 +14,7 @@ import { usePendingNewTasks } from "../../state/use-pending-new-tasks";
|
||||
import { useWorkspaceState } from "../../state/workspace";
|
||||
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
|
||||
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
|
||||
import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
|
||||
import { WorkspaceEmptyDetail } from "../layout/WorkspaceEmptyDetail";
|
||||
import { AndroidScreenHeader } from "../../components/AndroidScreenHeader";
|
||||
import { checkForAppUpdateOnLaunch, startAppUpdateForegroundRecheck } from "../updates/app-updates";
|
||||
@@ -29,6 +32,9 @@ import { getConnectionAwareBrandHeaderOptions } from "./WorkspaceConnectionTitle
|
||||
|
||||
export function HomeRouteScreen() {
|
||||
const { width: windowWidth } = useWindowDimensions();
|
||||
const nativePrimaryColumn = use(NativePrimaryColumnContext);
|
||||
const columnMetrics = useNativeColumnLayoutMetrics();
|
||||
const headerWidth = nativePrimaryColumn ? (columnMetrics?.width ?? windowWidth) : windowWidth;
|
||||
const { layout, panes } = useAdaptiveWorkspaceLayout();
|
||||
const projects = useProjects();
|
||||
const threads = useNavigationThreadShells();
|
||||
@@ -120,7 +126,7 @@ export function HomeRouteScreen() {
|
||||
|
||||
// In split layouts the persistent sidebar IS the thread list — Home becomes
|
||||
// an empty detail pane so selecting a thread never transitions layouts.
|
||||
if (layout.usesSplitView) {
|
||||
if (layout.usesSplitView && !nativePrimaryColumn) {
|
||||
return (
|
||||
<>
|
||||
<NativeStackScreenOptions
|
||||
@@ -169,10 +175,12 @@ export function HomeRouteScreen() {
|
||||
shallow-merged. The brand slot also doubles as the connection
|
||||
status surface while an environment reconnects. */}
|
||||
<NativeStackScreenOptions
|
||||
optionsVersion={windowWidth}
|
||||
optionsVersion={headerWidth}
|
||||
options={{
|
||||
...getConnectionAwareBrandHeaderOptions({
|
||||
headerWidth: windowWidth,
|
||||
headerWidth,
|
||||
trailingItemCount:
|
||||
nativePrimaryColumn && Platform.OS === "ios" && Platform.isPad ? 2 : 1,
|
||||
onOpenEnvironments: () =>
|
||||
navigation.navigate("SettingsSheet", {
|
||||
screen: "SettingsContent",
|
||||
|
||||
@@ -13,15 +13,18 @@ import {
|
||||
import { type EnvironmentId, type SidebarProjectGroupingMode } from "@t3tools/contracts";
|
||||
import { useAtomValue } from "@effect/atom-react";
|
||||
import { useFocusEffect } from "@react-navigation/native";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { use, useCallback, useEffect, useMemo, useRef, useState, type ComponentProps } from "react";
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Platform,
|
||||
ScrollView,
|
||||
View,
|
||||
type ScrollViewProps,
|
||||
type GestureResponderEvent,
|
||||
type NativeScrollEvent,
|
||||
type NativeSyntheticEvent,
|
||||
} from "react-native";
|
||||
import { ScrollViewMarker } from "react-native-screens";
|
||||
import type { SwipeableMethods } from "react-native-gesture-handler/ReanimatedSwipeable";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
@@ -30,7 +33,10 @@ import { EmptyState } from "../../components/EmptyState";
|
||||
import { MaterialFloatingActionButton } from "../../components/MaterialFloatingActionButton";
|
||||
import type { WorkspaceEnvironment, WorkspaceState } from "../../state/workspaceModel";
|
||||
import type { SavedRemoteConnection } from "../../lib/connection";
|
||||
import { scopedProjectKey } from "../../lib/scopedEntities";
|
||||
import { scopedProjectKey, scopedThreadKey } from "../../lib/scopedEntities";
|
||||
import { NativePrimaryColumnContext } from "../../native/v5-workspace-context";
|
||||
import { nativeHeaderScrollEdgeEffects } from "../../native/scrollEdgeEffects";
|
||||
import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
|
||||
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
|
||||
import { useThreadSearch } from "../../state/queries";
|
||||
import { useThreadJumpShortcuts } from "../keyboard/threadKeyboardShortcuts";
|
||||
@@ -140,7 +146,6 @@ const ESTIMATED_THREAD_LIST_V2_ROW_HEIGHT = 72;
|
||||
// swipe-row-activation), so render further ahead: a fast fling then reaches
|
||||
// rows that are already built instead of rows still being rebuilt.
|
||||
const THREAD_LIST_V2_DRAW_DISTANCE = 1_000;
|
||||
const PRE_LIQUID_GLASS_BOTTOM_TOOLBAR_HEIGHT = 44;
|
||||
/**
|
||||
* Top spacing between the list and the Android custom header. The Android
|
||||
* header is rendered in-flow above this screen and
|
||||
@@ -219,17 +224,61 @@ function HomeTopContentSpacer() {
|
||||
return <View className="h-4" />;
|
||||
}
|
||||
|
||||
function HomeScrollView(props: ComponentProps<typeof ScrollView>) {
|
||||
const insets = useSafeAreaInsets();
|
||||
const primaryColumn = use(NativePrimaryColumnContext);
|
||||
if (Platform.OS !== "ios") return <ScrollView {...props} />;
|
||||
|
||||
// v5 needs the actual content scroll view registered with its screen controller.
|
||||
// The layout observer and header siblings prevent UIKit from finding it implicitly.
|
||||
return (
|
||||
<ScrollViewMarker
|
||||
style={{ flex: 1 }}
|
||||
scrollEdgeEffects={{
|
||||
...nativeHeaderScrollEdgeEffects(Platform.OS, Platform.Version),
|
||||
// Retain the existing sidebar fade on iOS 26; iOS 27 uses the native bar material.
|
||||
top: Number.parseInt(String(Platform.Version), 10) >= 27 ? "automatic" : "soft",
|
||||
}}
|
||||
>
|
||||
<ScrollView
|
||||
{...props}
|
||||
// UIKit's scroll-edge material needs the scroll view's own surface color.
|
||||
className={cn(props.className, primaryColumn ? "bg-drawer" : "bg-screen")}
|
||||
// Use the column's measured inset so UIKit recognizes the resting top.
|
||||
// Padding visually clears the bar but leaves the native scroll offset
|
||||
// past its edge, activating scroll-edge protection before any scroll.
|
||||
automaticallyAdjustContentInsets={false}
|
||||
contentInsetAdjustmentBehavior="never"
|
||||
contentOffset={props.contentOffset ?? { x: 0, y: -insets.top }}
|
||||
/>
|
||||
</ScrollViewMarker>
|
||||
);
|
||||
}
|
||||
|
||||
function renderHomeScrollView(props: ScrollViewProps) {
|
||||
// FlatList clones this element with its cells and ref. Keep the marker inside
|
||||
// the component so those cells remain children of the actual ScrollView.
|
||||
return <HomeScrollView {...props} />;
|
||||
}
|
||||
|
||||
/* ─── Main screen ────────────────────────────────────────────────────── */
|
||||
|
||||
export function HomeScreen(props: HomeScreenProps) {
|
||||
const primaryColumn = use(NativePrimaryColumnContext);
|
||||
const contentBackground = primaryColumn ? "bg-drawer" : "bg-screen";
|
||||
const containerClassName = cn(
|
||||
"flex-1",
|
||||
Platform.OS === "android" ? "bg-header" : contentBackground,
|
||||
);
|
||||
const columnMetrics = useNativeColumnLayoutMetrics();
|
||||
const selectedThreadKey = primaryColumn?.selectedThreadKey ?? null;
|
||||
const fullSwipeWidth = primaryColumn && columnMetrics ? columnMetrics.width - 20 : undefined;
|
||||
const queuedThreadKeys = useQueuedThreadKeys();
|
||||
const openSwipeableRef = useRef<SwipeableMethods | null>(null);
|
||||
const insets = useSafeAreaInsets();
|
||||
const { fabClearance } = useAndroidControlSizing();
|
||||
const iosBottomToolbarClearance =
|
||||
Platform.OS === "ios" && !NATIVE_LIQUID_GLASS_SUPPORTED
|
||||
? PRE_LIQUID_GLASS_BOTTOM_TOOLBAR_HEIGHT
|
||||
: 0;
|
||||
// UIKit's column safe area already includes its bottom toolbar.
|
||||
const iosBottomClearance = Math.max(columnMetrics?.safeArea.bottom ?? insets.bottom, 24);
|
||||
const searchEnvironmentIds = useMemo(
|
||||
() =>
|
||||
props.selectedEnvironmentId === null
|
||||
@@ -563,12 +612,13 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
inboxReturnAt: threadListInboxReturns.returnedAt,
|
||||
snoozedShelfExpanded,
|
||||
settledShelfExpanded,
|
||||
selectedThreadKey: null,
|
||||
selectedThreadKey,
|
||||
});
|
||||
}, [
|
||||
workingShelfEnabled,
|
||||
workingShelfExpanded,
|
||||
pendingOrder,
|
||||
selectedThreadKey,
|
||||
queuedThreadKeys,
|
||||
nowMinute,
|
||||
snoozeWakeTick,
|
||||
@@ -715,6 +765,9 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
const thread = item.item.thread;
|
||||
return (
|
||||
<ThreadListV2Row
|
||||
pane={primaryColumn ? "sidebar" : "screen"}
|
||||
selected={scopedThreadKey(thread.environmentId, thread.id) === selectedThreadKey}
|
||||
fullSwipeWidth={fullSwipeWidth}
|
||||
onNewThreadOnBranch={props.onNewThreadOnBranch}
|
||||
thread={thread}
|
||||
variant={item.item.variant}
|
||||
@@ -802,6 +855,9 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
props.onDeletePendingTask,
|
||||
props.onSelectPendingTask,
|
||||
props.onSelectThread,
|
||||
primaryColumn,
|
||||
selectedThreadKey,
|
||||
fullSwipeWidth,
|
||||
props.onNewThreadOnBranch,
|
||||
props.savedConnectionsById,
|
||||
resolveProviderInstance,
|
||||
@@ -831,6 +887,7 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
listEnvironments,
|
||||
savedConnectionsById: props.savedConnectionsById,
|
||||
searchQuery: props.searchQuery,
|
||||
selectedThreadKey,
|
||||
threadSearchMatchByKey,
|
||||
// Rows read it for their reorder menu items.
|
||||
workingShelfEnabled,
|
||||
@@ -838,6 +895,7 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
[
|
||||
projectByKey,
|
||||
props.searchQuery,
|
||||
selectedThreadKey,
|
||||
props.savedConnectionsById,
|
||||
listEnvironments,
|
||||
threadSearchMatchByKey,
|
||||
@@ -868,14 +926,15 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
|
||||
if (!hasAnyThreads) {
|
||||
return (
|
||||
<View className="flex-1 bg-screen android:bg-header">
|
||||
<View className={containerClassName}>
|
||||
<View
|
||||
className={cn(
|
||||
"flex-1 items-center justify-center bg-screen px-8",
|
||||
"flex-1 items-center justify-center px-8",
|
||||
contentBackground,
|
||||
Platform.OS === "android" && "overflow-hidden rounded-t-[28px]",
|
||||
)}
|
||||
style={{
|
||||
paddingBottom: Math.max(insets.bottom, 24) + iosBottomToolbarClearance,
|
||||
paddingBottom: Platform.OS === "ios" ? iosBottomClearance : Math.max(insets.bottom, 24),
|
||||
paddingTop: NATIVE_LIQUID_GLASS_SUPPORTED ? insets.top + 72 : 0,
|
||||
}}
|
||||
>
|
||||
@@ -958,12 +1017,12 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
}
|
||||
|
||||
return (
|
||||
<View className="flex-1 bg-screen android:bg-header">
|
||||
<View className={containerClassName}>
|
||||
<View
|
||||
className={
|
||||
Platform.OS === "android"
|
||||
? "flex-1 overflow-hidden rounded-t-[28px] bg-screen"
|
||||
: "flex-1 bg-screen"
|
||||
: cn("flex-1", contentBackground)
|
||||
}
|
||||
>
|
||||
{/* Shared with the iPad sidebar: cells are reused across data
|
||||
@@ -976,6 +1035,7 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
onTouchStart={(event) => trackListTouches(event, true)}
|
||||
onTouchEnd={(event) => trackListTouches(event, false)}
|
||||
onTouchCancel={(event) => trackListTouches(event, false)}
|
||||
renderScrollComponent={Platform.OS === "ios" ? renderHomeScrollView : undefined}
|
||||
data={threadListV2Items}
|
||||
renderItem={renderV2Item}
|
||||
keyExtractor={v2KeyExtractor}
|
||||
@@ -997,16 +1057,19 @@ export function HomeScreen(props: HomeScreenProps) {
|
||||
ListEmptyComponent={v2ListEmpty}
|
||||
style={{ flex: 1 }}
|
||||
automaticallyAdjustsScrollIndicatorInsets={Platform.OS === "ios"}
|
||||
contentInsetAdjustmentBehavior={Platform.OS === "ios" ? "automatic" : "never"}
|
||||
contentInsetAdjustmentBehavior="never"
|
||||
contentInset={Platform.OS === "ios" ? { top: insets.top } : undefined}
|
||||
contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
|
||||
showsVerticalScrollIndicator={false}
|
||||
keyboardDismissMode="on-drag"
|
||||
keyboardShouldPersistTaps="handled"
|
||||
{...scrollGateHandlers}
|
||||
scrollEventThrottle={16}
|
||||
contentContainerStyle={{
|
||||
paddingHorizontal: primaryColumn ? 8 : 0,
|
||||
paddingBottom:
|
||||
Platform.OS === "ios"
|
||||
? Math.max(insets.bottom, 24) + 96 + iosBottomToolbarClearance
|
||||
? iosBottomClearance
|
||||
: Math.max(insets.bottom, 16) + (Platform.OS === "android" ? fabClearance : 88),
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -61,6 +61,10 @@ import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderE
|
||||
import { WORKSPACE_PANE_TIMING } from "./workspace-pane-animation";
|
||||
import { WorkspaceInspectorPane } from "./workspace-inspector-pane";
|
||||
import { WorkspaceContentWidthContext } from "./workspace-content-width";
|
||||
import {
|
||||
NativeWorkspaceModeContext,
|
||||
NativeWorkspaceInspectorContext,
|
||||
} from "../../native/v5-workspace-context";
|
||||
|
||||
interface AdaptiveWorkspaceContextValue {
|
||||
readonly layout: Layout;
|
||||
@@ -234,6 +238,7 @@ function AdaptiveWorkspaceLayoutContent(
|
||||
},
|
||||
) {
|
||||
const projectGroupingMode = props.projectGroupingMode;
|
||||
const nativeWorkspace = use(NativeWorkspaceModeContext);
|
||||
const { width, height } = useWindowDimensions();
|
||||
const pathname = props.pathname;
|
||||
const navigation = useNavigation();
|
||||
@@ -468,9 +473,10 @@ function AdaptiveWorkspaceLayoutContent(
|
||||
panes.primarySidebarVisible ? (layout.listPaneWidth ?? 0) : 0,
|
||||
);
|
||||
useEffect(() => {
|
||||
if (nativeWorkspace) return;
|
||||
const targetWidth = panes.primarySidebarVisible ? (layout.listPaneWidth ?? 0) : 0;
|
||||
renderedSidebarWidth.value = withTiming(targetWidth, WORKSPACE_PANE_TIMING);
|
||||
}, [layout.listPaneWidth, panes.primarySidebarVisible, renderedSidebarWidth]);
|
||||
}, [nativeWorkspace, layout.listPaneWidth, panes.primarySidebarVisible, renderedSidebarWidth]);
|
||||
const sidebarAnimatedStyle = useAnimatedStyle(() => ({
|
||||
opacity: Math.min(1, renderedSidebarWidth.value / 80),
|
||||
width: renderedSidebarWidth.value,
|
||||
@@ -565,6 +571,19 @@ function AdaptiveWorkspaceLayoutContent(
|
||||
],
|
||||
);
|
||||
|
||||
if (nativeWorkspace) {
|
||||
return (
|
||||
<HomeListOptionsProvider projectGroupingMode={projectGroupingMode}>
|
||||
<AdaptiveWorkspaceContext value={contextValue}>
|
||||
<NativeWorkspaceInspectorContext
|
||||
value={{ render: workspaceInspector?.render, visible: inspectorColumnTargetWidth > 0 }}
|
||||
>
|
||||
{props.children}
|
||||
</NativeWorkspaceInspectorContext>
|
||||
</AdaptiveWorkspaceContext>
|
||||
</HomeListOptionsProvider>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<HomeListOptionsProvider projectGroupingMode={projectGroupingMode}>
|
||||
<AdaptiveWorkspaceContext.Provider value={contextValue}>
|
||||
|
||||
@@ -0,0 +1,342 @@
|
||||
import {
|
||||
createNavigatorFactory,
|
||||
NavigationContext,
|
||||
NavigationRouteContext,
|
||||
StackRouter,
|
||||
useNavigationBuilder,
|
||||
type NavigatorTypeBagBase,
|
||||
type ParamListBase,
|
||||
type StackActionHelpers,
|
||||
type StackNavigationState,
|
||||
type StackRouterOptions,
|
||||
type StaticConfig,
|
||||
type TypedNavigator,
|
||||
} from "@react-navigation/native";
|
||||
import {
|
||||
NativeStackView,
|
||||
type NativeStackNavigationEventMap,
|
||||
type NativeStackNavigationOptions,
|
||||
type NativeStackNavigatorProps,
|
||||
type NativeStackTypeBag,
|
||||
} from "@react-navigation/native-stack";
|
||||
import { use, useCallback, useEffect, useMemo, useRef, type ComponentProps } from "react";
|
||||
import { View } from "react-native";
|
||||
import { Split, type SplitHostCommands } from "react-native-screens";
|
||||
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
|
||||
import { scopedThreadKey } from "../../lib/scopedEntities";
|
||||
|
||||
import { useAdaptiveWorkspaceLayout } from "./AdaptiveWorkspaceLayout";
|
||||
import { WorkspaceEmptyDetail } from "./WorkspaceEmptyDetail";
|
||||
import { NativeColumnContent as ColumnContent } from "../../native/NativeColumnContent.ios";
|
||||
import {
|
||||
modalEnvelopeOptions,
|
||||
V5CardStackView,
|
||||
V5StackView,
|
||||
} from "../../native/createV5StackNavigator.ios";
|
||||
import { NATIVE_WORKSPACE_COLUMNS_SUPPORTED } from "../../native/NativeWorkspaceColumns";
|
||||
import { V5StackHeader } from "../../native/V5StackHeader.ios";
|
||||
import {
|
||||
nativeWorkspacePopAction,
|
||||
projectWorkspaceStack,
|
||||
partitionStackPresentations,
|
||||
} from "../../native/workspace-stack-projection";
|
||||
import {
|
||||
NativePrimaryColumnContext,
|
||||
NativeWorkspaceInspectorContext,
|
||||
NativeWorkspaceModeContext,
|
||||
} from "../../native/v5-workspace-context";
|
||||
|
||||
type ViewProps = ComponentProps<typeof NativeStackView>;
|
||||
type Descriptor = ViewProps["descriptors"][string];
|
||||
type Route = ViewProps["state"]["routes"][number];
|
||||
|
||||
function ColumnScreen(props: {
|
||||
readonly descriptor: Descriptor;
|
||||
readonly primary?: boolean;
|
||||
readonly selectedThreadKey?: string | null;
|
||||
readonly onDismiss: (routeKey: string) => void;
|
||||
readonly navigation: ViewProps["navigation"];
|
||||
}) {
|
||||
const { descriptor } = props;
|
||||
const primaryColumn = useMemo(
|
||||
() => (props.primary ? { selectedThreadKey: props.selectedThreadKey ?? null } : null),
|
||||
[props.primary, props.selectedThreadKey],
|
||||
);
|
||||
const key = descriptor.route.key;
|
||||
return (
|
||||
<Split.Screen
|
||||
screenKey={key}
|
||||
onDismiss={(event) => {
|
||||
if (event.nativeEvent.isNativeDismiss) props.onDismiss(key);
|
||||
}}
|
||||
onWillAppear={() =>
|
||||
props.navigation.emit({ type: "transitionStart", target: key, data: { closing: false } })
|
||||
}
|
||||
onDidAppear={() =>
|
||||
props.navigation.emit({ type: "transitionEnd", target: key, data: { closing: false } })
|
||||
}
|
||||
onWillDisappear={() =>
|
||||
props.navigation.emit({ type: "transitionStart", target: key, data: { closing: true } })
|
||||
}
|
||||
onDidDisappear={() =>
|
||||
props.navigation.emit({ type: "transitionEnd", target: key, data: { closing: true } })
|
||||
}
|
||||
>
|
||||
<NavigationContext value={descriptor.navigation}>
|
||||
<NavigationRouteContext value={descriptor.route}>
|
||||
<V5StackHeader
|
||||
options={descriptor.options}
|
||||
canGoBack={!props.primary}
|
||||
primary={props.primary}
|
||||
/>
|
||||
<ColumnContent primary={props.primary}>
|
||||
<NativePrimaryColumnContext value={primaryColumn}>
|
||||
{descriptor.render()}
|
||||
</NativePrimaryColumnContext>
|
||||
</ColumnContent>
|
||||
</NavigationRouteContext>
|
||||
</NavigationContext>
|
||||
</Split.Screen>
|
||||
);
|
||||
}
|
||||
|
||||
function WorkspaceColumns(
|
||||
props: ViewProps & { readonly primary: Route; readonly detail: Route[] },
|
||||
) {
|
||||
const { layout, panes, togglePrimarySidebar, toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout();
|
||||
const inspector = use(NativeWorkspaceInspectorContext);
|
||||
const hostRef = useRef<SplitHostCommands>(null);
|
||||
const activeDetailKey = props.detail.at(-1)?.key;
|
||||
const threadParams = props.detail.findLast((route) => route.name === "Thread")?.params;
|
||||
const selectedThreadKey =
|
||||
threadParams &&
|
||||
"environmentId" in threadParams &&
|
||||
"threadId" in threadParams &&
|
||||
typeof threadParams.environmentId === "string" &&
|
||||
typeof threadParams.threadId === "string"
|
||||
? scopedThreadKey(
|
||||
EnvironmentId.make(threadParams.environmentId),
|
||||
ThreadId.make(threadParams.threadId),
|
||||
)
|
||||
: null;
|
||||
const handleNativeDismiss = useCallback(
|
||||
(key: string) => {
|
||||
const state = props.navigation.getState();
|
||||
const action = nativeWorkspacePopAction(state, key);
|
||||
if (action) props.navigation.dispatch(action);
|
||||
},
|
||||
[props.navigation],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
// In compact size classes UIKit exposes one column. Selecting a thread
|
||||
// changes the visible column without rebuilding either navigation stack.
|
||||
if (layout.usesSplitView) return;
|
||||
hostRef.current?.show(activeDetailKey ? "secondary" : "primary");
|
||||
}, [activeDetailKey, layout.usesSplitView]);
|
||||
|
||||
const primary = props.descriptors[props.primary.key];
|
||||
if (!primary) return null;
|
||||
return (
|
||||
<Split.Host
|
||||
ref={hostRef}
|
||||
testID="adaptive-workspace-layout"
|
||||
preferredSplitBehavior="tile"
|
||||
preferredDisplayMode={
|
||||
panes.primarySidebarVisible || !activeDetailKey ? "oneBesideSecondary" : "secondaryOnly"
|
||||
}
|
||||
displayModeButtonVisibility="never"
|
||||
presentsWithGesture
|
||||
showInspector={inspector.visible}
|
||||
onInspectorHide={() => {
|
||||
if (inspector.visible) toggleAuxiliaryPane();
|
||||
}}
|
||||
columnMetrics={{
|
||||
minimumPrimaryColumnWidth: 280,
|
||||
maximumPrimaryColumnWidth: 380,
|
||||
preferredPrimaryColumnWidthOrFraction: layout.listPaneWidth ?? 320,
|
||||
minimumSecondaryColumnWidth: 320,
|
||||
}}
|
||||
>
|
||||
<Split.Column>
|
||||
<Split.Stack>
|
||||
<ColumnScreen
|
||||
descriptor={primary}
|
||||
primary
|
||||
selectedThreadKey={selectedThreadKey}
|
||||
onDismiss={handleNativeDismiss}
|
||||
navigation={props.navigation}
|
||||
/>
|
||||
</Split.Stack>
|
||||
</Split.Column>
|
||||
<Split.Column>
|
||||
<Split.Stack>
|
||||
<Split.Screen
|
||||
screenKey="workspace-empty"
|
||||
activityMode={layout.usesSplitView && !activeDetailKey ? "attached" : "detached"}
|
||||
>
|
||||
<V5StackHeader
|
||||
options={{
|
||||
headerShown: true,
|
||||
title: "",
|
||||
unstable_headerLeftItems: () => [
|
||||
{
|
||||
type: "button",
|
||||
label: "",
|
||||
icon: { type: "sfSymbol", name: "sidebar.left" },
|
||||
onPress: togglePrimarySidebar,
|
||||
},
|
||||
],
|
||||
}}
|
||||
canGoBack={false}
|
||||
/>
|
||||
<ColumnContent>
|
||||
<WorkspaceEmptyDetail
|
||||
onStartNewTask={() =>
|
||||
props.navigation.navigate("NewTaskSheet", { screen: "NewTask" })
|
||||
}
|
||||
/>
|
||||
</ColumnContent>
|
||||
</Split.Screen>
|
||||
{props.detail.map((route) => {
|
||||
const descriptor = props.descriptors[route.key];
|
||||
return descriptor ? (
|
||||
<ColumnScreen
|
||||
key={route.key}
|
||||
descriptor={descriptor}
|
||||
onDismiss={handleNativeDismiss}
|
||||
navigation={props.navigation}
|
||||
/>
|
||||
) : null;
|
||||
})}
|
||||
</Split.Stack>
|
||||
</Split.Column>
|
||||
<Split.Inspector>
|
||||
{/* Inspector content supplies its own navigation header. */}
|
||||
<Split.HeaderConfig hidden />
|
||||
<ColumnContent>
|
||||
<View className="flex-1 bg-screen">{inspector.render?.()}</View>
|
||||
</ColumnContent>
|
||||
</Split.Inspector>
|
||||
</Split.Host>
|
||||
);
|
||||
}
|
||||
|
||||
function WorkspaceStackView(props: ViewProps) {
|
||||
const projection = projectWorkspaceStack(props.state, (route) => {
|
||||
const presentation = props.descriptors[route.key]?.options.presentation;
|
||||
return presentation !== undefined && presentation !== "card";
|
||||
});
|
||||
// Linking normally restores Home via initialRouteName. A detail-only history
|
||||
// must stay a single stack: placeholder descriptors cannot own an interactive
|
||||
// sidebar because React Navigation rejects their actions and setOptions.
|
||||
const primaryRoute = projection.primary;
|
||||
if (!primaryRoute) return <V5StackView {...props} />;
|
||||
const primaryDescriptor = props.descriptors[primaryRoute.key]!;
|
||||
const baseRoute = { key: `${props.state.key}:workspace`, name: "Workspace" };
|
||||
const baseDescriptor: Descriptor = {
|
||||
...primaryDescriptor,
|
||||
route: baseRoute,
|
||||
options: { headerShown: false },
|
||||
render: () => <WorkspaceColumns {...props} primary={primaryRoute} detail={projection.detail} />,
|
||||
};
|
||||
const overlays = partitionStackPresentations(projection.overlays, (route) => {
|
||||
const presentation = props.descriptors[route.key]?.options.presentation;
|
||||
return presentation !== undefined && presentation !== "card";
|
||||
});
|
||||
const routes = [baseRoute, ...overlays.map((group) => group[0]!)];
|
||||
return (
|
||||
<NativeStackView
|
||||
{...props}
|
||||
state={{ ...props.state, routes, index: routes.length - 1, preloadedRoutes: [] }}
|
||||
descriptors={{
|
||||
...Object.fromEntries(
|
||||
overlays.map((group) => {
|
||||
const route = group[0]!;
|
||||
const descriptor = props.descriptors[route.key]!;
|
||||
return [
|
||||
route.key,
|
||||
{
|
||||
...descriptor,
|
||||
options: modalEnvelopeOptions(descriptor.options),
|
||||
render: () => (
|
||||
<V5CardStackView
|
||||
{...props}
|
||||
state={{
|
||||
...props.state,
|
||||
routes: group,
|
||||
index: group.length - 1,
|
||||
preloadedRoutes: [],
|
||||
}}
|
||||
/>
|
||||
),
|
||||
},
|
||||
];
|
||||
}),
|
||||
),
|
||||
[baseRoute.key]: baseDescriptor,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function WorkspaceStackNavigator({
|
||||
id,
|
||||
initialRouteName,
|
||||
UNSTABLE_routeNamesChangeBehavior,
|
||||
children,
|
||||
layout,
|
||||
screenListeners,
|
||||
screenOptions,
|
||||
screenLayout,
|
||||
UNSTABLE_router,
|
||||
...rest
|
||||
}: NativeStackNavigatorProps) {
|
||||
const { state, describe, descriptors, navigation, NavigationContent } = useNavigationBuilder<
|
||||
StackNavigationState<ParamListBase>,
|
||||
StackRouterOptions,
|
||||
StackActionHelpers<ParamListBase>,
|
||||
NativeStackNavigationOptions,
|
||||
NativeStackNavigationEventMap
|
||||
>(StackRouter, {
|
||||
id,
|
||||
initialRouteName,
|
||||
UNSTABLE_routeNamesChangeBehavior,
|
||||
children,
|
||||
layout,
|
||||
screenListeners,
|
||||
screenOptions,
|
||||
screenLayout,
|
||||
UNSTABLE_router,
|
||||
});
|
||||
const WorkspaceView = NATIVE_WORKSPACE_COLUMNS_SUPPORTED ? WorkspaceStackView : V5StackView;
|
||||
return (
|
||||
<NativeWorkspaceModeContext value={NATIVE_WORKSPACE_COLUMNS_SUPPORTED}>
|
||||
<NavigationContent>
|
||||
<WorkspaceView
|
||||
{...rest}
|
||||
state={state}
|
||||
describe={describe}
|
||||
descriptors={descriptors}
|
||||
navigation={navigation}
|
||||
/>
|
||||
</NavigationContent>
|
||||
</NativeWorkspaceModeContext>
|
||||
);
|
||||
}
|
||||
|
||||
type WorkspaceTypeBag<
|
||||
ParamList extends ParamListBase,
|
||||
NavigatorID extends string | undefined,
|
||||
> = Omit<NativeStackTypeBag<ParamList, NavigatorID>, "Navigator"> & {
|
||||
Navigator: typeof WorkspaceStackNavigator;
|
||||
};
|
||||
|
||||
export function createWorkspaceStackNavigator<
|
||||
const ParamList extends ParamListBase,
|
||||
const NavigatorID extends string | undefined = string | undefined,
|
||||
const TypeBag extends NavigatorTypeBagBase = WorkspaceTypeBag<ParamList, NavigatorID>,
|
||||
const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,
|
||||
>(config?: Config): TypedNavigator<TypeBag, Config> {
|
||||
return createNavigatorFactory(WorkspaceStackNavigator)(config);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export { createNativeStackNavigator as createWorkspaceStackNavigator } from "@react-navigation/native-stack";
|
||||
@@ -3,11 +3,9 @@ import type { HeaderBarButtonMailSearchToolbarItem } from "react-native-screens"
|
||||
import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
|
||||
|
||||
/**
|
||||
* The patched mail-style toolbar is built natively from iOS 26 Liquid Glass
|
||||
* UIKit (`UIGlassEffect`) with no earlier fallback: pre-26 the native side
|
||||
* silently drops the item and hides the navigation toolbar entirely. Screens
|
||||
* that send it must fall back to standard search/toolbar primitives when this
|
||||
* is false.
|
||||
* Group search, filtering, and composition on platforms with Liquid Glass.
|
||||
* The v5 header adapter turns this intent into UISearchController and native
|
||||
* toolbar items. Earlier iOS versions use separate search and toolbar options.
|
||||
*/
|
||||
export const NATIVE_MAIL_SEARCH_TOOLBAR_SUPPORTED = NATIVE_LIQUID_GLASS_SUPPORTED;
|
||||
|
||||
@@ -20,12 +18,7 @@ type NativeMailSearchToolbarInput = Omit<
|
||||
>;
|
||||
|
||||
/**
|
||||
* Builds the patched react-native-screens Mail-style bottom search toolbar.
|
||||
*
|
||||
* Keeping this behind an app-level helper makes the iOS-only RNS patch an
|
||||
* explicit layout primitive instead of a per-screen object literal. Android can
|
||||
* keep using platform-specific header/search primitives without depending on
|
||||
* this helper.
|
||||
* Describe the thread-list search and actions for the native header adapter.
|
||||
*/
|
||||
export function createNativeMailSearchToolbarItem(
|
||||
input: NativeMailSearchToolbarInput,
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
|
||||
import { hasCloudPublicConfig } from "../cloud/publicConfig";
|
||||
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
|
||||
import { NativeHeaderToolbar } from "../../native/StackHeader";
|
||||
import { NativeHeaderToolbar, NativeStackScreenOptions } from "../../native/StackHeader";
|
||||
import { useSavedRemoteConnections } from "../../state/use-remote-environment-registry";
|
||||
import { SettingsRow } from "./components/SettingsRow";
|
||||
import { SettingsSection } from "./components/SettingsSection";
|
||||
@@ -29,14 +29,19 @@ export function SettingsRouteScreen() {
|
||||
|
||||
return (
|
||||
<>
|
||||
{Platform.OS === "ios" ? (
|
||||
<NativeStackScreenOptions options={{ headerBackVisible: !layout.usesSplitView }} />
|
||||
) : null}
|
||||
{Platform.OS === "ios" && layout.usesSplitView ? (
|
||||
<NativeHeaderToolbar placement="left">
|
||||
<NativeHeaderToolbar.Button
|
||||
accessibilityLabel="Go back"
|
||||
icon="chevron.left"
|
||||
onPress={() => navigation.goBack()}
|
||||
/>
|
||||
</NativeHeaderToolbar>
|
||||
<>
|
||||
<NativeHeaderToolbar placement="left">
|
||||
<NativeHeaderToolbar.Button
|
||||
accessibilityLabel="Go back"
|
||||
icon="chevron.left"
|
||||
onPress={() => navigation.goBack()}
|
||||
/>
|
||||
</NativeHeaderToolbar>
|
||||
</>
|
||||
) : null}
|
||||
<SettingsEnvironmentFilterHeader closeSettings />
|
||||
{Platform.OS === "android" ? (
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
import { type KnownTerminalSession } from "@t3tools/client-runtime/state/terminal";
|
||||
import { SymbolView } from "../../components/AppSymbol";
|
||||
import { ScreenHeader } from "../../components/ScreenHeader";
|
||||
import { useNativeColumnLayoutMetrics } from "../../native/native-layout-metrics";
|
||||
import { StackActions, useNavigation, type StaticScreenProps } from "@react-navigation/native";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { Alert, Platform, Pressable, View } from "react-native";
|
||||
@@ -254,6 +255,7 @@ type ThreadTerminalRouteScreenProps = StaticScreenProps<{
|
||||
|
||||
export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps) {
|
||||
const insets = useSafeAreaInsets();
|
||||
const nativeColumnMetrics = useNativeColumnLayoutMetrics();
|
||||
const navigation = useNavigation();
|
||||
const writeTerminal = useAtomCommand(terminalEnvironment.write, "terminal write");
|
||||
const resizeTerminal = useAtomCommand(terminalEnvironment.resize, "terminal resize");
|
||||
@@ -1202,6 +1204,10 @@ export function ThreadTerminalRouteScreen(props: ThreadTerminalRouteScreenProps)
|
||||
Platform.OS === "android"
|
||||
? themeVariables["--color-card-alt"]
|
||||
: terminalTheme.background,
|
||||
// The v5 column extends behind UIKit chrome. Its measured top
|
||||
// reservation is zero when UIKit has already inset the body or moved the bar.
|
||||
paddingTop:
|
||||
Platform.OS === "ios" ? (nativeColumnMetrics?.safeArea.top ?? insets.top) : 0,
|
||||
paddingBottom:
|
||||
Platform.OS === "android" && !keyboardState.isVisible ? insets.bottom : 0,
|
||||
}}
|
||||
|
||||
@@ -29,7 +29,7 @@ import {
|
||||
} from "@t3tools/client-runtime/state/thread-settled";
|
||||
import { useState, type ReactNode } from "react";
|
||||
import { NavigationContainer, NavigationIndependentTree } from "@react-navigation/native";
|
||||
import { createNativeStackNavigator } from "@react-navigation/native-stack";
|
||||
import { createV5StackNavigator as createNativeStackNavigator } from "../../native/createV5StackNavigator";
|
||||
import { ScrollView, useWindowDimensions, View } from "react-native";
|
||||
import { useMobileNavigationTheme } from "../../lib/useMobileNavigationTheme";
|
||||
import { NativeHeaderToolbar } from "../../native/StackHeader";
|
||||
|
||||
@@ -664,11 +664,11 @@ function ThreadRouteContent(
|
||||
() =>
|
||||
inspectorMode === null ? null : (
|
||||
<ThreadInspectorContentStack
|
||||
Files={FilesInspector}
|
||||
Git={GitInspector}
|
||||
renderFiles={FilesInspector}
|
||||
renderGit={GitInspector}
|
||||
mode={inspectorMode}
|
||||
resetKeys={[routeThreadIdentity, selectedThreadCwd]}
|
||||
Route={props.renderInspector ? RouteInspector : undefined}
|
||||
renderRoute={props.renderInspector ? RouteInspector : undefined}
|
||||
/>
|
||||
),
|
||||
[
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { createV5StackNavigator as createNativeStackNavigator } from "../../native/createV5StackNavigator";
|
||||
import type {
|
||||
EnvironmentId,
|
||||
ModelSelection,
|
||||
@@ -15,10 +16,7 @@ import {
|
||||
getProviderOptionDescriptors,
|
||||
} from "@t3tools/shared/model";
|
||||
import { useNavigation, useRoute, type RouteProp } from "@react-navigation/native";
|
||||
import {
|
||||
createNativeStackNavigator,
|
||||
type NativeStackNavigationProp,
|
||||
} from "@react-navigation/native-stack";
|
||||
import { type NativeStackNavigationProp } from "@react-navigation/native-stack";
|
||||
import * as Haptics from "expo-haptics";
|
||||
import { AsyncResult } from "effect/reactivity";
|
||||
import {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { createV5StackNavigator as createNativeStackNavigator } from "../../native/createV5StackNavigator";
|
||||
import { NavigationContainer, NavigationIndependentTree } from "@react-navigation/native";
|
||||
import {
|
||||
createNativeStackNavigator,
|
||||
type NativeStackNavigationOptions,
|
||||
} from "@react-navigation/native-stack";
|
||||
import { type NativeStackNavigationOptions } from "@react-navigation/native-stack";
|
||||
import type { ReactNode } from "react";
|
||||
import { Platform } from "react-native";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState, type ComponentType, type ReactNode } from "react";
|
||||
import { useEffect, useState, type ReactNode } from "react";
|
||||
import { View } from "react-native";
|
||||
|
||||
import { RenderErrorBoundary, RenderFailureView } from "../../components/RenderErrorBoundary";
|
||||
@@ -43,11 +43,11 @@ function InspectorContentPane(props: {
|
||||
}
|
||||
|
||||
export function ThreadInspectorContentStack(props: {
|
||||
readonly Files: ComponentType;
|
||||
readonly Git: ComponentType;
|
||||
readonly renderFiles: () => ReactNode;
|
||||
readonly renderGit?: () => ReactNode;
|
||||
readonly mode: ThreadInspectorMode;
|
||||
readonly resetKeys: readonly [string | null, string | null];
|
||||
readonly Route?: ComponentType;
|
||||
readonly renderRoute?: () => ReactNode;
|
||||
}) {
|
||||
const [mountedModes, setMountedModes] = useState<ReadonlySet<ThreadInspectorMode>>(
|
||||
() => new Set([props.mode]),
|
||||
@@ -81,10 +81,6 @@ export function ThreadInspectorContentStack(props: {
|
||||
return () => clearTimeout(timeout);
|
||||
}, [props.mode]);
|
||||
|
||||
const Files = props.Files;
|
||||
const Git = props.Git;
|
||||
const Route = props.Route;
|
||||
|
||||
return (
|
||||
<View className="flex-1">
|
||||
<InspectorContentPane
|
||||
@@ -92,24 +88,31 @@ export function ThreadInspectorContentStack(props: {
|
||||
resetKeys={props.resetKeys}
|
||||
visible={props.mode === "files"}
|
||||
>
|
||||
<Files />
|
||||
<InspectorRenderer render={props.renderFiles} />
|
||||
</InspectorContentPane>
|
||||
<InspectorContentPane
|
||||
mounted={mountedModes.has("git") || props.mode === "git"}
|
||||
resetKeys={props.resetKeys}
|
||||
visible={props.mode === "git"}
|
||||
>
|
||||
<Git />
|
||||
</InspectorContentPane>
|
||||
{Route ? (
|
||||
{props.renderGit ? (
|
||||
<InspectorContentPane
|
||||
mounted={mountedModes.has("git") || props.mode === "git"}
|
||||
resetKeys={props.resetKeys}
|
||||
visible={props.mode === "git"}
|
||||
>
|
||||
<InspectorRenderer render={props.renderGit} />
|
||||
</InspectorContentPane>
|
||||
) : null}
|
||||
{props.renderRoute ? (
|
||||
<InspectorContentPane
|
||||
mounted={mountedModes.has("route") || props.mode === "route"}
|
||||
resetKeys={props.resetKeys}
|
||||
visible={props.mode === "route"}
|
||||
>
|
||||
<Route />
|
||||
<InspectorRenderer render={props.renderRoute} />
|
||||
</InspectorContentPane>
|
||||
) : null}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
// Render callbacks carry changing route data; they are not component types.
|
||||
function InspectorRenderer(props: { readonly render: () => ReactNode }) {
|
||||
return <>{props.render()}</>;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
/** Geometry of the body inside a native navigation column. */
|
||||
export interface NativeLayoutMetrics {
|
||||
readonly width: number;
|
||||
readonly height: number;
|
||||
readonly horizontalSizeClass: "compact" | "regular";
|
||||
readonly safeArea: {
|
||||
readonly top: number;
|
||||
readonly bottom: number;
|
||||
readonly left: number;
|
||||
readonly right: number;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import { HeaderHeightContext } from "@react-navigation/elements";
|
||||
import { useState, type ReactNode } from "react";
|
||||
import { View } from "react-native";
|
||||
import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context";
|
||||
import { NativeColumnLayoutMetricsContext } from "./native-layout-metrics";
|
||||
import type { NativeLayoutMetrics } from "../lib/reserved-regions";
|
||||
import { NativeLayoutObserver } from "./NativeLayoutObserver";
|
||||
|
||||
export function NativeColumnContent(props: {
|
||||
readonly children: ReactNode;
|
||||
readonly primary?: boolean;
|
||||
}) {
|
||||
const [metrics, setMetrics] = useState<NativeLayoutMetrics | null>(null);
|
||||
return (
|
||||
<View className={props.primary ? "flex-1 bg-drawer" : "flex-1 bg-screen"}>
|
||||
<SafeAreaProvider style={{ flex: 1 }}>
|
||||
<SafeAreaView edges={["left", "right"]} style={{ flex: 1 }}>
|
||||
{/* Observe the inset body. UIKit can reserve other columns in its safe area. */}
|
||||
<View style={{ flex: 1 }}>
|
||||
<NativeLayoutObserver onChange={setMetrics} />
|
||||
<NativeColumnLayoutMetricsContext value={metrics}>
|
||||
<HeaderHeightContext value={metrics?.safeArea.top ?? undefined}>
|
||||
{props.children}
|
||||
</HeaderHeightContext>
|
||||
</NativeColumnLayoutMetricsContext>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
</SafeAreaProvider>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { requireNativeView, requireOptionalNativeModule } from "expo";
|
||||
import type { NativeSyntheticEvent, ViewProps } from "react-native";
|
||||
import type { NativeLayoutMetrics } from "../lib/reserved-regions";
|
||||
|
||||
interface ObserverProps extends ViewProps {
|
||||
readonly onMetricsChange?: (event: NativeSyntheticEvent<NativeLayoutMetrics>) => void;
|
||||
}
|
||||
|
||||
// An older development client can still run the compact app while it rebuilds.
|
||||
function resolveObserver() {
|
||||
try {
|
||||
const module = requireOptionalNativeModule<{
|
||||
readonly ViewPrototypes?: { readonly T3NativeControls_LayoutMetrics?: unknown };
|
||||
}>("T3NativeControls");
|
||||
if (!module?.ViewPrototypes?.T3NativeControls_LayoutMetrics) return null;
|
||||
return requireNativeView<ObserverProps>("T3NativeControls", "LayoutMetrics");
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
const Observer = resolveObserver();
|
||||
|
||||
export function NativeLayoutObserver(props: {
|
||||
readonly onChange?: (metrics: NativeLayoutMetrics) => void;
|
||||
}) {
|
||||
return Observer ? (
|
||||
<Observer
|
||||
pointerEvents="none"
|
||||
onMetricsChange={props.onChange ? (event) => props.onChange?.(event.nativeEvent) : undefined}
|
||||
style={{ position: "absolute", top: 0, bottom: 0, left: 0, right: 0 }}
|
||||
/>
|
||||
) : null;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { NativeLayoutMetrics } from "../lib/reserved-regions";
|
||||
|
||||
export function NativeLayoutObserver(_props: {
|
||||
readonly onChange?: (metrics: NativeLayoutMetrics) => void;
|
||||
}) {
|
||||
return null;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { requireOptionalNativeModule } from "expo";
|
||||
import { Platform } from "react-native";
|
||||
const nativeControls = requireOptionalNativeModule<{ readonly supportsWorkspaceColumns?: boolean }>(
|
||||
"T3NativeControls",
|
||||
);
|
||||
export const NATIVE_WORKSPACE_COLUMNS_SUPPORTED =
|
||||
Platform.OS === "ios" && Platform.isPad && nativeControls?.supportsWorkspaceColumns === true;
|
||||
@@ -0,0 +1,3 @@
|
||||
import { Platform } from "react-native";
|
||||
// Android retains its existing navigator. The iOS file checks native availability.
|
||||
export const NATIVE_WORKSPACE_COLUMNS_SUPPORTED = Platform.OS === "ios" && Platform.isPad;
|
||||
@@ -0,0 +1,253 @@
|
||||
import type {
|
||||
NativeStackHeaderItem,
|
||||
NativeStackHeaderItemMenu,
|
||||
NativeStackNavigationOptions,
|
||||
} from "@react-navigation/native-stack";
|
||||
import { isValidElement, useRef } from "react";
|
||||
import { Platform, StyleSheet } from "react-native";
|
||||
import { useMobileNavigationTheme } from "../lib/useMobileNavigationTheme";
|
||||
import {
|
||||
SearchBar,
|
||||
Stack,
|
||||
type HeaderBarButtonMailSearchToolbarItem,
|
||||
type SearchBarCommands,
|
||||
type StackHeaderConfigProps,
|
||||
type StackHeaderMenuElementIOS,
|
||||
type StackHeaderMenuIOS,
|
||||
type HeaderBarButtonItemWithMenu,
|
||||
type HeaderBarButtonSearchBarPlacementItem,
|
||||
} from "react-native-screens";
|
||||
|
||||
type HeaderItem = NonNullable<NonNullable<StackHeaderConfigProps["ios"]>["leadingItems"]>[number];
|
||||
type ToolbarItem =
|
||||
| NativeStackHeaderItem
|
||||
| HeaderBarButtonMailSearchToolbarItem
|
||||
| HeaderBarButtonSearchBarPlacementItem;
|
||||
type Options = NativeStackNavigationOptions & {
|
||||
readonly unstable_navigationItemStyle?: "editor" | "navigator";
|
||||
readonly headerSubtitle?: string;
|
||||
readonly unstable_headerSubtitle?: string;
|
||||
readonly headerSubtitleStyle?: { color?: string; fontSize?: number; fontFamily?: string };
|
||||
readonly unstable_headerCenterItems?: () => NativeStackHeaderItem[];
|
||||
readonly unstable_headerToolbarItems?: () => ToolbarItem[];
|
||||
};
|
||||
|
||||
type MenuElementInput =
|
||||
| NativeStackHeaderItemMenu["menu"]["items"][number]
|
||||
| HeaderBarButtonItemWithMenu["menu"]["items"][number];
|
||||
type MenuInput = { readonly title?: string; readonly items: readonly MenuElementInput[] };
|
||||
|
||||
function convertIcon(
|
||||
icon:
|
||||
| Extract<NativeStackHeaderItem, { type: "button" }>["icon"]
|
||||
| HeaderBarButtonItemWithMenu["icon"],
|
||||
) {
|
||||
if (!icon) return undefined;
|
||||
if (icon.type === "image")
|
||||
return icon.tinted === false
|
||||
? { type: "imageSource" as const, imageSource: icon.source }
|
||||
: { type: "templateSource" as const, templateSource: icon.source };
|
||||
return icon;
|
||||
}
|
||||
|
||||
function convertMenu(menu: MenuInput, id: string): StackHeaderMenuIOS {
|
||||
const children = menu.items.flatMap<StackHeaderMenuElementIOS>((item, index) => {
|
||||
if ("hidden" in item && item.hidden) return [];
|
||||
const childId = `${id}:${index}`;
|
||||
if (item.type === "submenu") {
|
||||
return [
|
||||
{
|
||||
...convertMenu({ items: item.items }, childId),
|
||||
title: "label" in item ? item.label : item.title,
|
||||
displayInline:
|
||||
"inline" in item
|
||||
? item.inline
|
||||
: "displayInline" in item
|
||||
? item.displayInline
|
||||
: undefined,
|
||||
},
|
||||
];
|
||||
}
|
||||
// Use actions even for checked entries: the app owns their durable state.
|
||||
return [
|
||||
{
|
||||
id: childId,
|
||||
type: "menuItem" as const,
|
||||
itemType: "action" as const,
|
||||
title: "label" in item ? item.label : item.title,
|
||||
icon: convertIcon(item.icon),
|
||||
onPress: item.disabled ? undefined : item.onPress,
|
||||
keepsMenuPresented: item.keepsMenuPresented,
|
||||
disabled: item.disabled,
|
||||
destructive: item.destructive,
|
||||
subtitle:
|
||||
("subtitle" in item ? item.subtitle : undefined) ??
|
||||
("description" in item ? item.description : undefined),
|
||||
state: item.state,
|
||||
},
|
||||
];
|
||||
});
|
||||
return { id, type: "menu", title: menu.title, children };
|
||||
}
|
||||
|
||||
function convertItems(items: NativeStackHeaderItem[], prefix: string): HeaderItem[] {
|
||||
return items.map((item, index): HeaderItem => {
|
||||
const id =
|
||||
item.type === "spacing" ? `${prefix}:${index}` : (item.identifier ?? `${prefix}:${index}`);
|
||||
switch (item.type) {
|
||||
case "spacing":
|
||||
return { type: "spacer", id, sizing: "fixed", width: item.spacing };
|
||||
case "custom":
|
||||
return {
|
||||
type: "item",
|
||||
id,
|
||||
render: () => item.element,
|
||||
hidesSharedBackground: item.hidesSharedBackground,
|
||||
};
|
||||
case "menu":
|
||||
return {
|
||||
type: "item",
|
||||
id,
|
||||
identifier: item.identifier,
|
||||
title: item.label || item.accessibilityLabel || undefined,
|
||||
icon: convertIcon(item.icon),
|
||||
menu: item.disabled ? undefined : convertMenu(item.menu, `${id}:menu`),
|
||||
hidesSharedBackground: item.hidesSharedBackground,
|
||||
};
|
||||
case "button":
|
||||
return {
|
||||
type: "item",
|
||||
id,
|
||||
identifier: item.identifier,
|
||||
title: item.label || item.accessibilityLabel || undefined,
|
||||
icon: convertIcon(item.icon),
|
||||
onPress: item.disabled ? undefined : item.onPress,
|
||||
hidesSharedBackground: item.hidesSharedBackground,
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Translate the existing screen options to v5's native header API. */
|
||||
export function V5StackHeader(props: {
|
||||
readonly options: Options;
|
||||
readonly canGoBack: boolean;
|
||||
readonly primary?: boolean;
|
||||
}) {
|
||||
const { options } = props;
|
||||
const theme = useMobileNavigationTheme();
|
||||
const searchRef = useRef<SearchBarCommands>(null);
|
||||
const itemProps = { tintColor: options.headerTintColor, canGoBack: props.canGoBack };
|
||||
const leading = convertItems(options.unstable_headerLeftItems?.(itemProps) ?? [], "leading");
|
||||
const trailing = convertItems(
|
||||
[
|
||||
...(options.unstable_headerCenterItems?.() ?? []),
|
||||
...(options.unstable_headerRightItems?.(itemProps) ?? []),
|
||||
],
|
||||
"trailing",
|
||||
);
|
||||
const toolbar = options.unstable_headerToolbarItems?.() ?? [];
|
||||
const mailSearch = toolbar.find(
|
||||
(item): item is HeaderBarButtonMailSearchToolbarItem => item.type === "mailSearchToolbar",
|
||||
);
|
||||
const bottomSearch = Boolean(mailSearch) && Platform.OS === "ios" && !Platform.isPad;
|
||||
const bottom = toolbar.flatMap<HeaderItem>((item, index) => {
|
||||
if (item.type === "mailSearchToolbar") return [];
|
||||
if (item.type === "searchBarPlacement")
|
||||
return [{ type: "item", id: `toolbar-search:${index}`, searchBarPlacement: true }];
|
||||
return convertItems([item], `toolbar:${index}`);
|
||||
});
|
||||
if (mailSearch) {
|
||||
if (mailSearch.filterMenu)
|
||||
bottom.push({
|
||||
type: "item",
|
||||
id: mailSearch.filterButtonId ?? "filter",
|
||||
icon: {
|
||||
type: "sfSymbol",
|
||||
name: mailSearch.filterSystemImageName ?? "line.3.horizontal.decrease",
|
||||
},
|
||||
menu: convertMenu(mailSearch.filterMenu, "filter-menu"),
|
||||
});
|
||||
if (bottomSearch) {
|
||||
if (bottom.length)
|
||||
bottom.push({ type: "spacer", id: "before-search", sizing: "fixed", width: 8 });
|
||||
bottom.push({ type: "item", id: "home-search", searchBarPlacement: true });
|
||||
if (mailSearch.onComposePress)
|
||||
bottom.push({ type: "spacer", id: "after-search", sizing: "fixed", width: 8 });
|
||||
}
|
||||
if (mailSearch.onComposePress)
|
||||
bottom.push({
|
||||
type: "item",
|
||||
id: mailSearch.composeButtonId ?? "compose",
|
||||
icon: { type: "sfSymbol", name: mailSearch.composeSystemImageName ?? "square.and.pencil" },
|
||||
onPress: mailSearch.onComposePress,
|
||||
});
|
||||
}
|
||||
const left = options.headerLeft?.(itemProps);
|
||||
const right = options.headerRight?.(itemProps);
|
||||
if (!options.unstable_headerLeftItems && isValidElement(left))
|
||||
leading.push({ type: "item", id: "custom-left", render: () => left });
|
||||
if (!options.unstable_headerRightItems && isValidElement(right))
|
||||
trailing.push({ type: "item", id: "custom-right", render: () => right });
|
||||
const title = typeof options.headerTitle === "string" ? options.headerTitle : options.title;
|
||||
const titleElement =
|
||||
typeof options.headerTitle === "function"
|
||||
? options.headerTitle({ children: title ?? "", tintColor: options.headerTintColor })
|
||||
: undefined;
|
||||
const searchOptions = options.headerSearchBarOptions;
|
||||
const titleStyle = StyleSheet.flatten(options.headerTitleStyle);
|
||||
const headerStyle = StyleSheet.flatten(options.headerStyle);
|
||||
const appearance = {
|
||||
backgroundColor:
|
||||
headerStyle?.backgroundColor ??
|
||||
(options.headerTransparent ? "transparent" : theme.colors.card),
|
||||
shadowColor: options.headerShadowVisible === false ? "transparent" : undefined,
|
||||
titleFontSize: titleStyle?.fontSize,
|
||||
titleFontFamily: titleStyle?.fontFamily,
|
||||
titleFontWeight: titleStyle?.fontWeight,
|
||||
titleFontColor: titleStyle?.color,
|
||||
subtitleFontSize: options.headerSubtitleStyle?.fontSize,
|
||||
subtitleFontColor: options.headerSubtitleStyle?.color,
|
||||
};
|
||||
return (
|
||||
<Stack.HeaderConfig
|
||||
hidden={options.headerShown === false}
|
||||
transparent={options.headerTransparent}
|
||||
title={title}
|
||||
subtitle={options.unstable_headerSubtitle ?? options.headerSubtitle}
|
||||
backButtonHidden={options.headerBackVisible === false}
|
||||
ios={{
|
||||
navigationItemStyle: options.unstable_navigationItemStyle,
|
||||
tintColor: options.headerTintColor,
|
||||
searchBar:
|
||||
mailSearch || searchOptions ? (
|
||||
<SearchBar
|
||||
{...searchOptions}
|
||||
ref={searchOptions?.ref ?? searchRef}
|
||||
hideNavigationBar={false}
|
||||
hideWhenScrolling={false}
|
||||
allowToolbarIntegration={searchOptions?.allowToolbarIntegration ?? true}
|
||||
placement={bottomSearch ? "integrated" : (searchOptions?.placement ?? "automatic")}
|
||||
placeholder={mailSearch?.placeholder ?? searchOptions?.placeholder ?? "Search"}
|
||||
onChangeText={(event) => {
|
||||
mailSearch?.onSearchTextChange?.(event.nativeEvent.text);
|
||||
searchOptions?.onChangeText?.(event);
|
||||
}}
|
||||
/>
|
||||
) : undefined,
|
||||
toolbarItems: bottom,
|
||||
leadingItems: leading,
|
||||
trailingItems: trailing,
|
||||
titleItem: isValidElement(titleElement)
|
||||
? { id: "title", render: () => titleElement }
|
||||
: undefined,
|
||||
largeTitleEnabled: options.headerLargeTitle,
|
||||
backButtonDisplayMode: options.headerBackButtonDisplayMode ?? "minimal",
|
||||
backButtonMenuEnabled: options.headerBackButtonMenuEnabled ?? true,
|
||||
backButtonTitle: options.headerBackTitle,
|
||||
standardAppearance: appearance,
|
||||
scrollEdgeAppearance: appearance,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,422 @@
|
||||
import {
|
||||
createNavigatorFactory,
|
||||
NavigationContext,
|
||||
NavigationRouteContext,
|
||||
StackRouter,
|
||||
useNavigationBuilder,
|
||||
usePreventRemoveContext,
|
||||
type NavigatorTypeBagBase,
|
||||
type ParamListBase,
|
||||
type StackActionHelpers,
|
||||
type StackNavigationState,
|
||||
type StackRouterOptions,
|
||||
type StaticConfig,
|
||||
type TypedNavigator,
|
||||
} from "@react-navigation/native";
|
||||
import {
|
||||
NativeStackView,
|
||||
type NativeStackNavigationEventMap,
|
||||
type NativeStackNavigationOptions,
|
||||
type NativeStackNavigatorProps,
|
||||
type NativeStackTypeBag,
|
||||
} from "@react-navigation/native-stack";
|
||||
import { useCallback, useState, type ComponentProps } from "react";
|
||||
import { StyleSheet, View } from "react-native";
|
||||
import { FormSheet, Stack } from "react-native-screens";
|
||||
import { V5StackHeader } from "./V5StackHeader.ios";
|
||||
import { NativeColumnContent } from "./NativeColumnContent.ios";
|
||||
import {
|
||||
nativeWorkspacePopAction,
|
||||
nativeWorkspacePopCount,
|
||||
partitionStackPresentations,
|
||||
reconcileStackScreens,
|
||||
} from "./workspace-stack-projection";
|
||||
|
||||
export type V5StackViewProps = ComponentProps<typeof NativeStackView>;
|
||||
|
||||
/** The presentation envelope must not mount a second search bar or header. */
|
||||
export function modalEnvelopeOptions(options: NativeStackNavigationOptions) {
|
||||
return {
|
||||
...Object.fromEntries(
|
||||
Object.entries(options).filter(
|
||||
([key]) =>
|
||||
!key.startsWith("header") &&
|
||||
!key.startsWith("unstable_header") &&
|
||||
key !== "unstable_navigationItemStyle",
|
||||
),
|
||||
),
|
||||
headerShown: false,
|
||||
};
|
||||
}
|
||||
|
||||
/** Keep outgoing screens until UIKit completes its pop, as required by v5. */
|
||||
export function V5CardStackView(props: V5StackViewProps) {
|
||||
const { preventedRoutes } = usePreventRemoveContext();
|
||||
const [screens, setScreens] = useState({
|
||||
completedNativeDismissals: new Set<string>(),
|
||||
routes: props.state.routes,
|
||||
descriptors: props.descriptors,
|
||||
observedRoutes: props.state.routes,
|
||||
observedDescriptors: props.descriptors,
|
||||
});
|
||||
if (
|
||||
screens.observedRoutes !== props.state.routes ||
|
||||
screens.observedDescriptors !== props.descriptors
|
||||
) {
|
||||
const routes = reconcileStackScreens(
|
||||
screens.routes,
|
||||
props.state.routes,
|
||||
screens.completedNativeDismissals,
|
||||
);
|
||||
const active = new Set(props.state.routes.map((route) => route.key));
|
||||
const retainedKeys = new Set(routes.map((route) => route.key));
|
||||
setScreens({
|
||||
completedNativeDismissals: new Set(
|
||||
[...screens.completedNativeDismissals].filter((key) => active.has(key)),
|
||||
),
|
||||
routes,
|
||||
descriptors: Object.fromEntries(
|
||||
Object.entries({ ...screens.descriptors, ...props.descriptors }).filter(([key]) =>
|
||||
retainedKeys.has(key),
|
||||
),
|
||||
),
|
||||
observedRoutes: props.state.routes,
|
||||
observedDescriptors: props.descriptors,
|
||||
});
|
||||
}
|
||||
// Keep the real descriptor through dismissal. describe(route, true) creates
|
||||
// a placeholder whose navigation rejects setOptions and dispatches.
|
||||
const nativeDismiss = useCallback(
|
||||
(key: string) => {
|
||||
const state = props.navigation.getState();
|
||||
const attached = state.routes.some((route) => route.key === key);
|
||||
setScreens((current) => {
|
||||
const completedNativeDismissals = new Set(current.completedNativeDismissals);
|
||||
if (attached) {
|
||||
completedNativeDismissals.add(key);
|
||||
return { ...current, completedNativeDismissals };
|
||||
}
|
||||
// A delayed callback needs immediate cleanup: the router already
|
||||
// removed the route, so no further router update will follow.
|
||||
completedNativeDismissals.delete(key);
|
||||
const descriptors = { ...current.descriptors };
|
||||
delete descriptors[key];
|
||||
return {
|
||||
...current,
|
||||
completedNativeDismissals,
|
||||
routes: current.routes.filter((route) => route.key !== key),
|
||||
descriptors,
|
||||
};
|
||||
});
|
||||
const action = nativeWorkspacePopAction(state, key);
|
||||
if (action) props.navigation.dispatch(action);
|
||||
},
|
||||
[props.navigation, setScreens],
|
||||
);
|
||||
const removeDismissed = useCallback(
|
||||
(key: string) => {
|
||||
if (!props.navigation.getState().routes.some((route) => route.key === key)) {
|
||||
setScreens((current) => {
|
||||
const descriptors = { ...current.descriptors };
|
||||
delete descriptors[key];
|
||||
return {
|
||||
...current,
|
||||
routes: current.routes.filter((route) => route.key !== key),
|
||||
descriptors,
|
||||
};
|
||||
});
|
||||
}
|
||||
},
|
||||
[props.navigation, setScreens],
|
||||
);
|
||||
return (
|
||||
<View className="flex-1 bg-screen">
|
||||
<Stack.Host>
|
||||
{screens.routes.map((route, index) => {
|
||||
const descriptor = props.descriptors[route.key] ?? screens.descriptors[route.key];
|
||||
if (!descriptor) return null;
|
||||
const attached = props.state.routes.some((current) => current.key === route.key);
|
||||
return (
|
||||
<Stack.Screen
|
||||
key={route.key}
|
||||
screenKey={route.key}
|
||||
activityMode={attached ? "attached" : "detached"}
|
||||
preventNativeDismiss={
|
||||
preventedRoutes[route.key]?.preventRemove ||
|
||||
descriptor.options.gestureEnabled === false
|
||||
}
|
||||
onDismiss={removeDismissed}
|
||||
onNativeDismiss={nativeDismiss}
|
||||
onNativeDismissPrevented={() => {
|
||||
if (preventedRoutes[route.key]?.preventRemove) descriptor.navigation.goBack();
|
||||
}}
|
||||
onWillAppear={() =>
|
||||
props.navigation.emit({
|
||||
type: "transitionStart",
|
||||
target: route.key,
|
||||
data: { closing: false },
|
||||
})
|
||||
}
|
||||
onDidAppear={() =>
|
||||
props.navigation.emit({
|
||||
type: "transitionEnd",
|
||||
target: route.key,
|
||||
data: { closing: false },
|
||||
})
|
||||
}
|
||||
onWillDisappear={() =>
|
||||
props.navigation.emit({
|
||||
type: "transitionStart",
|
||||
target: route.key,
|
||||
data: { closing: true },
|
||||
})
|
||||
}
|
||||
onDidDisappear={() =>
|
||||
props.navigation.emit({
|
||||
type: "transitionEnd",
|
||||
target: route.key,
|
||||
data: { closing: true },
|
||||
})
|
||||
}
|
||||
>
|
||||
<NavigationContext value={descriptor.navigation}>
|
||||
<NavigationRouteContext value={descriptor.route}>
|
||||
<V5StackHeader options={descriptor.options} canGoBack={index > 0} />
|
||||
<NativeColumnContent>{descriptor.render()}</NativeColumnContent>
|
||||
</NavigationRouteContext>
|
||||
</NavigationContext>
|
||||
</Stack.Screen>
|
||||
);
|
||||
})}
|
||||
</Stack.Host>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
/** v5 owns pushes and headers; the legacy renderer only presents modal groups. */
|
||||
export function V5StackView(props: V5StackViewProps) {
|
||||
const groups = partitionStackPresentations(props.state.routes, (route) => {
|
||||
const presentation = props.descriptors[route.key]?.options.presentation;
|
||||
return (
|
||||
["SettingsSheet", "NewTaskSheet"].includes(route.name) ||
|
||||
(presentation !== undefined && presentation !== "card")
|
||||
);
|
||||
});
|
||||
const routes = groups.map((group) => group[0]!);
|
||||
const descriptors = Object.fromEntries(
|
||||
groups.map((group) => {
|
||||
const first = group[0]!;
|
||||
const descriptor = props.descriptors[first.key]!;
|
||||
return [
|
||||
first.key,
|
||||
{
|
||||
...descriptor,
|
||||
options: modalEnvelopeOptions(descriptor.options),
|
||||
render: () => (
|
||||
<V5CardStackView
|
||||
{...props}
|
||||
state={{
|
||||
...props.state,
|
||||
routes: group,
|
||||
index: group.length - 1,
|
||||
preloadedRoutes: [],
|
||||
}}
|
||||
/>
|
||||
),
|
||||
},
|
||||
];
|
||||
}),
|
||||
);
|
||||
return (
|
||||
<NativeStackView
|
||||
{...props}
|
||||
descriptors={descriptors}
|
||||
state={{ ...props.state, routes, index: routes.length - 1, preloadedRoutes: [] }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/** Keep a direct card host mounted while v5 form sheets present above it. */
|
||||
export function V5SheetStackView(props: V5StackViewProps) {
|
||||
const { preventedRoutes } = usePreventRemoveContext();
|
||||
const groups = partitionStackPresentations(
|
||||
props.state.routes,
|
||||
(route) => props.descriptors[route.key]?.options.presentation === "formSheet",
|
||||
);
|
||||
const [retained, setRetained] = useState({
|
||||
groups: groups.slice(1),
|
||||
descriptors: props.descriptors,
|
||||
observedRoutes: props.state.routes,
|
||||
observedDescriptors: props.descriptors,
|
||||
});
|
||||
if (
|
||||
retained.observedRoutes !== props.state.routes ||
|
||||
retained.observedDescriptors !== props.descriptors
|
||||
) {
|
||||
const active = new Set(groups.slice(1).map((group) => group[0]!.key));
|
||||
const sheets = [
|
||||
...groups.slice(1),
|
||||
...retained.groups.filter((group) => !active.has(group[0]!.key)),
|
||||
];
|
||||
const sheetKeys = new Set(sheets.flatMap((group) => group.map((route) => route.key)));
|
||||
setRetained({
|
||||
groups: sheets,
|
||||
descriptors: Object.fromEntries(
|
||||
Object.entries({ ...retained.descriptors, ...props.descriptors }).filter(([key]) =>
|
||||
sheetKeys.has(key),
|
||||
),
|
||||
),
|
||||
observedRoutes: props.state.routes,
|
||||
observedDescriptors: props.descriptors,
|
||||
});
|
||||
}
|
||||
const removeSheet = (key: string) => {
|
||||
setRetained((current) => {
|
||||
const sheets = current.groups.filter((group) => group[0]!.key !== key);
|
||||
const sheetKeys = new Set(sheets.flatMap((group) => group.map((route) => route.key)));
|
||||
return {
|
||||
...current,
|
||||
groups: sheets,
|
||||
descriptors: Object.fromEntries(
|
||||
Object.entries(current.descriptors).filter(([routeKey]) => sheetKeys.has(routeKey)),
|
||||
),
|
||||
};
|
||||
});
|
||||
};
|
||||
const base = groups[0] ?? [];
|
||||
return (
|
||||
<View className="flex-1 bg-screen">
|
||||
<V5CardStackView
|
||||
{...props}
|
||||
state={{ ...props.state, routes: base, index: base.length - 1, preloadedRoutes: [] }}
|
||||
/>
|
||||
{retained.groups.map((group) => {
|
||||
const first = group[0]!;
|
||||
const descriptor = props.descriptors[first.key] ?? retained.descriptors[first.key];
|
||||
if (!descriptor) return null;
|
||||
const options = descriptor.options;
|
||||
const attached = nativeWorkspacePopCount(props.state, first.key) > 0;
|
||||
return (
|
||||
<FormSheet
|
||||
key={first.key}
|
||||
isOpen={attached}
|
||||
detents={options.sheetAllowedDetents}
|
||||
initialDetentIndex={options.sheetInitialDetentIndex}
|
||||
largestUndimmedDetentIndex={options.sheetLargestUndimmedDetentIndex}
|
||||
prefersGrabberVisible={options.sheetGrabberVisible}
|
||||
preferredCornerRadius={options.sheetCornerRadius}
|
||||
prefersScrollingExpandsWhenScrolledToEdge={options.sheetExpandsWhenScrolledToEdge}
|
||||
nativeContainerStyle={{
|
||||
backgroundColor: StyleSheet.flatten(options.contentStyle)?.backgroundColor,
|
||||
}}
|
||||
preventNativeDismiss={
|
||||
group.some((route) => preventedRoutes[route.key]?.preventRemove) ||
|
||||
options.gestureEnabled === false
|
||||
}
|
||||
onNativeDismissPrevented={() => {
|
||||
const guarded = group.findLast((route) => preventedRoutes[route.key]?.preventRemove);
|
||||
if (guarded) {
|
||||
const state = props.navigation.getState();
|
||||
const action = nativeWorkspacePopAction(state, first.key);
|
||||
if (action) props.navigation.dispatch(action);
|
||||
}
|
||||
}}
|
||||
onDismiss={() => removeSheet(first.key)}
|
||||
onNativeDismiss={() => {
|
||||
const state = props.navigation.getState();
|
||||
const action = nativeWorkspacePopAction(state, first.key);
|
||||
if (action) props.navigation.dispatch(action);
|
||||
removeSheet(first.key);
|
||||
}}
|
||||
>
|
||||
<V5CardStackView
|
||||
{...props}
|
||||
descriptors={{ ...retained.descriptors, ...props.descriptors }}
|
||||
state={{
|
||||
...props.state,
|
||||
routes: group,
|
||||
index: group.length - 1,
|
||||
preloadedRoutes: [],
|
||||
}}
|
||||
/>
|
||||
</FormSheet>
|
||||
);
|
||||
})}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
function V5Navigator({
|
||||
nativeSheets,
|
||||
id,
|
||||
initialRouteName,
|
||||
UNSTABLE_routeNamesChangeBehavior,
|
||||
children,
|
||||
layout,
|
||||
screenListeners,
|
||||
screenOptions,
|
||||
screenLayout,
|
||||
UNSTABLE_router,
|
||||
...rest
|
||||
}: NativeStackNavigatorProps & { readonly nativeSheets?: boolean }) {
|
||||
const { state, describe, descriptors, navigation, NavigationContent } = useNavigationBuilder<
|
||||
StackNavigationState<ParamListBase>,
|
||||
StackRouterOptions,
|
||||
StackActionHelpers<ParamListBase>,
|
||||
NativeStackNavigationOptions,
|
||||
NativeStackNavigationEventMap
|
||||
>(StackRouter, {
|
||||
id,
|
||||
initialRouteName,
|
||||
UNSTABLE_routeNamesChangeBehavior,
|
||||
children,
|
||||
layout,
|
||||
screenListeners,
|
||||
screenOptions,
|
||||
screenLayout,
|
||||
UNSTABLE_router,
|
||||
});
|
||||
const StackView = nativeSheets ? V5SheetStackView : V5StackView;
|
||||
return (
|
||||
<NavigationContent>
|
||||
<StackView
|
||||
{...rest}
|
||||
state={state}
|
||||
describe={describe}
|
||||
descriptors={descriptors}
|
||||
navigation={navigation}
|
||||
/>
|
||||
</NavigationContent>
|
||||
);
|
||||
}
|
||||
|
||||
function V5StackNavigator(props: NativeStackNavigatorProps) {
|
||||
return <V5Navigator {...props} />;
|
||||
}
|
||||
|
||||
function V5SheetStackNavigator(props: NativeStackNavigatorProps) {
|
||||
return <V5Navigator {...props} nativeSheets />;
|
||||
}
|
||||
|
||||
type V5TypeBag<ParamList extends ParamListBase, NavigatorID extends string | undefined> = Omit<
|
||||
NativeStackTypeBag<ParamList, NavigatorID>,
|
||||
"Navigator"
|
||||
> & { Navigator: typeof V5StackNavigator };
|
||||
export function createV5StackNavigator<
|
||||
const ParamList extends ParamListBase,
|
||||
const NavigatorID extends string | undefined = string | undefined,
|
||||
const TypeBag extends NavigatorTypeBagBase = V5TypeBag<ParamList, NavigatorID>,
|
||||
const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,
|
||||
>(config?: Config): TypedNavigator<TypeBag, Config> {
|
||||
return createNavigatorFactory(V5StackNavigator)(config);
|
||||
}
|
||||
|
||||
/** For navigators whose presentations are cards and form sheets only. */
|
||||
export function createV5SheetStackNavigator<
|
||||
const ParamList extends ParamListBase,
|
||||
const NavigatorID extends string | undefined = string | undefined,
|
||||
const TypeBag extends NavigatorTypeBagBase = V5TypeBag<ParamList, NavigatorID>,
|
||||
const Config extends StaticConfig<TypeBag> = StaticConfig<TypeBag>,
|
||||
>(config?: Config): TypedNavigator<TypeBag, Config> {
|
||||
return createNavigatorFactory(V5SheetStackNavigator)(config);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export {
|
||||
createNativeStackNavigator as createV5StackNavigator,
|
||||
createNativeStackNavigator as createV5SheetStackNavigator,
|
||||
} from "@react-navigation/native-stack";
|
||||
@@ -0,0 +1,25 @@
|
||||
import { createContext, use, useState, type ReactNode } from "react";
|
||||
import type { NativeLayoutMetrics } from "../lib/reserved-regions";
|
||||
import { NativeLayoutObserver } from "./NativeLayoutObserver";
|
||||
|
||||
const NativeLayoutContext = createContext<NativeLayoutMetrics | null>(null);
|
||||
// Column reservations come from UIKit's layout, outside the resizing navigator.
|
||||
export const NativeColumnLayoutMetricsContext = createContext<NativeLayoutMetrics | null>(null);
|
||||
|
||||
export function NativeLayoutMetricsProvider(props: { readonly children: ReactNode }) {
|
||||
const [metrics, setMetrics] = useState<NativeLayoutMetrics | null>(null);
|
||||
return (
|
||||
<NativeLayoutContext value={metrics}>
|
||||
<NativeLayoutObserver onChange={setMetrics} />
|
||||
{props.children}
|
||||
</NativeLayoutContext>
|
||||
);
|
||||
}
|
||||
|
||||
export function useNativeLayoutMetrics() {
|
||||
return use(NativeLayoutContext);
|
||||
}
|
||||
|
||||
export function useNativeColumnLayoutMetrics() {
|
||||
return use(NativeColumnLayoutMetricsContext);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { createContext, type ReactNode } from "react";
|
||||
|
||||
// The router is shared with the other platforms; only iOS uses native columns.
|
||||
export const NativeWorkspaceModeContext = createContext(false);
|
||||
export const NativePrimaryColumnContext = createContext<{
|
||||
readonly selectedThreadKey: string | null;
|
||||
} | null>(null);
|
||||
export const NativeWorkspaceInspectorContext = createContext<{
|
||||
readonly render: (() => ReactNode) | undefined;
|
||||
readonly visible: boolean;
|
||||
}>({ render: undefined, visible: false });
|
||||
@@ -0,0 +1,175 @@
|
||||
import * as NodeModule from "node:module";
|
||||
import type { ParamListBase, StackNavigationState } from "@react-navigation/native";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
nativeWorkspacePopAction,
|
||||
nativeWorkspacePopCount,
|
||||
projectWorkspaceStack,
|
||||
partitionStackPresentations,
|
||||
reconcileStackScreens,
|
||||
} from "./workspace-stack-projection";
|
||||
|
||||
// Load the same router as native navigation without importing React Native into Node.
|
||||
const requireNavigation = NodeModule.createRequire(
|
||||
NodeModule.createRequire(import.meta.url).resolve("@react-navigation/native/package.json"),
|
||||
);
|
||||
const { StackRouter } = requireNavigation("@react-navigation/routers") as {
|
||||
StackRouter: typeof import("@react-navigation/native").StackRouter;
|
||||
};
|
||||
|
||||
const home = { key: "home", name: "Home" };
|
||||
const thread = { key: "thread", name: "Thread", params: { threadId: "draft-thread" } };
|
||||
const files = { key: "files", name: "ThreadFiles", params: thread.params };
|
||||
const settings = { key: "settings", name: "SettingsSheet" };
|
||||
const legal = { key: "legal", name: "SettingsLegal" };
|
||||
|
||||
function history(
|
||||
routes: StackNavigationState<ParamListBase>["routes"],
|
||||
): StackNavigationState<ParamListBase> {
|
||||
return {
|
||||
key: "router",
|
||||
type: "stack",
|
||||
stale: false,
|
||||
index: routes.length - 1,
|
||||
routeNames: ["Home", "Thread", "ThreadFiles", "SettingsSheet", "SettingsLegal"],
|
||||
routes,
|
||||
preloadedRoutes: [],
|
||||
};
|
||||
}
|
||||
|
||||
describe("workspace router projection", () => {
|
||||
it("keeps workspace flows beside Home and restores them after a modal closes", () => {
|
||||
const draft = { key: "draft", name: "NewTaskSheet" };
|
||||
const modal = { key: "connect", name: "ConnectOnboarding" };
|
||||
const routes = [home, thread, draft, settings, legal];
|
||||
const isOverlay = (route: { name: string }) => route.name === "ConnectOnboarding";
|
||||
expect(projectWorkspaceStack(history([...routes, modal]), isOverlay)).toEqual({
|
||||
primary: home,
|
||||
detail: [thread, draft, settings, legal],
|
||||
overlays: [modal],
|
||||
});
|
||||
expect(projectWorkspaceStack(history(routes), isOverlay)).toEqual({
|
||||
primary: home,
|
||||
detail: [thread, draft, settings, legal],
|
||||
overlays: [],
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps the thread and file history in the detail column when a modal is opened", () => {
|
||||
const state = history([home, thread, files, settings, legal]);
|
||||
const projection = projectWorkspaceStack(state, (route) => route.name === "SettingsSheet");
|
||||
expect(projection).toEqual({
|
||||
primary: home,
|
||||
detail: [thread, files],
|
||||
overlays: [settings, legal],
|
||||
});
|
||||
expect(projection.detail[0]).toBe(thread);
|
||||
expect(state.routes).toEqual([home, thread, files, settings, legal]);
|
||||
});
|
||||
|
||||
it("retains a cold-linked detail route without changing the router history", () => {
|
||||
const state = history([thread, files]);
|
||||
expect(projectWorkspaceStack(state, () => false)).toEqual({
|
||||
primary: undefined,
|
||||
detail: [thread, files],
|
||||
overlays: [],
|
||||
});
|
||||
expect(state.routes[0]).toBe(thread);
|
||||
});
|
||||
|
||||
it("restores the empty detail column after Back reaches the thread list", () => {
|
||||
expect(projectWorkspaceStack(history([home]), () => false)).toEqual({
|
||||
primary: home,
|
||||
detail: [],
|
||||
overlays: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("native workspace dismissal", () => {
|
||||
it("dismisses a sheet and its pushed pages without removing the underlying draft", () => {
|
||||
const state = history([home, thread, settings, legal]);
|
||||
const action = nativeWorkspacePopAction(state, settings.key)!;
|
||||
const next = StackRouter({}).getStateForAction(state, action, {
|
||||
routeNames: state.routeNames,
|
||||
routeParamList: {},
|
||||
routeGetIdList: {},
|
||||
});
|
||||
expect(next?.routes).toEqual([home, thread]);
|
||||
expect(next?.routes[1]).toBe(thread);
|
||||
expect(next?.index).toBe(1);
|
||||
});
|
||||
|
||||
it("does not dismiss retained sheets beyond the active index", () => {
|
||||
const state = { ...history([home, thread, settings, legal]), index: 1 };
|
||||
expect(nativeWorkspacePopAction(state, settings.key)).toBeNull();
|
||||
expect(nativeWorkspacePopAction(state, legal.key)).toBeNull();
|
||||
});
|
||||
it("pops a native dismissed file while keeping the conversation and its draft mounted", () => {
|
||||
expect(nativeWorkspacePopCount(history([home, thread, files]), files.key)).toBe(1);
|
||||
});
|
||||
|
||||
it("removes the descendants when UIKit dismisses their parent conversation", () => {
|
||||
expect(nativeWorkspacePopCount(history([home, thread, files]), thread.key)).toBe(2);
|
||||
});
|
||||
|
||||
it("ignores delayed callbacks from JS removal and replacement", () => {
|
||||
expect(nativeWorkspacePopCount(history([home, thread]), files.key)).toBe(0);
|
||||
expect(
|
||||
nativeWorkspacePopCount(history([home, { ...thread, key: "replacement" }]), thread.key),
|
||||
).toBe(0);
|
||||
});
|
||||
|
||||
it("never removes the root or a route ahead of the active index", () => {
|
||||
const state = history([home, thread, files]);
|
||||
expect(nativeWorkspacePopCount(state, home.key)).toBe(0);
|
||||
expect(nativeWorkspacePopCount({ ...state, index: 1 }, files.key)).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("v5 stack handoff", () => {
|
||||
it("releases a completed native pop when the router acknowledges it", () => {
|
||||
const completed = new Set([files.key]);
|
||||
expect(reconcileStackScreens([home, thread, files], [home, thread, files], completed)).toEqual([
|
||||
home,
|
||||
thread,
|
||||
files,
|
||||
]);
|
||||
expect(reconcileStackScreens([home, thread, files], [home, thread], completed)).toEqual([
|
||||
home,
|
||||
thread,
|
||||
]);
|
||||
});
|
||||
it("still retains an unfinished JS pop beside a completed native pop", () => {
|
||||
expect(reconcileStackScreens([home, thread, files], [home], new Set([files.key]))).toEqual([
|
||||
thread,
|
||||
home,
|
||||
]);
|
||||
});
|
||||
it("retains removed native screens through a pop followed immediately by a push", () => {
|
||||
const popped = reconcileStackScreens([home, thread, files], [home, thread]);
|
||||
const next = { ...files, key: "new-files" };
|
||||
const screens = reconcileStackScreens(popped, [home, thread, next]);
|
||||
expect(screens.map((route) => route.key)).toEqual(["files", "home", "thread", "new-files"]);
|
||||
expect(screens.filter((route) => [home, thread, next].includes(route))).toEqual([
|
||||
home,
|
||||
thread,
|
||||
next,
|
||||
]);
|
||||
expect(screens[0]).toBe(files);
|
||||
});
|
||||
it("updates params without retaining duplicate copies of the same screen", () => {
|
||||
const updated = { ...thread, params: { threadId: "another-thread" } };
|
||||
expect(reconcileStackScreens([home, thread], [home, updated])).toEqual([home, updated]);
|
||||
});
|
||||
it("keeps card pushes inside the modal they belong to", () => {
|
||||
const secondModal = { ...settings, key: "another-settings" };
|
||||
expect(
|
||||
partitionStackPresentations(
|
||||
[home, thread, settings, legal, secondModal],
|
||||
(route) => route.name === "SettingsSheet",
|
||||
),
|
||||
).toEqual([[home, thread], [settings, legal], [secondModal]]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,73 @@
|
||||
import type {
|
||||
NavigationState,
|
||||
ParamListBase,
|
||||
StackNavigationState,
|
||||
} from "@react-navigation/native";
|
||||
|
||||
type Route = StackNavigationState<ParamListBase>["routes"][number];
|
||||
|
||||
/** Project one router history into native columns and a modal presentation stack. */
|
||||
export function projectWorkspaceStack(
|
||||
state: StackNavigationState<ParamListBase>,
|
||||
isOverlay: (route: Route) => boolean,
|
||||
) {
|
||||
const firstOverlay = state.routes.findIndex(isOverlay);
|
||||
const workspaceRoutes = state.routes.slice(0, firstOverlay < 0 ? undefined : firstOverlay);
|
||||
const primary = workspaceRoutes.find((route) => route.name === "Home");
|
||||
const detail = workspaceRoutes.filter((route) => route.name !== "Home");
|
||||
const overlays = firstOverlay < 0 ? [] : state.routes.slice(firstOverlay);
|
||||
return { primary, detail, overlays };
|
||||
}
|
||||
|
||||
/** Native callbacks can arrive after a JS pop or replace; those must not pop the next screen. */
|
||||
export function nativeWorkspacePopCount(
|
||||
state: Pick<NavigationState, "index" | "routes">,
|
||||
dismissedKey: string,
|
||||
): number {
|
||||
const index = state.routes.findIndex((route) => route.key === dismissedKey);
|
||||
return index <= 0 || index > state.index ? 0 : state.index - index + 1;
|
||||
}
|
||||
|
||||
/** POP counts backwards from its source, so dismiss a group from the active descendant. */
|
||||
export function nativeWorkspacePopAction(
|
||||
state: Pick<NavigationState, "key" | "index" | "routes">,
|
||||
dismissedKey: string,
|
||||
) {
|
||||
const count = nativeWorkspacePopCount(state, dismissedKey);
|
||||
return count
|
||||
? {
|
||||
type: "POP" as const,
|
||||
payload: { count },
|
||||
source: state.routes[state.index]!.key,
|
||||
target: state.key,
|
||||
}
|
||||
: null;
|
||||
}
|
||||
|
||||
/** Group pushes with the modal that owns their native stack. */
|
||||
export function partitionStackPresentations<T>(
|
||||
routes: readonly T[],
|
||||
isModal: (route: T) => boolean,
|
||||
): T[][] {
|
||||
const groups: T[][] = [];
|
||||
for (const route of routes) {
|
||||
if (groups.length === 0 || isModal(route)) groups.push([]);
|
||||
groups.at(-1)!.push(route);
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
||||
/** Preserve UIKit's outgoing screens, before newly pushed screens, until dismissal. */
|
||||
export function reconcileStackScreens<T extends { readonly key: string }>(
|
||||
previous: readonly T[],
|
||||
current: readonly T[],
|
||||
completedNativeDismissals: ReadonlySet<string> = new Set(),
|
||||
): T[] {
|
||||
const active = new Set(current.map((route) => route.key));
|
||||
return [
|
||||
...previous.filter(
|
||||
(route) => !active.has(route.key) && !completedNativeDismissals.has(route.key),
|
||||
),
|
||||
...current,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
# Building the mobile Screens dependency
|
||||
|
||||
The mobile v5 stack uses a committed tarball from the
|
||||
[T3 Screens fork](https://github.com/juliusmarminge/react-native-screens/tree/t3-v5.0.0-t3.7).
|
||||
The fork owns the integration changes; the app does not patch this package.
|
||||
Each archive includes compiled JavaScript, declarations, native source and
|
||||
`t3-fork.json` recording its version, source commit and upstream base.
|
||||
|
||||
To reproduce the current archive with Node 24 and the repository's pinned Yarn:
|
||||
|
||||
```sh
|
||||
git clone --branch t3-v5.0.0-t3.7 https://github.com/juliusmarminge/react-native-screens.git /tmp/t3-screens-fork
|
||||
yarn --cwd /tmp/t3-screens-fork pack:t3 /absolute/path/to/t3code/apps/mobile/deps
|
||||
```
|
||||
|
||||
For an update, sync the fork's `main` with upstream, merge it and the required
|
||||
proposal branches into `t3/main`, increment the `5.0.0-t3.N` version, pin `t3Fork.upstreamCommit` to the
|
||||
integrated upstream SHA and commit.
|
||||
Run `pack:t3` from that clean checkout and tag the source as `t3-v<version>`.
|
||||
Replace the old archive, update `apps/mobile/package.json` and run `vp i` to
|
||||
regenerate the lockfile. Verify mobile types and affected navigation tests.
|
||||
Changes to native source also require rebuilding and testing the native client.
|
||||
@@ -149,3 +149,56 @@ index 1e1246f709feb04c01cf3221472cc1219a8fffac..f526d4fe2d2738becbe8d29c59d1105a
|
||||
}>;
|
||||
|
||||
export interface SwipeableMethods {
|
||||
diff --git a/apple/Handlers/RNPanHandler.m b/apple/Handlers/RNPanHandler.m
|
||||
--- a/apple/Handlers/RNPanHandler.m
|
||||
+++ b/apple/Handlers/RNPanHandler.m
|
||||
@@ -31,6 +31,7 @@
|
||||
@property (nonatomic) CGFloat failOffsetYStart;
|
||||
@property (nonatomic) CGFloat failOffsetYEnd;
|
||||
@property (nonatomic) CGFloat activateAfterLongPress;
|
||||
+@property (nonatomic) BOOL handlingTouchStart;
|
||||
|
||||
#if !TARGET_OS_OSX && !TARGET_OS_TV
|
||||
@property (atomic, readonly, strong) RNGHStylusData *stylusData;
|
||||
@@ -126,9 +127,14 @@
|
||||
|
||||
- (void)interactionsBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
- if (self.state == UIGestureRecognizerStatePossible && ![self.delegate gestureRecognizerShouldBegin:self]) {
|
||||
- self.state = UIGestureRecognizerStateFailed;
|
||||
- return;
|
||||
+ if (self.state == UIGestureRecognizerStatePossible) {
|
||||
+ self.handlingTouchStart = touches.count > 0;
|
||||
+ BOOL shouldBegin = [self.delegate gestureRecognizerShouldBegin:self];
|
||||
+ self.handlingTouchStart = NO;
|
||||
+ if (!shouldBegin) {
|
||||
+ self.state = UIGestureRecognizerStateFailed;
|
||||
+ return;
|
||||
+ }
|
||||
}
|
||||
|
||||
if (touches.count == 0) {
|
||||
@@ -476,6 +482,23 @@
|
||||
|
||||
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
|
||||
{
|
||||
+#if !TARGET_OS_OSX && !TARGET_OS_TV
|
||||
+ RNBetterPanGestureRecognizer *recognizer = (RNBetterPanGestureRecognizer *)gestureRecognizer;
|
||||
+ if (!recognizer.handlingTouchStart && recognizer.allowedScrollTypesMask != 0 && recognizer.numberOfTouches == 0) {
|
||||
+ // Trackpad scroll events can begin without touchesMoved enforcing failure
|
||||
+ // offsets. Reject vertical scrolling before a horizontal row pan cancels
|
||||
+ // the enclosing UIScrollView. The manual touch-start preflight above has
|
||||
+ // no current translation yet, so leave that path to the touch callbacks.
|
||||
+ CGPoint translation = [recognizer translationInView:recognizer.view.window];
|
||||
+ BOOL horizontalOnly = (!isnan(recognizer.activeOffsetXStart) || !isnan(recognizer.activeOffsetXEnd)) &&
|
||||
+ isnan(recognizer.activeOffsetYStart) && isnan(recognizer.activeOffsetYEnd);
|
||||
+ if ([recognizer shouldFailUnderCustomCriteria] ||
|
||||
+ (horizontalOnly && fabs(translation.y) > fabs(translation.x))) {
|
||||
+ return NO;
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
RNGestureHandlerState savedState = _lastState;
|
||||
BOOL shouldBegin = [super gestureRecognizerShouldBegin:gestureRecognizer];
|
||||
_lastState = savedState;
|
||||
File diff suppressed because it is too large.
Load diff
Generated
+12
-12
@@ -116,11 +116,10 @@ patchedDependencies:
|
||||
[email protected]: fe40d857765bcd6a77aac1fed275e5b8f9415c29b972decdce05fb96de5665e6
|
||||
[email protected]: d00838b5b215a4c45f89b8b7d34878d158528756fbcf281bae1cbd6f0752deed
|
||||
[email protected]: f2fe901c61cde17986240002d05c172d5d0272d83ffaab8d0ebeb922763be414
|
||||
[email protected]: d518a937e3cb2df5e7d67f1ab6b265c74a8639e4572d1b032b7b747e9b1c01a9
|
||||
[email protected]: 3037216c0dd1b14e8877441bde1a7404d1c6e9c09f835bd184c3cdba4aa066ad
|
||||
[email protected]: 6e448411781347cd0b87868ee279117514a399801c18f233ddca4fa3935be75d
|
||||
[email protected]: 642b47830730acff3761fe29cf54271d18b493c0070c750097850b7ea032e00c
|
||||
[email protected]: daf4a639ce3f951af630a3711e4082d58e3a11e5a79f45efb0b59925327ebde2
|
||||
[email protected]: cc1301436ee62c39860acc9ee1a1e60b7d47e6abd211c42effa62c056d165483
|
||||
|
||||
importers:
|
||||
|
||||
@@ -292,7 +291,7 @@ importers:
|
||||
version: 7.3.4([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
'@react-navigation/native-stack':
|
||||
specifier: 7.17.6
|
||||
version: 7.17.6(patch_hash=e667c3cef8c78bb9ff4882ee5bd23a432247b843060a9499eb5f07e9e2295552)(cdeee8948497d4b80ffe015e2a003650)
|
||||
version: 7.17.6(patch_hash=e667c3cef8c78bb9ff4882ee5bd23a432247b843060a9499eb5f07e9e2295552)(141a742cd91f55378cde709a48a3af06)
|
||||
'@shikijs/core':
|
||||
specifier: 4.2.0
|
||||
version: 4.2.0
|
||||
@@ -454,7 +453,7 @@ importers:
|
||||
version: 0.88.0-rc.3(@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])
|
||||
react-native-gesture-handler:
|
||||
specifier: ~3.2.1
|
||||
version: 3.2.1(patch_hash=d518a937e3cb2df5e7d67f1ab6b265c74a8639e4572d1b032b7b747e9b1c01a9)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
version: 3.2.1(patch_hash=3037216c0dd1b14e8877441bde1a7404d1c6e9c09f835bd184c3cdba4aa066ad)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
react-native-image-viewing:
|
||||
specifier: ^0.2.2
|
||||
version: 0.2.2([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
@@ -474,8 +473,8 @@ importers:
|
||||
specifier: ~5.9.1
|
||||
version: 5.9.1([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
react-native-screens:
|
||||
specifier: ~4.28.0
|
||||
version: 4.28.0(patch_hash=cc1301436ee62c39860acc9ee1a1e60b7d47e6abd211c42effa62c056d165483)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
specifier: file:deps/react-native-screens-5.0.0-t3.7.tgz
|
||||
version: file:apps/mobile/deps/react-native-screens-5.0.0-t3.7.tgz([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
react-native-shiki-engine:
|
||||
specifier: ^0.3.12
|
||||
version: 0.3.12([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
@@ -10071,8 +10070,9 @@ packages:
|
||||
react: '*'
|
||||
react-native: '*'
|
||||
|
||||
react-native-screens@4.28.0:
|
||||
resolution: {integrity: sha512-0/79Z8RCibuaAHti+DJ2Dq0m6UFWh4+p1bH58K3cjiQ7IDWs5kU9tCAj4lXcJMHHonbF2mIE2BeaPSEvOpIiFg==}
|
||||
react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.7.tgz:
|
||||
resolution: {integrity: sha512-Di1+YTCuhWpk9helKBxkvXAVAQTCSRo24tpFBGXdbTAT4vPm2vGPbtPe+lnIXcePjNHbTEaI1ha5n9PqQKl5lg==, tarball: file:apps/mobile/deps/react-native-screens-5.0.0-t3.7.tgz}
|
||||
version: 5.0.0-t3.7
|
||||
peerDependencies:
|
||||
react: '*'
|
||||
react-native: '*'
|
||||
@@ -15198,7 +15198,7 @@ snapshots:
|
||||
optionalDependencies:
|
||||
'@react-native-masked-view/masked-view': 0.3.2([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
|
||||
'@react-navigation/[email protected](patch_hash=e667c3cef8c78bb9ff4882ee5bd23a432247b843060a9499eb5f07e9e2295552)(cdeee8948497d4b80ffe015e2a003650)':
|
||||
'@react-navigation/[email protected](patch_hash=e667c3cef8c78bb9ff4882ee5bd23a432247b843060a9499eb5f07e9e2295552)(141a742cd91f55378cde709a48a3af06)':
|
||||
dependencies:
|
||||
'@react-navigation/elements': 2.9.26(83de68753219ecf7f3321e065bd378be)
|
||||
'@react-navigation/native': 7.3.4([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
@@ -15206,7 +15206,7 @@ snapshots:
|
||||
react: 19.3.0
|
||||
react-native: 0.88.0-rc.3(@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])
|
||||
react-native-safe-area-context: 5.9.1([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
react-native-screens: 4.28.0(patch_hash=cc1301436ee62c39860acc9ee1a1e60b7d47e6abd211c42effa62c056d165483)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
react-native-screens: file:apps/mobile/deps/react-native-screens-5.0.0-t3.7.tgz([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected])
|
||||
sf-symbols-typescript: 2.2.0
|
||||
warn-once: 0.1.1
|
||||
transitivePeerDependencies:
|
||||
@@ -21123,7 +21123,7 @@ snapshots:
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
[email protected](patch_hash=d518a937e3cb2df5e7d67f1ab6b265c74a8639e4572d1b032b7b747e9b1c01a9)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected]):
|
||||
[email protected](patch_hash=3037216c0dd1b14e8877441bde1a7404d1c6e9c09f835bd184c3cdba4aa066ad)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected]):
|
||||
dependencies:
|
||||
'@types/react-test-renderer': 19.1.0
|
||||
invariant: 2.2.4
|
||||
@@ -21173,7 +21173,7 @@ snapshots:
|
||||
react: 19.3.0
|
||||
react-native: 0.88.0-rc.3(@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected])
|
||||
|
||||
react-native-screens@4.28.0(patch_hash=cc1301436ee62c39860acc9ee1a1e60b7d47e6abd211c42effa62c056d165483)([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected]):
|
||||
react-native-screens@file:apps/mobile/deps/react-native-screens-5.0.0-t3.7.tgz([email protected](@babel/[email protected])(@react-native/[email protected](@babel/[email protected])([email protected])([email protected]))(@types/[email protected])([email protected])([email protected])([email protected]))([email protected]):
|
||||
dependencies:
|
||||
react: 19.3.0
|
||||
react-freeze: 1.0.4([email protected])
|
||||
|
||||
@@ -284,7 +284,6 @@ patchedDependencies:
|
||||
[email protected]: patches/[email protected]
|
||||
[email protected]: patches/[email protected]
|
||||
[email protected]: patches/[email protected]
|
||||
[email protected]: patches/[email protected]
|
||||
|
||||
peerDependencyRules:
|
||||
allowAny:
|
||||
|
||||
@@ -41,6 +41,13 @@ function copyWorkspaceManifestFixture(targetRoot: string): void {
|
||||
NodeFS.cpSync(sourcePath, destinationPath);
|
||||
}
|
||||
|
||||
const mobileDependencies = NodePath.resolve(repoRoot, "apps/mobile/deps");
|
||||
if (NodeFS.existsSync(mobileDependencies)) {
|
||||
NodeFS.cpSync(mobileDependencies, NodePath.resolve(targetRoot, "apps/mobile/deps"), {
|
||||
recursive: true,
|
||||
});
|
||||
}
|
||||
|
||||
const patchesDirectory = NodePath.resolve(repoRoot, "patches");
|
||||
if (NodeFS.existsSync(patchesDirectory)) {
|
||||
NodeFS.cpSync(patchesDirectory, NodePath.resolve(targetRoot, "patches"), { recursive: true });
|
||||
|
||||
Reference in new issue
Block a user