chore: DRY setting up colors from theme
This commit is contained in:
parent
530d69a78c
commit
c1f19d1f27
|
@ -242,14 +242,13 @@ final class ProfileHeaderView: UIView {
|
||||||
|
|
||||||
extension ProfileHeaderView {
|
extension ProfileHeaderView {
|
||||||
private func _init() {
|
private func _init() {
|
||||||
backgroundColor = ThemeService.shared.currentTheme.value.systemBackgroundColor
|
let currentTheme = ThemeService.shared.currentTheme
|
||||||
avatarButton.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemBackgroundColor
|
setColors(from: currentTheme.value)
|
||||||
ThemeService.shared.currentTheme
|
|
||||||
|
currentTheme
|
||||||
.receive(on: DispatchQueue.main)
|
.receive(on: DispatchQueue.main)
|
||||||
.sink { [weak self] theme in
|
.sink { [weak self] theme in
|
||||||
guard let self = self else { return }
|
self?.setColors(from: theme)
|
||||||
self.backgroundColor = theme.systemBackgroundColor
|
|
||||||
self.avatarButton.backgroundColor = theme.secondarySystemBackgroundColor
|
|
||||||
}
|
}
|
||||||
.store(in: &_disposeBag)
|
.store(in: &_disposeBag)
|
||||||
|
|
||||||
|
@ -455,6 +454,11 @@ extension ProfileHeaderView {
|
||||||
|
|
||||||
updateLayoutMargins()
|
updateLayoutMargins()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private func setColors(from theme: Theme) {
|
||||||
|
backgroundColor = theme.systemBackgroundColor
|
||||||
|
avatarButton.backgroundColor = theme.secondarySystemBackgroundColor
|
||||||
|
}
|
||||||
|
|
||||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||||
super.traitCollectionDidChange(previousTraitCollection)
|
super.traitCollectionDidChange(previousTraitCollection)
|
||||||
|
|
Loading…
Reference in New Issue