Explorar el Código

improve styler, added commands json

Ran Greenberg hace 7 años
padre
commit
fc3203748e

+ 78
- 0
example/commands.json Ver fichero

@@ -0,0 +1,78 @@
1
+{
2
+  "singleScreenApp": {
3
+    "screen": {
4
+      "key": "com.example.FirstTabScreen"
5
+    }
6
+  },
7
+  "tabBasedApp": {
8
+    "tabs": [{
9
+             "screen": {
10
+              "key": "com.example.FirstTabScreen"
11
+             }
12
+             }, {
13
+             "screen": {
14
+              "key": "com.example.SecondTabScreen"
15
+             }
16
+             }, {
17
+             "screen": {
18
+              "key": "com.example.FirstTabScreen"
19
+             }
20
+             }]
21
+  },
22
+  "singleWithLeftSideMenu": {
23
+    "screen": {
24
+      "key": "com.example.MyScreen"
25
+    },
26
+    "sideMenu": {
27
+      "left": {
28
+        "key": "com.example.Menu"
29
+      }
30
+    }
31
+  },
32
+  "singleWithRightSideMenu": {
33
+    "screen": {
34
+      "key": "com.example.MyScreen"
35
+    },
36
+    "sideMenu": {
37
+      "right": {
38
+        "key": "com.example.Menu"
39
+      }
40
+    }
41
+  },
42
+  "singleWithBothMenus": {
43
+    "screen": {
44
+      "key": "com.example.MyScreen"
45
+    },
46
+    "sideMenu": {
47
+      "left": {
48
+        "key": "com.example.Menu1"
49
+      },
50
+      "right": {
51
+        "key": "com.example.Menu2"
52
+      }
53
+    }
54
+  },
55
+  "tabBasedWithSideMenu": {
56
+    "tabs": [{
57
+             "screen": {
58
+              "key": "com.example.FirstTabScreen"
59
+             }
60
+             }, {
61
+             "screen": {
62
+              "key": "com.example.SecondTabScreen"
63
+             }
64
+             }, {
65
+             "screen": {
66
+              "key": "com.example.FirstTabScreen"
67
+             }
68
+             }],
69
+    "sideMenu": {
70
+      "left": {
71
+        "key": "com.example.Menu1"
72
+      },
73
+      "right": {
74
+        "key": "com.example.Menu2"
75
+      }
76
+    }
77
+  }
78
+}

+ 3
- 1
ios/RNNStyler.h Ver fichero

@@ -16,7 +16,9 @@
16 16
 #define STYLE_DRAW_UNDER_TAB_BAR                                @"drawUnderTabBar"
17 17
 #define STYLE_NAV_BAR_TRANSLUCENT                               @"navBarTranslucent"
18 18
 #define STYLE_NAV_BAR_BLUR                                      @"navBarBlur"
19
-//#define STYLE_                      @""
19
+
20
+#define STYLE_NAV_BAR_SHADOW_IMAGE                              @"shadowImage"
21
+#define STYLE_NAV_BAR_BACKGROUND_IMAGE                          @"bgImage"
20 22
 //#define STYLE_                      @""
21 23
 
22 24
 

+ 16
- 1
ios/RNNStyler.m Ver fichero

@@ -9,6 +9,7 @@
9 9
 #import "RNNStyler.h"
10 10
 #import "RCTConvert.h"
11 11
 
12
+
12 13
 @interface RNNStyler()
13 14
 
14 15
 @property (nonatomic, readwrite) BOOL _hidesBottomBarWhenPushed;
@@ -117,7 +118,7 @@
117 118
     else {
118 119
         [RNNStyler navBarForVC:vc].translucent = NO;
119 120
     }
120
-    
121
+
121 122
 }
122 123
 
123 124
 
@@ -147,4 +148,18 @@
147 148
 }
148 149
 
149 150
 
151
+-(NSDictionary*)storeOriginalNavBarImages:(UIViewController*)vc {
152
+    NSMutableDictionary *originalNavBarImages = [@{} mutableCopy];
153
+    UIImage *bgImage = [[RNNStyler navBarForVC:vc] backgroundImageForBarMetrics:UIBarMetricsDefault];
154
+    if (bgImage != nil) {
155
+        originalNavBarImages[STYLE_NAV_BAR_BACKGROUND_COLOR] = bgImage;
156
+    }
157
+    UIImage *shadowImage = [RNNStyler navBarForVC:vc].shadowImage;
158
+    if (shadowImage != nil) {
159
+        originalNavBarImages[STYLE_NAV_BAR_SHADOW_IMAGE] = shadowImage;
160
+    }
161
+    return originalNavBarImages;
162
+}
163
+
164
+
150 165
 @end

+ 31
- 2
ios/RNNViewController.m Ver fichero

@@ -1,6 +1,7 @@
1 1
 #import "RNNViewController.h"
2 2
 #import "RCTRootView.h"
3 3
 #import "MMDrawerController.h"
4
+#import "RNNStyler.h"
4 5
 
5 6
 
6 7
 #define SCREEN                  @"screen"
@@ -10,7 +11,6 @@
10 11
 #define SIDE_MENU_LEFT          @"left"
11 12
 #define SIDE_MENU_RIGHT         @"right"
12 13
 
13
-
14 14
 typedef enum
15 15
 {
16 16
     SideMenuModeNone        = 0,
@@ -19,6 +19,13 @@ typedef enum
19 19
 } SideMenuMode;
20 20
 
21 21
 
22
+@interface RNNViewController ()
23
+
24
+@property (nonatomic, strong) RNNStyler *styler;
25
+
26
+@end
27
+
28
+
22 29
 @implementation RNNViewController
23 30
 
24 31
 
@@ -44,6 +51,29 @@ typedef enum
44 51
 }
45 52
 
46 53
 
54
+#pragma mark - System Methods
55
+
56
+
57
+- (BOOL)hidesBottomBarWhenPushed
58
+{
59
+    if (!self.styler._hidesBottomBarWhenPushed) return NO;
60
+    return (self.navigationController.topViewController == self);
61
+}
62
+
63
+- (BOOL)prefersStatusBarHidden
64
+{
65
+    if (self.styler._statusBarHidden) {
66
+        return YES;
67
+    }
68
+    if (self.styler._statusBarHideWithNavBar) {
69
+        return self.navigationController.isNavigationBarHidden;
70
+    }
71
+    else {
72
+        return NO;
73
+    }
74
+}
75
+
76
+
47 77
 #pragma mark - Helper methods
48 78
 
49 79
 
@@ -149,5 +179,4 @@ typedef enum
149 179
     return controller;
150 180
 }
151 181
 
152
-
153 182
 @end

+ 1
- 1
ios/ReactNativeNavigation.xcodeproj/project.pbxproj Ver fichero

@@ -272,7 +272,7 @@
272 272
 			isa = PBXProject;
273 273
 			attributes = {
274 274
 				LastUpgradeCheck = 0710;
275
-				ORGANIZATIONNAME = artal;
275
+				ORGANIZATIONNAME = Wix;
276 276
 				TargetAttributes = {
277 277
 					D8AFADBC1BEE6F3F00A4592D = {
278 278
 						CreatedOnToolsVersion = 7.1;