-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrouter.tsx
More file actions
62 lines (53 loc) · 1.73 KB
/
Copy pathrouter.tsx
File metadata and controls
62 lines (53 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import DependencyEnum from 'shared/domain/entities/dependencyEnum'
import { SessionStorePort } from 'auth/data/ports/sessionStore.port'
import LoginFactory from 'auth/application/login.factory'
import HomeFactory from 'home/application/home.factory'
import { NavigationContainer, Route } from '@react-navigation/native'
import { createStackNavigator } from '@react-navigation/stack'
import { createURL } from 'expo-linking'
import { observer } from 'mobx-react-lite'
import { useCallback } from 'react'
import { Text } from 'react-native'
import { container } from 'tsyringe'
const Router: React.FC = observer(() => {
const formatter = useCallback(
(
_options: Record<string, unknown> | undefined,
route: Route<string, object | undefined> | undefined
) => `${route?.name} - SkateSpot - Onde os picos DIY ganham força!`,
[]
)
const linking = {
prefixes: [createURL('/'), 'skate-spot://'],
config: {
screens: {
Home: '/',
Login: '/login',
},
},
}
const Stack = createStackNavigator()
const sessionStore = container.resolve<SessionStorePort>(
DependencyEnum.SESSION_STORE_ADAPTER
)
return (
<NavigationContainer
linking={linking}
fallback={<Text>Loading…</Text>}
documentTitle={{ formatter }}
>
<Stack.Navigator initialRouteName="Login">
{sessionStore.get() ? (
<Stack.Screen name="Home" options={{ headerShown: false }}>
{() => <HomeFactory />}
</Stack.Screen>
) : (
<Stack.Screen name="Login" options={{ headerShown: false }}>
{() => <LoginFactory />}
</Stack.Screen>
)}
</Stack.Navigator>
</NavigationContainer>
)
})
export default Router