Browse Source

improve styler, added commands json

Ran Greenberg 7 years ago
parent
commit
fc3203748e

+ 78
- 0
example/commands.json View File

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 View File

16
 #define STYLE_DRAW_UNDER_TAB_BAR                                @"drawUnderTabBar"
16
 #define STYLE_DRAW_UNDER_TAB_BAR                                @"drawUnderTabBar"
17
 #define STYLE_NAV_BAR_TRANSLUCENT                               @"navBarTranslucent"
17
 #define STYLE_NAV_BAR_TRANSLUCENT                               @"navBarTranslucent"
18
 #define STYLE_NAV_BAR_BLUR                                      @"navBarBlur"
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
 //#define STYLE_                      @""
22
 //#define STYLE_                      @""
21
 
23
 
22
 
24
 

+ 16
- 1
ios/RNNStyler.m View File

9
 #import "RNNStyler.h"
9
 #import "RNNStyler.h"
10
 #import "RCTConvert.h"
10
 #import "RCTConvert.h"
11
 
11
 
12
+
12
 @interface RNNStyler()
13
 @interface RNNStyler()
13
 
14
 
14
 @property (nonatomic, readwrite) BOOL _hidesBottomBarWhenPushed;
15
 @property (nonatomic, readwrite) BOOL _hidesBottomBarWhenPushed;
117
     else {
118
     else {
118
         [RNNStyler navBarForVC:vc].translucent = NO;
119
         [RNNStyler navBarForVC:vc].translucent = NO;
119
     }
120
     }
120
-    
121
+
121
 }
122
 }
122
 
123
 
123
 
124
 
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
 @end
165
 @end

+ 31
- 2
ios/RNNViewController.m View File

1
 #import "RNNViewController.h"
1
 #import "RNNViewController.h"
2
 #import "RCTRootView.h"
2
 #import "RCTRootView.h"
3
 #import "MMDrawerController.h"
3
 #import "MMDrawerController.h"
4
+#import "RNNStyler.h"
4
 
5
 
5
 
6
 
6
 #define SCREEN                  @"screen"
7
 #define SCREEN                  @"screen"
10
 #define SIDE_MENU_LEFT          @"left"
11
 #define SIDE_MENU_LEFT          @"left"
11
 #define SIDE_MENU_RIGHT         @"right"
12
 #define SIDE_MENU_RIGHT         @"right"
12
 
13
 
13
-
14
 typedef enum
14
 typedef enum
15
 {
15
 {
16
     SideMenuModeNone        = 0,
16
     SideMenuModeNone        = 0,
19
 } SideMenuMode;
19
 } SideMenuMode;
20
 
20
 
21
 
21
 
22
+@interface RNNViewController ()
23
+
24
+@property (nonatomic, strong) RNNStyler *styler;
25
+
26
+@end
27
+
28
+
22
 @implementation RNNViewController
29
 @implementation RNNViewController
23
 
30
 
24
 
31
 
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
 #pragma mark - Helper methods
77
 #pragma mark - Helper methods
48
 
78
 
49
 
79
 
149
     return controller;
179
     return controller;
150
 }
180
 }
151
 
181
 
152
-
153
 @end
182
 @end

+ 1
- 1
ios/ReactNativeNavigation.xcodeproj/project.pbxproj View File

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