diff --git a/app/Settings.tsx b/app/Settings.tsx index ce552ef..42de364 100644 --- a/app/Settings.tsx +++ b/app/Settings.tsx @@ -1,20 +1,25 @@ -import React, { useEffect, useState } from 'react'; +import React, { useContext, 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 { i18n } from './i18n/i18n'; +import { LanguageContext } from '@/app/shared/providers/LanguageProvider'; +import DropDownPicker from "react-native-dropdown-picker"; import { VerticalSpacer } from '@/components/shared/Spacers'; -import Button from '@/components/shared/Button'; -type NavigationProp = NativeStackNavigationProp; +const t = i18n.scoped('settings'); export default function Dashboard() { - const navigation = useNavigation(); const [soundEnabled, setSoundEnabled] = useState(false); + const { userChangeLanguage } = useContext(LanguageContext) + const [languageOpen, setLanguageOpen] = useState(false); + const [languageValue, setLanguageValue] = useState(i18n.localI18n.locale); + const [language, setLanguage] = useState([ + { label: t('french'), value: "fr" }, + { label: t('english'), value: "en" }, + ]); useEffect(() => { const init = async () => { @@ -40,20 +45,34 @@ export default function Dashboard() { return ( - Preferences - - + + )} + + + ); + + const button = getByTestId('change-language-button'); + button.props.onPress(); + + await waitFor(() => { + expect(i18n.localI18n.locale).toBe('en'); + expect(AsyncStorage.setItem).toHaveBeenCalledWith('storedLanguage', 'en'); + }); + }); +}); diff --git a/components/useCases/timer/view/FinishContent.tsx b/components/useCases/timer/view/FinishContent.tsx index 7a6d4d8..51ec026 100644 --- a/components/useCases/timer/view/FinishContent.tsx +++ b/components/useCases/timer/view/FinishContent.tsx @@ -6,6 +6,7 @@ import { NativeStackNavigationProp } from 'react-native-screens/lib/typescript/n import Button from '@/components/shared/Button'; import { HorizontalSpacer, VerticalSpacer } from '@/components/shared/Spacers'; import { RootStackParamList } from '@/app/RootStackParamList'; +import { i18n } from '@/app/i18n/i18n'; type FinishContentProps = { handleStart: () => void; @@ -13,6 +14,8 @@ type FinishContentProps = { type NavigationProp = NativeStackNavigationProp; +const t = i18n.scoped('timer.finishContent'); + export default function FinishContent({ handleStart }: FinishContentProps) { @@ -20,16 +23,16 @@ export default function FinishContent({ return ( <> - + -