Pārlūkot izejas kodu

added portraitOnlyMode

Daniel Zlotin 8 gadus atpakaļ
vecāks
revīzija
bf06c6a245

+ 3
- 0
android/app/src/main/AndroidManifest.xml Parādīt failu

@@ -5,6 +5,9 @@
5 5
         android:allowBackup="false"
6 6
         android:theme="@style/Theme.AppCompat.Light.NoActionBar">
7 7
         <activity android:name=".controllers.NavigationActivity" />
8
+        <activity
9
+            android:name=".controllers.PortraitNavigationActivity"
10
+            android:screenOrientation="portrait" />
8 11
         <activity
9 12
             android:name="com.facebook.react.devsupport.DevSettingsActivity"
10 13
             android:exported="false" />

+ 5
- 1
android/app/src/main/java/com/reactnativenavigation/bridge/NavigationReactModule.java Parādīt failu

@@ -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

+ 9
- 4
android/app/src/main/java/com/reactnativenavigation/controllers/NavigationCommandsHandler.java Parādīt failu

@@ -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 Parādīt failu

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

+ 20
- 19
example/src/app.js Parādīt failu

@@ -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
+//});