@@ -6,75 +6,71 @@ import {
6
6
ScrollView ,
7
7
TouchableOpacity ,
8
8
} from 'react-native' ;
9
- import { Navigator } from 'react-native-deprecated-custom-components'
9
+ import { StackNavigator } from 'react-navigation' ;
10
10
import SimpleExample from './SimpleExample' ;
11
11
import ScrollableTabsExample from './ScrollableTabsExample' ;
12
12
import OverlayExample from './OverlayExample' ;
13
13
import FacebookExample from './FacebookExample' ;
14
14
import DynamicExample from './DynamicExample' ;
15
15
16
- export default React . createClass ( {
17
- render ( ) {
18
- return < Navigator
19
- style = { { flex : 1 , } }
20
- initialRoute = { { } }
21
- renderScene = { this . renderScene }
22
- /> ;
16
+ const HomeScreen = React . createClass ( {
17
+ navigationOptions : {
18
+ title : 'Welcome' ,
23
19
} ,
24
20
25
- renderScene ( route , nav ) {
26
- switch ( route . id ) {
27
- case 'simple' :
28
- return < SimpleExample /> ;
29
- case 'scrollable' :
30
- return < ScrollableTabsExample /> ;
31
- case 'overlay' :
32
- return < OverlayExample /> ;
33
- case 'facebook' :
34
- return < FacebookExample /> ;
35
- case 'dynamic' :
36
- return < DynamicExample /> ;
37
- default :
38
- return < View style = { styles . container } >
39
- < TouchableOpacity
40
- style = { styles . button }
41
- onPress = { ( ) => nav . push ( { id : 'simple' , } ) }
42
- >
43
- < Text > Simple example</ Text >
44
- </ TouchableOpacity >
21
+ render ( ) {
22
+ const { navigate } = this . props . navigation ;
23
+
24
+ return < View style = { styles . container } >
25
+ < TouchableOpacity
26
+ style = { styles . button }
27
+ onPress = { ( ) => navigate ( 'Simple' ) }
28
+ >
29
+ < Text > Simple example</ Text >
30
+ </ TouchableOpacity >
45
31
46
- < TouchableOpacity
47
- style = { styles . button }
48
- onPress = { ( ) => nav . push ( { id : 'scrollable' , } ) }
49
- >
50
- < Text > Scrollable tabs example</ Text >
51
- </ TouchableOpacity >
32
+ < TouchableOpacity
33
+ style = { styles . button }
34
+ onPress = { ( ) => navigate ( 'Scrollable' ) }
35
+ >
36
+ < Text > Scrollable tabs example</ Text >
37
+ </ TouchableOpacity >
52
38
53
- < TouchableOpacity
54
- style = { styles . button }
55
- onPress = { ( ) => nav . push ( { id : 'overlay' , } ) }
56
- >
57
- < Text > Overlay example</ Text >
58
- </ TouchableOpacity >
39
+ < TouchableOpacity
40
+ style = { styles . button }
41
+ onPress = { ( ) => navigate ( 'Overlay' ) }
42
+ >
43
+ < Text > Overlay example</ Text >
44
+ </ TouchableOpacity >
59
45
60
- < TouchableOpacity
61
- style = { styles . button }
62
- onPress = { ( ) => nav . push ( { id : 'facebook' , } ) }
63
- >
64
- < Text > Facebook tabs example</ Text >
65
- </ TouchableOpacity >
46
+ < TouchableOpacity
47
+ style = { styles . button }
48
+ onPress = { ( ) => navigate ( 'Facebook' ) }
49
+ >
50
+ < Text > Facebook tabs example</ Text >
51
+ </ TouchableOpacity >
66
52
67
- < TouchableOpacity
68
- style = { styles . button }
69
- onPress = { ( ) => nav . push ( { id : 'dynamic' , } ) }
70
- >
71
- < Text > Dynamic tabs example</ Text >
72
- </ TouchableOpacity >
73
- </ View > ;
74
- }
53
+ < TouchableOpacity
54
+ style = { styles . button }
55
+ onPress = { ( ) => navigate ( 'Dynamic' ) }
56
+ >
57
+ < Text > Dynamic tabs example</ Text >
58
+ </ TouchableOpacity >
59
+ </ View > ;
75
60
} ,
76
61
} ) ;
77
62
63
+ const App = StackNavigator ( {
64
+ Home : { screen : HomeScreen } ,
65
+ Simple : { screen : SimpleExample } ,
66
+ Scrollable : { screen : ScrollableTabsExample } ,
67
+ Overlay : { screen : OverlayExample } ,
68
+ Facebook : { screen : FacebookExample } ,
69
+ Dynamic : { screen : DynamicExample } ,
70
+ } ) ;
71
+
72
+ export default App ;
73
+
78
74
const styles = StyleSheet . create ( {
79
75
container : {
80
76
flex : 1 ,
0 commit comments