Fix background color (IOS-194)

This commit is contained in:
Nathan Mattes 2023-11-20 12:35:13 +01:00
parent c45252b294
commit 32520be6c9
3 changed files with 5 additions and 45 deletions

View File

@ -21,9 +21,6 @@ extension ProfileCardView {
var disposeBag = Set<AnyCancellable>()
public let relationshipViewModel = RelationshipViewModel()
@Published public var userInterfaceStyle: UIUserInterfaceStyle?
@Published public var backgroundColor: UIColor?
// Author
@Published public var authorBannerImageURL: URL?
@ -46,32 +43,11 @@ extension ProfileCardView {
@Published public var groupedAccessibilityLabel = ""
@Published public var familiarFollowers: Mastodon.Entity.FamiliarFollowers?
init() {
backgroundColor = .systemBackground
$userInterfaceStyle
.sink { [weak self] userInterfaceStyle in
guard let self = self else { return }
guard let userInterfaceStyle = userInterfaceStyle else { return }
switch userInterfaceStyle {
case .dark:
self.backgroundColor = .secondarySystemBackground
case .light, .unspecified:
self.backgroundColor = Asset.Scene.Discovery.profileCardBackground.color
@unknown default:
self.backgroundColor = Asset.Scene.Discovery.profileCardBackground.color
assertionFailure()
// do nothing
}
}
.store(in: &disposeBag)
}
}
}
extension ProfileCardView.ViewModel {
func bind(view: ProfileCardView) {
bindAppearacne(view: view)
bindHeader(view: view)
bindUser(view: view)
bindBio(view: view)
@ -81,18 +57,6 @@ extension ProfileCardView.ViewModel {
// bindAccessibility(view: view)
}
private func bindAppearacne(view: ProfileCardView) {
userInterfaceStyle = view.traitCollection.userInterfaceStyle
$backgroundColor
.assign(to: \.backgroundColor, on: view.container)
.store(in: &disposeBag)
$backgroundColor
.assign(to: \.backgroundColor, on: view.avatarButtonBackgroundView)
.store(in: &disposeBag)
}
private func bindHeader(view: ProfileCardView) {
$authorBannerImageURL
.sink { url in

View File

@ -136,6 +136,7 @@ extension ProfileCardView {
container.axis = .vertical
container.spacing = 8
container.translatesAutoresizingMaskIntoConstraints = false
container.backgroundColor = Asset.Scene.Discovery.profileCardBackground.color
addSubview(container)
container.pinToParent()
@ -184,6 +185,7 @@ extension ProfileCardView {
avatarButton.heightAnchor.constraint(equalToConstant: ProfileCardView.avatarSize.height).priority(.required - 1),
])
avatarButtonBackgroundView.backgroundColor = Asset.Scene.Discovery.profileCardBackground.color
avatarButtonBackgroundView.layer.masksToBounds = true
avatarButtonBackgroundView.layer.cornerCurve = .continuous
avatarButtonBackgroundView.layer.cornerRadius = 12 + 1
@ -256,12 +258,6 @@ extension ProfileCardView {
familiarFollowersDashboardView.addGestureRecognizer(familiarFollowersDashboardViewTapGestureRecognizer)
}
public override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
viewModel.userInterfaceStyle = traitCollection.userInterfaceStyle
}
public override func layoutSubviews() {
updateInfoContainerLayout()
super.layoutSubviews()

View File

@ -23,9 +23,9 @@
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "4",
"green" : "5",
"red" : "6"
"blue" : "0x1E",
"green" : "0x1C",
"red" : "0x1C"
}
},
"idiom" : "universal"