Align back button

This commit is contained in:
Zhiyuan Zheng 2020-12-13 23:38:37 +01:00
parent c1076b8e94
commit 991741488d
No known key found for this signature in database
GPG Key ID: 078A93AB607D85E0
7 changed files with 100 additions and 40 deletions

View File

@ -118,7 +118,7 @@ export const Index: React.FC = () => {
} }
})} })}
> >
{() => <></>} {() => null}
</Tab.Screen> </Tab.Screen>
<Tab.Screen <Tab.Screen
name='Screen-Notifications' name='Screen-Notifications'

View File

@ -15,14 +15,23 @@ const HeaderLeft: React.FC<Props> = ({ onPress, text, icon }) => {
const { theme } = useTheme() const { theme } = useTheme()
return ( return (
<Pressable onPress={onPress} style={styles.base}> <Pressable
onPress={onPress}
style={[
styles.base,
{
backgroundColor: theme.backgroundGradientStart,
...(icon && { height: 44, width: 44 })
}
]}
>
{text ? ( {text ? (
<Text style={[styles.text, { color: theme.primary }]}>{text}</Text> <Text style={[styles.text, { color: theme.primary }]}>{text}</Text>
) : ( ) : (
<Feather <Feather
name={icon || 'chevron-left'} name={icon || 'chevron-left'}
color={theme.primary} color={theme.primary}
size={StyleConstants.Font.Size.L} size={StyleConstants.Spacing.L}
/> />
)} )}
</Pressable> </Pressable>
@ -31,7 +40,10 @@ const HeaderLeft: React.FC<Props> = ({ onPress, text, icon }) => {
const styles = StyleSheet.create({ const styles = StyleSheet.create({
base: { base: {
paddingRight: StyleConstants.Spacing.S flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
borderRadius: 100
}, },
text: { text: {
fontSize: StyleConstants.Font.Size.M fontSize: StyleConstants.Font.Size.M

View File

@ -29,7 +29,16 @@ const HeaderRight: React.FC<PropsText | PropsIcon> = ({
const { theme } = useTheme() const { theme } = useTheme()
return ( return (
<Pressable {...(!disabled && { onPress })} style={styles.base}> <Pressable
{...(!disabled && { onPress })}
style={[
styles.base,
{
backgroundColor: theme.backgroundGradientStart,
...(icon && { height: 44, width: 44 })
}
]}
>
{text && ( {text && (
<Text <Text
style={[ style={[
@ -44,7 +53,7 @@ const HeaderRight: React.FC<PropsText | PropsIcon> = ({
<Feather <Feather
name={icon} name={icon}
color={disabled ? theme.secondary : theme.primary} color={disabled ? theme.secondary : theme.primary}
size={StyleConstants.Font.Size.L} size={StyleConstants.Spacing.L}
/> />
)} )}
</Pressable> </Pressable>
@ -53,7 +62,10 @@ const HeaderRight: React.FC<PropsText | PropsIcon> = ({
const styles = StyleSheet.create({ const styles = StyleSheet.create({
base: { base: {
paddingLeft: StyleConstants.Spacing.S flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
borderRadius: 100
}, },
text: { text: {
fontSize: StyleConstants.Font.Size.M fontSize: StyleConstants.Font.Size.M

View File

@ -15,6 +15,7 @@ import {
import { useTheme } from '@utils/styles/ThemeManager' import { useTheme } from '@utils/styles/ThemeManager'
import { useNavigation } from '@react-navigation/native' import { useNavigation } from '@react-navigation/native'
import getCurrentTab from '@utils/getCurrentTab' import getCurrentTab from '@utils/getCurrentTab'
import { HeaderRight } from './Header'
const Stack = createNativeStackNavigator() const Stack = createNativeStackNavigator()
@ -112,12 +113,7 @@ const Timelines: React.FC<Props> = ({ name, content }) => {
</View> </View>
), ),
headerRight: () => ( headerRight: () => (
<Feather <HeaderRight icon='search' onPress={onPressSearch} />
name='search'
size={24}
color={theme.secondary}
onPress={onPressSearch}
/>
) )
}) })
}} }}

View File

@ -41,9 +41,7 @@ const TimelineCard: React.FC<Props> = ({ card }) => {
> >
{card.description} {card.description}
</Text> </Text>
) : ( ) : null}
<></>
)}
<Text numberOfLines={1} style={{ color: theme.secondary }}> <Text numberOfLines={1} style={{ color: theme.secondary }}>
{card.url} {card.url}
</Text> </Text>

View File

@ -1,7 +1,6 @@
import React from 'react' import React from 'react'
import { createNativeStackNavigator } from 'react-native-screens/native-stack' import { createNativeStackNavigator } from 'react-native-screens/native-stack'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { useSelector } from 'react-redux'
import ScreenMeRoot from '@screens/Me/Root' import ScreenMeRoot from '@screens/Me/Root'
import ScreenMeConversations from '@screens/Me/Cconversations' import ScreenMeConversations from '@screens/Me/Cconversations'
@ -12,71 +11,102 @@ import sharedScreens from '@screens/Shared/sharedScreens'
import ScreenMeListsList from '@screens/Me/Root/Lists/List' import ScreenMeListsList from '@screens/Me/Root/Lists/List'
import ScreenMeSettings from '@screens/Me/Settings' import ScreenMeSettings from '@screens/Me/Settings'
import { RootState } from 'src/store' import { HeaderLeft } from '@root/components/Header'
import { useNavigation } from '@react-navigation/native'
const Stack = createNativeStackNavigator() const Stack = createNativeStackNavigator()
const ScreenMe: React.FC = () => { const ScreenMe: React.FC = () => {
const navigation = useNavigation()
const { t } = useTranslation() const { t } = useTranslation()
const localRegistered = useSelector(
(state: RootState) => state.instances.local.url
)
return ( return (
<Stack.Navigator> <Stack.Navigator>
<Stack.Screen <Stack.Screen
name='Screen-Me-Root' name='Screen-Me-Root'
component={ScreenMeRoot} component={ScreenMeRoot}
options={ options={{
// localRegistered ? headerTranslucent: true,
{ headerStyle: { backgroundColor: 'rgba(255, 255, 255, 0)' },
headerTranslucent: true, headerCenter: () => null
headerStyle: { backgroundColor: 'rgba(255, 255, 255, 0)' }, }}
headerCenter: () => <></>
}
// : { headerTitle: t('meRoot:heading') }
}
/> />
<Stack.Screen <Stack.Screen
name='Screen-Me-Conversations' name='Screen-Me-Conversations'
component={ScreenMeConversations} component={ScreenMeConversations}
options={{ options={{
headerTitle: t('meConversations:heading') headerTitle: t('meConversations:heading'),
headerLeft: () => (
<HeaderLeft
icon='chevron-left'
onPress={() => navigation.goBack()}
/>
)
}} }}
/> />
<Stack.Screen <Stack.Screen
name='Screen-Me-Bookmarks' name='Screen-Me-Bookmarks'
component={ScreenMeBookmarks} component={ScreenMeBookmarks}
options={{ options={{
headerTitle: t('meBookmarks:heading') headerTitle: t('meBookmarks:heading'),
headerLeft: () => (
<HeaderLeft
icon='chevron-left'
onPress={() => navigation.goBack()}
/>
)
}} }}
/> />
<Stack.Screen <Stack.Screen
name='Screen-Me-Favourites' name='Screen-Me-Favourites'
component={ScreenMeFavourites} component={ScreenMeFavourites}
options={{ options={{
headerTitle: t('meFavourites:heading') headerTitle: t('meFavourites:heading'),
headerLeft: () => (
<HeaderLeft
icon='chevron-left'
onPress={() => navigation.goBack()}
/>
)
}} }}
/> />
<Stack.Screen <Stack.Screen
name='Screen-Me-Lists' name='Screen-Me-Lists'
component={ScreenMeLists} component={ScreenMeLists}
options={{ options={{
headerTitle: t('meLists:heading') headerTitle: t('meLists:heading'),
headerLeft: () => (
<HeaderLeft
icon='chevron-left'
onPress={() => navigation.goBack()}
/>
)
}} }}
/> />
<Stack.Screen <Stack.Screen
name='Screen-Me-Lists-List' name='Screen-Me-Lists-List'
component={ScreenMeListsList} component={ScreenMeListsList}
options={({ route }: any) => ({ options={({ route }: any) => ({
headerTitle: t('meListsList:heading', { list: route.params.title }) headerTitle: t('meListsList:heading', { list: route.params.title }),
headerLeft: () => (
<HeaderLeft
icon='chevron-left'
onPress={() => navigation.goBack()}
/>
)
})} })}
/> />
<Stack.Screen <Stack.Screen
name='Screen-Me-Settings' name='Screen-Me-Settings'
component={ScreenMeSettings} component={ScreenMeSettings}
options={{ options={{
headerTitle: t('meSettings:heading') headerTitle: t('meSettings:heading'),
headerLeft: () => (
<HeaderLeft
icon='chevron-left'
onPress={() => navigation.goBack()}
/>
)
}} }}
/> />

View File

@ -8,8 +8,11 @@ import Compose from '@screens/Shared/Compose'
import ComposeEditAttachment from '@screens/Shared/Compose/EditAttachment' import ComposeEditAttachment from '@screens/Shared/Compose/EditAttachment'
import ScreenSharedSearch from '@screens/Shared/Search' import ScreenSharedSearch from '@screens/Shared/Search'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { useNavigation } from '@react-navigation/native'
import { HeaderLeft } from '@root/components/Header'
const sharedScreens = (Stack: any) => { const sharedScreens = (Stack: any) => {
const navigation = useNavigation()
const { t } = useTranslation() const { t } = useTranslation()
return [ return [
@ -20,7 +23,10 @@ const sharedScreens = (Stack: any) => {
options={{ options={{
headerTranslucent: true, headerTranslucent: true,
headerStyle: { backgroundColor: 'rgba(255, 255, 255, 0)' }, headerStyle: { backgroundColor: 'rgba(255, 255, 255, 0)' },
headerCenter: () => <></> headerCenter: () => null,
headerLeft: () => (
<HeaderLeft icon='chevron-left' onPress={() => navigation.goBack()} />
)
}} }}
/>, />,
<Stack.Screen <Stack.Screen
@ -28,7 +34,10 @@ const sharedScreens = (Stack: any) => {
name='Screen-Shared-Hashtag' name='Screen-Shared-Hashtag'
component={ScreenSharedHashtag} component={ScreenSharedHashtag}
options={({ route }: any) => ({ options={({ route }: any) => ({
title: `#${decodeURIComponent(route.params.hashtag)}` title: `#${decodeURIComponent(route.params.hashtag)}`,
headerLeft: () => (
<HeaderLeft icon='chevron-left' onPress={() => navigation.goBack()} />
)
})} })}
/>, />,
<Stack.Screen <Stack.Screen
@ -36,7 +45,10 @@ const sharedScreens = (Stack: any) => {
name='Screen-Shared-Toot' name='Screen-Shared-Toot'
component={ScreenSharedToot} component={ScreenSharedToot}
options={() => ({ options={() => ({
title: t('sharedToot:heading') title: t('sharedToot:heading'),
headerLeft: () => (
<HeaderLeft icon='chevron-left' onPress={() => navigation.goBack()} />
)
})} })}
/>, />,
<Stack.Screen <Stack.Screen
@ -60,7 +72,7 @@ const sharedScreens = (Stack: any) => {
name='Screen-Shared-Compose-EditAttachment' name='Screen-Shared-Compose-EditAttachment'
component={ComposeEditAttachment} component={ComposeEditAttachment}
options={{ options={{
stackPresentation: 'modal', stackPresentation: 'modal'
}} }}
/>, />,
<Stack.Screen <Stack.Screen