feat(settings): add typed switch/select/stepper setting rows

This commit is contained in:
Gauvain
2026-06-04 12:11:21 +02:00
parent 8a88706776
commit 8071e76fc6
3 changed files with 100 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
import { Ionicons } from "@expo/vector-icons";
import type React from "react";
import { View } from "react-native";
import { Text } from "@/components/common/Text";
import { ListItem } from "@/components/list/ListItem";
import {
type OptionGroup,
PlatformDropdown,
} from "@/components/PlatformDropdown";
interface Props {
title: string;
valueLabel?: string;
groups: OptionGroup[];
dropdownTitle?: string;
disabled?: boolean;
}
export const SettingsSelectRow: React.FC<Props> = ({
title,
valueLabel,
groups,
dropdownTitle,
disabled,
}) => (
<ListItem title={title} disabled={disabled}>
<PlatformDropdown
groups={groups}
title={dropdownTitle}
trigger={
<View className='flex flex-row items-center justify-between py-1.5 pl-3'>
<Text className='mr-1 text-[#8E8D91]'>{valueLabel}</Text>
<Ionicons name='chevron-expand-sharp' size={18} color='#5A5960' />
</View>
}
/>
</ListItem>
);

View File

@@ -0,0 +1,39 @@
import type React from "react";
import { Stepper } from "@/components/inputs/Stepper";
import { ListItem } from "@/components/list/ListItem";
interface Props {
title: string;
subtitle?: string;
value: number;
step: number;
min: number;
max: number;
onUpdate: (value: number) => void;
appendValue?: string;
disabled?: boolean;
}
export const SettingsStepperRow: React.FC<Props> = ({
title,
subtitle,
value,
step,
min,
max,
onUpdate,
appendValue,
disabled,
}) => (
<ListItem title={title} subtitle={subtitle} disabled={disabled}>
<Stepper
value={value}
step={step}
min={min}
max={max}
onUpdate={onUpdate}
appendValue={appendValue}
disabled={disabled}
/>
</ListItem>
);

View File

@@ -0,0 +1,23 @@
import type React from "react";
import { Switch } from "react-native";
import { ListItem } from "@/components/list/ListItem";
interface Props {
title: string;
subtitle?: string;
value: boolean;
onValueChange: (value: boolean) => void;
disabled?: boolean;
}
export const SettingsSwitchRow: React.FC<Props> = ({
title,
subtitle,
value,
onValueChange,
disabled,
}) => (
<ListItem title={title} subtitle={subtitle} disabled={disabled}>
<Switch value={value} disabled={disabled} onValueChange={onValueChange} />
</ListItem>
);