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";
8import { useAndroidControlSizing } from "./useAndroidControlSizing";
9
10/** Shared geometry for Material navigation and selection lists. Group rows in one card. */
11export function NavigationRow({
12 title,
13 titleClassName,
14 subtitle,
15 subtitleNumberOfLines,
16 subtitleEllipsizeMode,
17 leading,
18 trailing,
19 className,
20 ...props
21}: Omit<ComponentProps<typeof Pressable>, "children"> & {
22 readonly title: string;
23 readonly titleClassName?: string;
24 readonly subtitle?: string | null;
25 readonly subtitleNumberOfLines?: ComponentProps<typeof AppText>["numberOfLines"];
26 readonly subtitleEllipsizeMode?: ComponentProps<typeof AppText>["ellipsizeMode"];
27 readonly leading?: ReactNode;
28 readonly trailing?: ReactNode;
29}) {
30 const { themeVariables } = useAppearancePreferences();
31 const { smallIconSize } = useAndroidControlSizing();
32 return (
33 <Pressable
34 accessibilityRole="button"
35 accessibilityLabel={[title, subtitle].filter(Boolean).join(", ")}
36 android_ripple={{ color: themeVariables["--color-subtle-strong"] }}
37 unstable_pressDelay={Platform.OS === "android" ? 50 : undefined}
38 {...props}
39 className={cn(
40 "flex-row items-center gap-4 overflow-hidden bg-card px-4 py-3",
41 subtitle ? "min-h-18" : "min-h-14",
42 props.disabled && "opacity-45",
43 className,
44 )}
45 >
46 {leading ? <View className="size-6 items-center justify-center">{leading}</View> : null}
47 <View className="min-w-0 flex-1 gap-1">
48 <AppText className={cn("text-base text-foreground", titleClassName)} numberOfLines={2}>
49 {title}
50 </AppText>
51 {subtitle ? (
52 <AppText
53 className="text-sm text-foreground-muted"
54 ellipsizeMode={subtitleEllipsizeMode}
55 numberOfLines={subtitleNumberOfLines ?? 2}
56 >
57 {subtitle}
58 </AppText>
59 ) : null}
60 </View>
61 {trailing !== undefined ? (
62 trailing
63 ) : !props.disabled ? (
64 <SymbolView name="chevron.right" size={smallIconSize} tintColorClassName="accent-chevron" />
65 ) : null}
66 </Pressable>
67 );
68}