From a9029a5f4f15cbe906b96f935fabcf66749c507f Mon Sep 17 00:00:00 2001 From: Mary Date: Tue, 13 Feb 2024 12:46:29 +0700 Subject: [PATCH] feat: language selection on web splash screen --- src/view/com/auth/SplashScreen.web.tsx | 69 ++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/src/view/com/auth/SplashScreen.web.tsx b/src/view/com/auth/SplashScreen.web.tsx index 5c4d55dd..ff8fe60b 100644 --- a/src/view/com/auth/SplashScreen.web.tsx +++ b/src/view/com/auth/SplashScreen.web.tsx @@ -13,6 +13,9 @@ import {Trans, msg} from '@lingui/macro' import {Logo} from '#/view/icons/Logo' import {Logotype} from '#/view/icons/Logotype' import {useLingui} from '@lingui/react' +import {sanitizeAppLanguageSetting} from '#/locale/helpers' +import {useLanguagePrefs, useLanguagePrefsApi} from '#/state/preferences' +import {APP_LANGUAGES} from '#/locale/languages' export const SplashScreen = ({ onDismiss, @@ -101,6 +104,23 @@ function Footer({styles}: {styles: ReturnType}) { const pal = usePalette('default') const {_} = useLingui() + const langPrefs = useLanguagePrefs() + const setLangPrefs = useLanguagePrefsApi() + + const sanitizedLang = sanitizeAppLanguageSetting(langPrefs.appLanguage) + + const onChangeAppLanguage = React.useCallback( + (ev: React.ChangeEvent) => { + const value = ev.target.value + + if (!value) return + if (sanitizedLang !== value) { + setLangPrefs.setAppLanguage(sanitizeAppLanguageSetting(value)) + } + }, + [sanitizedLang, setLangPrefs], + ) + return ( }) { text={_(msg`Jobs`)} style={[styles.footerLink, pal.link]} /> + + + + + + {APP_LANGUAGES.find(l => l.code2 === sanitizedLang)?.name} + + + + + ) } @@ -190,9 +252,10 @@ const useStyles = () => { padding: 20, borderTopWidth: 1, flexDirection: 'row', + flexWrap: 'wrap', + gap: 20, }, - footerLink: { - marginRight: 20, - }, + footerDivider: {flexGrow: 1}, + footerLink: {}, }) }