Browse Source

Merge branch 'master' into mergeController

Daniel Zlotin 8 years ago
parent
commit
0a2ab4f3ba

+ 9
- 1
android/app/src/main/AndroidManifest.xml View File

1
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
1
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
     package="com.reactnativenavigation">
2
     package="com.reactnativenavigation">
3
 
3
 
4
-    <application>
4
+    <application
5
+        android:allowBackup="false"
6
+        android:theme="@style/Theme.AppCompat.Light.NoActionBar">
5
         <activity android:name=".controllers.NavigationActivity" />
7
         <activity android:name=".controllers.NavigationActivity" />
8
+        <activity
9
+            android:name=".controllers.PortraitNavigationActivity"
10
+            android:screenOrientation="portrait" />
11
+        <activity
12
+            android:name="com.facebook.react.devsupport.DevSettingsActivity"
13
+            android:exported="false" />
6
     </application>
14
     </application>
7
 
15
 
8
 </manifest>
16
 </manifest>

+ 5
- 1
android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactModule.java View File

41
 
41
 
42
     @ReactMethod
42
     @ReactMethod
43
     public void startApp(final ReadableMap params) {
43
     public void startApp(final ReadableMap params) {
44
-        NavigationCommandsHandler.startApp(BundleConverter.toBundle(params));
44
+        boolean portraitOnlyMode = false;
45
+        if (params.hasKey("portraitOnlyMode")) {
46
+            portraitOnlyMode = params.getBoolean("portraitOnlyMode");
47
+        }
48
+        NavigationCommandsHandler.startApp(BundleConverter.toBundle(params), portraitOnlyMode);
45
     }
49
     }
46
 
50
 
47
     @ReactMethod
51
     @ReactMethod

+ 2
- 1
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java View File

104
         }
104
         }
105
         if (layout != null) {
105
         if (layout != null) {
106
             layout.destroy();
106
             layout.destroy();
107
+            layout = null;
107
         }
108
         }
108
     }
109
     }
109
 
110
 
120
 
121
 
121
     @Override
122
     @Override
122
     public void onBackPressed() {
123
     public void onBackPressed() {
123
-        if (!layout.onBackPressed()) {
124
+        if (layout != null && !layout.onBackPressed()) {
124
             NavigationApplication.instance.getReactGateway().onBackPressed();
125
             NavigationApplication.instance.getReactGateway().onBackPressed();
125
         }
126
         }
126
     }
127
     }

+ 9
- 4
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java View File

27
      *
27
      *
28
      * @param params ActivityParams as bundle
28
      * @param params ActivityParams as bundle
29
      */
29
      */
30
-    public static void startApp(Bundle params) {
31
-        Intent intent = new Intent(NavigationApplication.instance, NavigationActivity.class);
30
+    public static void startApp(Bundle params, boolean portraitOnlyMode) {
31
+        Intent intent;
32
+        if (portraitOnlyMode) {
33
+            intent = new Intent(NavigationApplication.instance, PortraitNavigationActivity.class);
34
+        } else {
35
+            intent = new Intent(NavigationApplication.instance, NavigationActivity.class);
36
+        }
32
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
37
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
33
         intent.putExtra(ACTIVITY_PARAMS_BUNDLE, params);
38
         intent.putExtra(ACTIVITY_PARAMS_BUNDLE, params);
34
         NavigationApplication.instance.startActivity(intent);
39
         NavigationApplication.instance.startActivity(intent);
183
     }
188
     }
184
 
189
 
185
     public static void setScreenTitleBarLeftButtons(final String screenInstanceId,
190
     public static void setScreenTitleBarLeftButtons(final String screenInstanceId,
186
-                                                     final String navigatorEventId,
187
-                                                     final TitleBarLeftButtonParams titleBarButtons) {
191
+                                                    final String navigatorEventId,
192
+                                                    final TitleBarLeftButtonParams titleBarButtons) {
188
         final NavigationActivity currentActivity = NavigationActivity.currentActivity;
193
         final NavigationActivity currentActivity = NavigationActivity.currentActivity;
189
         if (currentActivity == null) {
194
         if (currentActivity == null) {
190
             return;
195
             return;

+ 4
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/PortraitNavigationActivity.java View File

1
+package com.reactnativenavigation.controllers;
2
+
3
+public class PortraitNavigationActivity extends NavigationActivity {
4
+}

+ 11
- 8
android/app/src/main/java/com/reactnativenavigation/controllers/SplashActivity.java View File

16
     protected void onCreate(@Nullable Bundle savedInstanceState) {
16
     protected void onCreate(@Nullable Bundle savedInstanceState) {
17
         super.onCreate(savedInstanceState);
17
         super.onCreate(savedInstanceState);
18
         setSplashLayout();
18
         setSplashLayout();
19
+    }
19
 
20
 
20
-        if (NavigationApplication.instance.isReactContextInitialized()) {
21
-            finish();
21
+    @Override
22
+    protected void onResume() {
23
+        super.onResume();
24
+
25
+        if (NavigationApplication.instance.getReactGateway().hasStartedCreatingContext()) {
22
             return;
26
             return;
23
         }
27
         }
24
 
28
 
25
         if (ReactDevPermission.shouldAskPermission()) {
29
         if (ReactDevPermission.shouldAskPermission()) {
26
             ReactDevPermission.askPermission(this);
30
             ReactDevPermission.askPermission(this);
31
+            return;
32
+        }
33
+
34
+        if (NavigationApplication.instance.isReactContextInitialized()) {
27
             finish();
35
             finish();
28
             return;
36
             return;
29
         }
37
         }
30
 
38
 
39
+        // TODO I'm starting to think this entire flow is incorrect and should be done in Application
31
         NavigationApplication.instance.startReactContextOnceInBackgroundAndExecuteJS();
40
         NavigationApplication.instance.startReactContextOnceInBackgroundAndExecuteJS();
32
     }
41
     }
33
 
42
 
34
-    @Override
35
-    protected void onPause() {
36
-        super.onPause();
37
-        finish();
38
-    }
39
-
40
     private void setSplashLayout() {
43
     private void setSplashLayout() {
41
         final int splashLayout = getSplashLayout();
44
         final int splashLayout = getSplashLayout();
42
         if (splashLayout > 0) {
45
         if (splashLayout > 0) {

+ 5
- 0
android/app/src/main/java/com/reactnativenavigation/react/NavigationReactGateway.java View File

38
         return host.hasInstance() && getReactInstanceManager().getCurrentReactContext() != null;
38
         return host.hasInstance() && getReactInstanceManager().getCurrentReactContext() != null;
39
     }
39
     }
40
 
40
 
41
+    @Override
42
+    public boolean hasStartedCreatingContext() {
43
+        return getReactInstanceManager().hasStartedCreatingInitialContext();
44
+    }
45
+
41
     public ReactContext getReactContext() {
46
     public ReactContext getReactContext() {
42
         return getReactInstanceManager().getCurrentReactContext();
47
         return getReactInstanceManager().getCurrentReactContext();
43
     }
48
     }

+ 2
- 0
android/app/src/main/java/com/reactnativenavigation/react/ReactGateway.java View File

29
     void onBackPressed();
29
     void onBackPressed();
30
 
30
 
31
     void onActivityResult(int requestCode, int resultCode, Intent data);
31
     void onActivityResult(int requestCode, int resultCode, Intent data);
32
+
33
+    boolean hasStartedCreatingContext();
32
 }
34
 }

+ 1
- 4
example/android/app/src/main/AndroidManifest.xml View File

7
         android:name=".MyApplication"
7
         android:name=".MyApplication"
8
         android:allowBackup="false"
8
         android:allowBackup="false"
9
         android:icon="@mipmap/ic_launcher"
9
         android:icon="@mipmap/ic_launcher"
10
-        android:label="@string/app_name"
11
-        android:theme="@style/AppTheme">
10
+        android:label="@string/app_name">
12
         <activity
11
         <activity
13
             android:name=".MainActivity"
12
             android:name=".MainActivity"
14
-            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
15
             android:label="@string/app_name">
13
             android:label="@string/app_name">
16
             <intent-filter>
14
             <intent-filter>
17
                 <action android:name="android.intent.action.MAIN" />
15
                 <action android:name="android.intent.action.MAIN" />
18
                 <category android:name="android.intent.category.LAUNCHER" />
16
                 <category android:name="android.intent.category.LAUNCHER" />
19
             </intent-filter>
17
             </intent-filter>
20
         </activity>
18
         </activity>
21
-        <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
22
     </application>
19
     </application>
23
 
20
 
24
 </manifest>
21
 </manifest>

+ 0
- 8
example/android/app/src/main/res/values/styles.xml View File

1
-<resources>
2
-
3
-    <!-- Base application theme. -->
4
-    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
5
-        <!-- Customize your theme here. -->
6
-    </style>
7
-
8
-</resources>

+ 20
- 19
example/src/app.js View File

29
     left: {
29
     left: {
30
       screen: 'example.SideMenu'
30
       screen: 'example.SideMenu'
31
     }
31
     }
32
-  }
32
+  },
33
+  portraitOnlyMode: true
33
 });
34
 });
34
-// Navigation.startSingleScreenApp({
35
-//   screen: {
36
-//     screen: 'example.FirstTabScreen',
37
-//     title: 'Navigation',
38
-//     navigatorStyle: {
39
-//       navBarBackgroundColor: '#4dbce9',
40
-//       navBarTextColor: '#ffff00',
41
-//       navBarSubtitleTextColor: '#ff0000',
42
-//       navBarButtonColor: '#ffffff',
43
-//       statusBarTextColorScheme: 'light'
44
-//     }
45
-//   },
46
-//   drawer: {
47
-//     left: {
48
-//       screen: 'example.SideMenu'
49
-//     }
50
-//   }
51
-// });
35
+//Navigation.startSingleScreenApp({
36
+//  screen: {
37
+//    screen: 'example.FirstTabScreen',
38
+//    title: 'Navigation',
39
+//    navigatorStyle: {
40
+//      navBarBackgroundColor: '#4dbce9',
41
+//      navBarTextColor: '#ffff00',
42
+//      navBarSubtitleTextColor: '#ff0000',
43
+//      navBarButtonColor: '#ffffff',
44
+//      statusBarTextColorScheme: 'light'
45
+//    }
46
+//  },
47
+//  drawer: {
48
+//    left: {
49
+//      screen: 'example.SideMenu'
50
+//    }
51
+//  }
52
+//});

+ 4
- 1
example/src/screens/FirstTabScreen.js View File

120
       screen: "example.LightBoxScreen",
120
       screen: "example.LightBoxScreen",
121
       style: {
121
       style: {
122
         backgroundBlur: "dark"
122
         backgroundBlur: "dark"
123
-      }
123
+      },
124
+      passProps: {
125
+        greeting: 'hey there'
126
+      },
124
     });
127
     });
125
   }
128
   }
126
 
129
 

+ 31
- 10
example/src/screens/LightBoxScreen.js View File

1
 import React, {Component} from 'react';
1
 import React, {Component} from 'react';
2
 import {
2
 import {
3
+  StyleSheet,
3
   Text,
4
   Text,
4
   View,
5
   View,
5
-  ScrollView,
6
   TouchableOpacity,
6
   TouchableOpacity,
7
-  StyleSheet
7
+  Dimensions
8
 } from 'react-native';
8
 } from 'react-native';
9
 
9
 
10
 export default class LightBoxScreen extends Component {
10
 export default class LightBoxScreen extends Component {
13
   }
13
   }
14
   render() {
14
   render() {
15
     return (
15
     return (
16
-      <View style={{width: 300, height: 200, padding: 20}}>
17
-
18
-        <Text>
19
-          This is a LightBox
16
+      <View style={styles.container}>
17
+        <Text style={styles.welcome}>
18
+          This is a LightBox!
20
         </Text>
19
         </Text>
21
-
22
-        <TouchableOpacity onPress={ this.onDismissPress.bind(this) }>
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()}>
23
           <Text style={styles.button}>Dismiss</Text>
27
           <Text style={styles.button}>Dismiss</Text>
24
         </TouchableOpacity>
28
         </TouchableOpacity>
25
-
26
       </View>
29
       </View>
27
     );
30
     );
28
   }
31
   }
31
   }
34
   }
32
 }
35
 }
33
 
36
 
34
-const styles = StyleSheet.create({
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
+  },
35
   button: {
56
   button: {
36
     textAlign: 'center',
57
     textAlign: 'center',
37
     fontSize: 18,
58
     fontSize: 18,

+ 1
- 1
package.json View File

1
 {
1
 {
2
   "name": "react-native-navigation",
2
   "name": "react-native-navigation",
3
-  "version": "2.0.0-experimental.118",
3
+  "version": "2.0.0-experimental.121",
4
   "description": "React Native Navigation - truly native navigation for iOS and Android",
4
   "description": "React Native Navigation - truly native navigation for iOS and Android",
5
   "license": "MIT",
5
   "license": "MIT",
6
   "nativePackage": true,
6
   "nativePackage": true,