瀏覽代碼

playground working

Daniel Zlotin 7 年之前
父節點
當前提交
44de6b1928

+ 1
- 1
integration/SingleScreen.test.js 查看文件

@@ -11,7 +11,7 @@ describe('single screen integration', () => {
11 11
   xit('startApp directs to native with constructed hirarchy for single screens', () => {
12 12
     mockNativeNavigation.startApp = jest.fn();
13 13
     Navigation.startApp({
14
-      container: {
14
+      root: {
15 15
         key: 'com.integration.MyFirstScreen'
16 16
       }
17 17
     });

+ 10
- 10
playground/commands.json 查看文件

@@ -1,26 +1,26 @@
1 1
 {
2 2
   "singleScreenApp": {
3
-    "container": {
3
+    "root": {
4 4
       "key": "com.example.FirstTabScreen"
5 5
     }
6 6
   },
7 7
   "tabBasedApp": {
8 8
     "tabs": [{
9
-             "container": {
9
+             "root": {
10 10
               "key": "com.example.FirstTabScreen"
11 11
              }
12 12
              }, {
13
-             "container": {
13
+             "root": {
14 14
               "key": "com.example.SecondTabScreen"
15 15
              }
16 16
              }, {
17
-             "container": {
17
+             "root": {
18 18
               "key": "com.example.FirstTabScreen"
19 19
              }
20 20
              }]
21 21
   },
22 22
   "singleWithLeftSideMenu": {
23
-    "container": {
23
+    "root": {
24 24
       "key": "com.example.MyScreen"
25 25
     },
26 26
     "sideMenu": {
@@ -30,7 +30,7 @@
30 30
     }
31 31
   },
32 32
   "singleWithRightSideMenu": {
33
-    "container": {
33
+    "root": {
34 34
       "key": "com.example.MyScreen"
35 35
     },
36 36
     "sideMenu": {
@@ -40,7 +40,7 @@
40 40
     }
41 41
   },
42 42
   "singleWithBothMenus": {
43
-    "container": {
43
+    "root": {
44 44
       "key": "com.example.MyScreen"
45 45
     },
46 46
     "sideMenu": {
@@ -54,15 +54,15 @@
54 54
   },
55 55
   "tabBasedWithSideMenu": {
56 56
     "tabs": [{
57
-             "container": {
57
+             "root": {
58 58
               "key": "com.example.FirstTabScreen"
59 59
              }
60 60
              }, {
61
-             "container": {
61
+             "root": {
62 62
               "key": "com.example.SecondTabScreen"
63 63
              }
64 64
              }, {
65
-             "container": {
65
+             "root": {
66 66
               "key": "com.example.FirstTabScreen"
67 67
              }
68 68
              }],

+ 9
- 0
playground/e2e/app.test.js 查看文件

@@ -0,0 +1,9 @@
1
+describe('app', function() {
2
+  beforeEach(function(done) {
3
+    global.simulator.relaunchApp(done);
4
+  });
5
+
6
+  it('shows welcome screen', function() {
7
+    expect(element(by.label('React Native Navigation!'))).toBeVisible();
8
+  });
9
+});

+ 2
- 1
playground/e2e/init.js 查看文件

@@ -1,9 +1,10 @@
1 1
 /*eslint-disable*/
2
+require('babel-polyfill');
2 3
 const detox = require('detox');
3 4
 const config = require('../package.json').detox;
4 5
 
5 6
 before(function(done) {
6
-  this.timeout(120000);
7
+  this.timeout(60000);
7 8
   detox.config(config);
8 9
   detox.start(done);
9 10
 });

+ 0
- 9
playground/e2e/sanity.test.js 查看文件

@@ -1,9 +0,0 @@
1
-describe('sanity', function() {
2
-  beforeEach(function(done) {
3
-    global.simulator.reloadReactNativeApp(done);
4
-  });
5
-
6
-  it('should have screen one showing', function() {
7
-    expect(element(by.label('Screen One'))).toBeVisible();
8
-  });
9
-});

+ 5
- 5
playground/ios/playground/AppDelegate.m 查看文件

@@ -25,14 +25,14 @@
25 25
   // **********************************************
26 26
   // *** DON'T MISS: THIS IS HOW WE BOOTSTRAP *****
27 27
   // **********************************************
28
-  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
28
+  /*self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
29 29
   self.window.backgroundColor = [UIColor whiteColor];
30
-  [[RCCManager sharedInstance] initBridgeWithBundleURL:jsCodeLocation];
30
+  [[RCCManager sharedInstance] initBridgeWithBundleURL:jsCodeLocation];*/
31 31
 
32
-  /*
32
+  
33 33
   // original RN bootstrap - remove this part
34 34
   RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
35
-                                                      moduleName:@"playground"
35
+                                                      moduleName:@"com.example.WelcomeScreen"
36 36
                                                initialProperties:nil
37 37
                                                    launchOptions:launchOptions];
38 38
   self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
@@ -40,9 +40,9 @@
40 40
   rootViewController.view = rootView;
41 41
   self.window.rootViewController = rootViewController;
42 42
   [self.window makeKeyAndVisible];
43
-  */
44 43
   
45 44
 
45
+
46 46
   return YES;
47 47
 }
48 48
 

+ 11
- 1
playground/package.json 查看文件

@@ -24,8 +24,18 @@
24 24
       "sessionId": "playground"
25 25
     },
26 26
     "ios-simulator": {
27
-      "app": "ios/DerivedData/playground/Build/Products/Debug_Detox-iphonesimulator/playground.app",
27
+      "app": "ios/DerivedData/playground/Build/Products/Release_Detox-iphonesimulator/playground.app",
28 28
       "device": "iPhone 7, iOS 10.2"
29 29
     }
30
+  },
31
+  "babel": {
32
+    "env": {
33
+      "test": {
34
+        "presets": [
35
+          "react-native"
36
+        ],
37
+        "retainLines": true
38
+      }
39
+    }
30 40
   }
31 41
 }

+ 2
- 2
playground/scripts/e2e.ios.js 查看文件

@@ -15,7 +15,7 @@ function kill(process) {
15 15
 function buildProjForDetox() {
16 16
   exec(`RCT_NO_LAUNCH_PACKAGER=true \
17 17
           cd ios && xcodebuild \
18
-            -scheme playground_Detox clean build \
18
+            -scheme playground_release_Detox build \
19 19
             -project playground.xcodeproj \
20 20
             -sdk iphonesimulator \
21 21
             -derivedDataPath ./DerivedData/playground`);
@@ -25,7 +25,7 @@ function e2e() {
25 25
   try {
26 26
     kill(`detox-server`);
27 27
     cp.exec(`./node_modules/.bin/detox-server > ./detox-server.log 2>&1`);
28
-    exec(`BABEL_ENV=test ./node_modules/mocha/bin/mocha e2e --recursive --timeout 120000`);
28
+    exec(`BABEL_ENV=test ./node_modules/mocha/bin/mocha e2e --recursive --timeout 120000 --compilers js:babel-register`);
29 29
   } finally {
30 30
     kill(`detox-server`);
31 31
     kill(`Simulator`);

+ 0
- 133
playground/src/__screens/CollapsingTopBarScreen.android.js 查看文件

@@ -1,133 +0,0 @@
1
-import React, {Component} from 'react';
2
-import {
3
-  Text,
4
-  View,
5
-  ScrollView,
6
-  TouchableOpacity,
7
-  StyleSheet,
8
-} from 'react-native';
9
-
10
-// collapsingToolBarImage: require('../../img/gyro_header.jpg'),
11
-// collapsingToolBarImage: "https://static.wixstatic.com/media/ec14061b42d1dc5b809367f7cfda8eff.jpg/v1/fill/w_1002,h_499,q_80/ec14061b42d1dc5b809367f7cfda8eff.webp",
12
-
13
-export default class ThirdTabScreen extends Component {
14
-  static navigatorStyle = {
15
-    drawUnderTabBar: true,
16
-    navBarButtonColor: '#ffffff',
17
-    navBarTextColor: '#ffffff',
18
-    collapsingToolBarImage: require('../../img/gyro_header.jpg'),
19
-    collapsingToolBarCollapsedColor: '#0f2362',
20
-    navBarBackgroundColor: '#eeeeee'
21
-  };
22
-
23
-  static navigatorButtons = {
24
-    rightButtons: [
25
-      {
26
-        title: 'Edit',
27
-        id: 'edit'
28
-      },
29
-      {
30
-        icon: require('../../img/navicon_add.png'),
31
-        id: 'add'
32
-      }
33
-    ]
34
-  };
35
-
36
-  constructor(props) {
37
-    super(props);
38
-    this.state = {
39
-      navBarVisibility: 'shown'
40
-    }
41
-  }
42
-  render() {
43
-    return (
44
-        <ScrollView style={styles.container}>
45
-          <View style={{flex: 1, backgroundColor: '#ffffff'}}>
46
-            <Text style={styles.button}>Row 0</Text>
47
-            <Text style={styles.button}>Row 1</Text>
48
-            <Text style={styles.button}>Row 2</Text>
49
-            <Text style={styles.button}>Row 3</Text>
50
-            <Text style={styles.button}>Row 4</Text>
51
-            <Text style={styles.button}>Row 5</Text>
52
-            <Text style={styles.button}>Row 6</Text>
53
-            <Text style={styles.button}>Row 7</Text>
54
-            <Text style={styles.button}>Row 8</Text>
55
-
56
-            <TouchableOpacity onPress={ this.onPushPress.bind(this) }>
57
-              <Text style={styles.button}>Push Plain Screen</Text>
58
-            </TouchableOpacity>
59
-
60
-            <TouchableOpacity onPress={ this.onPushStyledPress.bind(this) }>
61
-              <Text style={styles.button}>Push Styled Screen</Text>
62
-            </TouchableOpacity>
63
-
64
-            <TouchableOpacity onPress={ this.onPushStyled2Press.bind(this) }>
65
-              <Text style={styles.button}>Push Styled Screen 2</Text>
66
-            </TouchableOpacity>
67
-
68
-            <TouchableOpacity onPress={ this.onModalPress.bind(this) }>
69
-              <Text style={styles.button}>Show Modal Screen</Text>
70
-            </TouchableOpacity>
71
-
72
-            <TouchableOpacity onPress={ this.onToggleNavBarPressed.bind(this) }>
73
-              <Text style={styles.button}>Toggle Navigation Bar</Text>
74
-            </TouchableOpacity>
75
-          </View>
76
-        </ScrollView>
77
-    );
78
-  }
79
-  onPushPress() {
80
-    this.props.navigator.push({
81
-      title: "More",
82
-      container: "example.PushedScreen"
83
-    });
84
-  }
85
-  onPushStyledPress() {
86
-    this.props.navigator.push({
87
-      title: "Styled",
88
-      container: "example.StyledScreen"
89
-    });
90
-  }
91
-  onPushStyled2Press () {
92
-    this.props.navigator.push({
93
-      title: "Styled",
94
-      titleImage: require('../../img/two.png'),
95
-      container: "example.StyledScreen"
96
-    });
97
-  }
98
-  onModalPress() {
99
-    this.props.navigator.showModal({
100
-      title: "Modal",
101
-      container: "example.ModalScreen"
102
-    });
103
-  }
104
-
105
-  onToggleNavBarPressed() {
106
-    this.state.navBarVisibility = (this.state.navBarVisibility === 'shown') ? 'hidden' : 'shown';
107
-    this.props.navigator.toggleNavBar({
108
-      to: this.state.navBarVisibility,
109
-      animated: true  // true is default
110
-    });
111
-  }
112
-
113
-  componentDidUpdate() {
114
-    console.error('this is an error: ' + Math.random());
115
-    this.state.navBarState = 'shown';
116
-  }
117
-
118
-}
119
-
120
-const styles = StyleSheet.create({
121
-  container: {
122
-    flex: 1,
123
-    padding: 20,
124
-    backgroundColor: '#eeeeee'
125
-  },
126
-  button: {
127
-    textAlign: 'center',
128
-    fontSize: 18,
129
-    marginBottom: 10,
130
-    marginTop:30,
131
-    color: 'blue'
132
-  }
133
-});

+ 0
- 158
playground/src/__screens/FirstTabScreen.js 查看文件

@@ -1,158 +0,0 @@
1
-import React, {Component} from 'react';
2
-import {
3
-  Text,
4
-  View,
5
-  TouchableOpacity,
6
-  StyleSheet,
7
-  Alert,
8
-  Platform
9
-} from 'react-native';
10
-import {Navigation} from 'react-native-navigation';
11
-
12
-export default class FirstTabScreen extends Component {
13
-  static navigatorButtons = {
14
-    leftButtons: [{
15
-      icon: require('../../img/navicon_menu.png'),
16
-      id: 'menu'
17
-    }],
18
-    rightButtons: [
19
-      {
20
-        title: 'Edit',
21
-        id: 'edit'
22
-      },
23
-      {
24
-        icon: require('../../img/navicon_add.png'),
25
-        id: 'add'
26
-      }
27
-    ]
28
-  };
29
-  static navigatorStyle = {
30
-    navBarBackgroundColor: '#4dbce9',
31
-    navBarTextColor: '#ffff00',
32
-    navBarSubtitleTextColor: '#ff0000',
33
-    navBarButtonColor: '#ffffff',
34
-    statusBarTextColorScheme: 'light',
35
-    tabBarBackgroundColor: '#4dbce9',
36
-    tabBarButtonColor: '#ffffff',
37
-    tabBarSelectedButtonColor: '#ffff00'
38
-  };
39
-
40
-  constructor(props) {
41
-    super(props);
42
-    // if you want to listen on navigator events, set this up
43
-    //this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
44
-  }
45
-
46
-  onNavigatorEvent(event) {
47
-    if (event.id === 'menu') {
48
-      this.props.navigator.toggleDrawer({
49
-        side: 'left',
50
-        animated: true
51
-      });
52
-    }
53
-    if (event.id === 'edit') {
54
-      Alert.alert('NavBar', 'Edit button pressed');
55
-    }
56
-    if (event.id === 'add') {
57
-      Alert.alert('NavBar', 'Add button pressed');
58
-    }
59
-  }
60
-
61
-  render() {
62
-    return (
63
-      <View style={{flex: 1, padding: 40}}>
64
-        <TouchableOpacity onPress={ this.onPushPress.bind(this) }>
65
-          <Text style={styles.button}>Push Plain Screen</Text>
66
-        </TouchableOpacity>
67
-
68
-        <TouchableOpacity onPress={ this.onPushStyledPress.bind(this) }>
69
-          <Text style={styles.button}>Push Styled Screen</Text>
70
-        </TouchableOpacity>
71
-
72
-        <TouchableOpacity onPress={ this.onModalPress.bind(this) }>
73
-          <Text style={styles.button}>Show Modal Screen</Text>
74
-        </TouchableOpacity>
75
-
76
-        {
77
-          Platform.OS === 'ios' ?
78
-            <TouchableOpacity onPress={ this.onLightBoxPress.bind(this) }>
79
-              <Text style={styles.button}>Show LightBox</Text>
80
-            </TouchableOpacity> : false
81
-        }
82
-
83
-        {
84
-          Platform.OS === 'ios' ?
85
-            <TouchableOpacity onPress={ this.onInAppNotificationPress.bind(this) }>
86
-              <Text style={styles.button}>Show In-App Notification</Text>
87
-            </TouchableOpacity> : false
88
-        }
89
-
90
-        <TouchableOpacity onPress={ this.onStartSingleScreenApp.bind(this) }>
91
-          <Text style={styles.button}>Show Single Screen App</Text>
92
-        </TouchableOpacity>
93
-      </View>
94
-    );
95
-  }
96
-
97
-  onPushPress() {
98
-    this.props.navigator.push({
99
-      title: "More",
100
-      container: "com.example.PushedScreen"
101
-    });
102
-  }
103
-
104
-  onPushStyledPress() {
105
-    this.props.navigator.push({
106
-      title: "Styled",
107
-      container: "com.example.StyledScreen"
108
-    });
109
-  }
110
-
111
-  onModalPress() {
112
-    this.props.navigator.showModal({
113
-      title: "Modal",
114
-      container: "com.example.ModalScreen"
115
-    });
116
-  }
117
-
118
-  onLightBoxPress() {
119
-    this.props.navigator.showLightBox({
120
-      container: "com.example.LightBoxScreen",
121
-      style: {
122
-        backgroundBlur: "dark"
123
-      },
124
-      passProps: {
125
-        greeting: 'hey there'
126
-      },
127
-    });
128
-  }
129
-
130
-  onInAppNotificationPress() {
131
-    this.props.navigator.showInAppNotification({
132
-      container: "com.example.NotificationScreen"
133
-    });
134
-  }
135
-
136
-  onStartSingleScreenApp() {
137
-    Navigation.startSingleScreenApp({
138
-      container: {
139
-        container: 'com.example.FirstTabScreen'
140
-      },
141
-      drawer: {
142
-        left: {
143
-          container: 'com.example.SideMenu'
144
-        }
145
-      }
146
-    });
147
-  }
148
-}
149
-
150
-const styles = StyleSheet.create({
151
-  button: {
152
-    textAlign: 'center',
153
-    fontSize: 18,
154
-    marginBottom: 10,
155
-    marginTop: 10,
156
-    color: 'blue'
157
-  }
158
-});

+ 0
- 63
playground/src/__screens/LightBoxScreen.js 查看文件

@@ -1,63 +0,0 @@
1
-import React, {Component} from 'react';
2
-import {
3
-  StyleSheet,
4
-  Text,
5
-  View,
6
-  TouchableOpacity,
7
-  Dimensions
8
-} from 'react-native';
9
-
10
-export default class LightBoxScreen extends Component {
11
-  constructor(props) {
12
-    super(props);
13
-  }
14
-  render() {
15
-    return (
16
-      <View style={styles.container}>
17
-        <Text style={styles.welcome}>
18
-          This is a LightBox!
19
-        </Text>
20
-        {
21
-          this.props.greeting &&
22
-            <Text style={[styles.welcome, {fontSize: 16, marginTop: 20}]}>
23
-              {this.props.greeting}
24
-            </Text>
25
-        }
26
-        <TouchableOpacity onPress={() => this.onDismissPress()}>
27
-          <Text style={styles.button}>Dismiss</Text>
28
-        </TouchableOpacity>
29
-      </View>
30
-    );
31
-  }
32
-  onDismissPress() {
33
-    this.props.navigator.dismissLightBox();
34
-  }
35
-}
36
-
37
-var styles = StyleSheet.create({
38
-  container: {
39
-    flex: 1,
40
-    width: Dimensions.get('window').width * 0.8,
41
-    justifyContent: 'center',
42
-    alignItems: 'center',
43
-    backgroundColor: 'white',
44
-    borderRadius: 10
45
-  },
46
-  welcome: {
47
-    fontSize: 20,
48
-    textAlign: 'center',
49
-    margin: 10,
50
-  },
51
-  instructions: {
52
-    textAlign: 'center',
53
-    color: '#333333',
54
-    marginBottom: 5,
55
-  },
56
-  button: {
57
-    textAlign: 'center',
58
-    fontSize: 18,
59
-    marginBottom: 10,
60
-    marginTop:10,
61
-    color: 'blue'
62
-  }
63
-});

+ 0
- 83
playground/src/__screens/ModalScreen.js 查看文件

@@ -1,83 +0,0 @@
1
-import React, {Component} from 'react';
2
-import {
3
-  Text,
4
-  View,
5
-  ScrollView,
6
-  TouchableOpacity,
7
-  StyleSheet
8
-} from 'react-native';
9
-
10
-export default class ModalScreen extends Component {
11
-  static navigatorButtons = {
12
-    leftButtons: [{
13
-      title: 'Close',
14
-      id: 'close'
15
-    }]
16
-  };
17
-  constructor(props) {
18
-    super(props);
19
-    // if you want to listen on navigator events, set this up
20
-    this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
21
-  }
22
-  render() {
23
-    return (
24
-      <View style={styles.container}>
25
-
26
-        <TouchableOpacity onPress={ this.onPushPress.bind(this) }>
27
-          <Text style={styles.button}>Push Plain Screen</Text>
28
-        </TouchableOpacity>
29
-
30
-        <TouchableOpacity onPress={ this.onPushStyledPress.bind(this) }>
31
-          <Text style={styles.button}>Push Styled Screen</Text>
32
-        </TouchableOpacity>
33
-
34
-        <TouchableOpacity onPress={ this.onClosePress.bind(this) }>
35
-          <Text style={styles.button}>Close Modal</Text>
36
-        </TouchableOpacity>
37
-
38
-        <TouchableOpacity onPress={ this.onCloseAllPress.bind(this) }>
39
-          <Text style={styles.button}>Close All Modals</Text>
40
-        </TouchableOpacity>
41
-
42
-      </View>
43
-    );
44
-  }
45
-  onNavigatorEvent(event) {
46
-    if (event.id == 'close') {
47
-      this.props.navigator.dismissModal();
48
-    }
49
-  }
50
-  onPushPress() {
51
-    this.props.navigator.push({
52
-      title: "More",
53
-      container: "com.example.PushedScreen"
54
-    });
55
-  }
56
-  onPushStyledPress() {
57
-    this.props.navigator.push({
58
-      title: "More",
59
-      container: "com.example.StyledScreen"
60
-    });
61
-  }
62
-  onClosePress() {
63
-    this.props.navigator.dismissModal();
64
-  }
65
-  onCloseAllPress() {
66
-    this.props.navigator.dismissAllModals();
67
-  }
68
-}
69
-
70
-const styles = StyleSheet.create({
71
-  container: {
72
-    flex: 1,
73
-    backgroundColor: 'white',
74
-    padding: 20
75
-  },
76
-  button: {
77
-    textAlign: 'center',
78
-    fontSize: 18,
79
-    marginBottom: 10,
80
-    marginTop:10,
81
-    color: 'blue'
82
-  }
83
-});

+ 0
- 52
playground/src/__screens/NotificationScreen.js 查看文件

@@ -1,52 +0,0 @@
1
-import React, {Component} from 'react';
2
-import {
3
-  StyleSheet,
4
-  Text,
5
-  View,
6
-  TouchableOpacity,
7
-  Dimensions
8
-} from 'react-native';
9
-
10
-export default class NotificationScreen extends Component {
11
-  constructor(props) {
12
-    super(props);
13
-  }
14
-  render() {
15
-    return (
16
-      <View style={styles.container}>
17
-        <Text style={styles.welcome}>
18
-          This is a Notification!
19
-        </Text>
20
-        <TouchableOpacity onPress={ this.onDismissPress.bind(this) }>
21
-          <Text style={styles.button}>Dismiss</Text>
22
-        </TouchableOpacity>
23
-      </View>
24
-    );
25
-  }
26
-  onDismissPress() {
27
-    this.props.navigator.dismissInAppNotification();
28
-  }
29
-}
30
-
31
-var styles = StyleSheet.create({
32
-  container: {
33
-    flex: 1,
34
-    width: Dimensions.get('window').width,
35
-    justifyContent: 'center',
36
-    alignItems: 'center',
37
-    backgroundColor: '#d6e7ad'
38
-  },
39
-  welcome: {
40
-    fontSize: 20,
41
-    textAlign: 'center',
42
-    margin: 10,
43
-    paddingTop: 20
44
-  },
45
-  button: {
46
-    textAlign: 'center',
47
-    fontSize: 18,
48
-    marginBottom: 10,
49
-    marginTop:10,
50
-    color: '#4692ad'
51
-  }
52
-});

+ 0
- 81
playground/src/__screens/PushedScreen.js 查看文件

@@ -1,81 +0,0 @@
1
-import React, {Component} from 'react';
2
-import {
3
-  Text,
4
-  View,
5
-  ScrollView,
6
-  TouchableOpacity,
7
-  StyleSheet
8
-} from 'react-native';
9
-
10
-export default class PushedScreen extends Component {
11
-  static navigatorStyle = {
12
-    drawUnderTabBar: true
13
-  };
14
-  constructor(props) {
15
-    super(props);
16
-  }
17
-  render() {
18
-    return (
19
-      <View style={styles.container}>
20
-        <TouchableOpacity onPress={ this.onPushPress.bind(this) }>
21
-          <Text style={styles.button}>Push Plain Screen</Text>
22
-        </TouchableOpacity>
23
-
24
-        <TouchableOpacity onPress={ this.onPushStyledPress.bind(this) }>
25
-          <Text style={styles.button}>Push Styled Screen</Text>
26
-        </TouchableOpacity>
27
-
28
-        <TouchableOpacity onPress={ this.onPopPress.bind(this) }>
29
-          <Text style={styles.button}>Pop Screen</Text>
30
-        </TouchableOpacity>
31
-
32
-        <TouchableOpacity onPress={ this.onPopToRootPress.bind(this) }>
33
-          <Text style={styles.button}>Pop To Root</Text>
34
-        </TouchableOpacity>
35
-
36
-        <TouchableOpacity onPress={ this.onResetToPress.bind(this) }>
37
-          <Text style={styles.button}>Reset To</Text>
38
-        </TouchableOpacity>
39
-      </View>
40
-    );
41
-  }
42
-  onPushPress() {
43
-    this.props.navigator.push({
44
-      title: "More",
45
-      container: "example.PushedScreen"
46
-    });
47
-  }
48
-  onPushStyledPress() {
49
-    this.props.navigator.push({
50
-      title: "More",
51
-      container: "com.example.StyledScreen"
52
-    });
53
-  }
54
-  onPopPress() {
55
-    this.props.navigator.pop();
56
-  }
57
-  onPopToRootPress() {
58
-    this.props.navigator.popToRoot();
59
-  }
60
-  onResetToPress() {
61
-    this.props.navigator.resetTo({
62
-      title: "New Root",
63
-      container: "com.example.ThirdTabScreen"
64
-    });
65
-  }
66
-}
67
-
68
-const styles = StyleSheet.create({
69
-  container: {
70
-    flex: 1,
71
-    padding: 20,
72
-    backgroundColor: 'white'
73
-  },
74
-  button: {
75
-    textAlign: 'center',
76
-    fontSize: 18,
77
-    marginBottom: 10,
78
-    marginTop:10,
79
-    color: 'blue'
80
-  }
81
-});

+ 0
- 146
playground/src/__screens/SecondTabScreen.js 查看文件

@@ -1,146 +0,0 @@
1
-import React, {Component} from 'react';
2
-import {
3
-  Text,
4
-  View,
5
-  ScrollView,
6
-  TouchableOpacity,
7
-  StyleSheet,
8
-  Alert
9
-} from 'react-native';
10
-
11
-export default class SecondTabScreen extends Component {
12
-  static navigatorStyle: {
13
-    drawUnderTabBar: true,
14
-    navBarBackgroundColor: '#4dbce9',
15
-    navBarTextColor: '#ffff00',
16
-    navBarSubtitleTextColor: '#ff0000',
17
-    navBarButtonColor: '#ffffff',
18
-    statusBarTextColorScheme: 'light'
19
-  };
20
-
21
-  constructor(props) {
22
-    super(props);
23
-    this.buttonsCounter = 0;
24
-    // if you want to listen on navigator events, set this up
25
-    //this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
26
-  }
27
-
28
-  render() {
29
-    return (
30
-      <View style={styles.container}>
31
-
32
-        <TouchableOpacity onPress={ this.onChangeButtonsPress.bind(this) }>
33
-          <Text style={styles.button}>Change Buttons</Text>
34
-        </TouchableOpacity>
35
-
36
-        <TouchableOpacity onPress={ this.onChangeTitlePress.bind(this) }>
37
-          <Text style={styles.button}>Change Title</Text>
38
-        </TouchableOpacity>
39
-
40
-        <TouchableOpacity onPress={ this.onSwitchTabPress.bind(this) }>
41
-          <Text style={styles.button}>Switch To Tab#1</Text>
42
-        </TouchableOpacity>
43
-
44
-        <TouchableOpacity onPress={ this.onSetTabBadgePress.bind(this) }>
45
-          <Text style={styles.button}>Set Tab Badge</Text>
46
-        </TouchableOpacity>
47
-
48
-        <TouchableOpacity onPress={ this.onToggleTabsPress.bind(this) }>
49
-          <Text style={styles.button}>Toggle Tabs</Text>
50
-        </TouchableOpacity>
51
-
52
-      </View>
53
-    );
54
-  }
55
-  onChangeTitlePress() {
56
-    this.props.navigator.setTitle({
57
-      title: Math.round(Math.random() * 100000).toString()
58
-    });
59
-  }
60
-  onChangeButtonsPress() {
61
-    let buttons;
62
-    if (this.buttonsCounter % 3 == 0) {
63
-      buttons = [
64
-        {
65
-          title: 'Edit',
66
-          id: 'edit',
67
-          disabled: true
68
-        },
69
-        {
70
-          icon: require('../../img/navicon_add.png'),
71
-          id: 'add'
72
-        }
73
-      ];
74
-    } else if (this.buttonsCounter % 3 == 1) {
75
-      buttons = [{
76
-        title: 'Save',
77
-        id: 'save'
78
-      }];
79
-    } else {
80
-      buttons = [];
81
-    }
82
-    this.buttonsCounter++;
83
-
84
-    this.props.navigator.setButtons({
85
-      rightButtons: buttons,
86
-      animated: true
87
-    });
88
-  }
89
-  onSwitchTabPress() {
90
-    this.props.navigator.switchToTab({
91
-      tabIndex: 0
92
-    });
93
-  }
94
-  onSetTabBadgePress() {
95
-    this.props.navigator.setTabBadge({
96
-      badge: 12
97
-    });
98
-  }
99
-  onToggleTabsPress() {
100
-    this.props.navigator.toggleTabs({
101
-      to: this.tabsHidden ? 'shown' : 'hidden'
102
-    });
103
-    this.tabsHidden = !this.tabsHidden;
104
-  }
105
-  onNavigatorEvent(event) {
106
-    // handle a deep link
107
-    if (event.type == 'DeepLink') {
108
-      const parts = event.link.split('/');
109
-      if (parts[0] == 'tab2') {
110
-        this.props.navigator.resetTo({
111
-          title: "Replaced Root",
112
-          container: parts[1],
113
-          animated: true
114
-        });
115
-        this.props.navigator.switchToTab();
116
-      }
117
-    }
118
-    // handle a button press
119
-    if (event.type == 'NavBarButtonPress') {
120
-      if (event.id == 'edit') {
121
-        Alert.alert('NavBar', 'Dynamic Edit button pressed');
122
-      }
123
-      if (event.id == 'add') {
124
-        Alert.alert('NavBar', 'Dynamic Add button pressed');
125
-      }
126
-      if (event.id == 'save') {
127
-        Alert.alert('NavBar', 'Dynamic Save button pressed');
128
-      }
129
-    }
130
-  }
131
-}
132
-
133
-const styles = StyleSheet.create({
134
-  container: {
135
-    flex: 1,
136
-    padding: 20,
137
-    backgroundColor: 'white'
138
-  },
139
-  button: {
140
-    textAlign: 'center',
141
-    fontSize: 18,
142
-    marginBottom: 10,
143
-    marginTop:10,
144
-    color: 'blue'
145
-  }
146
-});

+ 0
- 79
playground/src/__screens/SideMenu.js 查看文件

@@ -1,79 +0,0 @@
1
-import React, {Component} from 'react';
2
-import {
3
-  Text,
4
-  View,
5
-  ScrollView,
6
-  TouchableOpacity,
7
-  StyleSheet,
8
-  AlertIOS
9
-} from 'react-native';
10
-
11
-export default class SideMenu extends Component {
12
-  constructor(props) {
13
-    super(props);
14
-  }
15
-  render() {
16
-    return (
17
-      <View style={styles.container}>
18
-        <Text style={styles.title}>Side Menu</Text>
19
-
20
-        <TouchableOpacity onPress={ this.onReplaceTab2Press.bind(this) }>
21
-          <Text style={styles.button}>Replace Tab#2 Root</Text>
22
-        </TouchableOpacity>
23
-
24
-        <TouchableOpacity onPress={ this.onModalPress.bind(this) }>
25
-          <Text style={styles.button}>Show Modal Screen</Text>
26
-        </TouchableOpacity>
27
-      </View>
28
-    );
29
-  }
30
-  onReplaceTab2Press() {
31
-    this._toggleDrawer();
32
-    // push/pop navigator actions affect the navigation stack of the current screen only.
33
-    // since side menu actions are normally directed at sibling tabs, push/pop will
34
-    // not help us. the recommended alternative is to use deep links for this purpose
35
-    this.props.navigator.handleDeepLink({
36
-      link: "tab2/example.PushedScreen"
37
-    });
38
-  }
39
-
40
-  onModalPress() {
41
-    this._toggleDrawer();
42
-    this.props.navigator.showModal({
43
-      title: "Modal",
44
-      container: "example.ModalScreen"
45
-    });
46
-  }
47
-
48
-  _toggleDrawer() {
49
-    this.props.navigator.toggleDrawer({
50
-      to: 'closed',
51
-      side: 'left',
52
-      animated: true
53
-    });
54
-  }
55
-}
56
-
57
-const styles = StyleSheet.create({
58
-  container: {
59
-    flex: 1,
60
-    alignItems: 'center',
61
-    backgroundColor: 'white',
62
-    justifyContent: 'center',
63
-    width: 300
64
-  },
65
-  title: {
66
-    textAlign: 'center',
67
-    fontSize: 18,
68
-    marginBottom: 10,
69
-    marginTop:10,
70
-    fontWeight: '500'
71
-  },
72
-  button: {
73
-    textAlign: 'center',
74
-    fontSize: 18,
75
-    marginBottom: 10,
76
-    marginTop:10,
77
-    color: 'blue'
78
-  }
79
-});

+ 0
- 121
playground/src/__screens/StyledScreen.js 查看文件

@@ -1,121 +0,0 @@
1
-import React, {Component} from 'react';
2
-import {
3
-  Text,
4
-  View,
5
-  ScrollView,
6
-  TouchableOpacity,
7
-  Image,
8
-  StyleSheet,
9
-  Alert,
10
-  Platform
11
-} from 'react-native';
12
-
13
-export default class StyledScreen extends Component {
14
-  static navigatorStyle = {
15
-    drawUnderNavBar: true,
16
-    drawUnderTabBar: true,
17
-    navBarTranslucent: true
18
-  };
19
-  static navigatorButtons = {
20
-    rightButtons: [{
21
-      icon: require('../../img/navicon_edit.png'),
22
-      id: 'compose',
23
-      testID: 'e2e_is_awesome'
24
-    }]
25
-  };
26
-  constructor(props) {
27
-    super(props);
28
-    // if you want to listen on navigator events, set this up
29
-    this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
30
-  }
31
-  render() {
32
-    return (
33
-      <ScrollView style={styles.container}>
34
-        <Image style={{width: undefined, height: 100}} source={require('../../img/colors.png')} />
35
-
36
-        <View style={{padding: 20}}>
37
-          <TouchableOpacity onPress={ this.onPushPress.bind(this) }>
38
-            <Text style={styles.button}>Push Plain Screen</Text>
39
-          </TouchableOpacity>
40
-
41
-          <TouchableOpacity onPress={ this.onPushStyledPress.bind(this) }>
42
-            <Text style={styles.button}>Push Styled Screen</Text>
43
-          </TouchableOpacity>
44
-
45
-          <TouchableOpacity onPress={ this.onPopPress.bind(this) }>
46
-            <Text style={styles.button}>Pop Screen</Text>
47
-          </TouchableOpacity>
48
-
49
-          <TouchableOpacity onPress={ this.onSetSubtitlePress.bind(this) }>
50
-            <Text style={styles.button}>Set Subtitle</Text>
51
-          </TouchableOpacity>
52
-
53
-          <TouchableOpacity onPress={ this.onSetTitleImagePress.bind(this) }>
54
-            <Text style={styles.button}>Set Title Image</Text>
55
-          </TouchableOpacity>
56
-        </View>
57
-
58
-      </ScrollView>
59
-    );
60
-  }
61
-  onNavigatorEvent(event) {
62
-    if (event.id == 'compose') {
63
-      Alert.alert('NavBar', 'Compose button pressed');
64
-    }
65
-  }
66
-  onPushPress() {
67
-    this.props.navigator.push({
68
-      title: "More",
69
-      container: "com.example.PushedScreen"
70
-    });
71
-  }
72
-  onPushStyledPress() {
73
-    this.props.navigator.push({
74
-      title: "More",
75
-      container: "com.example.StyledScreen"
76
-    });
77
-  }
78
-  onPopPress() {
79
-    this.props.navigator.pop();
80
-  }
81
-
82
-  onSetSubtitlePress() {
83
-    if (Platform.OS === 'android') {
84
-      this.props.navigator.setSubTitle({
85
-        subtitle: 'Subtitle'
86
-      });
87
-    } else {
88
-      this.props.navigator.setTitle({
89
-        title: 'title',
90
-        subtitle: 'subtitle',
91
-        navigatorStyle: {
92
-          navBarSubtitleTextColor: '#ff00ff',
93
-          navBarTextColor: '#ffff00'
94
-
95
-        }
96
-      })
97
-    }
98
-  }
99
-
100
-  onSetTitleImagePress() {
101
-    this.props.navigator.setTitle({
102
-      title: 'title',
103
-      titleImage: require('../../img/one.png'),
104
-    })
105
-  }
106
-
107
-}
108
-
109
-const styles = StyleSheet.create({
110
-  container: {
111
-    flex: 1,
112
-    backgroundColor: 'white'
113
-  },
114
-  button: {
115
-    textAlign: 'center',
116
-    fontSize: 18,
117
-    marginBottom: 10,
118
-    marginTop:10,
119
-    color: 'blue'
120
-  }
121
-});

+ 0
- 20
playground/src/__screens/index.android.js 查看文件

@@ -1,20 +0,0 @@
1
-import {Navigation} from 'react-native-navigation';
2
-
3
-import FirstTabScreen from './FirstTabScreen';
4
-import SecondTabScreen from './SecondTabScreen';
5
-import PushedScreen from './PushedScreen';
6
-import StyledScreen from './StyledScreen';
7
-import SideMenu from './SideMenu';
8
-import ModalScreen from './ModalScreen';
9
-import CollapsingTopBarScreen from './CollapsingTopBarScreen';
10
-
11
-// register all screens of the app (including internal ones)
12
-export function registerScreens() {
13
-  Navigation.registerComponent('example.FirstTabScreen', () => FirstTabScreen);
14
-  Navigation.registerComponent('example.SecondTabScreen', () => SecondTabScreen);
15
-  Navigation.registerComponent('example.PushedScreen', () => PushedScreen);
16
-  Navigation.registerComponent('example.StyledScreen', () => StyledScreen);
17
-  Navigation.registerComponent('example.ModalScreen', () => ModalScreen);
18
-  Navigation.registerComponent('example.SideMenu', () => SideMenu);
19
-  Navigation.registerComponent('example.CollapsingTopBarScreen', () => CollapsingTopBarScreen);
20
-}

+ 0
- 28
playground/src/__screens/index.ios.js 查看文件

@@ -1,28 +0,0 @@
1
-import {Navigation} from 'react-native-navigation';
2
-
3
-import FirstTabScreen from './FirstTabScreen';
4
-import SecondTabScreen from './SecondTabScreen';
5
-import PushedScreen from './PushedScreen';
6
-import StyledScreen from './StyledScreen';
7
-import SideMenu from './SideMenu';
8
-import ModalScreen from './ModalScreen';
9
-import NotificationScreen from './NotificationScreen';
10
-import LightBoxScreen from './LightBoxScreen';
11
-
12
-// register all screens of the app (including internal ones)
13
-export function registerScreens() {
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
-	
28
-}

+ 34
- 6
playground/src/app.js 查看文件

@@ -1,10 +1,38 @@
1
-import Navigation from 'react-native-navigation';
1
+import React, {Component} from 'react';
2
+import {AppRegistry, View, Text} from 'react-native';
3
+
4
+//import Navigation from 'react-native-navigation';
5
+
6
+const styles = {
7
+  root: {
8
+    flexGrow: 1,
9
+    justifyContent: 'center',
10
+    alignItems: 'center',
11
+    backgroundColor: '#f5fcff'
12
+  },
13
+  h1: {
14
+    fontSize: 24,
15
+    textAlign: 'center',
16
+    margin: 10
17
+  }
18
+};
19
+
20
+class WelcomeScreen extends Component {
21
+  render() {
22
+    return (
23
+      <View style={styles.root}>
24
+        <Text style={styles.h1}>{`React Native Navigation!`}</Text>
25
+      </View>
26
+    );
27
+  }
28
+}
2 29
 
3 30
 export function start() {
4
-  Navigation.startApp({
5
-    container: {
6
-      key: 'com.example.WelcomeScreen'
7
-    }
8
-  });
31
+  AppRegistry.registerComponent('com.example.WelcomeScreen', () => WelcomeScreen);
32
+  //Navigation.startApp({
33
+  //  container: {
34
+  //    key: 'com.example.WelcomeScreen'
35
+  //  }
36
+  //});
9 37
 }
10 38
 

+ 2
- 2
src/commands/Commands.test.js 查看文件

@@ -9,11 +9,11 @@ describe('Commands', () => {
9 9
     it('receives params object', () => {
10 10
       uut.startApp({
11 11
         containerKey: {
12
-          container: 'example.MyContainer'
12
+          root: 'example.MyContainer'
13 13
         },
14 14
         drawer: {
15 15
           left: {
16
-            container: 'example.SideMenu'
16
+            root: 'example.SideMenu'
17 17
           }
18 18
         }
19 19
       });