Update ReactionsMenuButton UI

This commit is contained in:
SBiOSoftWhare
2019-06-25 12:06:54 +02:00
parent 516be40462
commit 8e2d1d6bc9
@@ -18,7 +18,14 @@ import UIKit
class ReactionsMenuButton: UIButton, Themable {
// MARK: Private
// MARK: - Constants
private enum Constants {
static let borderWidthSelected: CGFloat = 1/UIScreen.main.scale
static let borderColorAlpha: CGFloat = 0.15
}
// MARK: - Properties
private var theme: Theme!
@@ -38,8 +45,8 @@ class ReactionsMenuButton: UIButton, Themable {
override func layoutSubviews() {
super.layoutSubviews()
self.layer.cornerRadius = self.frame.size.height / 2
self.layer.borderWidth = self.isSelected ? 1 : 0
self.layer.cornerRadius = self.frame.size.height / 3
self.layer.borderWidth = self.isSelected ? Constants.borderWidthSelected : 0
}
// MARK: - Private
@@ -59,16 +66,15 @@ class ReactionsMenuButton: UIButton, Themable {
func update(theme: Theme) {
self.theme = theme
// TODO: Color for black theme
self.setTitleColor(self.theme.textPrimaryColor, for: .normal)
self.setTitleColor(self.theme.textPrimaryColor, for: .selected)
self.layer.borderColor = self.theme.tintColor.cgColor
self.layer.borderColor = self.theme.tintColor.withAlphaComponent(Constants.borderColorAlpha).cgColor
}
private func updateView() {
backgroundColor = isSelected ? self.theme.tintBackgroundColor : self.theme.headerBackgroundColor
backgroundColor = isSelected ? self.theme.tintBackgroundColor : UIColor.clear
}
override open var isSelected: Bool {