diff options
author | Paul Frazee <pfrazee@gmail.com> | 2024-02-13 09:38:39 -0800 |
---|---|---|
committer | Paul Frazee <pfrazee@gmail.com> | 2024-02-13 09:38:39 -0800 |
commit | 01a708ae3ded3fe6919d07c5095b1ed91f438314 (patch) | |
tree | df3f1041786f0c70b979ba32ac5cadc810d9e08d /src/view/com/auth/SplashScreen.tsx | |
parent | 990fc218bd4c4c4d884aa969f85f354cb8de41bb (diff) | |
parent | b1240c1e49736c3bec62c67ebe40d02a98d88594 (diff) | |
download | voidsky-01a708ae3ded3fe6919d07c5095b1ed91f438314.tar.zst |
Merge branch 'feat/logged-out-improvements' of https://github.com/mary-ext/fork-bsky-app into mary-ext-feat/logged-out-improvements
Diffstat (limited to 'src/view/com/auth/SplashScreen.tsx')
-rw-r--r-- | src/view/com/auth/SplashScreen.tsx | 75 |
1 files changed, 74 insertions, 1 deletions
diff --git a/src/view/com/auth/SplashScreen.tsx b/src/view/com/auth/SplashScreen.tsx index ffd07d945..4fd800c3b 100644 --- a/src/view/com/auth/SplashScreen.tsx +++ b/src/view/com/auth/SplashScreen.tsx @@ -9,6 +9,14 @@ import {Trans, msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {Logo} from '#/view/icons/Logo' import {Logotype} from '#/view/icons/Logotype' +import { + FontAwesomeIcon, + FontAwesomeIconStyle, +} from '@fortawesome/react-native-fontawesome' +import RNPickerSelect, {PickerSelectProps} from 'react-native-picker-select' +import {sanitizeAppLanguageSetting} from '#/locale/helpers' +import {useLanguagePrefs, useLanguagePrefsApi} from '#/state/preferences' +import {APP_LANGUAGES} from '#/locale/languages' export const SplashScreen = ({ onPressSignin, @@ -20,6 +28,21 @@ export const SplashScreen = ({ const pal = usePalette('default') const {_} = useLingui() + const langPrefs = useLanguagePrefs() + const setLangPrefs = useLanguagePrefsApi() + + const sanitizedLang = sanitizeAppLanguageSetting(langPrefs.appLanguage) + + const onChangeAppLanguage = React.useCallback( + (value: Parameters<PickerSelectProps['onValueChange']>[0]) => { + if (!value) return + if (sanitizedLang !== value) { + setLangPrefs.setAppLanguage(sanitizeAppLanguageSetting(value)) + } + }, + [sanitizedLang, setLangPrefs], + ) + return ( <CenteredView style={[styles.container, pal.view]}> <ErrorBoundary> @@ -58,6 +81,50 @@ export const SplashScreen = ({ </Text> </TouchableOpacity> </View> + <View style={styles.footer}> + <View style={{position: 'relative'}}> + <RNPickerSelect + placeholder={{}} + value={sanitizedLang} + onValueChange={onChangeAppLanguage} + items={APP_LANGUAGES.filter(l => Boolean(l.code2)).map(l => ({ + label: l.name, + value: l.code2, + key: l.code2, + }))} + useNativeAndroidPickerStyle={false} + style={{ + inputAndroid: { + color: pal.textLight.color, + fontSize: 16, + paddingRight: 10 + 4, + }, + inputIOS: { + color: pal.text.color, + fontSize: 16, + paddingRight: 10 + 4, + }, + }} + /> + + <View + style={{ + position: 'absolute', + top: 0, + right: 0, + bottom: 0, + pointerEvents: 'none', + alignItems: 'center', + justifyContent: 'center', + }}> + <FontAwesomeIcon + icon="chevron-down" + size={10} + style={pal.textLight as FontAwesomeIconStyle} + /> + </View> + </View> + </View> </ErrorBoundary> </CenteredView> ) @@ -73,7 +140,7 @@ const styles = StyleSheet.create({ alignItems: 'center', }, btns: { - paddingBottom: 40, + paddingBottom: 0, }, title: { textAlign: 'center', @@ -95,4 +162,10 @@ const styles = StyleSheet.create({ textAlign: 'center', fontSize: 21, }, + footer: { + paddingHorizontal: 16, + paddingVertical: 12, + justifyContent: 'center', + alignItems: 'center', + }, }) |