@devries-cameron20 / t3code Mirror · read-only / commits / 487423a320
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 09:15 UTC

feat(mobile): share actionable toasts and native progress (#19952)

Julius Marminge committed Oct 15, 2026 at 15:46 UTC 487423a320fa407f77f5a64000ac5a7480a616d6
8 files changed +174 -227
apps/mobile/src/components/LoadingStrip.tsx
+5 -82
@@ -1,93 +1,16 @@
1 -import { useEffect, useState } from "react";
1 import { View } from "react-native";
3 -import Animated, {
4 - cancelAnimation,
5 - Easing,
6 - useAnimatedStyle,
7 - useSharedValue,
8 - withRepeat,
9 - withTiming,
10 -} from "react-native-reanimated";
2 +import { Progress } from "./Progress";
3
12 -const INDICATOR_WIDTH_FRACTION = 0.3;
13 -const MIN_INDICATOR_WIDTH = 48;
14 -
15 -function LoadingStripFrame(props: {
16 - readonly children: React.ReactNode;
17 - readonly onLayout?: (width: number) => void;
18 -}) {
4 +/** Thin, noninteractive progress at the top of its owning screen. */
5 +export function LoadingStrip(props: { readonly progress?: number }) {
6 return (
7 <View
8 pointerEvents="none"
9 accessibilityElementsHidden
10 importantForAccessibility="no-hide-descendants"
24 - className="absolute inset-x-0 top-0 z-10 h-0.5 overflow-hidden"
25 - onLayout={
26 - props.onLayout
27 - ? (event) => {
28 - props.onLayout?.(event.nativeEvent.layout.width);
29 - }
30 - : undefined
31 - }
11 + className="absolute inset-x-0 top-0 z-10 h-1 overflow-hidden"
12 >
33 - {props.children}
13 + <Progress value={props.progress} />
14 </View>
15 );
16 }
37 -
38 -function IndeterminateLoadingStrip() {
39 - const [containerWidth, setContainerWidth] = useState(0);
40 - const travelProgress = useSharedValue(0);
41 - const indicatorWidth = Math.max(MIN_INDICATOR_WIDTH, containerWidth * INDICATOR_WIDTH_FRACTION);
42 -
43 - useEffect(() => {
44 - travelProgress.value = 0;
45 - travelProgress.value = withRepeat(
46 - withTiming(1, {
47 - duration: 1100,
48 - easing: Easing.inOut(Easing.quad),
49 - }),
50 - -1,
51 - false,
52 - );
53 -
54 - return () => {
55 - cancelAnimation(travelProgress);
56 - };
57 - }, [travelProgress]);
58 -
59 - const indicatorStyle = useAnimatedStyle(
60 - () => ({
61 - transform: [
62 - {
63 - translateX: (containerWidth + indicatorWidth) * travelProgress.value - indicatorWidth,
64 - },
65 - ],
66 - width: indicatorWidth,
67 - }),
68 - [containerWidth, indicatorWidth],
69 - );
70 -
71 - return (
72 - <LoadingStripFrame onLayout={setContainerWidth}>
73 - <Animated.View className="h-full rounded-full bg-primary" style={indicatorStyle} />
74 - </LoadingStripFrame>
75 - );
76 -}
77 -
78 -export function LoadingStrip(props: { readonly progress?: number }) {
79 - if (props.progress === undefined) {
80 - return <IndeterminateLoadingStrip />;
81 - }
82 -
83 - const clampedProgress = Math.min(1, Math.max(0, props.progress));
84 -
85 - return (
86 - <LoadingStripFrame>
87 - <View
88 - className="h-full rounded-r-full bg-primary"
89 - style={{ width: `${clampedProgress * 100}%` }}
90 - />
91 - </LoadingStripFrame>
92 - );
93 -}
apps/mobile/src/components/Progress.android.tsx new
+34
@@ -0,0 +1,34 @@
1 +import { LinearProgressIndicator } from "@expo/ui/jetpack-compose";
2 +import { fillMaxWidth } from "@expo/ui/jetpack-compose/modifiers";
3 +import { View } from "react-native";
4 +import { NativeThemeHost } from "./NativeThemeHost.android";
5 +import { useControlTheme } from "./useControlTheme";
6 +import { clampProgress, type ProgressProps } from "./Progress.types";
7 +
8 +export function Progress(props: ProgressProps) {
9 + const value = clampProgress(props.value);
10 + const { colors } = useControlTheme();
11 + return (
12 + <View
13 + className={props.className}
14 + accessible
15 + accessibilityRole="progressbar"
16 + accessibilityLabel={props.label}
17 + accessibilityValue={
18 + value === undefined ? undefined : { min: 0, max: 100, now: Math.round(value * 100) }
19 + }
20 + accessibilityState={{ busy: value === undefined }}
21 + >
22 + <View importantForAccessibility="no-hide-descendants">
23 + <NativeThemeHost matchContents={{ vertical: true }} style={{ width: "100%" }}>
24 + <LinearProgressIndicator
25 + progress={value}
26 + color={colors["--color-primary"]}
27 + trackColor={colors["--color-subtle"]}
28 + modifiers={[fillMaxWidth()]}
29 + />
30 + </NativeThemeHost>
31 + </View>
32 + </View>
33 + );
34 +}
apps/mobile/src/components/Progress.ios.tsx new
+30
@@ -0,0 +1,30 @@
1 +import { ProgressView } from "@expo/ui/swift-ui";
2 +import { progressViewStyle, tint } from "@expo/ui/swift-ui/modifiers";
3 +import { View } from "react-native";
4 +import { NativeThemeHost } from "./NativeThemeHost";
5 +import { useControlTheme } from "./useControlTheme";
6 +import { clampProgress, type ProgressProps } from "./Progress.types";
7 +
8 +export function Progress(props: ProgressProps) {
9 + const value = clampProgress(props.value);
10 + const { colors } = useControlTheme();
11 + return (
12 + <View
13 + className={props.className}
14 + accessible
15 + accessibilityRole="progressbar"
16 + accessibilityLabel={props.label}
17 + accessibilityValue={
18 + value === undefined ? undefined : { min: 0, max: 100, now: Math.round(value * 100) }
19 + }
20 + accessibilityState={{ busy: value === undefined }}
21 + >
22 + <NativeThemeHost matchContents={{ vertical: true }} style={{ width: "100%" }}>
23 + <ProgressView
24 + value={value}
25 + modifiers={[progressViewStyle("linear"), tint(colors["--color-primary"])]}
26 + />
27 + </NativeThemeHost>
28 + </View>
29 + );
30 +}
apps/mobile/src/components/Progress.tsx new
+2
@@ -0,0 +1,2 @@
1 +export { Progress } from "./Progress.ios";
2 +export type { ProgressProps } from "./Progress.types";
apps/mobile/src/components/Progress.types.ts new
+12
@@ -0,0 +1,12 @@
1 +export interface ProgressProps {
2 + /** Omit for indeterminate progress. Finite values are clamped to 0..1. */
3 + readonly value?: number;
4 + readonly label?: string;
5 + readonly className?: string;
6 +}
7 +
8 +export function clampProgress(value: number | undefined): number | undefined {
9 + return value === undefined || !Number.isFinite(value)
10 + ? undefined
11 + : Math.max(0, Math.min(1, value));
12 +}
apps/mobile/src/components/Toast.tsx new
+56
@@ -0,0 +1,56 @@
1 +import { useEffect } from "react";
2 +import { AccessibilityInfo, Platform, View } from "react-native";
3 +
4 +import { AppText } from "./AppText";
5 +import { Button } from "./Button";
6 +import { GlassSurface } from "./GlassSurface";
7 +import { IconButton } from "./IconButton";
8 +import { AppActivityIndicator } from "./AppActivityIndicator";
9 +import { SymbolView } from "./AppSymbol";
10 +
11 +export interface ToastProps {
12 + readonly message: string;
13 + readonly description?: string;
14 + readonly tone?: "default" | "success" | "danger";
15 + readonly busy?: boolean;
16 + readonly action?: { readonly label: string; readonly onPress: () => void };
17 + readonly onDismiss?: () => void;
18 +}
19 +
20 +/** The owning screen places and dismisses feedback; actions are never implicit. */
21 +export function Toast(props: ToastProps) {
22 + useEffect(() => {
23 + if (Platform.OS === "ios") AccessibilityInfo.announceForAccessibility(props.message);
24 + }, [props.message]);
25 + return (
26 + <GlassSurface className="p-3">
27 + <View className="flex-row items-center gap-3">
28 + {props.busy ? (
29 + <AppActivityIndicator />
30 + ) : (
31 + <SymbolView
32 + name={props.tone === "danger" ? "exclamationmark.triangle" : "checkmark.circle"}
33 + size={20}
34 + tintColorClassName={
35 + props.tone === "danger" ? "accent-danger-foreground" : "accent-icon"
36 + }
37 + />
38 + )}
39 + <View className="min-w-0 flex-1" accessibilityLiveRegion="polite">
40 + <AppText className="text-sm font-t3-semibold">{props.message}</AppText>
41 + {props.description ? (
42 + <AppText className="text-xs text-foreground-muted">{props.description}</AppText>
43 + ) : null}
44 + </View>
45 + {props.onDismiss ? (
46 + <IconButton accessibilityLabel="Dismiss message" icon="xmark" onPress={props.onDismiss} />
47 + ) : null}
48 + </View>
49 + {props.action ? (
50 + <View className="mt-2 self-end">
51 + <Button label={props.action.label} onPress={props.action.onPress} />
52 + </View>
53 + ) : null}
54 + </GlassSurface>
55 + );
56 +}
apps/mobile/src/features/development/ComponentCatalogScreen.tsx
+13 -7
@@ -1,3 +1,5 @@
1 +import { Toast } from "../../components/Toast";
2 +import { Progress } from "../../components/Progress";
3 import { useNavigation } from "@react-navigation/native";
4 import { useRef, useState } from "react";
5 import { View, type TextInputInstance } from "react-native";
@@ -15,7 +17,6 @@ import { Button } from "../../components/Button";
17 import { IconButton } from "../../components/IconButton";
18 import { FloatingActionButton } from "../../components/FloatingActionButton";
19 import { SearchField } from "../../components/SearchField";
18 -import { LoadingStrip } from "../../components/LoadingStrip";
20 import { Notice } from "../../components/Notice";
21 import { NumberField } from "../../components/NumberField";
22 import { AppBar } from "../../components/AppBar";
@@ -203,10 +204,16 @@ export function ComponentCatalogScreen() {
204 <AppText className="text-lg font-t3-semibold">Feedback and presentation</AppText>
205 <Notice message="This action could not finish. Try again." tone="danger" />
206 {notice ? (
206 - <Notice
207 + <Toast
208 message="Changes are ready to review."
208 - icon="checkmark.circle"
209 - floating
209 + tone="success"
210 + action={{
211 + label: "Undo",
212 + onPress: () => {
213 + setNotice(false);
214 + setText("Restored example");
215 + },
216 + }}
217 onDismiss={() => setNotice(false)}
218 />
219 ) : (
@@ -239,9 +246,8 @@ export function ComponentCatalogScreen() {
246 <Chip label="Menu" trailingIcon="chevron.down" />
247 </Menu>
248 </View>
242 - <View className="relative h-3 overflow-hidden rounded-full bg-subtle">
243 - <LoadingStrip progress={0.6} />
244 - </View>
249 + <Progress value={0.6} label="Example upload" />
250 + <Progress label="Connecting" />
251 <View className="items-start">
252 <FloatingActionButton
253 label="New thread"
apps/mobile/src/features/threads/GitActionProgressOverlay.tsx
+22 -138
@@ -1,24 +1,12 @@
1 import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
2 import * as Haptics from "expo-haptics";
3 -import { GlassView } from "expo-glass-effect";
4 -import { AppActivityIndicator } from "../../components/AppActivityIndicator";
5 -import { SymbolView } from "../../components/AppSymbol";
6 -import { useCallback, useEffect, useRef } from "react";
7 -import { Pressable, StyleSheet, useColorScheme, View } from "react-native";
8 -import Animated, { FadeIn, FadeOut, LinearTransition } from "react-native-reanimated";
3 +import { useEffect, useRef } from "react";
4 +import Animated, { FadeIn, FadeOut, ReduceMotion } from "react-native-reanimated";
5 import { useSafeAreaInsets } from "react-native-safe-area-context";
10 -
11 -import { AppText as Text } from "../../components/AppText";
6 +import { Toast } from "../../components/Toast";
7 import { APP_BAR_HEIGHT } from "../../lib/layoutMetrics";
13 -import { themeColorWithAlpha } from "../../lib/mobileTheme";
14 -import { useUniwindTheme } from "../../lib/useUniwindTheme";
15 -import { NATIVE_LIQUID_GLASS_SUPPORTED } from "../../native/native-glass";
8 import type { GitActionProgress } from "../../state/use-vcs-action-state";
9
18 -const OVERLAY_LAYOUT_TRANSITION = LinearTransition.duration(220);
19 -const OVERLAY_TOP_GAP = 8;
20 -const AnimatedGlassView = Animated.createAnimatedComponent(GlassView);
21 -
10 export function GitActionProgressOverlay(props: {
11 readonly progress: GitActionProgress;
12 readonly onDismiss: () => void;
@@ -40,7 +28,7 @@ export function GitActionProgressOverlay(props: {
28 }
29 }, [progress.phase]);
30
43 - const handlePress = useCallback(() => {
31 + const handlePress = () => {
32 if (progress.prUrl) {
33 void (openPullRequest
34 ? openPullRequest(progress.prUrl)
@@ -50,7 +38,7 @@ export function GitActionProgressOverlay(props: {
38 if (progress.phase === "success" || progress.phase === "error") {
39 onDismiss();
40 }
53 - }, [onDismiss, progress.phase, progress.prUrl, openPullRequest]);
41 + };
42
43 if (progress.phase === "idle") {
44 return null;
@@ -58,130 +46,26 @@ export function GitActionProgressOverlay(props: {
46
47 return (
48 <Animated.View
61 - entering={NATIVE_LIQUID_GLASS_SUPPORTED ? undefined : FadeIn.duration(200)}
62 - exiting={FadeOut.duration(150)}
49 + entering={FadeIn.duration(200).reduceMotion(ReduceMotion.System)}
50 + exiting={FadeOut.duration(150).reduceMotion(ReduceMotion.System)}
51 className="absolute inset-x-3 z-[100]"
64 - style={{ top: insets.top + APP_BAR_HEIGHT + OVERLAY_TOP_GAP }}
52 + style={{ top: insets.top + APP_BAR_HEIGHT + 8 }}
53 pointerEvents="box-none"
54 >
67 - <Pressable onPress={handlePress}>
68 - <OverlayContent progress={progress} />
69 - </Pressable>
55 + <Toast
56 + message={progress.label ?? "Source control"}
57 + description={progress.description ?? undefined}
58 + tone={
59 + progress.phase === "error"
60 + ? "danger"
61 + : progress.phase === "success"
62 + ? "success"
63 + : "default"
64 + }
65 + busy={progress.phase === "running"}
66 + action={progress.prUrl ? { label: "Open PR", onPress: handlePress } : undefined}
67 + onDismiss={progress.phase === "running" ? undefined : onDismiss}
68 + />
69 </Animated.View>
70 );
71 }
73 -
74 -function OverlayContent(props: { readonly progress: GitActionProgress }) {
75 - const { progress } = props;
76 - const colors = useUniwindTheme();
77 - const glassSurface = colors["--color-glass-surface"];
78 - const foreground = colors["--color-foreground"];
79 - const shadowColor = colors["--color-primary-shadow"];
80 - const isDarkMode = useColorScheme() === "dark";
81 - const glassTint = themeColorWithAlpha(String(glassSurface), isDarkMode ? 0.48 : 0.38);
82 - const glassBorder = themeColorWithAlpha(String(foreground), isDarkMode ? 0.18 : 0.12);
83 - const content = (
84 - <>
85 - <OverlayIcon phase={progress.phase} />
86 -
87 - <View className="flex-1 gap-0.5">
88 - {progress.label ? (
89 - <Text className="text-sm font-t3-bold text-foreground" numberOfLines={1}>
90 - {progress.label}
91 - </Text>
92 - ) : null}
93 - {progress.description ? (
94 - <Text className="text-2xs text-foreground-muted" numberOfLines={1}>
95 - {progress.description}
96 - </Text>
97 - ) : null}
98 - </View>
99 -
100 - {progress.prUrl ? (
101 - <SymbolView
102 - name="arrow.up.right"
103 - size={13}
104 - tintColorClassName={"accent-icon"}
105 - type="monochrome"
106 - />
107 - ) : null}
108 - </>
109 - );
110 -
111 - if (NATIVE_LIQUID_GLASS_SUPPORTED) {
112 - return (
113 - <Animated.View
114 - layout={OVERLAY_LAYOUT_TRANSITION}
115 - style={{
116 - borderCurve: "continuous",
117 - borderRadius: 26,
118 - elevation: 12,
119 - shadowColor,
120 - shadowOffset: { width: 0, height: 8 },
121 - shadowOpacity: isDarkMode ? 0.42 : 0.2,
122 - shadowRadius: 18,
123 - }}
124 - >
125 - <AnimatedGlassView
126 - colorScheme={isDarkMode ? "dark" : "light"}
127 - glassEffectStyle="regular"
128 - isInteractive
129 - layout={OVERLAY_LAYOUT_TRANSITION}
130 - tintColor={glassTint}
131 - style={{
132 - borderColor: glassBorder,
133 - borderCurve: "continuous",
134 - borderRadius: 26,
135 - borderWidth: StyleSheet.hairlineWidth,
136 - overflow: "hidden",
137 - }}
138 - >
139 - <Animated.View
140 - entering={FadeIn.delay(60).duration(140)}
141 - className="flex-row items-center gap-2.5 px-3.5 py-3"
142 - >
143 - {content}
144 - </Animated.View>
145 - </AnimatedGlassView>
146 - </Animated.View>
147 - );
148 - }
149 -
150 - const bgClass =
151 - progress.phase === "error" ? "border-danger-border bg-danger" : "bg-card border-border";
152 -
153 - return (
154 - <Animated.View
155 - layout={OVERLAY_LAYOUT_TRANSITION}
156 - className={`flex-row items-center gap-2.5 rounded-[26px] border border-continuous px-3.5 py-3 shadow-lg shadow-black/10 ${bgClass}`}
157 - >
158 - {content}
159 - </Animated.View>
160 - );
161 -}
162 -
163 -function OverlayIcon(props: { readonly phase: GitActionProgress["phase"] }) {
164 - switch (props.phase) {
165 - case "running":
166 - return <AppActivityIndicator size="small" colorClassName={"accent-icon"} />;
167 - case "success":
168 - return (
169 - <View className="h-6 w-6 items-center justify-center rounded-full bg-green-500">
170 - <SymbolView name="checkmark" size={12} tintColor="white" type="monochrome" />
171 - </View>
172 - );
173 - case "error":
174 - return (
175 - <View className="h-6 w-6 items-center justify-center rounded-full bg-danger">
176 - <SymbolView
177 - name="exclamationmark.triangle"
178 - size={12}
179 - tintColorClassName="accent-danger-foreground"
180 - type="monochrome"
181 - />
182 - </View>
183 - );
184 - default:
185 - return null;
186 - }
187 -}