Browse Source

Feature/styling (#307)

* Set to use old bridge for compatibility with 0.30+

* Fixed crash occurring when tabBarBackgroundColor or tabBarButtonColor is not supplied

* Adds setStyle property to index.js

* Adds native code for setting style on RCCViewController

* Fixes setStyle function

* Fixes setting style on navigator

* Adds some styling to tab bar controller and fixes some bugs

* Adds ability to set modal presentation style

* Makes sure autoAdjustScrollViewInsets isn't propagated through when push another view controller

* Changes import to reference controllers rather than react-native-controllers and fixes setStyle mutating colours

* Fixed to work with RN 33

* Fixes updating title font styling with new RCCTitleViewHelper logic

* Fixes subtitle being shown

* Adds extendedLayoutIncludesOpaqueBars to navigation styling

* Adds ability to add shadows to text in navigation bar / tab bar

* Fixed merged ReactGateway.java file

* Fixed issue with rightButtons getting ignored in preference for empty Screen buttons

* Fixes compiler error
Simon Mitchell 7 years ago
parent
commit
356d42e063

+ 8
- 0
ios/Helpers/RCCTitleViewHelper.h View File

@@ -9,6 +9,14 @@
9 9
 #import <Foundation/Foundation.h>
10 10
 #import <UIKit/UIKit.h>
11 11
 
12
+@interface RCCTitleView : UIView
13
+
14
+@property (nonatomic, strong) UILabel *titleLabel;
15
+
16
+@property (nonatomic, strong) UILabel *subtitleLabel;
17
+
18
+@end
19
+
12 20
 @interface RCCTitleViewHelper : NSObject
13 21
 
14 22
 

+ 17
- 27
ios/Helpers/RCCTitleViewHelper.m View File

@@ -8,6 +8,12 @@
8 8
 
9 9
 #import "RCCTitleViewHelper.h"
10 10
 #import "RCTConvert.h"
11
+#import "RCTHelpers.h"
12
+
13
+@implementation RCCTitleView
14
+
15
+
16
+@end
11 17
 
12 18
 @interface RCCTitleViewHelper ()
13 19
 
@@ -18,7 +24,7 @@
18 24
 @property (nonatomic, strong) NSString *subtitle;
19 25
 @property (nonatomic, strong) id titleImageData;
20 26
 
21
-@property (nonatomic, strong) UIView *titleView;
27
+@property (nonatomic, strong) RCCTitleView *titleView;
22 28
 
23 29
 @end
24 30
 
@@ -50,15 +56,11 @@ navigationController:(UINavigationController*)navigationController
50 56
     
51 57
     CGRect navigationBarBounds = self.navigationController.navigationBar.bounds;
52 58
     
53
-    UILabel *titleLabel;
54
-    UILabel *subtitleLabel;
55
-    
56
-    self.titleView = [[UIView alloc] initWithFrame:navigationBarBounds];
59
+    self.titleView = [[RCCTitleView alloc] initWithFrame:navigationBarBounds];
57 60
     self.titleView.backgroundColor = [UIColor clearColor];
58 61
     self.titleView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
59 62
     self.titleView.clipsToBounds = YES;
60 63
     
61
-    
62 64
     self.viewController.title = self.title;
63 65
     
64 66
     if ([self isTitleOnly]) {
@@ -74,15 +76,15 @@ navigationController:(UINavigationController*)navigationController
74 76
     
75 77
     if (self.subtitle)
76 78
     {
77
-        subtitleLabel = [self setupSubtitle:style];
79
+        self.titleView.subtitleLabel = [self setupSubtitle:style];
78 80
     }
79 81
     
80 82
     if (self.title)
81 83
     {
82
-        titleLabel = [self setupTitle:style];
84
+        self.titleView.titleLabel = [self setupTitle:style];
83 85
     }
84 86
     
85
-    [self centerTitleView:navigationBarBounds titleLabel:titleLabel subtitleLabel:subtitleLabel];
87
+    [self centerTitleView:navigationBarBounds titleLabel:self.titleView.titleLabel subtitleLabel:self.titleView.subtitleLabel];
86 88
     
87 89
     self.viewController.navigationItem.titleView = self.titleView;
88 90
 }
@@ -135,28 +137,14 @@ navigationController:(UINavigationController*)navigationController
135 137
     subtitleFrame.origin.y = subtitleFrame.size.height;
136 138
     
137 139
     UILabel *subtitleLabel = [[UILabel alloc] initWithFrame:subtitleFrame];
138
-    subtitleLabel.text = self.subtitle;
139 140
     subtitleLabel.textAlignment = NSTextAlignmentCenter;
140 141
     subtitleLabel.backgroundColor = [UIColor clearColor];
141 142
     subtitleLabel.autoresizingMask = self.titleView.autoresizingMask;
142
-    UIFont *subtitleFont = [UIFont systemFontOfSize:14.f];
143
-    
144
-    id fontSize = style[@"navBarSubtitleFontSize"];
145
-    if (fontSize) {
146
-        CGFloat fontSizeFloat = [RCTConvert CGFloat:fontSize];
147
-        subtitleFont = [UIFont boldSystemFontOfSize:fontSizeFloat];
148
-    }
149 143
     
150
-    subtitleLabel.font = subtitleFont;
144
+    NSMutableDictionary *subtitleAttributes = [RCTHelpers textAttributesFromDictionary:style withPrefix:@"navBarSubtitle" baseFont:[UIFont systemFontOfSize:14.f]];
145
+    [subtitleLabel setAttributedText:[[NSAttributedString alloc] initWithString:self.subtitle attributes:subtitleAttributes]];
151 146
     
152
-    id navBarSubtitleTextColor = style[@"navBarSubtitleTextColor"];
153
-    if (navBarSubtitleTextColor)
154
-    {
155
-        UIColor *color = navBarSubtitleTextColor != (id)[NSNull null] ? [RCTConvert UIColor:navBarSubtitleTextColor] : nil;
156
-        subtitleLabel.textColor = color;
157
-    }
158
-    
159
-    CGSize labelSize = [subtitleLabel.text sizeWithAttributes:@{NSFontAttributeName:subtitleFont}];
147
+    CGSize labelSize = [subtitleLabel.text sizeWithAttributes:subtitleAttributes];
160 148
     CGRect labelframe = subtitleLabel.frame;
161 149
     labelframe.size = labelSize;
162 150
     subtitleLabel.frame = labelframe;
@@ -175,7 +163,6 @@ navigationController:(UINavigationController*)navigationController
175 163
         titleFrame.size.height /= 2;
176 164
     }
177 165
     UILabel *titleLabel = [[UILabel alloc] initWithFrame:titleFrame];
178
-    titleLabel.text = self.title;
179 166
     titleLabel.textAlignment = NSTextAlignmentCenter;
180 167
     titleLabel.backgroundColor = [UIColor clearColor];
181 168
     
@@ -191,6 +178,9 @@ navigationController:(UINavigationController*)navigationController
191 178
     
192 179
     titleLabel.font = titleFont;
193 180
     
181
+    NSMutableDictionary *titleAttributes = [RCTHelpers textAttributesFromDictionary:style withPrefix:@"navBarTitle" baseFont:[UIFont systemFontOfSize:14.f]];
182
+    [titleLabel setAttributedText:[[NSAttributedString alloc] initWithString:self.title attributes:titleAttributes]];
183
+    
194 184
     CGSize labelSize = [titleLabel.text sizeWithAttributes:@{NSFontAttributeName:titleFont}];
195 185
     CGRect labelframe = titleLabel.frame;
196 186
     labelframe.size = labelSize;

+ 2
- 0
ios/Helpers/RCTHelpers.h View File

@@ -11,4 +11,6 @@
11 11
 
12 12
 @interface RCTHelpers : NSObject
13 13
 +(BOOL)removeYellowBox:(RCTRootView*)reactRootView;
14
++ (NSMutableDictionary *)textAttributesFromDictionary:(NSDictionary *)dictionary withPrefix:(NSString *)prefix;
15
++ (NSMutableDictionary *)textAttributesFromDictionary:(NSDictionary *)dictionary withPrefix:(NSString *)prefix baseFont:(UIFont *)font;
14 16
 @end

+ 130
- 4
ios/Helpers/RCTHelpers.m View File

@@ -9,6 +9,7 @@
9 9
 #import "RCTHelpers.h"
10 10
 #import "RCTView.h"
11 11
 #import "RCTScrollView.h"
12
+#import "RCTFont.h"
12 13
 
13 14
 @implementation RCTHelpers
14 15
 
@@ -24,10 +25,10 @@
24 25
 }
25 26
 
26 27
 /*
27
-    The YellowBox is added to each RCTRootView. Regardless if there are warnings or not, if there's a warning anywhere in the app - it is added
28
-    Since it is always appears on the top, it blocks interactions with other components.
29
-    It is most noticeable in RCCLightBox and RCCNotification where button (for example) are not clickable if placed at the bottom part of the view
30
-*/
28
+ The YellowBox is added to each RCTRootView. Regardless if there are warnings or not, if there's a warning anywhere in the app - it is added
29
+ Since it is always appears on the top, it blocks interactions with other components.
30
+ It is most noticeable in RCCLightBox and RCCNotification where button (for example) are not clickable if placed at the bottom part of the view
31
+ */
31 32
 
32 33
 +(BOOL)removeYellowBox:(RCTRootView*)reactRootView
33 34
 {
@@ -74,5 +75,130 @@
74 75
     return removed;
75 76
 }
76 77
 
78
++ (NSMutableDictionary *)textAttributesFromDictionary:(NSDictionary *)dictionary withPrefix:(NSString *)prefix baseFont:(UIFont *)baseFont
79
+{
80
+    NSMutableDictionary *textAttributes = [NSMutableDictionary new];
81
+    
82
+    NSString *colorKey = @"color";
83
+    NSString *familyKey = @"fontFamily";
84
+    NSString *weightKey = @"fontWeight";
85
+    NSString *sizeKey = @"fontSize";
86
+    NSString *styleKey = @"fontStyle";
87
+    NSString *shadowColourKey = @"shadowColor";
88
+    NSString *shadowOffsetKey = @"shadowOffset";
89
+    NSString *shadowBlurRadiusKey = @"shadowBlurRadius";
90
+    NSString *showShadowKey = @"showShadow";
91
+    
92
+    if (prefix) {
93
+        
94
+        colorKey = [colorKey stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:[colorKey substringToIndex:1].capitalizedString];
95
+        colorKey = [NSString stringWithFormat:@"%@%@", prefix, colorKey];
96
+        
97
+        familyKey = [familyKey stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:[familyKey substringToIndex:1].capitalizedString];
98
+        familyKey = [NSString stringWithFormat:@"%@%@", prefix, familyKey];
99
+        
100
+        weightKey = [weightKey stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:[weightKey substringToIndex:1].capitalizedString];
101
+        weightKey = [NSString stringWithFormat:@"%@%@", prefix, weightKey];
102
+        
103
+        sizeKey = [sizeKey stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:[sizeKey substringToIndex:1].capitalizedString];
104
+        sizeKey = [NSString stringWithFormat:@"%@%@", prefix, sizeKey];
105
+        
106
+        styleKey = [styleKey stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:[styleKey substringToIndex:1].capitalizedString];
107
+        styleKey = [NSString stringWithFormat:@"%@%@", prefix, styleKey];
108
+        
109
+        shadowColourKey = [shadowColourKey stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:[shadowColourKey substringToIndex:1].capitalizedString];
110
+        shadowColourKey = [NSString stringWithFormat:@"%@%@", prefix, shadowColourKey];
111
+        
112
+        shadowOffsetKey = [shadowOffsetKey stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:[shadowOffsetKey substringToIndex:1].capitalizedString];
113
+        shadowOffsetKey = [NSString stringWithFormat:@"%@%@", prefix, shadowOffsetKey];
114
+        
115
+        shadowBlurRadiusKey = [shadowBlurRadiusKey stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:[shadowBlurRadiusKey substringToIndex:1].capitalizedString];
116
+        shadowBlurRadiusKey = [NSString stringWithFormat:@"%@%@", prefix, shadowBlurRadiusKey];
117
+        
118
+        showShadowKey = [showShadowKey stringByReplacingCharactersInRange:NSMakeRange(0, 1) withString:[showShadowKey substringToIndex:1].capitalizedString];
119
+        showShadowKey = [NSString stringWithFormat:@"%@%@", prefix, showShadowKey];
120
+    }
121
+    
122
+    NSShadow *shadow;
123
+    
124
+    NSNumber *shadowColor = dictionary[shadowColourKey];
125
+    if (shadowColor && [shadowColor isKindOfClass:[NSNumber class]]) {
126
+        if (!shadow) {
127
+            shadow = [NSShadow new];
128
+        }
129
+        shadow.shadowColor = [RCTConvert UIColor:shadowColor];
130
+    }
131
+    
132
+    NSDictionary *shadowOffsetDict = dictionary[shadowOffsetKey];
133
+    if (shadowOffsetDict && [shadowOffsetDict isKindOfClass:[NSDictionary class]]) {
134
+        CGSize shadowOffset = [RCTConvert CGSize:shadowOffsetDict];
135
+        if (!shadow) {
136
+            shadow = [NSShadow new];
137
+        }
138
+        shadow.shadowOffset = shadowOffset;
139
+    }
140
+    
141
+    NSNumber *shadowRadius = dictionary[shadowBlurRadiusKey];
142
+    if (shadowRadius) {
143
+        CGFloat radius = [RCTConvert CGFloat:shadowRadius];
144
+        if (!shadow) {
145
+            shadow = [NSShadow new];
146
+        }
147
+        shadow.shadowBlurRadius = radius;
148
+    }
149
+    
150
+    NSNumber *showShadow = dictionary[showShadowKey];
151
+    if (showShadow) {
152
+        BOOL show = [RCTConvert BOOL:showShadow];
153
+        if (!show) {
154
+            shadow = nil;
155
+        }
156
+    }
157
+    
158
+    if (shadow) {
159
+        [textAttributes setObject:shadow forKey:NSShadowAttributeName];
160
+    }
161
+    
162
+    NSNumber *textColor = dictionary[colorKey];
163
+    if (textColor && [textColor isKindOfClass:[NSNumber class]])
164
+    {
165
+        UIColor *color = [RCTConvert UIColor:textColor];
166
+        [textAttributes setObject:color forKey:NSForegroundColorAttributeName];
167
+    }
168
+    
169
+    NSString *fontFamily = dictionary[familyKey];
170
+    if (![fontFamily isKindOfClass:[NSString class]]) {
171
+        fontFamily = nil;
172
+    }
173
+    
174
+    NSString *fontWeight = dictionary[weightKey];
175
+    if (![fontWeight isKindOfClass:[NSString class]]) {
176
+        fontWeight = nil;
177
+    }
178
+    
179
+    NSNumber *fontSize = dictionary[sizeKey];
180
+    if (![fontSize isKindOfClass:[NSNumber class]]) {
181
+        fontSize = nil;
182
+    }
183
+    
184
+    NSNumber *fontStyle = dictionary[styleKey];
185
+    if (![fontStyle isKindOfClass:[NSString class]]) {
186
+        fontStyle = nil;
187
+    }
188
+    
189
+    UIFont *font = [RCTFont updateFont:baseFont withFamily:fontFamily size:fontSize weight:fontWeight style:fontStyle variant:nil scaleMultiplier:1];
190
+    
191
+    if (font && (fontStyle || fontWeight || fontSize || fontFamily)) {
192
+        [textAttributes setObject:font forKey:NSFontAttributeName];
193
+    }
194
+    
195
+    return textAttributes;
196
+}
197
+
198
++ (NSMutableDictionary *)textAttributesFromDictionary:(NSDictionary *)dictionary withPrefix:(NSString *)prefix
199
+{
200
+    return [self textAttributesFromDictionary:dictionary withPrefix:prefix baseFont:[UIFont systemFontOfSize:[UIFont systemFontSize]]];
201
+}
202
+
77 203
 
78 204
 @end

+ 111
- 75
ios/RCCManagerModule.m View File

@@ -27,6 +27,22 @@ RCT_ENUM_CONVERTER(RCCManagerModuleErrorCode,
27 27
                       }), RCCManagerModuleCantCreateControllerErrorCode, integerValue)
28 28
 @end
29 29
 
30
+@implementation RCTConvert (UIModalPresentationStyle)
31
+
32
+RCT_ENUM_CONVERTER(UIModalPresentationStyle,
33
+                   (@{@"fullScreen": @(UIModalPresentationFullScreen),
34
+                      @"pageSheet": @(UIModalPresentationPageSheet),
35
+                      @"formSheet": @(UIModalPresentationFormSheet),
36
+                      @"currentContext": @(UIModalPresentationCurrentContext),
37
+                      @"custom": @(UIModalPresentationCustom),
38
+                      @"overFullScreen": @(UIModalPresentationOverFullScreen),
39
+                      @"overCurrentContext": @(UIModalPresentationOverCurrentContext),
40
+                      @"popover": @(UIModalPresentationPopover),
41
+                      @"none": @(UIModalPresentationNone)
42
+                      }), UIModalPresentationFullScreen, integerValue)
43
+
44
+@end
45
+
30 46
 @implementation RCCManagerModule
31 47
 
32 48
 RCT_EXPORT_MODULE(RCCManager);
@@ -39,6 +55,15 @@ RCT_EXPORT_MODULE(RCCManager);
39 55
              //Error codes
40 56
              @"RCCManagerModuleCantCreateControllerErrorCode" : @(RCCManagerModuleCantCreateControllerErrorCode),
41 57
              @"RCCManagerModuleCantFindTabControllerErrorCode" : @(RCCManagerModuleCantFindTabControllerErrorCode),
58
+             @"PresentFullScreen": @"fullScreen",
59
+             @"PresentPageSheet": @"pageSheet",
60
+             @"PresentFormSheet": @"formSheet",
61
+             @"PresentCurrentContext": @"currentContext",
62
+             @"PresentCustom": @"custom",
63
+             @"PresentOverFullScreen": @"overFullScreen",
64
+             @"PresentOverCurrentContext": @"overCurrentContext",
65
+             @"PresentPopover": @"popover",
66
+             @"PresentNone": @"none"
42 67
              };
43 68
 }
44 69
 
@@ -119,50 +144,50 @@ RCT_EXPORT_MODULE(RCCManager);
119 144
     if (allPresentedViewControllers.count > 0)
120 145
     {
121 146
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^
122
-        {
123
-            __block NSUInteger counter = 0;
124
-            for (UIViewController *viewController in allPresentedViewControllers)
125
-            {
126
-                counter++;
127
-                
128
-                [[RCCManager sharedIntance] unregisterController:viewController];
129
-                if (viewController.presentedViewController != nil)
130
-                {
131
-                    dispatch_semaphore_t dismiss_sema = dispatch_semaphore_create(0);
132
-                    
133
-                    dispatch_async(dispatch_get_main_queue(), ^
134
-                    {
135
-                        [viewController dismissViewControllerAnimated:NO completion:^()
136
-                         {
137
-                             if (counter == allPresentedViewControllers.count && allPresentedViewControllers.count > 0)
138
-                             {
139
-                                 [allPresentedViewControllers removeAllObjects];
140
-                                 
141
-                                 if (resolve != nil)
142
-                                 {
143
-                                     resolve(nil);
144
-                                 }
145
-                             }
146
-                             dispatch_semaphore_signal(dismiss_sema);
147
-                         }];
148
-                    });
149
-                    
150
-                    dispatch_semaphore_wait(dismiss_sema, DISPATCH_TIME_FOREVER);
151
-                }
152
-                else if (counter == allPresentedViewControllers.count && allPresentedViewControllers.count > 0)
153
-                {
154
-                    [allPresentedViewControllers removeAllObjects];
155
-                    
156
-                    if (resolve != nil)
157
-                    {
158
-                        dispatch_async(dispatch_get_main_queue(), ^
159
-                        {
160
-                            resolve(nil);
161
-                        });
162
-                    }
163
-                }
164
-            }
165
-        });
147
+                       {
148
+                           __block NSUInteger counter = 0;
149
+                           for (UIViewController *viewController in allPresentedViewControllers)
150
+                           {
151
+                               counter++;
152
+                               
153
+                               [[RCCManager sharedIntance] unregisterController:viewController];
154
+                               if (viewController.presentedViewController != nil)
155
+                               {
156
+                                   dispatch_semaphore_t dismiss_sema = dispatch_semaphore_create(0);
157
+                                   
158
+                                   dispatch_async(dispatch_get_main_queue(), ^
159
+                                                  {
160
+                                                      [viewController dismissViewControllerAnimated:NO completion:^()
161
+                                                       {
162
+                                                           if (counter == allPresentedViewControllers.count && allPresentedViewControllers.count > 0)
163
+                                                           {
164
+                                                               [allPresentedViewControllers removeAllObjects];
165
+                                                               
166
+                                                               if (resolve != nil)
167
+                                                               {
168
+                                                                   resolve(nil);
169
+                                                               }
170
+                                                           }
171
+                                                           dispatch_semaphore_signal(dismiss_sema);
172
+                                                       }];
173
+                                                  });
174
+                                   
175
+                                   dispatch_semaphore_wait(dismiss_sema, DISPATCH_TIME_FOREVER);
176
+                               }
177
+                               else if (counter == allPresentedViewControllers.count && allPresentedViewControllers.count > 0)
178
+                               {
179
+                                   [allPresentedViewControllers removeAllObjects];
180
+                                   
181
+                                   if (resolve != nil)
182
+                                   {
183
+                                       dispatch_async(dispatch_get_main_queue(), ^
184
+                                                      {
185
+                                                          resolve(nil);
186
+                                                      });
187
+                                   }
188
+                               }
189
+                           }
190
+                       });
166 191
     }
167 192
     else if (resolve != nil)
168 193
     {
@@ -173,7 +198,7 @@ RCT_EXPORT_MODULE(RCCManager);
173 198
 #pragma mark - RCT exported methods
174 199
 
175 200
 RCT_EXPORT_METHOD(
176
-setRootController:(NSDictionary*)layout animationType:(NSString*)animationType globalProps:(NSDictionary*)globalProps)
201
+                  setRootController:(NSDictionary*)layout animationType:(NSString*)animationType globalProps:(NSDictionary*)globalProps)
177 202
 {
178 203
     if ([[RCCManager sharedInstance] getBridge].loading) {
179 204
         [self deferSetRootControllerWhileBridgeLoading:layout animationType:animationType globalProps:globalProps];
@@ -182,7 +207,7 @@ setRootController:(NSDictionary*)layout animationType:(NSString*)animationType g
182 207
     
183 208
     dispatch_async(dispatch_get_main_queue(), ^{
184 209
         [self performSetRootController:layout animationType:animationType globalProps:globalProps];
185
-   });
210
+    });
186 211
 }
187 212
 
188 213
 /**
@@ -239,27 +264,27 @@ setRootController:(NSDictionary*)layout animationType:(NSString*)animationType g
239 264
 }
240 265
 
241 266
 RCT_EXPORT_METHOD(
242
-NavigationControllerIOS:(NSString*)controllerId performAction:(NSString*)performAction actionParams:(NSDictionary*)actionParams)
267
+                  NavigationControllerIOS:(NSString*)controllerId performAction:(NSString*)performAction actionParams:(NSDictionary*)actionParams)
243 268
 {
244
-  if (!controllerId || !performAction) return;
245
-  RCCNavigationController* controller = [[RCCManager sharedInstance] getControllerWithId:controllerId componentType:@"NavigationControllerIOS"];
246
-  if (!controller || ![controller isKindOfClass:[RCCNavigationController class]]) return;
247
-  return [controller performAction:performAction actionParams:actionParams bridge:[[RCCManager sharedInstance] getBridge]];
269
+    if (!controllerId || !performAction) return;
270
+    RCCNavigationController* controller = [[RCCManager sharedInstance] getControllerWithId:controllerId componentType:@"NavigationControllerIOS"];
271
+    if (!controller || ![controller isKindOfClass:[RCCNavigationController class]]) return;
272
+    return [controller performAction:performAction actionParams:actionParams bridge:[[RCCManager sharedInstance] getBridge]];
248 273
 }
249 274
 
250 275
 RCT_EXPORT_METHOD(
251
-DrawerControllerIOS:(NSString*)controllerId performAction:(NSString*)performAction actionParams:(NSDictionary*)actionParams)
276
+                  DrawerControllerIOS:(NSString*)controllerId performAction:(NSString*)performAction actionParams:(NSDictionary*)actionParams)
252 277
 {
253
-  if (!controllerId || !performAction) return;
254
-
255
-  id<RCCDrawerDelegate> controller = [[RCCManager sharedIntance] getControllerWithId:controllerId componentType:@"DrawerControllerIOS"];
256
-  if (!controller || (![controller isKindOfClass:[RCCDrawerController class]] && ![controller isKindOfClass:[RCCTheSideBarManagerViewController class]])) return;
257
-  return [controller performAction:performAction actionParams:actionParams bridge:[[RCCManager sharedIntance] getBridge]];
258
-
278
+    if (!controllerId || !performAction) return;
279
+    
280
+    id<RCCDrawerDelegate> controller = [[RCCManager sharedIntance] getControllerWithId:controllerId componentType:@"DrawerControllerIOS"];
281
+    if (!controller || (![controller isKindOfClass:[RCCDrawerController class]] && ![controller isKindOfClass:[RCCTheSideBarManagerViewController class]])) return;
282
+    return [controller performAction:performAction actionParams:actionParams bridge:[[RCCManager sharedIntance] getBridge]];
283
+    
259 284
 }
260 285
 
261 286
 RCT_EXPORT_METHOD(
262
-TabBarControllerIOS:(NSString*)controllerId performAction:(NSString*)performAction actionParams:(NSDictionary*)actionParams resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
287
+                  TabBarControllerIOS:(NSString*)controllerId performAction:(NSString*)performAction actionParams:(NSDictionary*)actionParams resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
263 288
 {
264 289
     if (!controllerId || !performAction)
265 290
     {
@@ -279,19 +304,19 @@ TabBarControllerIOS:(NSString*)controllerId performAction:(NSString*)performActi
279 304
 }
280 305
 
281 306
 RCT_EXPORT_METHOD(
282
-modalShowLightBox:(NSDictionary*)params)
307
+                  modalShowLightBox:(NSDictionary*)params)
283 308
 {
284 309
     [RCCLightBox showWithParams:params];
285 310
 }
286 311
 
287 312
 RCT_EXPORT_METHOD(
288
-modalDismissLightBox)
313
+                  modalDismissLightBox)
289 314
 {
290 315
     [RCCLightBox dismiss];
291 316
 }
292 317
 
293 318
 RCT_EXPORT_METHOD(
294
-showController:(NSDictionary*)layout animationType:(NSString*)animationType globalProps:(NSDictionary*)globalProps resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
319
+                  showController:(NSDictionary*)layout animationType:(NSString*)animationType globalProps:(NSDictionary*)globalProps resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
295 320
 {
296 321
     UIViewController *controller = [RCCViewController controllerWithLayout:layout globalProps:globalProps bridge:[[RCCManager sharedInstance] getBridge]];
297 322
     if (controller == nil)
@@ -300,22 +325,33 @@ showController:(NSDictionary*)layout animationType:(NSString*)animationType glob
300 325
                                                 error:[RCCManagerModule rccErrorWithCode:RCCManagerModuleCantCreateControllerErrorCode description:@"could not create controller"]];
301 326
         return;
302 327
     }
303
-
328
+    
329
+    if (layout[@"props"] && [layout[@"props"] isKindOfClass:[NSDictionary class]] && layout[@"props"][@"style"] && [layout[@"props"][@"style"] isKindOfClass: [NSDictionary class]]) {
330
+        
331
+        NSDictionary *style = layout[@"props"][@"style"];
332
+        if (style[@"modalPresentationStyle"] && [style[@"modalPresentationStyle"] isKindOfClass:[NSString class]]) {
333
+            
334
+            NSString *presentationStyle = style[@"modalPresentationStyle"];
335
+            UIModalPresentationStyle modalPresentationStyle = [RCTConvert UIModalPresentationStyle:presentationStyle];
336
+            controller.modalPresentationStyle = modalPresentationStyle;
337
+        }
338
+    }
339
+    
304 340
     [[RCCManagerModule lastModalPresenterViewController] presentViewController:controller
305
-                                                           animated:![animationType isEqualToString:@"none"]
306
-                                                         completion:^(){ resolve(nil); }];
341
+                                                                      animated:![animationType isEqualToString:@"none"]
342
+                                                                    completion:^(){ resolve(nil); }];
307 343
 }
308 344
 
309 345
 -(BOOL)viewControllerIsModal:(UIViewController*)viewController
310 346
 {
311 347
     BOOL viewControllerIsModal = (viewController.presentingViewController.presentedViewController == viewController)
312
-                                || ((viewController.navigationController != nil) && (viewController.navigationController.presentingViewController.presentedViewController == viewController.navigationController) && (viewController == viewController.navigationController.viewControllers[0]))
313
-                                || ([viewController.tabBarController.presentingViewController isKindOfClass:[UITabBarController class]]);
348
+    || ((viewController.navigationController != nil) && (viewController.navigationController.presentingViewController.presentedViewController == viewController.navigationController) && (viewController == viewController.navigationController.viewControllers[0]))
349
+    || ([viewController.tabBarController.presentingViewController isKindOfClass:[UITabBarController class]]);
314 350
     return viewControllerIsModal;
315 351
 }
316 352
 
317 353
 RCT_EXPORT_METHOD(
318
-dismissController:(NSString*)animationType resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
354
+                  dismissController:(NSString*)animationType resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
319 355
 {
320 356
     UIViewController* vc = [RCCManagerModule lastModalPresenterViewController];
321 357
     if ([self viewControllerIsModal:vc])
@@ -332,7 +368,7 @@ dismissController:(NSString*)animationType resolver:(RCTPromiseResolveBlock)reso
332 368
 }
333 369
 
334 370
 RCT_EXPORT_METHOD(
335
-dismissAllControllers:(NSString*)animationType resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
371
+                  dismissAllControllers:(NSString*)animationType resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
336 372
 {
337 373
     if([UIApplication sharedApplication].delegate.window.rootViewController.presentedViewController == nil)
338 374
     {//if there are no modal - do nothing
@@ -351,9 +387,9 @@ dismissAllControllers:(NSString*)animationType resolver:(RCTPromiseResolveBlock)
351 387
         [appDelegate.window addSubview:snapshot];
352 388
         
353 389
         [self dismissAllModalPresenters:allPresentedViewControllers resolver:^(id result)
354
-        {
355
-            [self animateSnapshot:snapshot animationType:animationType resolver:resolve];
356
-        }];
390
+         {
391
+             [self animateSnapshot:snapshot animationType:animationType resolver:resolve];
392
+         }];
357 393
     }
358 394
     else
359 395
     {
@@ -362,19 +398,19 @@ dismissAllControllers:(NSString*)animationType resolver:(RCTPromiseResolveBlock)
362 398
 }
363 399
 
364 400
 RCT_EXPORT_METHOD(
365
-showNotification:(NSDictionary*)params resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
401
+                  showNotification:(NSDictionary*)params resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
366 402
 {
367 403
     [RCCNotification showWithParams:params resolver:resolve rejecter:reject];
368 404
 }
369 405
 
370 406
 RCT_EXPORT_METHOD(
371
-dismissNotification:(NSDictionary*)params resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
407
+                  dismissNotification:(NSDictionary*)params resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
372 408
 {
373 409
     [RCCNotification dismissWithParams:params resolver:resolve rejecter:reject];
374 410
 }
375 411
 
376 412
 RCT_EXPORT_METHOD(
377
-cancelAllReactTouches)
413
+                  cancelAllReactTouches)
378 414
 {
379 415
     [RCCManagerModule cancelAllRCCViewControllerReactTouches];
380 416
 }

+ 24
- 0
ios/RCCNavigationController.m View File

@@ -77,6 +77,7 @@ NSString const *CALLBACK_ASSOCIATED_ID = @"RCCNavigationController.CALLBACK_ASSO
77 77
       [mergedStyle removeObjectForKey:@"navBarBlur"];
78 78
       [mergedStyle removeObjectForKey:@"navBarTranslucent"];
79 79
       [mergedStyle removeObjectForKey:@"statusBarHideWithNavBar"];
80
+      [mergedStyle removeObjectForKey:@"autoAdjustScrollViewInsets"];
80 81
       [mergedStyle removeObjectForKey:@"statusBarTextColorSchemeSingleScreen"];
81 82
       
82 83
       [mergedStyle addEntriesFromDictionary:navigatorStyle];
@@ -207,6 +208,29 @@ NSString const *CALLBACK_ASSOCIATED_ID = @"RCCNavigationController.CALLBACK_ASSO
207 208
     [topViewController setNavBarVisibilityChange:animatedBool];
208 209
     
209 210
   }
211
+    
212
+    // setStyle
213
+    if ([performAction isEqualToString:@"setStyle"])
214
+    {
215
+        
216
+        NSDictionary *navigatorStyle = actionParams;
217
+        
218
+        // merge the navigatorStyle of our parent
219
+        if ([self.topViewController isKindOfClass:[RCCViewController class]])
220
+        {
221
+            RCCViewController *parent = (RCCViewController*)self.topViewController;
222
+            NSMutableDictionary *mergedStyle = [NSMutableDictionary dictionaryWithDictionary:parent.navigatorStyle];
223
+            
224
+            // there are a few styles that we don't want to remember from our parent (they should be local)
225
+            [mergedStyle setValuesForKeysWithDictionary:navigatorStyle];
226
+            navigatorStyle = mergedStyle;
227
+            
228
+            parent.navigatorStyle = navigatorStyle;
229
+            
230
+            [parent setStyleOnInit];
231
+            [parent updateStyle];
232
+        }
233
+    }
210 234
 }
211 235
 
212 236
 -(void)onButtonPress:(UIBarButtonItem*)barButtonItem

+ 14
- 11
ios/RCCTabBarController.m View File

@@ -2,6 +2,7 @@
2 2
 #import "RCCViewController.h"
3 3
 #import "RCTConvert.h"
4 4
 #import "RCCManager.h"
5
+#import "RCTHelpers.h"
5 6
 #import "RCTUIManager.h"
6 7
 
7 8
 @interface RCTUIManager ()
@@ -118,19 +119,21 @@
118 119
     viewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:title image:iconImage tag:0];
119 120
     viewController.tabBarItem.accessibilityIdentifier = tabItemLayout[@"props"][@"testID"];
120 121
     viewController.tabBarItem.selectedImage = iconImageSelected;
121
-
122
-    if (buttonColor)
123
-    {
124
-      [viewController.tabBarItem setTitleTextAttributes:
125
-       @{NSForegroundColorAttributeName : buttonColor} forState:UIControlStateNormal];
122
+    
123
+    NSMutableDictionary *unselectedAttributes = [RCTHelpers textAttributesFromDictionary:tabsStyle withPrefix:@"tabBarText" baseFont:[UIFont systemFontOfSize:10]];
124
+    if (!unselectedAttributes[NSForegroundColorAttributeName] && buttonColor) {
125
+      unselectedAttributes[NSForegroundColorAttributeName] = buttonColor;
126 126
     }
127
-
128
-    if (selectedButtonColor)
129
-    {
130
-      [viewController.tabBarItem setTitleTextAttributes:
131
-       @{NSForegroundColorAttributeName : selectedButtonColor} forState:UIControlStateSelected];
127
+    
128
+    [viewController.tabBarItem setTitleTextAttributes:unselectedAttributes forState:UIControlStateNormal]
129
+    ;
130
+    
131
+    NSMutableDictionary *selectedAttributes = [RCTHelpers textAttributesFromDictionary:tabsStyle withPrefix:@"tabBarSelectedText" baseFont:[UIFont systemFontOfSize:10]];
132
+    if (!selectedAttributes[NSForegroundColorAttributeName] && selectedButtonColor) {
133
+      selectedAttributes[NSForegroundColorAttributeName] = selectedButtonColor;
132 134
     }
133
-
135
+    
136
+    [viewController.tabBarItem setTitleTextAttributes:selectedAttributes forState:UIControlStateSelected];
134 137
     // create badge
135 138
     NSObject *badge = tabItemLayout[@"props"][@"badge"];
136 139
     if (badge == nil || [badge isEqual:[NSNull null]])

+ 1
- 0
ios/RCCViewController.h View File

@@ -14,6 +14,7 @@ extern NSString* const RCCViewControllerCancelReactTouchesNotification;
14 14
 - (instancetype)initWithComponent:(NSString *)component passProps:(NSDictionary *)passProps navigatorStyle:(NSDictionary*)navigatorStyle globalProps:(NSDictionary *)globalProps bridge:(RCTBridge *)bridge;
15 15
 - (void)setStyleOnAppear;
16 16
 - (void)setStyleOnInit;
17
+- (void)updateStyle;
17 18
 - (void)setNavBarVisibilityChange:(BOOL)animated;
18 19
 
19 20
 @end

+ 141
- 133
ios/RCCViewController.m View File

@@ -7,6 +7,8 @@
7 7
 #import "RCCManager.h"
8 8
 #import "RCTConvert.h"
9 9
 #import "RCCExternalViewControllerProtocol.h"
10
+#import "RCTHelpers.h"
11
+#import "RCCTitleViewHelper.h"
10 12
 
11 13
 NSString* const RCCViewControllerCancelReactTouchesNotification = @"RCCViewControllerCancelReactTouchesNotification";
12 14
 
@@ -189,138 +191,164 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
189 191
 // we want to reset the style to what we expect (so we need to reset on every willAppear)
190 192
 - (void)setStyleOnAppear
191 193
 {
192
-    [self setStyleOnAppearForViewController:self];
194
+    [self setStyleOnAppearForViewController:self appeared:false];
193 195
 }
194 196
 
195
--(void)setStyleOnAppearForViewController:(UIViewController*)viewController
197
+- (void)updateStyle
196 198
 {
199
+    [self setStyleOnAppearForViewController:self appeared:true];
200
+}
201
+
202
+-(void)setStyleOnAppearForViewController:(UIViewController*)viewController appeared:(BOOL)appeared
203
+{
204
+
197 205
     NSString *screenBackgroundColor = self.navigatorStyle[@"screenBackgroundColor"];
198
-    if (screenBackgroundColor)
199
-    {
206
+    if (screenBackgroundColor) {
207
+        
200 208
         UIColor *color = screenBackgroundColor != (id)[NSNull null] ? [RCTConvert UIColor:screenBackgroundColor] : nil;
201
-        self.view.backgroundColor = color;
209
+        viewController.view.backgroundColor = color;
202 210
     }
203 211
     
204 212
     NSString *navBarBackgroundColor = self.navigatorStyle[@"navBarBackgroundColor"];
205
-    if (navBarBackgroundColor)
206
-    {
213
+    if (navBarBackgroundColor) {
214
+        
207 215
         UIColor *color = navBarBackgroundColor != (id)[NSNull null] ? [RCTConvert UIColor:navBarBackgroundColor] : nil;
208 216
         viewController.navigationController.navigationBar.barTintColor = color;
209
-    }
210
-    else
211
-    {
217
+        
218
+    } else {
212 219
         viewController.navigationController.navigationBar.barTintColor = nil;
213 220
     }
214
-    
215
-    NSString *navBarTextColor = self.navigatorStyle[@"navBarTextColor"];
216
-    if (navBarTextColor)
217
-    {
218
-        UIColor *color = navBarTextColor != (id)[NSNull null] ? [RCTConvert UIColor:navBarTextColor] : nil;
219
-        [viewController.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : color}];
221
+
222
+    NSMutableDictionary *titleTextAttributes = [RCTHelpers textAttributesFromDictionary:self.navigatorStyle withPrefix:@"navBarText" baseFont:[UIFont boldSystemFontOfSize:17]];
223
+    [self.navigationController.navigationBar setTitleTextAttributes:titleTextAttributes];
224
+
225
+    if (self.navigationItem.titleView && [self.navigationItem.titleView isKindOfClass:[RCCTitleView class]]) {
226
+        
227
+        RCCTitleView *titleView = (RCCTitleView *)self.navigationItem.titleView;
228
+        RCCTitleViewHelper *helper = [[RCCTitleViewHelper alloc] init:viewController navigationController:viewController.navigationController title:titleView.titleLabel.text subtitle:titleView.subtitleLabel.text titleImageData:nil];
229
+        [helper setup:self.navigatorStyle];
220 230
     }
221
-    else
222
-    {
223
-        [viewController.navigationController.navigationBar setTitleTextAttributes:nil];
231
+
232
+    NSMutableDictionary *navButtonTextAttributes = [RCTHelpers textAttributesFromDictionary:self.navigatorStyle withPrefix:@"navBarButton"];
233
+
234
+    if (navButtonTextAttributes.allKeys.count > 0) {
235
+        
236
+        for (UIBarButtonItem *item in viewController.navigationItem.leftBarButtonItems) {
237
+            [item setTitleTextAttributes:navButtonTextAttributes forState:UIControlStateNormal];
238
+        }
239
+        
240
+        for (UIBarButtonItem *item in viewController.navigationItem.rightBarButtonItems) {
241
+            [item setTitleTextAttributes:navButtonTextAttributes forState:UIControlStateNormal];
242
+        }
243
+
244
+        // At the moment, this seems to be the only thing that gets the back button correctly
245
+        [navButtonTextAttributes removeObjectForKey:NSForegroundColorAttributeName];
246
+        [[UIBarButtonItem appearance] setTitleTextAttributes:navButtonTextAttributes forState:UIControlStateNormal];
247
+        //        [viewController.navigationItem.backBarButtonItem setTitleTextAttributes:navButtonTextAttributes forState:UIControlStateNormal];
224 248
     }
225
-    
249
+
226 250
     NSString *navBarButtonColor = self.navigatorStyle[@"navBarButtonColor"];
227
-    if (navBarButtonColor)
228
-    {
251
+    if (navBarButtonColor) {
252
+    
229 253
         UIColor *color = navBarButtonColor != (id)[NSNull null] ? [RCTConvert UIColor:navBarButtonColor] : nil;
230 254
         viewController.navigationController.navigationBar.tintColor = color;
231
-    }
232
-    else
255
+        
256
+    } else
233 257
     {
234 258
         viewController.navigationController.navigationBar.tintColor = nil;
235 259
     }
236 260
   
237
-    NSString *statusBarTextColorSchemeSingleScreen = self.navigatorStyle[@"statusBarTextColorSchemeSingleScreen"];
238
-    if (statusBarTextColorSchemeSingleScreen && [statusBarTextColorSchemeSingleScreen isEqualToString:@"light"])
239
-    {
240
-      self._statusBarTextColorSchemeLight = YES;
241
-    }
242
-    else
243
-    {
244
-      self._statusBarTextColorSchemeLight = NO;
261
+    BOOL viewControllerBasedStatusBar = false;
262
+
263
+    NSObject *viewControllerBasedStatusBarAppearance = [[NSBundle mainBundle] infoDictionary][@"UIViewControllerBasedStatusBarAppearance"];
264
+    if (viewControllerBasedStatusBarAppearance && [viewControllerBasedStatusBarAppearance isKindOfClass:[NSNumber class]]) {
265
+      viewControllerBasedStatusBar = [(NSNumber *)viewControllerBasedStatusBarAppearance boolValue];
245 266
     }
246 267
   
247
-    // incase statusBarTextColorSchemeSingleScreen exists ignore the statusBarTextColorScheme which more globaly
248
-    if (!statusBarTextColorSchemeSingleScreen) {
249
-      NSString *statusBarTextColorScheme = self.navigatorStyle[@"statusBarTextColorScheme"];
250
-      if (statusBarTextColorScheme && [statusBarTextColorScheme isEqualToString:@"light"] && !statusBarTextColorSchemeSingleScreen)
251
-      {
252
-          viewController.navigationController.navigationBar.barStyle = UIBarStyleBlack;
253
-          self._statusBarTextColorSchemeLight = YES;
268
+    NSString *statusBarTextColorSchemeSingleScreen = self.navigatorStyle[@"statusBarTextColorSchemeSingleScreen"];
269
+    NSString *statusBarTextColorScheme = self.navigatorStyle[@"statusBarTextColorScheme"];
270
+    NSString *finalColorScheme = statusBarTextColorSchemeSingleScreen ? : statusBarTextColorScheme;
271
+
272
+    if (finalColorScheme && [finalColorScheme isEqualToString:@"light"]) {
273
+        
274
+        if (!statusBarTextColorSchemeSingleScreen) {
275
+              viewController.navigationController.navigationBar.barStyle = UIBarStyleBlack;
276
+        }
277
+      
278
+        self._statusBarTextColorSchemeLight = true;
279
+        if (!viewControllerBasedStatusBarAppearance) {
280
+            [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
281
+        }
282
+      
283
+        [viewController setNeedsStatusBarAppearanceUpdate];
284
+        
285
+    } else {
254 286
         
255
-      }
256
-      else
257
-      {
258
-          viewController.navigationController.navigationBar.barStyle = UIBarStyleDefault;
259
-          self._statusBarTextColorSchemeLight = NO;
260
-      }
287
+        if (!statusBarTextColorSchemeSingleScreen) {
288
+              viewController.navigationController.navigationBar.barStyle = UIBarStyleDefault;
289
+        }
290
+      
291
+        self._statusBarTextColorSchemeLight = false;
292
+      
293
+        if (!viewControllerBasedStatusBarAppearance) {
294
+            [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
295
+        }
296
+        [viewController setNeedsStatusBarAppearanceUpdate];
261 297
     }
262 298
   
263 299
     NSNumber *navBarHidden = self.navigatorStyle[@"navBarHidden"];
264 300
     BOOL navBarHiddenBool = navBarHidden ? [navBarHidden boolValue] : NO;
265
-    if (viewController.navigationController.navigationBarHidden != navBarHiddenBool)
266
-    {
301
+    if (viewController.navigationController.navigationBarHidden != navBarHiddenBool) {
267 302
         [viewController.navigationController setNavigationBarHidden:navBarHiddenBool animated:YES];
268 303
     }
269
-    
304
+
270 305
     NSNumber *navBarHideOnScroll = self.navigatorStyle[@"navBarHideOnScroll"];
271 306
     BOOL navBarHideOnScrollBool = navBarHideOnScroll ? [navBarHideOnScroll boolValue] : NO;
272
-    if (navBarHideOnScrollBool)
273
-    {
307
+    if (navBarHideOnScrollBool) {
274 308
         viewController.navigationController.hidesBarsOnSwipe = YES;
275
-    }
276
-    else
277
-    {
309
+    } else {
278 310
         viewController.navigationController.hidesBarsOnSwipe = NO;
279 311
     }
280
-    
312
+
281 313
     NSNumber *statusBarBlur = self.navigatorStyle[@"statusBarBlur"];
282 314
     BOOL statusBarBlurBool = statusBarBlur ? [statusBarBlur boolValue] : NO;
283
-    if (statusBarBlurBool)
284
-    {
285
-        if (![viewController.view viewWithTag:BLUR_STATUS_TAG])
286
-        {
287
-            UIVisualEffectView *blur = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
288
-            blur.frame = [[UIApplication sharedApplication] statusBarFrame];
289
-            blur.tag = BLUR_STATUS_TAG;
290
-            [viewController.view addSubview:blur];
291
-        }
315
+    if (statusBarBlurBool && ![viewController.view viewWithTag:BLUR_STATUS_TAG]) {
316
+        
317
+        UIVisualEffectView *blur = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
318
+        blur.frame = [[UIApplication sharedApplication] statusBarFrame];
319
+        blur.tag = BLUR_STATUS_TAG;
320
+        [viewController.view insertSubview:blur atIndex:0];
292 321
     }
293
-    
322
+
294 323
     NSNumber *navBarBlur = self.navigatorStyle[@"navBarBlur"];
295 324
     BOOL navBarBlurBool = navBarBlur ? [navBarBlur boolValue] : NO;
296
-    if (navBarBlurBool)
297
-    {
298
-        if (![viewController.navigationController.navigationBar viewWithTag:BLUR_NAVBAR_TAG])
299
-        {
325
+    if (navBarBlurBool) {
326
+        
327
+        if (![viewController.navigationController.navigationBar viewWithTag:BLUR_NAVBAR_TAG]) {
300 328
             [self storeOriginalNavBarImages];
301
-            
302
-            [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
303
-            self.navigationController.navigationBar.shadowImage = [UIImage new];
329
+
330
+            [viewController.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
331
+            viewController.navigationController.navigationBar.shadowImage = [UIImage new];
304 332
             UIVisualEffectView *blur = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
305 333
             CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
306
-            blur.frame = CGRectMake(0, -1 * statusBarFrame.size.height, self.navigationController.navigationBar.frame.size.width, self.navigationController.navigationBar.frame.size.height + statusBarFrame.size.height);
334
+            blur.frame = CGRectMake(0, -1 * statusBarFrame.size.height, viewController.navigationController.navigationBar.frame.size.width, viewController.navigationController.navigationBar.frame.size.height + statusBarFrame.size.height);
307 335
             blur.userInteractionEnabled = NO;
308 336
             blur.tag = BLUR_NAVBAR_TAG;
309
-            [self.navigationController.navigationBar insertSubview:blur atIndex:0];
337
+            [viewController.navigationController.navigationBar insertSubview:blur atIndex:0];
338
+            [viewController.navigationController.navigationBar sendSubviewToBack:blur];
310 339
         }
311
-    }
312
-    else
313
-    {
340
+        
341
+    } else {
342
+        
314 343
         UIView *blur = [viewController.navigationController.navigationBar viewWithTag:BLUR_NAVBAR_TAG];
315
-        if (blur)
316
-        {
344
+        if (blur) {
317 345
             [blur removeFromSuperview];
318 346
             [viewController.navigationController.navigationBar setBackgroundImage:self.originalNavBarImages[@"bgImage"] forBarMetrics:UIBarMetricsDefault];
319 347
             viewController.navigationController.navigationBar.shadowImage = self.originalNavBarImages[@"shadowImage"];
320 348
             self.originalNavBarImages = nil;
321 349
         }
322 350
     }
323
-    
351
+
324 352
     NSNumber *navBarTransparent = self.navigatorStyle[@"navBarTransparent"];
325 353
     BOOL navBarTransparentBool = navBarTransparent ? [navBarTransparent boolValue] : NO;
326 354
     
@@ -362,48 +390,44 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
362 390
             backgroundView.alpha = originalAlpha;
363 391
         }];
364 392
     }
365
-    
393
+
394
+    NSNumber *autoAdjustsScrollViewInsets = self.navigatorStyle[@"autoAdjustScrollViewInsets"];
395
+    viewController.automaticallyAdjustsScrollViewInsets = autoAdjustsScrollViewInsets ? [autoAdjustsScrollViewInsets boolValue] : false;
396
+
366 397
     NSNumber *navBarTranslucent = self.navigatorStyle[@"navBarTranslucent"];
367 398
     BOOL navBarTranslucentBool = navBarTranslucent ? [navBarTranslucent boolValue] : NO;
368
-    if (navBarTranslucentBool || navBarBlurBool)
369
-    {
399
+    if (navBarTranslucentBool || navBarBlurBool) {
370 400
         viewController.navigationController.navigationBar.translucent = YES;
371
-    }
372
-    else
373
-    {
401
+    } else {
374 402
         viewController.navigationController.navigationBar.translucent = NO;
375 403
     }
376
-    
404
+
405
+    NSNumber *extendedLayoutIncludesOpaqueBars = self.navigatorStyle[@"extendedLayoutIncludesOpaqueBars"];
406
+    BOOL extendedLayoutIncludesOpaqueBarsBool = extendedLayoutIncludesOpaqueBars ? [extendedLayoutIncludesOpaqueBars boolValue] : NO;
407
+    viewController.extendedLayoutIncludesOpaqueBars = extendedLayoutIncludesOpaqueBarsBool;
408
+
377 409
     NSNumber *drawUnderNavBar = self.navigatorStyle[@"drawUnderNavBar"];
378 410
     BOOL drawUnderNavBarBool = drawUnderNavBar ? [drawUnderNavBar boolValue] : NO;
379
-    if (drawUnderNavBarBool)
380
-    {
411
+    if (drawUnderNavBarBool) {
381 412
         viewController.edgesForExtendedLayout |= UIRectEdgeTop;
382 413
     }
383
-    else
384
-    {
414
+    else {
385 415
         viewController.edgesForExtendedLayout &= ~UIRectEdgeTop;
386 416
     }
387
-    
417
+
388 418
     NSNumber *drawUnderTabBar = self.navigatorStyle[@"drawUnderTabBar"];
389 419
     BOOL drawUnderTabBarBool = drawUnderTabBar ? [drawUnderTabBar boolValue] : NO;
390
-    if (drawUnderTabBarBool)
391
-    {
420
+    if (drawUnderTabBarBool) {
392 421
         viewController.edgesForExtendedLayout |= UIRectEdgeBottom;
393
-    }
394
-    else
395
-    {
422
+    } else {
396 423
         viewController.edgesForExtendedLayout &= ~UIRectEdgeBottom;
397 424
     }
398
-    
425
+
399 426
     NSNumber *removeNavBarBorder = self.navigatorStyle[@"navBarNoBorder"];
400 427
     BOOL removeNavBarBorderBool = removeNavBarBorder ? [removeNavBarBorder boolValue] : NO;
401
-    if(removeNavBarBorderBool)
402
-    {
428
+    if (removeNavBarBorderBool) {
403 429
         self.navBarHairlineImageView.hidden = YES;
404
-    }
405
-    else
406
-    {
430
+    } else {
407 431
         self.navBarHairlineImageView.hidden = NO;
408 432
     }
409 433
     
@@ -422,15 +446,14 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
422 446
 }
423 447
 
424 448
 -(void)storeOriginalNavBarImages {
449
+    
425 450
     NSMutableDictionary *originalNavBarImages = [@{} mutableCopy];
426 451
     UIImage *bgImage = [self.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault];
427
-    if (bgImage != nil)
428
-    {
452
+    if (bgImage != nil) {
429 453
         originalNavBarImages[@"bgImage"] = bgImage;
430 454
     }
431 455
     UIImage *shadowImage = self.navigationController.navigationBar.shadowImage;
432
-    if (shadowImage != nil)
433
-    {
456
+    if (shadowImage != nil) {
434 457
         originalNavBarImages[@"shadowImage"] = shadowImage;
435 458
     }
436 459
     self.originalNavBarImages = originalNavBarImages;
@@ -453,34 +476,25 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
453 476
 {
454 477
     NSNumber *tabBarHidden = self.navigatorStyle[@"tabBarHidden"];
455 478
     BOOL tabBarHiddenBool = tabBarHidden ? [tabBarHidden boolValue] : NO;
456
-    if (tabBarHiddenBool)
457
-    {
479
+    if (tabBarHiddenBool) {
458 480
         self._hidesBottomBarWhenPushed = YES;
459
-    }
460
-    else
461
-    {
481
+    } else {
462 482
         self._hidesBottomBarWhenPushed = NO;
463 483
     }
464 484
     
465 485
     NSNumber *statusBarHideWithNavBar = self.navigatorStyle[@"statusBarHideWithNavBar"];
466 486
     BOOL statusBarHideWithNavBarBool = statusBarHideWithNavBar ? [statusBarHideWithNavBar boolValue] : NO;
467
-    if (statusBarHideWithNavBarBool)
468
-    {
487
+    if (statusBarHideWithNavBarBool) {
469 488
         self._statusBarHideWithNavBar = YES;
470
-    }
471
-    else
472
-    {
489
+    } else {
473 490
         self._statusBarHideWithNavBar = NO;
474 491
     }
475 492
     
476 493
     NSNumber *statusBarHidden = self.navigatorStyle[@"statusBarHidden"];
477 494
     BOOL statusBarHiddenBool = statusBarHidden ? [statusBarHidden boolValue] : NO;
478
-    if (statusBarHiddenBool)
479
-    {
495
+    if (statusBarHiddenBool) {
480 496
         self._statusBarHidden = YES;
481
-    }
482
-    else
483
-    {
497
+    } else {
484 498
         self._statusBarHidden = NO;
485 499
     }
486 500
 }
@@ -493,16 +507,13 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
493 507
 
494 508
 - (BOOL)prefersStatusBarHidden
495 509
 {
496
-    if (self._statusBarHidden)
497
-    {
510
+    if (self._statusBarHidden) {
498 511
         return YES;
499 512
     }
500
-    if (self._statusBarHideWithNavBar)
501
-    {
513
+    
514
+    if (self._statusBarHideWithNavBar) {
502 515
         return self.navigationController.isNavigationBarHidden;
503
-    }
504
-    else
505
-    {
516
+    } else {
506 517
         return NO;
507 518
     }
508 519
 }
@@ -514,12 +525,9 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
514 525
 
515 526
 - (UIStatusBarStyle)preferredStatusBarStyle
516 527
 {
517
-    if (self._statusBarTextColorSchemeLight)
518
-    {
528
+    if (self._statusBarTextColorSchemeLight){
519 529
         return UIStatusBarStyleLightContent;
520
-    }
521
-    else
522
-    {
530
+    } else {
523 531
         return UIStatusBarStyleDefault;
524 532
     }
525 533
 }

+ 8
- 0
src/Screen.js View File

@@ -84,6 +84,14 @@ class Navigator {
84 84
     return platformSpecific.navigatorSetTitleImage(this, params);
85 85
   }
86 86
 
87
+  setStyle(params = {}) {
88
+    if (Platform.OS === 'ios') {
89
+      return platformSpecific.navigatorSetStyle(this, params);
90
+    } else {
91
+      console.log(`Setting style isn\'t supported on ${Platform.OS} yet`);
92
+    }
93
+  }
94
+
87 95
   toggleDrawer(params = {}) {
88 96
     return platformSpecific.navigatorToggleDrawer(this, params);
89 97
   }

+ 5
- 0
src/deprecated/controllers/index.js View File

@@ -171,6 +171,11 @@ var Controllers = {
171 171
         }
172 172
         RCCManager.NavigationControllerIOS(id, "setTitle", params);
173 173
       },
174
+      setStyle: function (params) {
175
+        style = Object.assign({}, params);
176
+        _processProperties(style);
177
+        RCCManager.NavigationControllerIOS(id, "setStyle", style);
178
+      },
174 179
       resetTo: function (params) {
175 180
         var unsubscribes = [];
176 181
         if (params['style']) {

+ 6
- 0
src/deprecated/platformSpecificDeprecated.ios.js View File

@@ -74,6 +74,7 @@ function startTabBasedApp(params) {
74 74
                   <NavigationControllerIOS
75 75
                     id={tab.navigationParams.navigatorID}
76 76
                     title={tab.title}
77
+                    subtitle={tab.subtitle}
77 78
                     titleImage={tab.titleImage}
78 79
                     component={tab.screen}
79 80
                     passProps={{
@@ -318,6 +319,10 @@ function navigatorToggleNavBar(navigator, params) {
318 319
   });
319 320
 }
320 321
 
322
+function navigatorSetStyle(navigator, params) {
323
+  Controllers.NavigationControllerIOS(navigator.navigatorID).setStyle(params)
324
+}
325
+
321 326
 function navigatorToggleDrawer(navigator, params) {
322 327
   const controllerID = navigator.navigatorID.split('_')[0];
323 328
   if (params.to == 'open') {
@@ -585,6 +590,7 @@ export default {
585 590
   dismissInAppNotification,
586 591
   navigatorSetButtons,
587 592
   navigatorSetTitle,
593
+  navigatorSetStyle,
588 594
   navigatorSetTitleImage,
589 595
   navigatorToggleDrawer,
590 596
   navigatorToggleTabs,