Open History to see the last commit
1import type { ComponentProps, ReactNode } from "react";
2import { Platform, Pressable, View } from "react-native";
3
4import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
5import { cn } from "../lib/cn";
6import { AppText } from "./AppText";
7import { SymbolView } from "./AppSymbol";
8
9/** Shared geometry for Material navigation and selection lists. Group rows in one card. */
10export function MaterialListRow({
11 title,
12 titleClassName,
13 subtitle,
14 leading,
15 trailing,
16 className,
17 ...props
18}: Omit<ComponentProps<typeof Pressable>, "children"> & {
19 readonly title: string;
20 readonly titleClassName?: string;
21 readonly subtitle?: string | null;
22 readonly leading?: ReactNode;
23 readonly trailing?: ReactNode;
24}) {
25 const { themeVariables } = useAppearancePreferences();
26 return (
27 <Pressable
28 accessibilityRole="button"
29 accessibilityLabel={[title, subtitle].filter(Boolean).join(", ")}
30 android_ripple={{ color: themeVariables["--color-subtle-strong"] }}
31 // Give the scroll view time to claim drags before starting the ripple.
32 unstable_pressDelay={Platform.OS === "android" ? 50 : undefined}
33 {...props}
34 className={cn(
35 "flex-row items-center gap-4 overflow-hidden bg-card px-4 py-3",
36 subtitle ? "min-h-18" : "min-h-14",
37 props.disabled && "opacity-45",
38 className,
39 )}
40 >
41 {leading ? <View className="size-6 items-center justify-center">{leading}</View> : null}
42 <View className="min-w-0 flex-1 gap-1">
43 <AppText className={cn("text-base text-foreground", titleClassName)} numberOfLines={2}>
44 {title}
45 </AppText>
46 {subtitle ? (
47 <AppText className="text-sm text-foreground-muted" numberOfLines={2}>
48 {subtitle}
49 </AppText>
50 ) : null}
51 </View>
52 {trailing !== undefined ? (
53 trailing
54 ) : !props.disabled ? (
55 <SymbolView name="chevron.right" size={16} tintColorClassName="accent-chevron" />
56 ) : null}
57 </Pressable>
58 );
59}