From ee3f37b39cdbbda4ca9f94a4d60104975b9e726d Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Thu, 21 Nov 2024 19:54:45 +0200 Subject: [PATCH] Fix button colors in some themes --- iOS/GBBackgroundView.m | 2 +- iOS/GBTheme.h | 1 + iOS/GBTheme.m | 10 ++++++++++ iOS/GBViewController.m | 4 ++-- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/iOS/GBBackgroundView.m b/iOS/GBBackgroundView.m index 55ecac783..6b6c514af 100644 --- a/iOS/GBBackgroundView.m +++ b/iOS/GBBackgroundView.m @@ -497,7 +497,7 @@ - (void)setLayout:(GBLayout *)layout if (@available(iOS 13.0, *)) { self.overrideUserInterfaceStyle = layout.theme.isDark? UIUserInterfaceStyleDark : UIUserInterfaceStyleLight; - self.tintColor = layout.theme.brandColor; + self.tintColor = layout.theme.buttonColor; } _screenLabel.frame = screenFrame; diff --git a/iOS/GBTheme.h b/iOS/GBTheme.h index e35ad5994..884cd79bc 100644 --- a/iOS/GBTheme.h +++ b/iOS/GBTheme.h @@ -2,6 +2,7 @@ @interface GBTheme : NSObject @property (readonly, direct) UIColor *brandColor; +@property (readonly, direct) UIColor *buttonColor; @property (readonly, direct) UIColor *backgroundGradientTop; @property (readonly, direct) UIColor *backgroundGradientBottom; @property (readonly, direct) UIColor *bezelsGradientTop; diff --git a/iOS/GBTheme.m b/iOS/GBTheme.m index 8555c0841..448b058a3 100644 --- a/iOS/GBTheme.m +++ b/iOS/GBTheme.m @@ -155,6 +155,16 @@ - (instancetype)initDarkTheme } +- (UIColor *)buttonColor +{ + double r, g, b; + [_brandColor getRed:&r green:&g blue:&b alpha:NULL]; + if (r == 1.0 && g == 1.0 && b == 1.0) { + return _backgroundGradientTop; + } + return [UIColor colorWithRed:r green:g blue:b alpha:1.0]; +} + - (bool)isDark { double r, g, b; diff --git a/iOS/GBViewController.m b/iOS/GBViewController.m index 281d8cd1c..530589ad0 100644 --- a/iOS/GBViewController.m +++ b/iOS/GBViewController.m @@ -229,7 +229,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( [[GBHorizontalLayout alloc] initWithTheme:theme cutoutOnRight:true] : _horizontalLayoutLeft; _verticalLayout = [[GBVerticalLayout alloc] initWithTheme:theme]; - _printerSpinner.color = theme.brandColor; + _printerSpinner.color = theme.buttonColor; [self willRotateToInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation duration:0]; @@ -376,7 +376,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( _printerButton = [[UIButton alloc] init]; _printerSpinner = [[UIActivityIndicatorView alloc] init]; _printerSpinner.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhite; - _printerSpinner.color = _verticalLayout.theme.brandColor; + _printerSpinner.color = _verticalLayout.theme.buttonColor; [self didRotateFromInterfaceOrientation:[UIApplication sharedApplication].statusBarOrientation]; if (@available(iOS 13.0, *)) {