Skip to content

Commit

Permalink
Black on grey without border in light mode (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
krugerk authored Oct 19, 2024
1 parent c751942 commit 590fcd3
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions BeeKit/UI/BSButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@ import UIKit
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()
fatalError("init(coder:) has not been implemented; neither xib nor storyboards in use")
}

override init(frame: CGRect) {
Expand All @@ -32,23 +24,22 @@ public class BSButton : UIButton {
self.resetStyle()
}

self.setUp()
self.resetStyle()
}

private func setUp() {
private func resetStyle() {
self.configuration = .filled()

self.titleLabel?.font = UIFont.beeminder.defaultBoldFont

self.setTitleColor(dynamicTitleColor, for: UIControl.State())
self.tintColor = dynamicTintFillColor
self.configuration = .filled()

self.backgroundColor = .clear

self.layer.borderColor = UIColor.Beeminder.yellow.cgColor
self.layer.borderWidth = 1
self.layer.cornerRadius = 4
}

private func resetStyle() {
self.tintColor = dynamicTintFillColor
self.setTitleColor(dynamicTitleColor, for: UIControl.State())
self.layer.borderColor = traitCollection.userInterfaceStyle == .dark ? UIColor.Beeminder.yellow.cgColor : UIColor.clear.cgColor
self.layer.borderWidth = traitCollection.userInterfaceStyle == .dark ? 1 : 0
self.layer.cornerRadius = traitCollection.userInterfaceStyle == .dark ? 4 : 0
}

private let dynamicTintFillColor = UIColor { traitCollection in
Expand Down

0 comments on commit 590fcd3

Please sign in to comment.