Browse Source

changed for the new native API

Ran Greenberg 7 years ago
parent
commit
6d63cbd3e3

+ 22
- 8
example/src/app.js View File

11
   let tabs = [
11
   let tabs = [
12
     {
12
     {
13
       label: 'One',
13
       label: 'One',
14
-      screen: 'example.FirstTabScreen',
14
+      screen: 'com.example.FirstTabScreen',
15
       icon: require('../img/one.png'),
15
       icon: require('../img/one.png'),
16
       selectedIcon: require('../img/one_selected.png'),
16
       selectedIcon: require('../img/one_selected.png'),
17
-      title: 'Screen One'
17
+      title: 'Screen One',
18
+      navigatorStyle: {
19
+          tabBarHidden: true
20
+      }
18
     },
21
     },
19
     {
22
     {
20
       label: 'Two',
23
       label: 'Two',
21
-      screen: 'example.SecondTabScreen',
24
+      screen: 'com.example.SecondTabScreen',
22
       icon: require('../img/two.png'),
25
       icon: require('../img/two.png'),
23
       selectedIcon: require('../img/two_selected.png'),
26
       selectedIcon: require('../img/two_selected.png'),
24
       title: 'Screen Two',
27
       title: 'Screen Two',
37
   }
40
   }
38
   return tabs;
41
   return tabs;
39
 };
42
 };
43
+
44
+import * as Commands from './../node_modules/react-native-navigation/src2/commands/valid-commands';
45
+//Navigation.startApp(Commands.singleScreenApp);
46
+//Navigation.startApp(Commands.tabBasedApp);
47
+//Navigation.startApp(Commands.singleWithSideMenu);
48
+//Navigation.startApp(Commands.singleWithRightSideMenu);
49
+//Navigation.startApp(Commands.singleWithBothMenus);
50
+//Navigation.startApp(Commands.tabBasedWithSideMenu);
51
+
40
 // this will start our app
52
 // this will start our app
41
 Navigation.startTabBasedApp({
53
 Navigation.startTabBasedApp({
42
   tabs: createTabs(),
54
   tabs: createTabs(),
43
   appStyle: {
55
   appStyle: {
44
     tabBarBackgroundColor: '#0f2362',
56
     tabBarBackgroundColor: '#0f2362',
45
     tabBarButtonColor: '#ffffff',
57
     tabBarButtonColor: '#ffffff',
46
-    tabBarSelectedButtonColor: '#63d7cc'
58
+    tabBarSelectedButtonColor: '#63d7cc',
47
   },
59
   },
48
   drawer: {
60
   drawer: {
49
     left: {
61
     left: {
50
-      screen: 'example.SideMenu'
62
+      screen: 'com.example.SideMenu'
51
     }
63
     }
52
   }
64
   }
53
 });
65
 });
54
 //Navigation.startSingleScreenApp({
66
 //Navigation.startSingleScreenApp({
55
 //  screen: {
67
 //  screen: {
56
-//    screen: 'example.FirstTabScreen',
68
+//    screen: 'com.example.FirstTabScreen',
57
 //    title: 'Navigation',
69
 //    title: 'Navigation',
58
 //    navigatorStyle: {
70
 //    navigatorStyle: {
59
 //      navBarBackgroundColor: '#4dbce9',
71
 //      navBarBackgroundColor: '#4dbce9',
60
 //      navBarTextColor: '#ffff00',
72
 //      navBarTextColor: '#ffff00',
61
 //      navBarSubtitleTextColor: '#ff0000',
73
 //      navBarSubtitleTextColor: '#ff0000',
62
 //      navBarButtonColor: '#ffffff',
74
 //      navBarButtonColor: '#ffffff',
63
-//      statusBarTextColorScheme: 'light'
75
+//      statusBarTextColorScheme: 'light',
76
+//      tabBarHidden: true
64
 //    }
77
 //    }
65
 //  },
78
 //  },
66
 //  drawer: {
79
 //  drawer: {
67
 //    left: {
80
 //    left: {
68
-//      screen: 'example.SideMenu'
81
+//      screen: 'com.example.SideMenu'
69
 //    }
82
 //    }
70
 //  }
83
 //  }
71
 //});
84
 //});
85
+

+ 9
- 9
example/src/screens/FirstTabScreen.js View File

40
   constructor(props) {
40
   constructor(props) {
41
     super(props);
41
     super(props);
42
     // if you want to listen on navigator events, set this up
42
     // if you want to listen on navigator events, set this up
43
-    this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
43
+    //this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
44
   }
44
   }
45
 
45
 
46
   onNavigatorEvent(event) {
46
   onNavigatorEvent(event) {
60
 
60
 
61
   render() {
61
   render() {
62
     return (
62
     return (
63
-      <View style={{flex: 1, padding: 20}}>
63
+      <View style={{flex: 1, padding: 40}}>
64
         <TouchableOpacity onPress={ this.onPushPress.bind(this) }>
64
         <TouchableOpacity onPress={ this.onPushPress.bind(this) }>
65
           <Text style={styles.button}>Push Plain Screen</Text>
65
           <Text style={styles.button}>Push Plain Screen</Text>
66
         </TouchableOpacity>
66
         </TouchableOpacity>
97
   onPushPress() {
97
   onPushPress() {
98
     this.props.navigator.push({
98
     this.props.navigator.push({
99
       title: "More",
99
       title: "More",
100
-      screen: "example.PushedScreen"
100
+      screen: "com.example.PushedScreen"
101
     });
101
     });
102
   }
102
   }
103
 
103
 
104
   onPushStyledPress() {
104
   onPushStyledPress() {
105
     this.props.navigator.push({
105
     this.props.navigator.push({
106
       title: "Styled",
106
       title: "Styled",
107
-      screen: "example.StyledScreen"
107
+      screen: "com.example.StyledScreen"
108
     });
108
     });
109
   }
109
   }
110
 
110
 
111
   onModalPress() {
111
   onModalPress() {
112
     this.props.navigator.showModal({
112
     this.props.navigator.showModal({
113
       title: "Modal",
113
       title: "Modal",
114
-      screen: "example.ModalScreen"
114
+      screen: "com.example.ModalScreen"
115
     });
115
     });
116
   }
116
   }
117
 
117
 
118
   onLightBoxPress() {
118
   onLightBoxPress() {
119
     this.props.navigator.showLightBox({
119
     this.props.navigator.showLightBox({
120
-      screen: "example.LightBoxScreen",
120
+      screen: "com.example.LightBoxScreen",
121
       style: {
121
       style: {
122
         backgroundBlur: "dark"
122
         backgroundBlur: "dark"
123
       },
123
       },
129
 
129
 
130
   onInAppNotificationPress() {
130
   onInAppNotificationPress() {
131
     this.props.navigator.showInAppNotification({
131
     this.props.navigator.showInAppNotification({
132
-      screen: "example.NotificationScreen"
132
+      screen: "com.example.NotificationScreen"
133
     });
133
     });
134
   }
134
   }
135
 
135
 
136
   onStartSingleScreenApp() {
136
   onStartSingleScreenApp() {
137
     Navigation.startSingleScreenApp({
137
     Navigation.startSingleScreenApp({
138
       screen: {
138
       screen: {
139
-        screen: 'example.FirstTabScreen'
139
+        screen: 'com.example.FirstTabScreen'
140
       },
140
       },
141
       drawer: {
141
       drawer: {
142
         left: {
142
         left: {
143
-          screen: 'example.SideMenu'
143
+          screen: 'com.example.SideMenu'
144
         }
144
         }
145
       }
145
       }
146
     });
146
     });

+ 2
- 2
example/src/screens/ModalScreen.js View File

50
   onPushPress() {
50
   onPushPress() {
51
     this.props.navigator.push({
51
     this.props.navigator.push({
52
       title: "More",
52
       title: "More",
53
-      screen: "example.PushedScreen"
53
+      screen: "com.example.PushedScreen"
54
     });
54
     });
55
   }
55
   }
56
   onPushStyledPress() {
56
   onPushStyledPress() {
57
     this.props.navigator.push({
57
     this.props.navigator.push({
58
       title: "More",
58
       title: "More",
59
-      screen: "example.StyledScreen"
59
+      screen: "com.example.StyledScreen"
60
     });
60
     });
61
   }
61
   }
62
   onClosePress() {
62
   onClosePress() {

+ 2
- 3
example/src/screens/PushedScreen.js View File

48
   onPushStyledPress() {
48
   onPushStyledPress() {
49
     this.props.navigator.push({
49
     this.props.navigator.push({
50
       title: "More",
50
       title: "More",
51
-      screen: "example.StyledScreen"
51
+      screen: "com.example.StyledScreen"
52
     });
52
     });
53
   }
53
   }
54
   onPopPress() {
54
   onPopPress() {
60
   onResetToPress() {
60
   onResetToPress() {
61
     this.props.navigator.resetTo({
61
     this.props.navigator.resetTo({
62
       title: "New Root",
62
       title: "New Root",
63
-      screen: "example.StyledScreen",
64
-      animated: true
63
+      screen: "com.example.ThirdTabScreen"
65
     });
64
     });
66
   }
65
   }
67
 }
66
 }

+ 1
- 1
example/src/screens/SecondTabScreen.js View File

22
     super(props);
22
     super(props);
23
     this.buttonsCounter = 0;
23
     this.buttonsCounter = 0;
24
     // if you want to listen on navigator events, set this up
24
     // if you want to listen on navigator events, set this up
25
-    this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
25
+    //this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
26
   }
26
   }
27
 
27
 
28
   render() {
28
   render() {

+ 2
- 2
example/src/screens/StyledScreen.js View File

66
   onPushPress() {
66
   onPushPress() {
67
     this.props.navigator.push({
67
     this.props.navigator.push({
68
       title: "More",
68
       title: "More",
69
-      screen: "example.PushedScreen"
69
+      screen: "com.example.PushedScreen"
70
     });
70
     });
71
   }
71
   }
72
   onPushStyledPress() {
72
   onPushStyledPress() {
73
     this.props.navigator.push({
73
     this.props.navigator.push({
74
       title: "More",
74
       title: "More",
75
-      screen: "example.StyledScreen"
75
+      screen: "com.example.StyledScreen"
76
     });
76
     });
77
   }
77
   }
78
   onPopPress() {
78
   onPopPress() {

+ 14
- 8
example/src/screens/index.ios.js View File

11
 
11
 
12
 // register all screens of the app (including internal ones)
12
 // register all screens of the app (including internal ones)
13
 export function registerScreens() {
13
 export function registerScreens() {
14
-  Navigation.registerComponent('example.FirstTabScreen', () => FirstTabScreen);
15
-  Navigation.registerComponent('example.SecondTabScreen', () => SecondTabScreen);
16
-  Navigation.registerComponent('example.PushedScreen', () => PushedScreen);
17
-  Navigation.registerComponent('example.StyledScreen', () => StyledScreen);
18
-  Navigation.registerComponent('example.ModalScreen', () => ModalScreen);
19
-  Navigation.registerComponent('example.NotificationScreen', () => NotificationScreen);
20
-  Navigation.registerComponent('example.SideMenu', () => SideMenu);
21
-  Navigation.registerComponent('example.LightBoxScreen', () => LightBoxScreen);
14
+  Navigation.registerComponent('com.example.FirstTabScreen', () => FirstTabScreen);
15
+  Navigation.registerComponent('com.example.SecondTabScreen', () => SecondTabScreen);
16
+  Navigation.registerComponent('com.example.PushedScreen', () => PushedScreen);
17
+  Navigation.registerComponent('com.example.StyledScreen', () => StyledScreen);
18
+  Navigation.registerComponent('com.example.ModalScreen', () => ModalScreen);
19
+  Navigation.registerComponent('com.example.NotificationScreen', () => NotificationScreen);
20
+  Navigation.registerComponent('com.example.SideMenu', () => SideMenu);
21
+  Navigation.registerComponent('com.example.LightBoxScreen', () => LightBoxScreen);
22
+	
23
+  Navigation.registerComponent('com.example.MyScreen', () => FirstTabScreen);
24
+  Navigation.registerComponent('com.example.Menu', () => SideMenu);
25
+  Navigation.registerComponent('com.example.Menu1', () => SideMenu);
26
+  Navigation.registerComponent('com.example.Menu2', () => SideMenu);
27
+	
22
 }
28
 }