Files
t3code/apps/mobile/src/features/settings/components/SettingsRow.tsx
T
6676f9c83b fix(mobile): stabilize thread composer and interactions (#5986)
Co-authored-by: codex <[email protected]>
Co-authored-by: Thuong Tin <[email protected]>
Co-authored-by: Kapish14 <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
2026-08-11 14:05:03 +00:00

97 lines
2.7 KiB
TypeScript

import { useNavigation } from "@react-navigation/native";
import type { ComponentProps } from "react";
import { Pressable, View } from "react-native";
import { SymbolView } from "../../../components/AppSymbol";
import { AppText as Text } from "../../../components/AppText";
import { useThemeColor } from "../../../lib/useThemeColor";
import type { SettingsLegalDocumentTarget, SettingsSheetTarget } from "./settings-sheet-targets";
type SymbolName = ComponentProps<typeof SymbolView>["name"];
export function SettingsRow(props: {
readonly disabled?: boolean;
readonly icon: SymbolName;
readonly label: string;
readonly value?: string;
readonly target?: SettingsSheetTarget;
readonly fullScreenTarget?: SettingsLegalDocumentTarget;
readonly onPress?: () => void;
}) {
const navigation = useNavigation();
const icon = useThemeColor("--color-icon");
const chevron = useThemeColor("--color-chevron");
const content = (
<View
className={
props.disabled
? "flex-row items-center gap-4 p-4 opacity-[0.45]"
: "flex-row items-center gap-4 p-4"
}
>
<SymbolView name={props.icon} size={22} tintColor={icon} type="monochrome" weight="regular" />
<Text className="shrink-0 text-lg text-foreground" numberOfLines={1}>
{props.label}
</Text>
<View className="min-w-0 flex-1 items-end">
{props.value ? (
<Text
className="max-w-[180px] text-right text-base text-foreground-muted"
ellipsizeMode="middle"
numberOfLines={1}
>
{props.value}
</Text>
) : null}
</View>
<SymbolView
name="chevron.right"
size={16}
tintColor={chevron}
type="monochrome"
weight="semibold"
/>
</View>
);
const target = props.target;
if (target) {
return (
<Pressable
accessibilityLabel={props.label}
accessibilityRole="button"
disabled={props.disabled}
onPress={() =>
navigation.navigate("SettingsSheet", {
screen: "SettingsContent",
params: { screen: target },
})
}
>
{content}
</Pressable>
);
}
const fullScreenTarget = props.fullScreenTarget;
if (fullScreenTarget) {
return (
<Pressable
accessibilityLabel={props.label}
accessibilityRole="button"
disabled={props.disabled}
onPress={() => navigation.navigate(fullScreenTarget)}
>
{content}
</Pressable>
);
}
return (
<Pressable accessibilityRole="button" disabled={props.disabled} onPress={props.onPress}>
{content}
</Pressable>
);
}