Bläddra i källkod

add appStyle support for iOS (Android already support) 🤖 (#1772)

Ran Greenberg 7 år sedan
förälder
incheckning
9ad3baa4a4

+ 2
- 0
ios/RCCManager.h Visa fil

@@ -11,6 +11,8 @@
11 11
 -(void)initBridgeWithBundleURL:(NSURL *)bundleURL launchOptions:(NSDictionary *)launchOptions;
12 12
 -(RCTBridge*)getBridge;
13 13
 -(UIWindow*)getAppWindow;
14
+-(void)setAppStyle:(NSDictionary*)appStyle;
15
+-(NSDictionary*)getAppStyle;
14 16
 
15 17
 -(void)registerController:(UIViewController*)controller componentId:(NSString*)componentId componentType:(NSString*)componentType;
16 18
 -(id)getControllerWithId:(NSString*)componentId componentType:(NSString*)componentType;

+ 13
- 0
ios/RCCManager.m Visa fil

@@ -8,6 +8,7 @@
8 8
 @property (nonatomic, strong) NSMutableDictionary *modulesRegistry;
9 9
 @property (nonatomic, strong) RCTBridge *sharedBridge;
10 10
 @property (nonatomic, strong) NSURL *bundleURL;
11
+@property (nonatomic, strong, readwrite) NSDictionary *globalAppStyle;
11 12
 @end
12 13
 
13 14
 @implementation RCCManager
@@ -53,6 +54,7 @@
53 54
 {
54 55
   id<UIApplicationDelegate> appDelegate = [UIApplication sharedApplication].delegate;
55 56
   appDelegate.window.rootViewController = nil;
57
+  [self setAppStyle:nil];
56 58
   [self clearModuleRegistry];
57 59
 }
58 60
 
@@ -238,6 +240,17 @@
238 240
   return window;
239 241
 }
240 242
 
243
+-(NSDictionary*)getAppStyle
244
+{
245
+  return [NSDictionary dictionaryWithDictionary:self.globalAppStyle];
246
+}
247
+
248
+-(void)setAppStyle:(NSDictionary*)appStyle
249
+{
250
+  self.globalAppStyle = [NSDictionary dictionaryWithDictionary:appStyle];
251
+}
252
+
253
+
241 254
 #pragma mark - RCTBridgeDelegate methods
242 255
 
243 256
 - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge

+ 6
- 0
ios/RCCManagerModule.m Visa fil

@@ -229,6 +229,12 @@ RCT_EXPORT_METHOD(
229 229
     
230 230
     // first clear the registry to remove any refernece to the previous controllers
231 231
     [[RCCManager sharedInstance] clearModuleRegistry];
232
+    [[RCCManager sharedInstance] setAppStyle:nil];
233
+    
234
+    NSDictionary *appStyle = layout[@"props"][@"appStyle"];
235
+    if (appStyle) {
236
+        [[RCCManager sharedIntance] setAppStyle:appStyle];
237
+    }
232 238
     
233 239
     // create the new controller
234 240
     UIViewController *controller = [RCCViewController controllerWithLayout:layout globalProps:modifiedGloablProps bridge:[[RCCManager sharedInstance] getBridge]];

+ 3
- 1
ios/RCCViewController.m Visa fil

@@ -178,7 +178,9 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
178 178
   self.edgesForExtendedLayout = UIRectEdgeNone; // default
179 179
   self.automaticallyAdjustsScrollViewInsets = NO; // default
180 180
   
181
-  self.navigatorStyle = [NSMutableDictionary dictionaryWithDictionary:navigatorStyle];
181
+  self.navigatorStyle = [NSMutableDictionary dictionaryWithDictionary:[[RCCManager sharedInstance] getAppStyle]];
182
+  [self.navigatorStyle addEntriesFromDictionary:navigatorStyle];
183
+
182 184
   
183 185
   [self setStyleOnInit];
184 186
   

+ 2
- 2
ios/ReactNativeNavigation.xcodeproj/project.pbxproj Visa fil

@@ -59,8 +59,8 @@
59 59
 		26714EAB1EB0E9D3009F4D52 /* RCCCustomTitleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCCCustomTitleView.m; sourceTree = "<group>"; };
60 60
 		26AFF3F31D7EEE2400CBA211 /* RCCTitleViewHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RCCTitleViewHelper.h; path = Helpers/RCCTitleViewHelper.h; sourceTree = "<group>"; };
61 61
 		26AFF3F41D7EEE2400CBA211 /* RCCTitleViewHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RCCTitleViewHelper.m; path = Helpers/RCCTitleViewHelper.m; sourceTree = "<group>"; };
62
-2DCD49981F33AAC30035123A /* RCCCustomBarButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RCCCustomBarButtonItem.m; path = RCCCustomBarButtonItem.m; sourceTree = "<group>"; };
63
-		2DCD49991F33AAC30035123A /* RCCCustomBarButtonItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RCCCustomBarButtonItem.h; path = RCCCustomBarButtonItem.h; sourceTree = "<group>"; };
62
+		2DCD49981F33AAC30035123A /* RCCCustomBarButtonItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCCCustomBarButtonItem.m; sourceTree = "<group>"; };
63
+		2DCD49991F33AAC30035123A /* RCCCustomBarButtonItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCCCustomBarButtonItem.h; sourceTree = "<group>"; };
64 64
 		CC84A1931C1A0C4E00B3A6A2 /* RCCManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCCManager.h; sourceTree = "<group>"; };
65 65
 		CC84A1941C1A0C4E00B3A6A2 /* RCCManager.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; path = RCCManager.m; sourceTree = "<group>"; tabWidth = 2; };
66 66
 		CC84A1951C1A0C4E00B3A6A2 /* RCCManagerModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCCManagerModule.h; sourceTree = "<group>"; };

+ 2
- 0
src/deprecated/controllers/index.js Visa fil

@@ -1,4 +1,5 @@
1 1
 /*eslint-disable*/
2
+var _ = require('lodash');
2 3
 var OriginalReactNative = require('react-native');
3 4
 var RCCManager = OriginalReactNative.NativeModules.RCCManager;
4 5
 var NativeAppEventEmitter = OriginalReactNative.NativeAppEventEmitter;
@@ -125,6 +126,7 @@ var Controllers = {
125 126
       if (controller === undefined) return;
126 127
       var layout = controller.render();
127 128
       _validateDrawerProps(layout);
129
+      _processProperties(_.get(layout, 'props.appStyle', {}));
128 130
       RCCManager.setRootController(layout, animationType, passProps);
129 131
     }
130 132
   },