@devries-cameron20 / t3code Mirror · read-only / commits / e028a083b9
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, 13:00 UTC

refactor(mobile): share theme mapping across Android controls (#19217)

Julius Marminge committed Oct 15, 2026 at 15:46 UTC e028a083b913856310594831cdc85d51d006f456
10 files changed +56 -98
apps/mobile/src/components/AppActivityIndicator.android.tsx
+4 -3
@@ -1,4 +1,5 @@
1 -import { LoadingIndicator, Host } from "@expo/ui/jetpack-compose";
1 +import { NativeThemeHost } from "./NativeThemeHost.android";
2 +import { LoadingIndicator } from "@expo/ui/jetpack-compose";
3 import { size as composeSize } from "@expo/ui/jetpack-compose/modifiers";
4 import { StyleSheet, View, type ActivityIndicatorProps } from "react-native";
5 import { useResolveClassNames, withUniwind } from "uniwind";
@@ -30,12 +31,12 @@ function AndroidActivityIndicator({
31 style={{ width: diameter, height: diameter }}
32 >
33 {animating ? (
33 - <Host ignoreSafeAreaKeyboardInsets style={{ flex: 1 }}>
34 + <NativeThemeHost ignoreSafeAreaKeyboardInsets style={{ flex: 1 }}>
35 <LoadingIndicator
36 color={color ?? primaryColor}
37 modifiers={[composeSize(diameter, diameter)]}
38 />
38 - </Host>
39 + </NativeThemeHost>
40 ) : null}
41 </View>
42 </View>
apps/mobile/src/components/Button.android.tsx
+4 -5
@@ -1,10 +1,10 @@
1 import { SymbolView } from "./AppSymbol";
2 +import { NativeThemeHost } from "./NativeThemeHost.android";
3 import {
4 Box,
5 Button as ComposeButton,
6 LoadingIndicator,
7 FilledTonalButton,
7 - Host,
8 Row,
9 RNHostView,
10 Text,
@@ -19,7 +19,7 @@ import type { ButtonProps } from "./Button";
19 import { useAndroidControlSizing } from "./useAndroidControlSizing";
20
21 export function Button(props: ButtonProps) {
22 - const { colorScheme, colors } = useControlTheme();
22 + const { colors } = useControlTheme();
23 const typography = useScaledTextRole("footnote");
24 const { scale, mediumIconSize } = useAndroidControlSizing();
25 const tone = props.tone ?? "secondary";
@@ -62,9 +62,8 @@ export function Button(props: ButtonProps) {
62 style={props.fullWidth ? { width: "100%" } : { alignSelf: "flex-start" }}
63 >
64 <View importantForAccessibility="no-hide-descendants">
65 - <Host
65 + <NativeThemeHost
66 matchContents={props.fullWidth ? { vertical: true } : true}
67 - colorScheme={colorScheme}
67 ignoreSafeAreaKeyboardInsets
68 style={props.fullWidth ? { width: "100%" } : { alignSelf: "flex-start" }}
69 >
@@ -110,7 +109,7 @@ export function Button(props: ButtonProps) {
109 <Text style={{ ...typography, fontWeight: "500" }}>{props.label}</Text>
110 </Row>
111 </Component>
113 - </Host>
112 + </NativeThemeHost>
113 </View>
114 </View>
115 );
apps/mobile/src/components/MaterialConfirmDialog.android.tsx
+4 -8
@@ -1,6 +1,6 @@
1 +import { NativeThemeHost } from "./NativeThemeHost.android";
2 import {
3 AlertDialog,
3 - Host,
4 OutlinedTextField,
5 Text,
6 TextButton,
@@ -12,7 +12,7 @@ import { useScaledTextRole } from "../features/settings/appearance/useScaledText
12 import type { MaterialConfirmDialogProps } from "./MaterialConfirmDialog";
13
14 export function MaterialConfirmDialog(props: MaterialConfirmDialogProps) {
15 - const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
15 + const { themeVariables: colors } = useAppearancePreferences();
16 const titleTypography = useScaledTextRole("title");
17 const bodyTypography = useScaledTextRole("footnote");
18 const inputTypography = useScaledTextRole("body");
@@ -25,11 +25,7 @@ export function MaterialConfirmDialog(props: MaterialConfirmDialogProps) {
25 props.onConfirm(value);
26 };
27 return (
28 - <Host
29 - colorScheme={themeAppearance}
30 - ignoreSafeAreaKeyboardInsets
31 - style={{ height: 0, width: 0 }}
32 - >
28 + <NativeThemeHost ignoreSafeAreaKeyboardInsets style={{ height: 0, width: 0 }}>
29 <AlertDialog
30 onDismissRequest={props.onCancel}
31 tonalElevation={0}
@@ -96,6 +92,6 @@ export function MaterialConfirmDialog(props: MaterialConfirmDialogProps) {
92 </TextButton>
93 </AlertDialog.ConfirmButton>
94 </AlertDialog>
99 - </Host>
95 + </NativeThemeHost>
96 );
97 }
apps/mobile/src/components/MaterialFloatingActionButton.android.tsx
+4 -4
@@ -1,8 +1,8 @@
1 +import { NativeThemeHost } from "./NativeThemeHost.android";
2 import {
3 Box,
4 ExtendedFloatingActionButton,
5 FloatingActionButton,
5 - Host,
6 LargeFloatingActionButton,
7 Text,
8 } from "@expo/ui/jetpack-compose";
@@ -23,7 +23,7 @@ export function MaterialFloatingActionButton(props: {
23 readonly className?: string;
24 readonly style?: StyleProp<ViewStyle>;
25 }) {
26 - const { themeAppearance, themeVariables: colors } = useAppearancePreferences();
26 + const { themeVariables: colors } = useAppearancePreferences();
27 const typography = useScaledTextRole("footnote");
28 const { scale, iconSize: standardIconSize, fabSize, largeFabSize } = useAndroidControlSizing();
29 const buttonSize = props.variant === "large" ? largeFabSize : fabSize;
@@ -49,7 +49,7 @@ export function MaterialFloatingActionButton(props: {
49 style={props.style}
50 >
51 <View importantForAccessibility="no-hide-descendants">
52 - <Host matchContents colorScheme={themeAppearance} ignoreSafeAreaKeyboardInsets>
52 + <NativeThemeHost matchContents ignoreSafeAreaKeyboardInsets>
53 <Component
54 modifiers={[
55 defaultMinSize({ minWidth: buttonSize }),
@@ -71,7 +71,7 @@ export function MaterialFloatingActionButton(props: {
71 </ExtendedFloatingActionButton.Text>
72 ) : null}
73 </Component>
74 - </Host>
74 + </NativeThemeHost>
75 </View>
76 {/* The RN icon stays outside Compose so it cannot intercept native button taps. */}
77 <View
apps/mobile/src/components/MaterialIconButton.android.tsx
+5 -10
@@ -1,9 +1,5 @@
1 -import {
2 - FilledIconButton,
3 - FilledTonalIconButton,
4 - Host,
5 - IconButton,
6 -} from "@expo/ui/jetpack-compose";
1 +import { NativeThemeHost } from "./NativeThemeHost.android";
2 +import { FilledIconButton, FilledTonalIconButton, IconButton } from "@expo/ui/jetpack-compose";
3 import { size } from "@expo/ui/jetpack-compose/modifiers";
4 import { View } from "react-native";
5
@@ -20,7 +16,7 @@ export function MaterialIconButton(props: {
16 readonly variant?: "standard" | "primary" | "tonal" | "danger";
17 readonly tintColorClassName?: string;
18 }) {
23 - const { colorScheme, colors } = useControlTheme();
19 + const { colors } = useControlTheme();
20 const { iconSize, buttonSize } = useAndroidControlSizing();
21 const variant = props.variant ?? "standard";
22 const Component =
@@ -57,8 +53,7 @@ export function MaterialIconButton(props: {
53 style={{ width: buttonSize, height: buttonSize }}
54 >
55 <View importantForAccessibility="no-hide-descendants">
60 - <Host
61 - colorScheme={colorScheme}
56 + <NativeThemeHost
57 ignoreSafeAreaKeyboardInsets
58 style={{ width: buttonSize, height: buttonSize }}
59 >
@@ -74,7 +69,7 @@ export function MaterialIconButton(props: {
69 >
70 {null}
71 </Component>
77 - </Host>
72 + </NativeThemeHost>
73 </View>
74 {/* Keep RN SVG measurement outside Compose; the native button owns touch and ripple. */}
75 <View pointerEvents="none" className="absolute inset-0 items-center justify-center">
apps/mobile/src/components/MaterialMenuPopup.android.tsx
+6 -8
@@ -1,9 +1,9 @@
1 +import { NativeThemeHost } from "./NativeThemeHost.android";
2 import {
3 Box,
4 Column,
5 DropdownMenu,
6 DropdownMenuItem,
6 - Host,
7 RNHostView,
8 Text,
9 } from "@expo/ui/jetpack-compose";
@@ -47,7 +47,7 @@ function MenuIcon(props: {
47
48 /** Native popup positioned at the original trigger, outside virtualized rows. */
49 export function MaterialMenuPopup(props: MaterialMenuPopupProps) {
50 - const { appearance, themeAppearance, themeVariables: colors } = useAppearancePreferences();
50 + const { appearance, themeVariables: colors } = useAppearancePreferences();
51 const { scale, menuItemHeight } = useAndroidControlSizing();
52 const body = resolveScaledTextRole("body", appearance.baseFontSize);
53 const caption = resolveScaledTextRole("caption", appearance.baseFontSize);
@@ -129,19 +129,17 @@ export function MaterialMenuPopup(props: MaterialMenuPopupProps) {
129 );
130 if (props.inline) {
131 return (
132 - <Host
133 - colorScheme={themeAppearance}
132 + <NativeThemeHost
133 ignoreSafeAreaKeyboardInsets
134 matchContents
135 style={{ width: props.menuWidth }}
136 >
137 <Column>{items}</Column>
139 - </Host>
138 + </NativeThemeHost>
139 );
140 }
141 return (
143 - <Host
144 - colorScheme={themeAppearance}
142 + <NativeThemeHost
143 ignoreSafeAreaKeyboardInsets
144 style={{
145 position: "absolute",
@@ -157,6 +155,6 @@ export function MaterialMenuPopup(props: MaterialMenuPopupProps) {
155 </DropdownMenu.Trigger>
156 <DropdownMenu.Items>{items}</DropdownMenu.Items>
157 </DropdownMenu>
160 - </Host>
158 + </NativeThemeHost>
159 );
160 }
apps/mobile/src/components/MaterialRadioIndicator.android.tsx
+18 -46
@@ -1,56 +1,28 @@
1 -import { Host, RadioButton } from "@expo/ui/jetpack-compose";
1 +import { RadioButton } from "@expo/ui/jetpack-compose";
2 import { size } from "@expo/ui/jetpack-compose/modifiers";
3 import { View } from "react-native";
4 -
5 -import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
4 +import { NativeThemeHost } from "./NativeThemeHost.android";
5 +import { useControlTheme } from "./useControlTheme";
6
7 /** The enclosing radio row owns selection, touch and accessibility. */
8 export function MaterialRadioIndicator({ selected }: { readonly selected: boolean }) {
9 - const { themeAppearance, themeVariables, systemColorsActive } = useAppearancePreferences();
10 - // Expo's radio button cannot override colors in the pinned SDK. Custom
11 - // themes need their exact accent rather than a generated Material palette.
12 - if (!systemColorsActive) {
13 - return (
14 - <View
15 - pointerEvents="none"
16 - importantForAccessibility="no-hide-descendants"
17 - style={{ width: 24, height: 24, alignItems: "center", justifyContent: "center" }}
18 - >
19 - <View
20 - style={{
21 - width: 20,
22 - height: 20,
23 - borderRadius: 10,
24 - borderWidth: 2,
25 - borderColor:
26 - themeVariables[selected ? "--color-primary-text" : "--color-foreground-muted"],
27 - alignItems: "center",
28 - justifyContent: "center",
29 - }}
30 - >
31 - {selected ? (
32 - <View
33 - style={{
34 - width: 10,
35 - height: 10,
36 - borderRadius: 5,
37 - backgroundColor: themeVariables["--color-primary-text"],
38 - }}
39 - />
40 - ) : null}
41 - </View>
42 - </View>
43 - );
44 - }
9 + const { colors, systemColorsActive } = useControlTheme();
10 return (
11 <View pointerEvents="none" importantForAccessibility="no-hide-descendants">
47 - <Host
48 - colorScheme={themeAppearance}
49 - ignoreSafeAreaKeyboardInsets
50 - style={{ width: 24, height: 24 }}
51 - >
52 - <RadioButton selected={selected} modifiers={[size(24, 24)]} />
53 - </Host>
12 + <NativeThemeHost ignoreSafeAreaKeyboardInsets style={{ width: 24, height: 24 }}>
13 + <RadioButton
14 + selected={selected}
15 + modifiers={[size(24, 24)]}
16 + colors={
17 + systemColorsActive
18 + ? {}
19 + : {
20 + selectedColor: colors["--color-primary-text"],
21 + unselectedColor: colors["--color-foreground-muted"],
22 + }
23 + }
24 + />
25 + </NativeThemeHost>
26 </View>
27 );
28 }
apps/mobile/src/components/MaterialScrollComposeButton.android.tsx
+5 -5
@@ -1,4 +1,5 @@
1 -import { Box, ExtendedFloatingActionButton, Host, Icon, Text } from "@expo/ui/jetpack-compose";
1 +import { NativeThemeHost } from "./NativeThemeHost.android";
2 +import { Box, ExtendedFloatingActionButton, Icon, Text } from "@expo/ui/jetpack-compose";
3 import {
4 defaultMinSize,
5 fillMaxWidth,
@@ -20,7 +21,7 @@ export function MaterialScrollComposeButton(props: {
21 readonly className?: string;
22 readonly style?: StyleProp<ViewStyle>;
23 }) {
23 - const { appearance, themeAppearance, themeVariables: colors } = useAppearancePreferences();
24 + const { appearance, themeVariables: colors } = useAppearancePreferences();
25 const typography = resolveScaledTextRole("footnote", appearance.baseFontSize);
26 const { iconSize, fabSize } = useAndroidControlSizing();
27 // Scale the native 56dp minimum; keep text and icons at their requested sizes.
@@ -38,9 +39,8 @@ export function MaterialScrollComposeButton(props: {
39 style={[props.style, { left: 20, height: fabSize }]}
40 >
41 <View pointerEvents="none" importantForAccessibility="no-hide-descendants">
41 - <Host
42 + <NativeThemeHost
43 matchContents={{ vertical: true }}
43 - colorScheme={themeAppearance}
44 ignoreSafeAreaKeyboardInsets
45 style={{ width: "100%" }}
46 >
@@ -83,7 +83,7 @@ export function MaterialScrollComposeButton(props: {
83 </ExtendedFloatingActionButton.Text>
84 </ExtendedFloatingActionButton>
85 </Box>
86 - </Host>
86 + </NativeThemeHost>
87 </View>
88 {/* The visual host is wider than the button; only this target intercepts list touches. */}
89 <Pressable
apps/mobile/src/components/MaterialSwitch.android.tsx
+5 -8
@@ -1,4 +1,5 @@
1 -import { Host, Switch as ComposeSwitch } from "@expo/ui/jetpack-compose";
1 +import { NativeThemeHost } from "./NativeThemeHost.android";
2 +import { Switch as ComposeSwitch } from "@expo/ui/jetpack-compose";
3 import { View } from "react-native";
4 import type { ThemedSwitchProps } from "./MaterialSwitch.types";
5
@@ -6,7 +7,7 @@ import { useControlTheme } from "./useControlTheme";
7
8 /** Material's native switch, with the same palette and accessibility contract as our RN controls. */
9 export function MaterialSwitch(props: ThemedSwitchProps) {
9 - const { colorScheme, colors } = useControlTheme();
10 + const { colors } = useControlTheme();
11 const toggle = () => {
12 if (!props.disabled) props.onValueChange?.(!props.value);
13 };
@@ -24,11 +25,7 @@ export function MaterialSwitch(props: ThemedSwitchProps) {
25 testID={props.testID}
26 >
27 <View importantForAccessibility="no-hide-descendants">
27 - <Host
28 - colorScheme={colorScheme}
29 - ignoreSafeAreaKeyboardInsets
30 - style={{ width: 52, height: 48 }}
31 - >
28 + <NativeThemeHost ignoreSafeAreaKeyboardInsets style={{ width: 52, height: 48 }}>
29 <ComposeSwitch
30 value={Boolean(props.value)}
31 enabled={!props.disabled}
@@ -42,7 +39,7 @@ export function MaterialSwitch(props: ThemedSwitchProps) {
39 uncheckedBorderColor: colors["--color-switch-inactive-thumb"],
40 }}
41 />
45 - </Host>
42 + </NativeThemeHost>
43 </View>
44 </View>
45 );
apps/mobile/src/components/SliderRow.android.tsx
+1 -1
@@ -6,7 +6,7 @@ import { View } from "react-native";
6
7 import { AppText as Text } from "./AppText";
8 import { SymbolView } from "./AppSymbol";
9 -import { NativeThemeHost } from "./NativeThemeHost";
9 +import { NativeThemeHost } from "./NativeThemeHost.android";
10 import { useControlTheme } from "./useControlTheme";
11 import type { SliderRow as SharedSliderRow } from "./SliderRow";
12