Open History to see the last commit
1import { Platform, View } from "react-native";
2import { useResolveClassNames } from "uniwind";
3
4import { cn } from "../../lib/cn";
5import { SymbolView } from "./AppSymbol";
6import { ListRowLayout } from "./ListRowLayout";
7import { RadioIndicator } from "./RadioIndicator";
8import { RowPressable } from "./RowPressable";
9
10export function ListChoiceRow(props: {
11 readonly label: string;
12 readonly description?: string;
13 readonly selected: boolean;
14 readonly separated?: boolean;
15 readonly disabled?: boolean;
16 readonly onPress: () => void;
17}) {
18 const rippleStyle = useResolveClassNames("bg-subtle-strong");
19 return (
20 <RowPressable
21 accessibilityRole="radio"
22 accessibilityLabel={props.label}
23 accessibilityHint={props.description}
24 accessibilityState={{ checked: props.selected, disabled: Boolean(props.disabled) }}
25 disabled={props.disabled}
26 onPress={props.onPress}
27 android_ripple={{ color: rippleStyle.backgroundColor }}
28 unstable_pressDelay={Platform.OS === "android" ? 50 : undefined}
29 // Like UIKit and Material lists, only the checkmark or radio marks the selected row.
30 className={cn("bg-grouped-card", props.separated && "border-t border-border-subtle")}
31 >
32 <ListRowLayout
33 label={props.label}
34 description={props.description}
35 disabled={props.disabled}
36 accessory={
37 <View
38 accessibilityElementsHidden
39 importantForAccessibility="no-hide-descendants"
40 className="size-6 items-center justify-center"
41 >
42 {Platform.OS === "android" ? (
43 <RadioIndicator selected={props.selected} />
44 ) : props.selected ? (
45 <SymbolView
46 name="checkmark"
47 size={18}
48 tintColorClassName="accent-primary-text"
49 type="monochrome"
50 weight="semibold"
51 />
52 ) : null}
53 </View>
54 }
55 />
56 </RowPressable>
57 );
58}