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, 13:00 UTC
refactor(mobile): share settings action rows (#18529)
Julius Marminge committed
Oct 15, 2026 at 15:46 UTC
b089f959b255b11b3c999d7a9c6032a0428e8814
3 files changed
+53
-63
apps/mobile/src/components/ListActionRow.tsx
new
+42
@@ -0,0 +1,42 @@
1
+import { Platform } from "react-native";
2
+import { useResolveClassNames } from "uniwind";
3
+
4
+import { AppActivityIndicator } from "./AppActivityIndicator";
5
+import { ListRowLayout, type ListRowContentProps } from "./ListRowLayout";
6
+import { RowPressable } from "./RowPressable";
7
+
8
+export function ListActionRow(
9
+ props: ListRowContentProps & {
10
+ readonly tone?: "default" | "danger";
11
+ readonly loading?: boolean;
12
+ readonly onPress: () => void;
13
+ },
14
+) {
15
+ const rippleStyle = useResolveClassNames("bg-subtle-strong");
16
+ const disabled = Boolean(props.disabled || props.loading);
17
+ return (
18
+ <RowPressable
19
+ accessibilityRole="button"
20
+ accessibilityLabel={props.label}
21
+ accessibilityHint={props.description}
22
+ accessibilityState={{ disabled, busy: Boolean(props.loading) }}
23
+ disabled={disabled}
24
+ onPress={props.onPress}
25
+ android_ripple={{ color: rippleStyle.backgroundColor }}
26
+ unstable_pressDelay={Platform.OS === "android" ? 50 : undefined}
27
+ className="bg-grouped-card"
28
+ >
29
+ <ListRowLayout
30
+ {...props}
31
+ disabled={disabled}
32
+ accessory={
33
+ props.loading ? (
34
+ <AppActivityIndicator
35
+ colorClassName={props.tone === "danger" ? "accent-danger-foreground" : "accent-icon"}
36
+ />
37
+ ) : undefined
38
+ }
39
+ />
40
+ </RowPressable>
41
+ );
42
+}
apps/mobile/src/components/ListRowLayout.tsx
+10
-3
@@ -21,7 +21,8 @@ export function ListRowLayout({
21
detail,
22
disabled,
23
accessory,
24
-}: ListRowContentProps & { readonly accessory?: ReactNode }) {
24
+ tone = "default",
25
+}: ListRowContentProps & { readonly accessory?: ReactNode; readonly tone?: "default" | "danger" }) {
26
const { fontScale } = useWindowDimensions();
27
// Leave the label room to wrap at accessibility text sizes.
28
const stackDetail = fontScale >= 1.5;
@@ -38,14 +39,20 @@ export function ListRowLayout({
39
<SymbolView
40
name={icon}
41
size={Platform.OS === "android" ? 24 : 22}
41
- tintColorClassName="accent-icon"
42
+ tintColorClassName={tone === "danger" ? "accent-danger-foreground" : "accent-icon"}
43
type="monochrome"
44
weight="regular"
45
/>
46
</View>
47
) : null}
48
<View className="min-w-0 flex-1 gap-1">
48
- <AppText className="text-base text-foreground">{label}</AppText>
49
+ <AppText
50
+ className={
51
+ tone === "danger" ? "text-base text-danger-foreground" : "text-base text-foreground"
52
+ }
53
+ >
54
+ {label}
55
+ </AppText>
56
{description ? (
57
<AppText className="text-sm text-foreground-muted">{description}</AppText>
58
) : null}
apps/mobile/src/features/settings/components/SettingsActionRow.tsx
+1
-60
@@ -1,60 +1 @@
1
-import type { ComponentProps } from "react";
2
-import { Platform, Pressable } from "react-native";
3
-
4
-import { AppActivityIndicator } from "../../../components/AppActivityIndicator";
5
-import { SymbolView } from "../../../components/AppSymbol";
6
-import { AppText as Text } from "../../../components/AppText";
7
-import { MaterialListRow } from "../../../components/MaterialListRow";
8
-import { cn } from "../../../lib/cn";
9
-
10
-export function SettingsActionRow(props: {
11
- readonly icon: ComponentProps<typeof SymbolView>["name"];
12
- readonly label: string;
13
- readonly tone?: "default" | "danger";
14
- readonly disabled?: boolean;
15
- readonly loading?: boolean;
16
- readonly onPress: () => void;
17
-}) {
18
- const danger = props.tone === "danger";
19
- const textClassName = danger ? "tabular-nums text-danger-foreground" : "text-foreground";
20
- const iconColorClassName = danger ? "accent-danger-foreground" : "accent-icon";
21
- const icon = (
22
- <SymbolView
23
- name={props.icon}
24
- size={Platform.OS === "android" ? 24 : 22}
25
- tintColorClassName={iconColorClassName}
26
- type="monochrome"
27
- weight="regular"
28
- />
29
- );
30
- const spinner = props.loading ? (
31
- <AppActivityIndicator colorClassName={iconColorClassName} />
32
- ) : null;
33
-
34
- if (Platform.OS === "android") {
35
- return (
36
- <MaterialListRow
37
- className="bg-grouped-card"
38
- title={props.label}
39
- titleClassName={textClassName}
40
- leading={icon}
41
- trailing={spinner}
42
- disabled={props.disabled}
43
- onPress={props.onPress}
44
- />
45
- );
46
- }
47
-
48
- return (
49
- <Pressable
50
- accessibilityRole="button"
51
- disabled={props.disabled}
52
- onPress={props.onPress}
53
- className="flex-row items-center gap-4 p-4 disabled:opacity-40"
54
- >
55
- {icon}
56
- <Text className={cn("flex-1 text-lg", textClassName)}>{props.label}</Text>
57
- {spinner}
58
- </Pressable>
59
- );
60
-}
1
+export { ListActionRow as SettingsActionRow } from "../../../components/ListActionRow";