-
Notifications
You must be signed in to change notification settings - Fork 194
/
Copy pathSharedElements.js
180 lines (170 loc) · 4.69 KB
/
SharedElements.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import React from 'react';
import { View, Text, Button, StyleSheet } from 'react-native';
import { Transition, createFluidNavigator } from '../lib';
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
padding: 20,
},
screen1: {
flex: 1,
flexDirection: 'row',
alignItems: 'flex-start',
justifyContent: 'center',
alignSelf: 'stretch',
padding: 20,
},
screen2: {
flex: 1,
flexDirection: 'row',
alignItems: 'flex-end',
alignSelf: 'stretch',
justifyContent: 'center',
padding: 20,
},
screen3: {
flex: 1,
flexDirection: 'row',
alignItems: 'center',
alignSelf: 'stretch',
justifyContent: 'center',
padding: 20,
},
buttons: {
flexDirection: 'row',
padding: 20,
},
});
const Circle = ({ background, size }) => (
<View
style={{
justifyContent: 'center',
alignItems: 'center',
backgroundColor: background,
width: size,
height: size,
borderRadius: size / 2,
}}
/>
);
const Shape = ({ background, size, borderRadius }) => (
<View
style={{
backgroundColor: background || '#EE0000',
width: size,
height: size,
borderRadius: borderRadius || 0,
}}
/>
);
const Screen1 = (props) => (
<View style={styles.container}>
<Transition appear="flip">
<Text>1.Screen</Text>
</Transition>
<View style={styles.screen1}>
<Transition shared="circle">
<Shape size={50} borderRadius={4} background="#EE0000" />
</Transition>
</View>
<View style={{ flexDirection: 'row' }}>
<Transition appear="horizontal" delay>
<Circle background="#55AA55" size={20} />
</Transition>
<View style={{ width: 20 }} />
<Transition appear="horizontal" delay>
<Circle background="#55AA55" size={20} />
</Transition>
<View style={{ width: 20 }} />
<Transition appear="horizontal" delay>
<Circle background="#55AA55" size={20} />
</Transition>
</View>
<Transition appear="horizontal">
<View style={styles.buttons}>
<Button title="Next" onPress={() => props.navigation.navigate('screen2')} />
</View>
</Transition>
</View>
);
const Screen2 = (props) => (
<View style={styles.container}>
<Transition appear="flip">
<Text>2.Screen</Text>
</Transition>
<View style={styles.screen2}>
<Transition shared="circle">
<Shape size={50} borderRadius={25} background="#EE0000" />
</Transition>
</View>
<View style={{ flexDirection: 'row' }}>
<Transition appear="horizontal" delay>
<Circle background="#55AA55" size={20} />
</Transition>
<View style={{ width: 20 }} />
<Transition appear="horizontal" delay>
<Circle background="#55AA55" size={20} />
</Transition>
<View style={{ width: 20 }} />
<Transition appear="horizontal" delay>
<Circle background="#55AA55" size={20} />
</Transition>
</View>
<Transition appear="horizontal">
<View style={styles.buttons}>
<Button title="Back" onPress={() => props.navigation.goBack()} />
<View style={{ width: 20 }} />
<Button title="Next" onPress={() => props.navigation.navigate('screen3')} />
</View>
</Transition>
</View>
);
const Screen3 = (props) => (
<View style={styles.container}>
<Transition appear="flip">
<Text>3.Screen</Text>
</Transition>
<View style={styles.screen3}>
<Transition shared="circle">
<Shape size={140} borderRadius={70} background="#EE0000" />
</Transition>
</View>
<View style={{ flexDirection: 'row' }}>
<Transition appear="horizontal" delay>
<Circle background="#55AA55" size={20} />
</Transition>
<View style={{ width: 20 }} />
<Transition appear="horizontal" delay>
<Circle background="#55AA55" size={20} />
</Transition>
<View style={{ width: 20 }} />
<Transition appear="horizontal" delay>
<Circle background="#55AA55" size={20} />
</Transition>
</View>
<Transition appear="horizontal">
<View style={styles.buttons}>
<Button title="Back" onPress={() => props.navigation.goBack()} />
</View>
</Transition>
</View>
);
const Navigator = createFluidNavigator({
screen1: { screen: Screen1 },
screen2: { screen: Screen2 },
screen3: { screen: Screen3 },
}, {
defaultNavigationOptions: { gesturesEnabled: false },
});
class SharedElements extends React.Component {
static router = Navigator.router;
render() {
const { navigation } = this.props;
return (
<Navigator navigation={navigation} />
);
}
}
export default SharedElements;