Open History to see the last commit
1import { Host, RadioButton } from "@expo/ui/jetpack-compose";
2import { size } from "@expo/ui/jetpack-compose/modifiers";
3import { View } from "react-native";
4
5import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
6
7/** The enclosing radio row owns selection, touch and accessibility. */
8export 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: themeVariables[selected ? "--color-primary" : "--color-foreground-muted"],
26 alignItems: "center",
27 justifyContent: "center",
28 }}
29 >
30 {selected ? (
31 <View
32 style={{
33 width: 10,
34 height: 10,
35 borderRadius: 5,
36 backgroundColor: themeVariables["--color-primary"],
37 }}
38 />
39 ) : null}
40 </View>
41 </View>
42 );
43 }
44 return (
45 <View pointerEvents="none" importantForAccessibility="no-hide-descendants">
46 <Host
47 colorScheme={themeAppearance}
48 ignoreSafeAreaKeyboardInsets
49 style={{ width: 24, height: 24 }}
50 >
51 <RadioButton selected={selected} modifiers={[size(24, 24)]} />
52 </Host>
53 </View>
54 );
55}