1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Basic typing for react-navigation

This commit is contained in:
Zhiyuan Zheng
2021-01-07 22:18:14 +01:00
parent 4b99813bb7
commit 4a6229514f
17 changed files with 229 additions and 151 deletions

View File

@ -11,10 +11,12 @@ import { createNativeStackNavigator } from 'react-native-screens/native-stack'
import { TabView } from 'react-native-tab-view'
import { useSelector } from 'react-redux'
const Stack = createNativeStackNavigator()
const Stack = createNativeStackNavigator<
Nav.LocalStackParamList | Nav.RemoteStackParamList
>()
export interface Props {
name: 'Local' | 'Public'
name: 'Screen-Local-Root' | 'Screen-Public-Root'
content: { title: string; page: App.Pages }[]
}
@ -68,9 +70,11 @@ const Timelines: React.FC<Props> = ({ name, content }) => {
return (
<Stack.Navigator screenOptions={{ headerHideShadow: true }}>
<Stack.Screen
name={`Screen-${name}-Root`}
// @ts-ignore
name={name}
component={screenComponent}
options={{
headerTitle: name === 'Public' ? publicDomain : '',
headerTitle: name === 'Screen-Public-Root' ? publicDomain : '',
...(localActiveIndex !== null && {
headerCenter: () => (
<View style={styles.segmentsContainer}>
@ -89,9 +93,7 @@ const Timelines: React.FC<Props> = ({ name, content }) => {
)
})
}}
>
{screenComponent}
</Stack.Screen>
/>
{sharedScreens(Stack)}
</Stack.Navigator>