-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
executable file
·91 lines (88 loc) · 2.32 KB
/
App.js
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { NavigationContainer } from '@react-navigation/native'
import React from 'react'
import { createSharedElementStackNavigator } from 'react-navigation-shared-element'
import Add from './src/screens/Add/Add'
import Detail from './src/screens/Detail/Detail'
import Edit from './src/screens/Edit/Edit'
import Home from './src/screens/Home/Home'
const App = () => {
return (
<NavigationContainer>
<MyStack />
</NavigationContainer>
)
}
export default App
const Stack = createSharedElementStackNavigator()
const MyStack = () => {
return (
<Stack.Navigator
screenOptions={{
gestureEnabled: false,
transitionSpec: {
open: { animation: 'timing', config: { duration: 400 } },
close: { animation: 'timing', config: { duration: 400 } }
},
cardStyleInterpolator: ({ current: { progress } }) => {
return {
cardStyle: {
opacity: progress
}
}
},
cardStyle: { backgroundColor: '#F9F9F9' }
}}
headerMode='none'
initialRouteName='Home'>
<Stack.Screen
name='Home'
component={Home}
sharedElements={(route, otherRoute, showing) => {
const { title } = route.params
if (otherRoute.name === 'Detail' && showing) {
return [ { id: `item.${title}.view` }, { id: `item.${title}.title` } ]
}
}}
/>
<Stack.Screen
name='Detail'
component={Detail}
sharedElements={(route, otherRoute, showing) => {
const { title } = route.params
if (otherRoute.name === 'Edit' && showing) {
return [
{ id: `item.${title}.view` },
{ id: `item.${title}.title` },
{ id: `item.${title}.content` },
{ id: `item.left.note` },
{ id: `item.fab.note` }
]
} else {
return [ { id: `item.${title}.view` }, { id: `item.${title}.title` } ]
}
}}
/>
<Stack.Screen
name='Edit'
component={Edit}
sharedElements={(route, otherRoute, showing) => {
const { title } = route.params
return [
{ id: `item.${title}.view` },
{ id: `item.${title}.title` },
{ id: `item.${title}.content` },
{ id: `item.left.note` },
{ id: `item.fab.note` }
]
}}
/>
<Stack.Screen
name='Add'
component={Add}
sharedElements={(route, otherRoute, showing) => {
return [ { id: `item.fab.note`, animation: 'fade' } ]
}}
/>
</Stack.Navigator>
)
}