mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-04 13:08:33 +01:00
feat(settings): add typed switch/select/stepper setting rows
This commit is contained in:
38
components/settings/index/SettingsSelectRow.tsx
Normal file
38
components/settings/index/SettingsSelectRow.tsx
Normal 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>
|
||||
);
|
||||
39
components/settings/index/SettingsStepperRow.tsx
Normal file
39
components/settings/index/SettingsStepperRow.tsx
Normal 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>
|
||||
);
|
||||
23
components/settings/index/SettingsSwitchRow.tsx
Normal file
23
components/settings/index/SettingsSwitchRow.tsx
Normal 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>
|
||||
);
|
||||
Reference in New Issue
Block a user