Quellcode durchsuchen

Merge branch 'master' into mergeController

Daniel Zlotin vor 8 Jahren
Ursprung
Commit
0a2ab4f3ba

+ 9
- 1
android/app/src/main/AndroidManifest.xml Datei anzeigen

@@ -1,8 +1,16 @@
1 1
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2 2
     package="com.reactnativenavigation">
3 3
 
4
-    <application>
4
+    <application
5
+        android:allowBackup="false"
6
+        android:theme="@style/Theme.AppCompat.Light.NoActionBar">
5 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 14
     </application>
7 15
 
8 16
 </manifest>

+ 5
- 1
android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactModule.java Datei anzeigen

@@ -41,7 +41,11 @@ public class NavigationReactModule extends ReactContextBaseJavaModule {
41 41
 
42 42
     @ReactMethod
43 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 51
     @ReactMethod

+ 2
- 1
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationActivity.java Datei anzeigen

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

+ 9
- 4
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java Datei anzeigen

@@ -27,8 +27,13 @@ public class NavigationCommandsHandler {
27 27
      *
28 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 37
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
33 38
         intent.putExtra(ACTIVITY_PARAMS_BUNDLE, params);
34 39
         NavigationApplication.instance.startActivity(intent);
@@ -183,8 +188,8 @@ public class NavigationCommandsHandler {
183 188
     }
184 189
 
185 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 193
         final NavigationActivity currentActivity = NavigationActivity.currentActivity;
189 194
         if (currentActivity == null) {
190 195
             return;

+ 4
- 0
android/app/src/main/java/com/reactnativenavigation/controllers/PortraitNavigationActivity.java Datei anzeigen

@@ -0,0 +1,4 @@
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 Datei anzeigen

@@ -16,27 +16,30 @@ public abstract class SplashActivity extends AppCompatActivity {
16 16
     protected void onCreate(@Nullable Bundle savedInstanceState) {
17 17
         super.onCreate(savedInstanceState);
18 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 26
             return;
23 27
         }
24 28
 
25 29
         if (ReactDevPermission.shouldAskPermission()) {
26 30
             ReactDevPermission.askPermission(this);
31
+            return;
32
+        }
33
+
34
+        if (NavigationApplication.instance.isReactContextInitialized()) {
27 35
             finish();
28 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 40
         NavigationApplication.instance.startReactContextOnceInBackgroundAndExecuteJS();
32 41
     }
33 42
 
34
-    @Override
35
-    protected void onPause() {
36
-        super.onPause();
37
-        finish();
38
-    }
39
-
40 43
     private void setSplashLayout() {
41 44
         final int splashLayout = getSplashLayout();
42 45
         if (splashLayout > 0) {

+ 5
- 0
android/app/src/main/java/com/reactnativenavigation/react/NavigationReactGateway.java Datei anzeigen

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

+ 2
- 0
android/app/src/main/java/com/reactnativenavigation/react/ReactGateway.java Datei anzeigen

@@ -29,4 +29,6 @@ public interface ReactGateway {
29 29
     void onBackPressed();
30 30
 
31 31
     void onActivityResult(int requestCode, int resultCode, Intent data);
32
+
33
+    boolean hasStartedCreatingContext();
32 34
 }

+ 1
- 4
example/android/app/src/main/AndroidManifest.xml Datei anzeigen

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

+ 0
- 8
example/android/app/src/main/res/values/styles.xml Datei anzeigen

@@ -1,8 +0,0 @@
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 Datei anzeigen

@@ -29,23 +29,24 @@ Navigation.startTabBasedApp({
29 29
     left: {
30 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 Datei anzeigen

@@ -120,7 +120,10 @@ export default class FirstTabScreen extends Component {
120 120
       screen: "example.LightBoxScreen",
121 121
       style: {
122 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 Datei anzeigen

@@ -1,10 +1,10 @@
1 1
 import React, {Component} from 'react';
2 2
 import {
3
+  StyleSheet,
3 4
   Text,
4 5
   View,
5
-  ScrollView,
6 6
   TouchableOpacity,
7
-  StyleSheet
7
+  Dimensions
8 8
 } from 'react-native';
9 9
 
10 10
 export default class LightBoxScreen extends Component {
@@ -13,16 +13,19 @@ export default class LightBoxScreen extends Component {
13 13
   }
14 14
   render() {
15 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 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 27
           <Text style={styles.button}>Dismiss</Text>
24 28
         </TouchableOpacity>
25
-
26 29
       </View>
27 30
     );
28 31
   }
@@ -31,7 +34,25 @@ export default class LightBoxScreen extends Component {
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 56
   button: {
36 57
     textAlign: 'center',
37 58
     fontSize: 18,

+ 1
- 1
package.json Datei anzeigen

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