-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: root background color change on dark/light view for ios (#617)
- Loading branch information
Showing
5 changed files
with
45 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -731,4 +731,4 @@ SPEC CHECKSUMS: | |
|
||
PODFILE CHECKSUM: 62e6d8fc85ac6b63b6370c161340ec610b2d688a | ||
|
||
COCOAPODS: 1.9.3 | ||
COCOAPODS: 1.10.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#import <React/RCTRootView.h> | ||
@interface AtBRootView : RCTRootView | ||
-(void)setBackgroundByTrait; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#import "AtBRootView.h" | ||
#import <React/RCTRootView.h> | ||
|
||
@implementation AtBRootView | ||
|
||
- (void) traitCollectionDidChange: (UITraitCollection *) previousTraitCollection | ||
{ | ||
[super traitCollectionDidChange: previousTraitCollection]; | ||
|
||
if (@available(iOS 13.0, *)) { | ||
if (self.traitCollection.userInterfaceStyle != previousTraitCollection.userInterfaceStyle) { | ||
[self setBackgroundByTrait]; | ||
} | ||
} | ||
} | ||
|
||
- (void)setBackgroundByTrait | ||
{ | ||
if (@available(iOS 13.0, *)) { | ||
if ([UITraitCollection currentTraitCollection].userInterfaceStyle == UIUserInterfaceStyleDark) | ||
{ | ||
self.window.rootViewController.view.backgroundColor = [[UIColor alloc] initWithRed:0.0f green:0.0f blue:0.0f alpha:1]; | ||
} else { | ||
self.window.rootViewController.view.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; | ||
} | ||
} else { | ||
self.window.rootViewController.view.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; | ||
} | ||
} | ||
|
||
@end |