refactor(mobile): share push animation, cover missed transparent headers
Review follow-ups: - Extract the iOS push-animation choice into lib/pushScreenAnimation and use it in every stack that pushed with slide_from_right (root, thread, git, settings, connections, new) so the black-void workaround cannot drift between files. - Apply useHeaderBlurEffect to the two transparent headers the first pass missed: the review sheet and the files tree screen. - Drop String() around ColorValue contentStyle backgrounds; an unresolved CSS variable would otherwise stringify to the invalid color "undefined" instead of a harmless no-op. - Document why the terminal screen intentionally omits fullScreenGestureEnabled. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
e03abb3a61
commit
d327c77e10
9 files changed
+51
-31
No files matched your search
@@ -8,7 +8,7 @@ import {
|
||||
import { usePathname } from "expo-router";
|
||||
import Stack from "expo-router/stack";
|
||||
import { useCallback } from "react";
|
||||
import { Platform, StatusBar, useColorScheme } from "react-native";
|
||||
import { StatusBar, useColorScheme } from "react-native";
|
||||
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
||||
import { KeyboardProvider } from "react-native-keyboard-controller";
|
||||
import { SafeAreaProvider } from "react-native-safe-area-context";
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
useClerkSettingsSheetDetent,
|
||||
} from "../features/cloud/ClerkSettingsSheetDetent";
|
||||
import { useAgentNotificationNavigation } from "../features/agent-awareness/notificationNavigation";
|
||||
import { pushScreenAnimation } from "../lib/pushScreenAnimation";
|
||||
import { useHeaderBlurEffect } from "../lib/useHeaderBlurEffect";
|
||||
import { useThemeColor } from "../lib/useThemeColor";
|
||||
|
||||
@@ -99,7 +100,7 @@ function AppNavigatorContent() {
|
||||
<Stack.Screen
|
||||
name="index"
|
||||
options={{
|
||||
contentStyle: { backgroundColor: String(screenColor) },
|
||||
contentStyle: { backgroundColor: screenColor },
|
||||
headerShown: true,
|
||||
headerTransparent: true,
|
||||
headerBlurEffect,
|
||||
@@ -116,11 +117,8 @@ function AppNavigatorContent() {
|
||||
<Stack.Screen
|
||||
name="threads/[environmentId]/[threadId]"
|
||||
options={{
|
||||
// iOS keeps the default push animation: forcing slide_from_right
|
||||
// switches react-native-screens to its custom swipe animator,
|
||||
// which leaves a black void behind the screen during swipe-back.
|
||||
animation: Platform.OS === "ios" ? "default" : "slide_from_right",
|
||||
contentStyle: { backgroundColor: String(screenColor) },
|
||||
animation: pushScreenAnimation,
|
||||
contentStyle: { backgroundColor: screenColor },
|
||||
gestureEnabled: true,
|
||||
fullScreenGestureEnabled: true,
|
||||
headerShown: false,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Stack from "expo-router/stack";
|
||||
import { useResolveClassNames } from "uniwind";
|
||||
import { pushScreenAnimation } from "../../lib/pushScreenAnimation";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
export const unstable_settings = {
|
||||
@@ -23,7 +24,7 @@ export default function ConnectionsLayout() {
|
||||
}}
|
||||
>
|
||||
<Stack.Screen name="index" options={{ animation: "none" }} />
|
||||
<Stack.Screen name="new" options={{ animation: "slide_from_right" }} />
|
||||
<Stack.Screen name="new" options={{ animation: pushScreenAnimation }} />
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import Stack from "expo-router/stack";
|
||||
import { useResolveClassNames } from "uniwind";
|
||||
|
||||
import { NewTaskFlowProvider } from "../../features/threads/new-task-flow-provider";
|
||||
import { pushScreenAnimation } from "../../lib/pushScreenAnimation";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
export const unstable_settings = {
|
||||
@@ -29,21 +30,21 @@ export default function NewTaskLayout() {
|
||||
<Stack.Screen name="index" options={{ animation: "none", title: "Choose project" }} />
|
||||
<Stack.Screen
|
||||
name="add-project/index"
|
||||
options={{ animation: "slide_from_right", title: "New project" }}
|
||||
options={{ animation: pushScreenAnimation, title: "New project" }}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="add-project/repository"
|
||||
options={{ animation: "slide_from_right", title: "Repository" }}
|
||||
options={{ animation: pushScreenAnimation, title: "Repository" }}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="add-project/destination"
|
||||
options={{ animation: "slide_from_right", title: "Clone destination" }}
|
||||
options={{ animation: pushScreenAnimation, title: "Clone destination" }}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="add-project/local"
|
||||
options={{ animation: "slide_from_right", title: "Local folder" }}
|
||||
options={{ animation: pushScreenAnimation, title: "Local folder" }}
|
||||
/>
|
||||
<Stack.Screen name="draft" options={{ animation: "slide_from_right", title: "New task" }} />
|
||||
<Stack.Screen name="draft" options={{ animation: pushScreenAnimation, title: "New task" }} />
|
||||
</Stack>
|
||||
</NewTaskFlowProvider>
|
||||
);
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useCallback } from "react";
|
||||
import { useResolveClassNames } from "uniwind";
|
||||
|
||||
import { useClerkSettingsSheetDetent } from "../../features/cloud/ClerkSettingsSheetDetent";
|
||||
import { pushScreenAnimation } from "../../lib/pushScreenAnimation";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
|
||||
export const unstable_settings = {
|
||||
@@ -37,25 +38,25 @@ export default function SettingsLayout() {
|
||||
<Stack.Screen name="index" options={{ animation: "none", title: "Settings" }} />
|
||||
<Stack.Screen
|
||||
name="environments"
|
||||
options={{ animation: "slide_from_right", title: "Environments" }}
|
||||
options={{ animation: pushScreenAnimation, title: "Environments" }}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="environment-new"
|
||||
options={{ animation: "slide_from_right", title: "Add Environment" }}
|
||||
options={{ animation: pushScreenAnimation, title: "Add Environment" }}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="waitlist"
|
||||
options={{ animation: "slide_from_right", title: "Join the waitlist" }}
|
||||
options={{ animation: pushScreenAnimation, title: "Join the waitlist" }}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="archive"
|
||||
listeners={{ transitionEnd: handleExpandedRouteTransitionEnd }}
|
||||
options={{ animation: "slide_from_right", title: "Archived Threads" }}
|
||||
options={{ animation: pushScreenAnimation, title: "Archived Threads" }}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="auth"
|
||||
listeners={{ transitionEnd: handleExpandedRouteTransitionEnd }}
|
||||
options={{ animation: "slide_from_right", title: "Sign in" }}
|
||||
options={{ animation: pushScreenAnimation, title: "Sign in" }}
|
||||
/>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
import Stack from "expo-router/stack";
|
||||
import { Platform, StyleSheet } from "react-native";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { useResolveClassNames } from "uniwind";
|
||||
|
||||
import { pushScreenAnimation } from "../../../../lib/pushScreenAnimation";
|
||||
import { useHeaderBlurEffect } from "../../../../lib/useHeaderBlurEffect";
|
||||
|
||||
// iOS keeps the default push animation: forcing slide_from_right switches
|
||||
// react-native-screens to its custom swipe animator, which paints a black
|
||||
// void behind the outgoing screen during interactive swipe-back.
|
||||
const pushAnimation = Platform.OS === "ios" ? ("default" as const) : ("slide_from_right" as const);
|
||||
|
||||
export default function ThreadLayout() {
|
||||
const headerBlurEffect = useHeaderBlurEffect();
|
||||
const sheetStyle = StyleSheet.flatten(useResolveClassNames("bg-sheet"));
|
||||
@@ -54,7 +50,7 @@ export default function ThreadLayout() {
|
||||
<Stack.Screen
|
||||
name="review"
|
||||
options={{
|
||||
animation: pushAnimation,
|
||||
animation: pushScreenAnimation,
|
||||
contentStyle: sheetStyle,
|
||||
fullScreenGestureEnabled: true,
|
||||
headerBackButtonDisplayMode: "minimal",
|
||||
@@ -68,7 +64,7 @@ export default function ThreadLayout() {
|
||||
<Stack.Screen
|
||||
name="files/index"
|
||||
options={{
|
||||
animation: pushAnimation,
|
||||
animation: pushScreenAnimation,
|
||||
contentStyle: sheetStyle,
|
||||
fullScreenGestureEnabled: true,
|
||||
headerBackButtonDisplayMode: "minimal",
|
||||
@@ -82,7 +78,7 @@ export default function ThreadLayout() {
|
||||
<Stack.Screen
|
||||
name="files/[...path]"
|
||||
options={{
|
||||
animation: pushAnimation,
|
||||
animation: pushScreenAnimation,
|
||||
contentStyle: sheetStyle,
|
||||
fullScreenGestureEnabled: true,
|
||||
headerBackButtonDisplayMode: "minimal",
|
||||
@@ -107,8 +103,11 @@ export default function ThreadLayout() {
|
||||
<Stack.Screen
|
||||
name="terminal"
|
||||
options={{
|
||||
animation: pushAnimation,
|
||||
animation: pushScreenAnimation,
|
||||
contentStyle: { backgroundColor: "#050505" },
|
||||
// No fullScreenGestureEnabled here: the terminal consumes
|
||||
// horizontal pans (readline editing, mouse reporting), so
|
||||
// back-swipe stays confined to the screen edge.
|
||||
headerBackButtonDisplayMode: "minimal",
|
||||
headerShown: true,
|
||||
headerShadowVisible: false,
|
||||
|
||||
@@ -2,6 +2,8 @@ import Stack from "expo-router/stack";
|
||||
import { StyleSheet } from "react-native";
|
||||
import { useResolveClassNames } from "uniwind";
|
||||
|
||||
import { pushScreenAnimation } from "../../../../../lib/pushScreenAnimation";
|
||||
|
||||
export const unstable_settings = {
|
||||
anchor: "index",
|
||||
};
|
||||
@@ -23,7 +25,7 @@ export default function GitSheetLayout() {
|
||||
<Stack.Screen
|
||||
name="commit"
|
||||
options={{
|
||||
animation: "slide_from_right",
|
||||
animation: pushScreenAnimation,
|
||||
headerShown: true,
|
||||
headerTitle: "Commit changes",
|
||||
headerBackTitle: "",
|
||||
@@ -34,7 +36,7 @@ export default function GitSheetLayout() {
|
||||
<Stack.Screen
|
||||
name="branches"
|
||||
options={{
|
||||
animation: "slide_from_right",
|
||||
animation: pushScreenAnimation,
|
||||
headerShown: true,
|
||||
headerTitle: "Branches & worktrees",
|
||||
headerBackTitle: "",
|
||||
@@ -45,7 +47,7 @@ export default function GitSheetLayout() {
|
||||
<Stack.Screen
|
||||
name="review"
|
||||
options={{
|
||||
animation: "slide_from_right",
|
||||
animation: pushScreenAnimation,
|
||||
headerShown: true,
|
||||
headerTitle: "Review changes",
|
||||
headerBackTitle: "",
|
||||
|
||||
@@ -19,6 +19,7 @@ import { cn } from "../../lib/cn";
|
||||
import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
|
||||
import { buildThreadFilesNavigation } from "../../lib/routes";
|
||||
import { MOBILE_TYPOGRAPHY } from "../../lib/typography";
|
||||
import { useHeaderBlurEffect } from "../../lib/useHeaderBlurEffect";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
import { useThreadSelection } from "../../state/use-thread-selection";
|
||||
import { useSelectedThreadWorktree } from "../../state/use-selected-thread-worktree";
|
||||
@@ -444,6 +445,7 @@ function FilesToolbarBottomFade() {
|
||||
|
||||
export function ThreadFilesTreeScreen() {
|
||||
const router = useRouter();
|
||||
const headerBlurEffect = useHeaderBlurEffect();
|
||||
const [searchQuery, setSearchQuery] = useState("");
|
||||
const { cwd, environmentId, projectName, selectedThread, threadId } = useThreadFilesWorkspace();
|
||||
const entriesQuery = useEnvironmentQuery(
|
||||
@@ -481,6 +483,7 @@ export function ThreadFilesTreeScreen() {
|
||||
title: "Files",
|
||||
headerShown: true,
|
||||
headerTransparent: true,
|
||||
headerBlurEffect,
|
||||
headerStyle: { backgroundColor: "transparent" },
|
||||
headerShadowVisible: false,
|
||||
headerTitle: () => <FilesHeaderTitle projectName={projectName} />,
|
||||
|
||||
@@ -19,6 +19,7 @@ import { AppText as Text } from "../../components/AppText";
|
||||
import { environmentCatalog } from "../../connection/catalog";
|
||||
import { useEnvironmentPresentation } from "../../state/presentation";
|
||||
import { useAtomCommand } from "../../state/use-atom-command";
|
||||
import { useHeaderBlurEffect } from "../../lib/useHeaderBlurEffect";
|
||||
import { useThemeColor } from "../../lib/useThemeColor";
|
||||
import { MOBILE_TYPOGRAPHY } from "../../lib/typography";
|
||||
import { useThreadDraftForThread } from "../../state/use-thread-composer-state";
|
||||
@@ -113,6 +114,7 @@ function ReviewSelectionActionBar(props: {
|
||||
export function ReviewSheet() {
|
||||
const insets = useSafeAreaInsets();
|
||||
const colorScheme = useColorScheme();
|
||||
const headerBlurEffect = useHeaderBlurEffect();
|
||||
const headerForeground = String(useThemeColor("--color-foreground"));
|
||||
const headerMuted = String(useThemeColor("--color-foreground-muted"));
|
||||
const headerIcon = String(useThemeColor("--color-icon"));
|
||||
@@ -241,6 +243,7 @@ export function ReviewSheet() {
|
||||
<Stack.Screen
|
||||
options={{
|
||||
headerTransparent: true,
|
||||
headerBlurEffect,
|
||||
headerShadowVisible: false,
|
||||
headerTintColor: headerIcon,
|
||||
headerStyle: {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Platform } from "react-native";
|
||||
|
||||
/**
|
||||
* Stack animation for pushed (non-sheet) screens.
|
||||
*
|
||||
* iOS keeps the default push animation: forcing `slide_from_right` switches
|
||||
* react-native-screens to its custom swipe animator, which paints a black
|
||||
* void behind the outgoing screen during interactive swipe-back. The native
|
||||
* default is visually the same slide with proper parallax over the previous
|
||||
* screen. Android has no interactive pop, so it keeps `slide_from_right`.
|
||||
*/
|
||||
export const pushScreenAnimation = Platform.OS === "ios" ? "default" : "slide_from_right";
|
||||
Reference in new issue
Block a user