fix: account switch scene not adopt elevated color issue

This commit is contained in:
CMK 2021-11-04 15:13:17 +08:00
parent 00cf2db8a1
commit 469acd12f5
6 changed files with 48 additions and 17 deletions

View File

@ -75,7 +75,7 @@ extension AccountListViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = ThemeService.shared.currentTheme.value.systemBackgroundColor.withAlphaComponent(0.9)
setupBackgroundColor(theme: ThemeService.shared.currentTheme.value)
ThemeService.shared.currentTheme
.receive(on: DispatchQueue.main)
.sink { [weak self] theme in
@ -131,7 +131,15 @@ extension AccountListViewController {
}
private func setupBackgroundColor(theme: Theme) {
view.backgroundColor = theme.systemBackgroundColor.withAlphaComponent(0.9)
let backgroundColor = UIColor { traitCollection in
switch traitCollection.userInterfaceLevel {
case .elevated where traitCollection.userInterfaceStyle == .dark:
return theme.systemElevatedBackgroundColor
default:
return theme.systemBackgroundColor.withAlphaComponent(0.9)
}
}
view.backgroundColor = backgroundColor
}
}

View File

@ -12,6 +12,7 @@ import MetaTextKit
final class AccountListTableViewCell: UITableViewCell {
private var _disposeBag = Set<AnyCancellable>()
var disposeBag = Set<AnyCancellable>()
let avatarButton = CircleAvatarButton(frame: .zero)
@ -47,6 +48,15 @@ final class AccountListTableViewCell: UITableViewCell {
extension AccountListTableViewCell {
private func _init() {
backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemGroupedBackgroundColor
ThemeService.shared.currentTheme
.receive(on: RunLoop.main)
.sink { [weak self] theme in
guard let self = self else { return }
self.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemGroupedBackgroundColor
}
.store(in: &_disposeBag)
avatarButton.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(avatarButton)
NSLayoutConstraint.activate([

View File

@ -6,10 +6,13 @@
//
import UIKit
import Combine
import MetaTextKit
final class AddAccountTableViewCell: UITableViewCell {
private var _disposeBag = Set<AnyCancellable>()
let iconImageView: UIImageView = {
let image = UIImage(systemName: "plus.circle.fill")!
let imageView = UIImageView(image: image)
@ -41,6 +44,15 @@ final class AddAccountTableViewCell: UITableViewCell {
extension AddAccountTableViewCell {
private func _init() {
backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemGroupedBackgroundColor
ThemeService.shared.currentTheme
.receive(on: RunLoop.main)
.sink { [weak self] theme in
guard let self = self else { return }
self.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemGroupedBackgroundColor
}
.store(in: &_disposeBag)
iconImageView.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(iconImageView)
NSLayoutConstraint.activate([

View File

@ -312,7 +312,7 @@ extension MastodonRegisterViewController {
view.addGestureRecognizer(tapGestureRecognizer)
tapGestureRecognizer.addTarget(self, action: #selector(tapGestureRecognizerHandler))
// stackview
// stackView
stackView.axis = .vertical
stackView.distribution = .fill
stackView.spacing = 40
@ -370,7 +370,7 @@ extension MastodonRegisterViewController {
scrollView.frameLayoutGuide.widthAnchor.constraint(equalTo: scrollView.contentLayoutGuide.widthAnchor),
])
// stackview
// stackView
scrollView.addSubview(stackView)
stackView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([

View File

@ -51,7 +51,7 @@ class ReportViewController: UIViewController, NeedsDependency {
return view
}()
lazy var stackview: UIStackView = {
lazy var stackView: UIStackView = {
let view = UIStackView()
view.axis = .vertical
view.alignment = .fill
@ -122,19 +122,19 @@ class ReportViewController: UIViewController, NeedsDependency {
setupNavigation()
stackview.addArrangedSubview(header)
stackview.addArrangedSubview(contentView)
stackview.addArrangedSubview(footer)
stackview.addArrangedSubview(bottomSpacing)
stackView.addArrangedSubview(header)
stackView.addArrangedSubview(contentView)
stackView.addArrangedSubview(footer)
stackView.addArrangedSubview(bottomSpacing)
contentView.addSubview(tableView)
view.addSubview(stackview)
view.addSubview(stackView)
NSLayoutConstraint.activate([
stackview.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
stackview.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stackview.bottomAnchor.constraint(equalTo: view.bottomAnchor),
stackview.trailingAnchor.constraint(equalTo: view.trailingAnchor),
stackView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor),
stackView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
stackView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
stackView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
tableView.topAnchor.constraint(equalTo: contentView.topAnchor),
tableView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor),
tableView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),
@ -273,8 +273,8 @@ class ReportViewController: UIViewController, NeedsDependency {
navigationItem.titleView = titleView
if let user = beReportedUser {
do {
let mastodonConent = MastodonContent(content: user.displayNameWithFallback, emojis: user.emojiMeta)
let metaContent = try MastodonMetaContent.convert(document: mastodonConent)
let mastodonContent = MastodonContent(content: user.displayNameWithFallback, emojis: user.emojiMeta)
let metaContent = try MastodonMetaContent.convert(document: mastodonContent)
titleView.update(titleMetaContent: metaContent, subtitle: nil)
} catch {
let metaContent = PlaintextMetaContent(string: user.displayNameWithFallback)

View File

@ -19,6 +19,7 @@ final class ReportedStatusTableViewCell: UITableViewCell, StatusCell {
static let bottomPaddingHeight: CGFloat = 10
weak var dependency: ReportViewController?
private var _disposeBag = Set<AnyCancellable>()
var disposeBag = Set<AnyCancellable>()
var observations = Set<NSKeyValueObservation>()
@ -98,7 +99,7 @@ extension ReportedStatusTableViewCell {
guard let self = self else { return }
self.backgroundColor = ThemeService.shared.currentTheme.value.secondarySystemGroupedBackgroundColor
}
.store(in: &disposeBag)
.store(in: &_disposeBag)
checkbox.translatesAutoresizingMaskIntoConstraints = false
contentView.addSubview(checkbox)