From 200a3e4741d47274cdd4fca38363b8399afbd230 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Sat, 18 Dec 2021 23:44:08 +0100 Subject: [PATCH] Fix Android titles --- src/Screens.tsx | 2 +- src/screens/Compose.tsx | 29 ++++++++---------------- src/screens/Compose/DraftsList.tsx | 16 ++++--------- src/screens/Compose/EditAttachment.tsx | 2 +- src/screens/Tabs/Local.tsx | 2 +- src/screens/Tabs/Me.tsx | 23 ++++++++----------- src/screens/Tabs/Me/Profile.tsx | 8 +++---- src/screens/Tabs/Me/Root/Collections.tsx | 2 +- src/screens/Tabs/Notifications.tsx | 2 +- src/screens/Tabs/Shared/Root.tsx | 25 +++++++++----------- 10 files changed, 44 insertions(+), 67 deletions(-) diff --git a/src/Screens.tsx b/src/Screens.tsx index 392bc8d8..229eff2e 100644 --- a/src/Screens.tsx +++ b/src/Screens.tsx @@ -187,7 +187,7 @@ const Screens: React.FC = ({ localCorrupt }) => { headerLeft: () => ( navigation.goBack()} /> ), - headerTitle: t('screenAnnouncements:heading') + title: t('screenAnnouncements:heading') })} /> > = ({ name='Screen-Compose-Root' component={ComposeRoot} options={{ - ...Platform.select({ - ios: { - headerTitle: headerContent, - headerTitleStyle: { - fontWeight: - totalTextCount > maxTootChars - ? StyleConstants.Font.Weight.Bold - : StyleConstants.Font.Weight.Normal, - fontSize: StyleConstants.Font.Size.M - }, - headerTintColor: - totalTextCount > maxTootChars - ? theme.red - : theme.secondary - }, - android: { - headerCenter: () => - } - }), + title: headerContent, + titleStyle: { + fontWeight: + totalTextCount > maxTootChars + ? StyleConstants.Font.Weight.Bold + : StyleConstants.Font.Weight.Normal, + fontSize: StyleConstants.Font.Size.M + }, + headerTintColor: + totalTextCount > maxTootChars ? theme.red : theme.secondary, headerLeft, headerRight }} diff --git a/src/screens/Compose/DraftsList.tsx b/src/screens/Compose/DraftsList.tsx index ff0adb61..642bc41d 100644 --- a/src/screens/Compose/DraftsList.tsx +++ b/src/screens/Compose/DraftsList.tsx @@ -1,16 +1,15 @@ -import { HeaderCenter, HeaderLeft } from '@components/Header' +import { HeaderLeft } from '@components/Header' import { createNativeStackNavigator } from '@react-navigation/native-stack' import { ScreenComposeStackScreenProps } from '@utils/navigation/navigators' import React, { useCallback } from 'react' import { useTranslation } from 'react-i18next' -import { Platform } from 'react-native' import ComposeDraftsListRoot from './DraftsList/Root' const Stack = createNativeStackNavigator() -const ComposeDraftsList: React.FC> = ({ +const ComposeDraftsList: React.FC< + ScreenComposeStackScreenProps<'Screen-Compose-DraftsList'> +> = ({ route: { params: { timestamp } }, @@ -40,12 +39,7 @@ const ComposeDraftsList: React.FC ( - - ) - }), + title: t('content.draftsList.header.title'), headerShadowVisible: false }} /> diff --git a/src/screens/Compose/EditAttachment.tsx b/src/screens/Compose/EditAttachment.tsx index 66f8813b..70a27500 100644 --- a/src/screens/Compose/EditAttachment.tsx +++ b/src/screens/Compose/EditAttachment.tsx @@ -49,7 +49,7 @@ const ComposeEditAttachment: React.FC , - headerTitle: t('content.editAttachment.header.title') + title: t('content.editAttachment.header.title') }} /> diff --git a/src/screens/Tabs/Local.tsx b/src/screens/Tabs/Local.tsx index 37c48779..21afed29 100644 --- a/src/screens/Tabs/Local.tsx +++ b/src/screens/Tabs/Local.tsx @@ -21,7 +21,7 @@ const TabLocal = React.memo( const screenOptionsRoot = useMemo( () => ({ - headerTitle: t('tabs.local.name'), + title: t('tabs.local.name'), ...(Platform.OS === 'android' && { headerCenter: () => }), diff --git a/src/screens/Tabs/Me.tsx b/src/screens/Tabs/Me.tsx index 400809bd..17e1feb1 100644 --- a/src/screens/Tabs/Me.tsx +++ b/src/screens/Tabs/Me.tsx @@ -38,7 +38,7 @@ const TabMe = React.memo( name='Tab-Me-Bookmarks' component={TabMeBookmarks} options={({ navigation }: any) => ({ - headerTitle: t('me.stacks.bookmarks.name'), + title: t('me.stacks.bookmarks.name'), ...(Platform.OS === 'android' && { headerCenter: () => ( @@ -51,7 +51,7 @@ const TabMe = React.memo( name='Tab-Me-Conversations' component={TabMeConversations} options={({ navigation }: any) => ({ - headerTitle: t('me.stacks.conversations.name'), + title: t('me.stacks.conversations.name'), ...(Platform.OS === 'android' && { headerCenter: () => ( @@ -64,7 +64,7 @@ const TabMe = React.memo( name='Tab-Me-Favourites' component={TabMeFavourites} options={({ navigation }: any) => ({ - headerTitle: t('me.stacks.favourites.name'), + title: t('me.stacks.favourites.name'), ...(Platform.OS === 'android' && { headerCenter: () => ( @@ -77,7 +77,7 @@ const TabMe = React.memo( name='Tab-Me-Lists' component={TabMeLists} options={({ navigation }: any) => ({ - headerTitle: t('me.stacks.lists.name'), + title: t('me.stacks.lists.name'), ...(Platform.OS === 'android' && { headerCenter: () => ( @@ -90,7 +90,7 @@ const TabMe = React.memo( name='Tab-Me-Lists-List' component={TabMeListsList} options={({ route, navigation }: any) => ({ - headerTitle: t('me.stacks.list.name', { list: route.params.title }), + title: t('me.stacks.list.name', { list: route.params.title }), ...(Platform.OS === 'android' && { headerCenter: () => ( ({ presentation: 'modal', headerShown: true, - headerTitle: t('me.stacks.push.name'), + title: t('me.stacks.push.name'), ...(Platform.OS === 'android' && { headerCenter: () => ( @@ -135,12 +135,7 @@ const TabMe = React.memo( name='Tab-Me-Settings' component={TabMeSettings} options={({ navigation }: any) => ({ - headerTitle: t('me.stacks.settings.name'), - ...(Platform.OS === 'android' && { - headerCenter: () => ( - - ) - }), + title: t('me.stacks.settings.name'), headerLeft: () => navigation.pop(1)} /> })} /> @@ -148,7 +143,7 @@ const TabMe = React.memo( name='Tab-Me-Settings-Fontsize' component={TabMeSettingsFontsize} options={({ navigation }: any) => ({ - headerTitle: t('me.stacks.fontSize.name'), + title: t('me.stacks.fontSize.name'), ...(Platform.OS === 'android' && { headerCenter: () => ( @@ -163,7 +158,7 @@ const TabMe = React.memo( options={({ navigation }) => ({ presentation: 'modal', headerShown: true, - headerTitle: t('me.stacks.switch.name'), + title: t('me.stacks.switch.name'), ...(Platform.OS === 'android' && { headerCenter: () => ( diff --git a/src/screens/Tabs/Me/Profile.tsx b/src/screens/Tabs/Me/Profile.tsx index a3a41221..1e5ca7d7 100644 --- a/src/screens/Tabs/Me/Profile.tsx +++ b/src/screens/Tabs/Me/Profile.tsx @@ -31,7 +31,7 @@ const TabMeProfile: React.FC> = ({ ( @@ -56,7 +56,7 @@ const TabMeProfile: React.FC> = ({ ( @@ -75,7 +75,7 @@ const TabMeProfile: React.FC> = ({ ( @@ -94,7 +94,7 @@ const TabMeProfile: React.FC> = ({ ( diff --git a/src/screens/Tabs/Me/Root/Collections.tsx b/src/screens/Tabs/Me/Root/Collections.tsx index 28a4da7d..bd75030f 100644 --- a/src/screens/Tabs/Me/Root/Collections.tsx +++ b/src/screens/Tabs/Me/Root/Collections.tsx @@ -109,7 +109,7 @@ const Collections: React.FC = () => { iconBack='ChevronRight' title={t('me.stacks.push.name')} content={ - instancePush + instancePush.global.value ? t('me.root.push.content.enabled') : t('me.root.push.content.disabled') } diff --git a/src/screens/Tabs/Notifications.tsx b/src/screens/Tabs/Notifications.tsx index 0e9bb4d3..a6746b4a 100644 --- a/src/screens/Tabs/Notifications.tsx +++ b/src/screens/Tabs/Notifications.tsx @@ -19,7 +19,7 @@ const TabNotifications = React.memo( const screenOptionsRoot = useMemo( () => ({ - headerTitle: t('tabs.notifications.name'), + title: t('tabs.notifications.name'), ...(Platform.OS === 'android' && { headerCenter: () => ( diff --git a/src/screens/Tabs/Shared/Root.tsx b/src/screens/Tabs/Shared/Root.tsx index 18738745..563049bb 100644 --- a/src/screens/Tabs/Shared/Root.tsx +++ b/src/screens/Tabs/Shared/Root.tsx @@ -41,7 +41,7 @@ const TabSharedRoot = ({ headerStyle: { backgroundColor: `rgba(255, 255, 255, 0)` }, - headerTitle: '', + title: '', headerLeft: () => ( navigation.goBack()} background /> ) @@ -91,14 +91,7 @@ const TabSharedRoot = ({ options={({ route }: TabSharedStackScreenProps<'Tab-Shared-Hashtag'>) => ({ - headerTitle: `#${decodeURIComponent(route.params.hashtag)}`, - ...(Platform.OS === 'android' && { - headerCenter: () => ( - - ) - }) + title: `#${decodeURIComponent(route.params.hashtag)}` })} /> @@ -109,6 +102,13 @@ const TabSharedRoot = ({ options={({ navigation }: TabSharedStackScreenProps<'Tab-Shared-Search'>) => ({ + ...(Platform.OS === 'ios' + ? { + headerLeft: () => ( + navigation.goBack()} /> + ) + } + : { headerLeft: () => null }), headerTitle: () => { const onChangeText = debounce( (text: string) => navigation.setParams({ text }), @@ -164,10 +164,7 @@ const TabSharedRoot = ({ name='Tab-Shared-Toot' component={TabSharedToot} options={{ - headerTitle: t('shared.toot.name'), - ...(Platform.OS === 'android' && { - headerCenter: () => - }) + title: t('shared.toot.name') }} /> @@ -180,7 +177,7 @@ const TabSharedRoot = ({ params: { reference, type, count } } }: TabSharedStackScreenProps<'Tab-Shared-Users'>) => ({ - headerTitle: t(`shared.users.${reference}.${type}`, { count }), + title: t(`shared.users.${reference}.${type}`, { count }), ...(Platform.OS === 'android' && { headerCenter: () => (