import React, { useEffect, useState } from 'react'; import { Text } from '@/components/shared/Themed'; import styled from '@emotion/native'; import { useNavigation } from '@react-navigation/native'; import { NativeStackNavigationProp } from '@react-navigation/native-stack'; import { RootStackParamList } from '@/app/RootStackParamList'; import { loadUserSettings, saveUserSettings } from '@/components/shared/business/AsyncStorage'; import { Switch } from 'react-native'; import { VerticalSpacer } from '@/components/shared/Spacers'; import Button from '@/components/shared/Button'; type NavigationProp = NativeStackNavigationProp; export default function Dashboard() { const navigation = useNavigation(); const [soundEnabled, setSoundEnabled] = useState(false); useEffect(() => { const init = async () => { try { const soundEnabledLocal = await loadUserSettings('soundEnabled'); console.log('soundEnabledLocal', soundEnabledLocal); if (soundEnabledLocal === null) { console.log('soundEnabledLocal is null'); setSoundEnabled(true); } else { console.log('soundEnabledLocal is present', ); setSoundEnabled(Boolean(Number(soundEnabledLocal))); } } catch (error) { throw new Error('Erreur lors du chargement des paramètres utilisateur'); } }; init(); }, []); useEffect(() => { saveUserSettings('soundEnabled', String(Number(soundEnabled))); }, [soundEnabled]); return ( Preferences