mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-28 17:19:27 +01:00
add edit server string i18n
set add/edit header title with i18n fix albums plural in artist view
This commit is contained in:
parent
860a4cec16
commit
a9dbcfb69d
@ -92,6 +92,7 @@
|
|||||||
},
|
},
|
||||||
"actions": {
|
"actions": {
|
||||||
"add": "Add Server",
|
"add": "Add Server",
|
||||||
|
"edit": "Edit Server",
|
||||||
"testConnection": "Test Connection",
|
"testConnection": "Test Connection",
|
||||||
"delete": "Delete",
|
"delete": "Delete",
|
||||||
"save": "Save"
|
"save": "Save"
|
||||||
|
|||||||
@ -117,7 +117,7 @@ const SearchTab = createTabStackNavigator(Search)
|
|||||||
|
|
||||||
type SettingsStackParamList = {
|
type SettingsStackParamList = {
|
||||||
main: undefined
|
main: undefined
|
||||||
server?: { id?: string }
|
server?: { id?: string; title?: string }
|
||||||
web: { uri: string; title?: string }
|
web: { uri: string; title?: string }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +127,9 @@ type ServerScreenProps = {
|
|||||||
route: ServerScreenRouteProp
|
route: ServerScreenRouteProp
|
||||||
navigation: ServerScreenNavigationProp
|
navigation: ServerScreenNavigationProp
|
||||||
}
|
}
|
||||||
const ServerScreen: React.FC<ServerScreenProps> = ({ route }) => <ServerView id={route.params?.id} />
|
const ServerScreen: React.FC<ServerScreenProps> = ({ route }) => (
|
||||||
|
<ServerView id={route.params?.id} title={route.params?.title} />
|
||||||
|
)
|
||||||
|
|
||||||
type WebScreenNavigationProp = NativeStackNavigationProp<SettingsStackParamList, 'web'>
|
type WebScreenNavigationProp = NativeStackNavigationProp<SettingsStackParamList, 'web'>
|
||||||
type WebScreenRouteProp = RouteProp<SettingsStackParamList, 'web'>
|
type WebScreenRouteProp = RouteProp<SettingsStackParamList, 'web'>
|
||||||
@ -149,7 +151,6 @@ const SettingsTab = () => {
|
|||||||
name="server"
|
name="server"
|
||||||
component={ServerScreen}
|
component={ServerScreen}
|
||||||
options={{
|
options={{
|
||||||
title: 'Edit Server',
|
|
||||||
headerStyle: styles.stackheaderStyle,
|
headerStyle: styles.stackheaderStyle,
|
||||||
headerHideShadow: true,
|
headerHideShadow: true,
|
||||||
headerTintColor: 'white',
|
headerTintColor: 'white',
|
||||||
|
|||||||
@ -89,7 +89,7 @@ const ArtistAlbums = withSuspenseMemo<{
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Header>{t('name', { count: 1 })}</Header>
|
<Header>{t('name', { count: 2 })}</Header>
|
||||||
<View style={styles.albums} onLayout={albumsLayout.onLayout}>
|
<View style={styles.albums} onLayout={albumsLayout.onLayout}>
|
||||||
{sortedAlbums.map(a => (
|
{sortedAlbums.map(a => (
|
||||||
<AlbumItem key={a.id} album={a} height={albumSize} width={albumSize} />
|
<AlbumItem key={a.id} album={a} height={albumSize} width={albumSize} />
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import font from '@app/styles/font'
|
|||||||
import toast from '@app/util/toast'
|
import toast from '@app/util/toast'
|
||||||
import { useNavigation } from '@react-navigation/native'
|
import { useNavigation } from '@react-navigation/native'
|
||||||
import md5 from 'md5'
|
import md5 from 'md5'
|
||||||
import React, { useCallback, useState } from 'react'
|
import React, { useCallback, useEffect, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { StyleSheet, Text, TextInput, View, ViewStyle } from 'react-native'
|
import { StyleSheet, Text, TextInput, View, ViewStyle } from 'react-native'
|
||||||
import uuid from 'react-native-uuid'
|
import uuid from 'react-native-uuid'
|
||||||
@ -18,7 +18,8 @@ const PASSWORD_PLACEHOLDER = 'PASSWORD_PLACEHOLDER'
|
|||||||
|
|
||||||
const ServerView = withSuspense<{
|
const ServerView = withSuspense<{
|
||||||
id?: string
|
id?: string
|
||||||
}>(({ id }) => {
|
title?: string
|
||||||
|
}>(({ id, title }) => {
|
||||||
const { t } = useTranslation('settings.servers')
|
const { t } = useTranslation('settings.servers')
|
||||||
const navigation = useNavigation()
|
const navigation = useNavigation()
|
||||||
const activeServerId = useStore(store => store.settings.activeServerId)
|
const activeServerId = useStore(store => store.settings.activeServerId)
|
||||||
@ -39,6 +40,10 @@ const ServerView = withSuspense<{
|
|||||||
|
|
||||||
const [testing, setTesting] = useState(false)
|
const [testing, setTesting] = useState(false)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
navigation.setOptions({ title })
|
||||||
|
}, [navigation, title])
|
||||||
|
|
||||||
const validate = useCallback(() => {
|
const validate = useCallback(() => {
|
||||||
return !!address && !!username && !!password
|
return !!address && !!username && !!password
|
||||||
}, [address, username, password])
|
}, [address, username, password])
|
||||||
|
|||||||
@ -20,12 +20,13 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|||||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'
|
import Icon from 'react-native-vector-icons/MaterialCommunityIcons'
|
||||||
import { version } from '../../package.json'
|
import { version } from '../../package.json'
|
||||||
|
|
||||||
const ServerItem = React.memo<{
|
const ServerItem = withSuspenseMemo<{
|
||||||
server: Server
|
server: Server
|
||||||
}>(({ server }) => {
|
}>(({ server }) => {
|
||||||
const activeServerId = useStore(store => store.settings.activeServerId)
|
const activeServerId = useStore(store => store.settings.activeServerId)
|
||||||
const switchActiveServer = useSwitchActiveServer()
|
const switchActiveServer = useSwitchActiveServer()
|
||||||
const navigation = useNavigation()
|
const navigation = useNavigation()
|
||||||
|
const { t } = useTranslation('settings.servers.actions')
|
||||||
|
|
||||||
const setActive = useCallback(() => {
|
const setActive = useCallback(() => {
|
||||||
switchActiveServer(server.id)
|
switchActiveServer(server.id)
|
||||||
@ -35,7 +36,7 @@ const ServerItem = React.memo<{
|
|||||||
<SettingsItem
|
<SettingsItem
|
||||||
title={server.address}
|
title={server.address}
|
||||||
subtitle={server.username}
|
subtitle={server.username}
|
||||||
onPress={() => navigation.navigate('server', { id: server.id })}>
|
onPress={() => navigation.navigate('server', { id: server.id, title: t('edit') })}>
|
||||||
<PressableOpacity style={styles.serverActive} onPress={setActive}>
|
<PressableOpacity style={styles.serverActive} onPress={setActive}>
|
||||||
{activeServerId === server.id ? (
|
{activeServerId === server.id ? (
|
||||||
<Icon name="checkbox-marked-circle" size={30} color={colors.accent} />
|
<Icon name="checkbox-marked-circle" size={30} color={colors.accent} />
|
||||||
@ -219,7 +220,7 @@ const SettingsContent = withSuspenseMemo(() => {
|
|||||||
<Button
|
<Button
|
||||||
style={styles.button}
|
style={styles.button}
|
||||||
title={t('servers.actions.add')}
|
title={t('servers.actions.add')}
|
||||||
onPress={() => navigation.navigate('server')}
|
onPress={() => navigation.navigate('server', { title: t('servers.actions.add') })}
|
||||||
buttonStyle="hollow"
|
buttonStyle="hollow"
|
||||||
/>
|
/>
|
||||||
<Header style={styles.header}>{t('network.name')}</Header>
|
<Header style={styles.header}>{t('network.name')}</Header>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user