Add some styling (IOS-234)

This commit is contained in:
Nathan Mattes 2024-04-09 18:44:42 +02:00
parent 6e61e3ca25
commit c1c6ef44e9
1 changed files with 17 additions and 2 deletions

View File

@ -15,7 +15,6 @@ class TimelineStatusPill: UIButton {
reason.title, attributes: AttributeContainer(
[
.font: UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .systemFont(ofSize: 15, weight: .bold)),
.foregroundColor: UIColor.white
]
))
@ -26,12 +25,28 @@ class TimelineStatusPill: UIButton {
configuration.image = image
configuration.imagePadding = 8
configuration.baseBackgroundColor = reason.backgroundColor
configuration.cornerStyle = .capsule
configuration.background.backgroundColor = reason.backgroundColor
self.configuration = configuration
}
override func updateConfiguration() {
guard let reason, var updatedConfiguration = configuration else {
return super.updateConfiguration()
}
switch state {
case .selected, .highlighted, .focused:
updatedConfiguration.baseForegroundColor = UIColor.white.withAlphaComponent(0.5)
default:
updatedConfiguration.baseForegroundColor = .white
}
updatedConfiguration.background.backgroundColor = reason.backgroundColor
self.configuration = updatedConfiguration
}
public enum Reason {
case newPosts
case postSent