Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic dark mode #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Blur/MRBlurView.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ - (void)statusBarOrientationDidChange:(NSNotification *)notification {

- (void)setPlaceholder {
self.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.96];

if ([UIApplication sharedApplication].statusBarStyle == UIStatusBarStyleLightContent) {
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.96];
}
}

- (void)clearPlaceholder {
Expand All @@ -126,7 +130,11 @@ - (void)redraw {
}

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
image = [image mr_applyBlurWithRadius:30.0 tintColor:[UIColor colorWithWhite:0.97 alpha:0.82] saturationDeltaFactor:1.0 maskImage:nil];
UIColor *defaultBgColor = [UIColor colorWithWhite:0.97 alpha:0.82];
if ([UIApplication sharedApplication].statusBarStyle == UIStatusBarStyleLightContent) {
defaultBgColor = [UIColor colorWithWhite:0.03 alpha:0.82];
}
image = [image mr_applyBlurWithRadius:30.0 tintColor:defaultBgColor saturationDeltaFactor:1.0 maskImage:nil];
dispatch_async(dispatch_get_main_queue(), ^{
// Fade on content's change, dependent if there was already an image.
CATransition *transition = [CATransition new];
Expand Down
13 changes: 11 additions & 2 deletions src/Components/MRProgressOverlayView.m
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,12 @@ - (void)commonInit {
// Create titleLabel
UILabel *titleLabel = [UILabel new];
self.titleLabel = titleLabel;
UIColor *textColor = UIColor.blackColor;
if ([UIApplication sharedApplication].statusBarStyle == UIStatusBarStyleLightContent) {
textColor = UIColor.whiteColor;
}
self.titleLabel.attributedText = [[NSAttributedString alloc] initWithString:@"Loading ..." attributes:@{
NSForegroundColorAttributeName: UIColor.blackColor,
NSForegroundColorAttributeName: textColor,
NSFontAttributeName: [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline],
NSKernAttributeName: NSNull.null, // turn on auto-kerning
}];
Expand Down Expand Up @@ -566,7 +570,12 @@ - (void)show:(BOOL)animated {

void(^animBlock)() = ^{
[self setSubviewTransform:CGAffineTransformIdentity alpha:1.0f];
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4f];
if ([UIApplication sharedApplication].statusBarStyle == UIStatusBarStyleLightContent) {
self.backgroundColor = [UIColor colorWithWhite:1 alpha:0.4f];
} else {
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4f];
}

};

if (animated) {
Expand Down