Browse Source

added portraitOnlyMode

Daniel Zlotin 8 years ago
parent
commit
bf06c6a245

+ 3
- 0
android/app/src/main/AndroidManifest.xml View File

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

+ 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

+ 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
+}

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