Skip to content

Commit

Permalink
Add window.backgroundColor option (#5942)
Browse files Browse the repository at this point in the history
  • Loading branch information
yogevbd authored Feb 19, 2020
1 parent 66fefc8 commit c99ecf9
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/ios/RNNBasePresenter.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ - (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions {
if (@available(iOS 13.0, *)) {
viewController.modalInPresentation = ![withDefault.modal.swipeToDismiss getWithDefaultValue:YES];
}

UIApplication.sharedApplication.delegate.window.backgroundColor = [withDefault.window.backgroundColor getWithDefaultValue:nil];
}

- (void)applyOptionsOnViewDidLayoutSubviews:(RNNNavigationOptions *)options {
Expand Down Expand Up @@ -165,6 +167,10 @@ - (void)mergeOptions:(RNNNavigationOptions *)options resolvedOptions:(RNNNavigat
UITabBarItem *tabItem = [RNNTabBarItemCreator updateTabBarItem:viewController.tabBarItem bottomTabOptions:withDefault.bottomTab];
viewController.tabBarItem = tabItem;
}

if (options.window.backgroundColor.hasValue) {
UIApplication.sharedApplication.delegate.window.backgroundColor = withDefault.window.backgroundColor.get;
}
}

- (void)renderComponents:(RNNNavigationOptions *)options perform:(RNNReactViewReadyCompletionBlock)readyBlock {
Expand Down
2 changes: 2 additions & 0 deletions lib/ios/RNNNavigationOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#import "RNNSplitViewOptions.h"
#import "RNNModalOptions.h"
#import "DeprecationOptions.h"
#import "WindowOptions.h"

extern const NSInteger BLUR_TOPBAR_TAG;

Expand All @@ -32,6 +33,7 @@ extern const NSInteger BLUR_TOPBAR_TAG;
@property (nonatomic, strong) RNNSplitViewOptions* splitView;
@property (nonatomic, strong) RNNModalOptions* modal;
@property (nonatomic, strong) DeprecationOptions* deprecations;
@property (nonatomic, strong) WindowOptions* window;

@property (nonatomic, strong) Bool* popGesture;
@property (nonatomic, strong) Image* backgroundImage;
Expand Down
1 change: 1 addition & 0 deletions lib/ios/RNNNavigationOptions.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ - (instancetype)initWithDict:(NSDictionary *)dict {
self.layout = [[RNNLayoutOptions alloc] initWithDict:dict[@"layout"]];
self.modal = [[RNNModalOptions alloc] initWithDict:dict[@"modal"]];
self.deprecations = [[DeprecationOptions alloc] initWithDict:dict[@"deprecations"]];
self.window = [[WindowOptions alloc] initWithDict:dict[@"window"]];

self.popGesture = [[Bool alloc] initWithValue:dict[@"popGesture"]];

Expand Down
8 changes: 8 additions & 0 deletions lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@
50A00C38200F84D6000F01A6 /* RNNOverlayOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50A00C36200F84D6000F01A6 /* RNNOverlayOptions.m */; };
50A246372395399700A192C5 /* RNNModalOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 50A246352395399700A192C5 /* RNNModalOptions.h */; };
50A246382395399700A192C5 /* RNNModalOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50A246362395399700A192C5 /* RNNModalOptions.m */; };
50A4962323FD51B900F4816D /* WindowOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 50A4962123FD51B900F4816D /* WindowOptions.h */; };
50A4962423FD51B900F4816D /* WindowOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50A4962223FD51B900F4816D /* WindowOptions.m */; };
50A5628A23DDAB5A0027C219 /* TransitionDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 50A5628823DDAB5A0027C219 /* TransitionDelegate.h */; };
50A5628B23DDAB5A0027C219 /* TransitionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 50A5628923DDAB5A0027C219 /* TransitionDelegate.m */; };
50A5628E23DDAB6F0027C219 /* ModalTransitionDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 50A5628C23DDAB6F0027C219 /* ModalTransitionDelegate.h */; };
Expand Down Expand Up @@ -741,6 +743,8 @@
50A00C36200F84D6000F01A6 /* RNNOverlayOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNOverlayOptions.m; sourceTree = "<group>"; };
50A246352395399700A192C5 /* RNNModalOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNModalOptions.h; sourceTree = "<group>"; };
50A246362395399700A192C5 /* RNNModalOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNModalOptions.m; sourceTree = "<group>"; };
50A4962123FD51B900F4816D /* WindowOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WindowOptions.h; sourceTree = "<group>"; };
50A4962223FD51B900F4816D /* WindowOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WindowOptions.m; sourceTree = "<group>"; };
50A5628823DDAB5A0027C219 /* TransitionDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TransitionDelegate.h; sourceTree = "<group>"; };
50A5628923DDAB5A0027C219 /* TransitionDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TransitionDelegate.m; sourceTree = "<group>"; };
50A5628C23DDAB6F0027C219 /* ModalTransitionDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ModalTransitionDelegate.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1180,6 +1184,8 @@
children = (
504AFE621FFE53070076E904 /* RNNOptions.h */,
504AFE631FFE53070076E904 /* RNNOptions.m */,
50A4962123FD51B900F4816D /* WindowOptions.h */,
50A4962223FD51B900F4816D /* WindowOptions.m */,
4534E72320CB6724009F8185 /* RNNLargeTitleOptions.h */,
4534E72420CB6724009F8185 /* RNNLargeTitleOptions.m */,
E83BAD691F27362500A9F3DD /* RNNNavigationOptions.h */,
Expand Down Expand Up @@ -1644,6 +1650,7 @@
26916C981E4B9E7700D13680 /* RNNReactRootViewCreator.h in Headers */,
5012241A21736678000F5F98 /* Image.h in Headers */,
506A2B1420973DFD00F43A95 /* RNNErrorHandler.h in Headers */,
50A4962323FD51B900F4816D /* WindowOptions.h in Headers */,
50A5628A23DDAB5A0027C219 /* TransitionDelegate.h in Headers */,
503A8A0923BB86200094D1C4 /* TimeIntervalParser.h in Headers */,
263905B01E4C6F440023D7D3 /* MMDrawerController+Subclass.h in Headers */,
Expand Down Expand Up @@ -2009,6 +2016,7 @@
5038A3BA216DFCFD009280BC /* UITabBarController+RNNOptions.m in Sources */,
5030B62123D5B4CB008F1642 /* LNInterpolable.m in Sources */,
50A246382395399700A192C5 /* RNNModalOptions.m in Sources */,
50A4962423FD51B900F4816D /* WindowOptions.m in Sources */,
50E38DDE23A7A306009817F6 /* AnimatedImageView.m in Sources */,
263905B21E4C6F440023D7D3 /* MMDrawerController.m in Sources */,
50644A2120E11A720026709C /* Constants.m in Sources */,
Expand Down
7 changes: 7 additions & 0 deletions lib/ios/WindowOptions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#import "RNNOptions.h"

@interface WindowOptions : RNNOptions

@property (nonatomic, strong) Color* backgroundColor;

@end
11 changes: 11 additions & 0 deletions lib/ios/WindowOptions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#import "WindowOptions.h"

@implementation WindowOptions

- (instancetype)initWithDict:(NSDictionary *)dict {
self = [super init];
self.backgroundColor = [ColorParser parse:dict key:@"backgroundColor"];
return self;
}

@end

0 comments on commit c99ecf9

Please sign in to comment.