From a9dbcfb69d9512a37cfb526570ea7191fb908ec2 Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Fri, 15 Apr 2022 12:55:11 +0900 Subject: [PATCH] add edit server string i18n set add/edit header title with i18n fix albums plural in artist view --- android/app/src/main/assets/custom/i18n/en.json | 1 + app/navigation/BottomTabNavigator.tsx | 7 ++++--- app/screens/ArtistView.tsx | 2 +- app/screens/ServerView.tsx | 9 +++++++-- app/screens/Settings.tsx | 7 ++++--- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/android/app/src/main/assets/custom/i18n/en.json b/android/app/src/main/assets/custom/i18n/en.json index 74f5f08..af9f861 100644 --- a/android/app/src/main/assets/custom/i18n/en.json +++ b/android/app/src/main/assets/custom/i18n/en.json @@ -92,6 +92,7 @@ }, "actions": { "add": "Add Server", + "edit": "Edit Server", "testConnection": "Test Connection", "delete": "Delete", "save": "Save" diff --git a/app/navigation/BottomTabNavigator.tsx b/app/navigation/BottomTabNavigator.tsx index 8a23b3b..a1626fb 100644 --- a/app/navigation/BottomTabNavigator.tsx +++ b/app/navigation/BottomTabNavigator.tsx @@ -117,7 +117,7 @@ const SearchTab = createTabStackNavigator(Search) type SettingsStackParamList = { main: undefined - server?: { id?: string } + server?: { id?: string; title?: string } web: { uri: string; title?: string } } @@ -127,7 +127,9 @@ type ServerScreenProps = { route: ServerScreenRouteProp navigation: ServerScreenNavigationProp } -const ServerScreen: React.FC = ({ route }) => +const ServerScreen: React.FC = ({ route }) => ( + +) type WebScreenNavigationProp = NativeStackNavigationProp type WebScreenRouteProp = RouteProp @@ -149,7 +151,6 @@ const SettingsTab = () => { name="server" component={ServerScreen} options={{ - title: 'Edit Server', headerStyle: styles.stackheaderStyle, headerHideShadow: true, headerTintColor: 'white', diff --git a/app/screens/ArtistView.tsx b/app/screens/ArtistView.tsx index ea2022c..7ec93f2 100644 --- a/app/screens/ArtistView.tsx +++ b/app/screens/ArtistView.tsx @@ -89,7 +89,7 @@ const ArtistAlbums = withSuspenseMemo<{ return ( <> -
{t('name', { count: 1 })}
+
{t('name', { count: 2 })}
{sortedAlbums.map(a => ( diff --git a/app/screens/ServerView.tsx b/app/screens/ServerView.tsx index e2ca7fc..d509e51 100644 --- a/app/screens/ServerView.tsx +++ b/app/screens/ServerView.tsx @@ -9,7 +9,7 @@ import font from '@app/styles/font' import toast from '@app/util/toast' import { useNavigation } from '@react-navigation/native' import md5 from 'md5' -import React, { useCallback, useState } from 'react' +import React, { useCallback, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { StyleSheet, Text, TextInput, View, ViewStyle } from 'react-native' import uuid from 'react-native-uuid' @@ -18,7 +18,8 @@ const PASSWORD_PLACEHOLDER = 'PASSWORD_PLACEHOLDER' const ServerView = withSuspense<{ id?: string -}>(({ id }) => { + title?: string +}>(({ id, title }) => { const { t } = useTranslation('settings.servers') const navigation = useNavigation() const activeServerId = useStore(store => store.settings.activeServerId) @@ -39,6 +40,10 @@ const ServerView = withSuspense<{ const [testing, setTesting] = useState(false) + useEffect(() => { + navigation.setOptions({ title }) + }, [navigation, title]) + const validate = useCallback(() => { return !!address && !!username && !!password }, [address, username, password]) diff --git a/app/screens/Settings.tsx b/app/screens/Settings.tsx index 3053aed..0dfbd3a 100644 --- a/app/screens/Settings.tsx +++ b/app/screens/Settings.tsx @@ -20,12 +20,13 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context' import Icon from 'react-native-vector-icons/MaterialCommunityIcons' import { version } from '../../package.json' -const ServerItem = React.memo<{ +const ServerItem = withSuspenseMemo<{ server: Server }>(({ server }) => { const activeServerId = useStore(store => store.settings.activeServerId) const switchActiveServer = useSwitchActiveServer() const navigation = useNavigation() + const { t } = useTranslation('settings.servers.actions') const setActive = useCallback(() => { switchActiveServer(server.id) @@ -35,7 +36,7 @@ const ServerItem = React.memo<{ navigation.navigate('server', { id: server.id })}> + onPress={() => navigation.navigate('server', { id: server.id, title: t('edit') })}> {activeServerId === server.id ? ( @@ -219,7 +220,7 @@ const SettingsContent = withSuspenseMemo(() => {