feat: autoplay toggle and setting

This commit is contained in:
Adrian Castro
2024-03-25 18:57:56 +01:00
parent cd0b302602
commit 37e61d1296
2 changed files with 13 additions and 1 deletions

View File

@@ -36,7 +36,8 @@ const themeOptions: ThemeStoreOption[] = [
]; ];
export default function SettingsScreen() { export default function SettingsScreen() {
const { gestureControls, setGestureControls } = usePlayerSettingsStore(); const { gestureControls, setGestureControls, autoPlay, setAutoPlay } =
usePlayerSettingsStore();
const toastController = useToastController(); const toastController = useToastController();
const handleGestureControlsToggle = async (isEnabled: boolean) => { const handleGestureControlsToggle = async (isEnabled: boolean) => {
@@ -85,6 +86,13 @@ export default function SettingsScreen() {
<MWSwitch.Thumb animation="quicker" /> <MWSwitch.Thumb animation="quicker" />
</MWSwitch> </MWSwitch>
</XStack> </XStack>
<XStack width={200} alignItems="center" gap="$4">
<Label minWidth={110}>Autoplay</Label>
<Separator minHeight={20} vertical />
<MWSwitch checked={autoPlay} onCheckedChange={setAutoPlay}>
<MWSwitch.Thumb animation="quicker" />
</MWSwitch>
</XStack>
</YStack> </YStack>
</View> </View>
<View justifyContent="center" alignItems="center"> <View justifyContent="center" alignItems="center">

View File

@@ -46,6 +46,8 @@ export const useThemeSettingsStore = create<
interface PlayerStoreState { interface PlayerStoreState {
gestureControls: boolean; gestureControls: boolean;
setGestureControls: (enabled: boolean) => void; setGestureControls: (enabled: boolean) => void;
autoPlay: boolean;
setAutoPlay: (enabled: boolean) => void;
} }
export const usePlayerSettingsStore = create< export const usePlayerSettingsStore = create<
@@ -61,6 +63,8 @@ export const usePlayerSettingsStore = create<
}), }),
setGestureControls: (enabled: boolean) => setGestureControls: (enabled: boolean) =>
set({ gestureControls: enabled }), set({ gestureControls: enabled }),
autoPlay: true,
setAutoPlay: (enabled: boolean) => set({ autoPlay: enabled }),
}), }),
{ {
name: "player-settings", name: "player-settings",