From 3fb4124bc66156f329b3c0d5746ce87bff11b1c2 Mon Sep 17 00:00:00 2001 From: krugerk <4656811+krugerk@users.noreply.github.com> Date: Sun, 6 Oct 2024 13:53:11 +0200 Subject: [PATCH 1/3] BSButton's fill color was too dark in light mode --- BeeKit/UI/BSButton.swift | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/BeeKit/UI/BSButton.swift b/BeeKit/UI/BSButton.swift index cb1c1bd90..d375cee22 100644 --- a/BeeKit/UI/BSButton.swift +++ b/BeeKit/UI/BSButton.swift @@ -24,7 +24,7 @@ public class BSButton : UIButton { private func setUp() { self.titleLabel?.font = UIFont.beeminder.defaultBoldFont self.setTitleColor(UIColor.Beeminder.yellow, for: UIControl.State()) - self.tintColor = .black + self.tintColor = dynamicTintFillColor self.configuration = .filled() self.layer.borderColor = UIColor.Beeminder.yellow.cgColor @@ -32,4 +32,15 @@ public class BSButton : UIButton { self.layer.cornerRadius = 4 } + private let dynamicTintFillColor = UIColor { traitCollection in + switch traitCollection.userInterfaceStyle { + case .dark: + return UIColor.black + default: + return UIColor(red: 59.0/255.0, + green: 59.0/255.0, + blue: 59.0/255.0, + alpha: 0.5) + } + } } From 77f78e3646d3fae57d441d823381376dd4bbe246 Mon Sep 17 00:00:00 2001 From: krugerk <4656811+krugerk@users.noreply.github.com> Date: Sun, 6 Oct 2024 14:06:12 +0200 Subject: [PATCH 2/3] BSButton's style updates on light/dark appearance --- BeeKit/UI/BSButton.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/BeeKit/UI/BSButton.swift b/BeeKit/UI/BSButton.swift index d375cee22..29e3e305e 100644 --- a/BeeKit/UI/BSButton.swift +++ b/BeeKit/UI/BSButton.swift @@ -13,11 +13,25 @@ public class BSButton : UIButton { required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) + + registerForTraitChanges( + [UITraitUserInterfaceStyle.self]) { + (self: Self, previousTraitCollection: UITraitCollection) in + self.resetStyle() + } + self.setUp() } override init(frame: CGRect) { super.init(frame: frame) + + registerForTraitChanges( + [UITraitUserInterfaceStyle.self]) { + (self: Self, previousTraitCollection: UITraitCollection) in + self.resetStyle() + } + self.setUp() } @@ -32,6 +46,10 @@ public class BSButton : UIButton { self.layer.cornerRadius = 4 } + private func resetStyle() { + self.tintColor = dynamicTintFillColor + } + private let dynamicTintFillColor = UIColor { traitCollection in switch traitCollection.userInterfaceStyle { case .dark: From ad122c11303bf73f1dd8bd5f9e9c6db0c1e8d777 Mon Sep 17 00:00:00 2001 From: krugerk <4656811+krugerk@users.noreply.github.com> Date: Sun, 6 Oct 2024 22:48:01 +0200 Subject: [PATCH 3/3] increase contrast of button when in light mode --- BeeKit/UI/BSButton.swift | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/BeeKit/UI/BSButton.swift b/BeeKit/UI/BSButton.swift index 29e3e305e..87d74a69f 100644 --- a/BeeKit/UI/BSButton.swift +++ b/BeeKit/UI/BSButton.swift @@ -37,7 +37,7 @@ public class BSButton : UIButton { private func setUp() { self.titleLabel?.font = UIFont.beeminder.defaultBoldFont - self.setTitleColor(UIColor.Beeminder.yellow, for: UIControl.State()) + self.setTitleColor(dynamicTitleColor, for: UIControl.State()) self.tintColor = dynamicTintFillColor self.configuration = .filled() @@ -48,6 +48,7 @@ public class BSButton : UIButton { private func resetStyle() { self.tintColor = dynamicTintFillColor + self.setTitleColor(dynamicTitleColor, for: UIControl.State()) } private let dynamicTintFillColor = UIColor { traitCollection in @@ -55,10 +56,19 @@ public class BSButton : UIButton { case .dark: return UIColor.black default: - return UIColor(red: 59.0/255.0, - green: 59.0/255.0, - blue: 59.0/255.0, - alpha: 0.5) + return UIColor(red: 235.0/255.0, + green: 235.0/255.0, + blue: 235.0/255.0, + alpha: 1.0) + } + } + + private let dynamicTitleColor = UIColor { traitCollection in + switch traitCollection.userInterfaceStyle { + case .dark: + return UIColor.Beeminder.yellow + default: + return UIColor.black } } }