From 0b77c1985753630ff2f4f18bee0bf8ee8ad951ec Mon Sep 17 00:00:00 2001 From: CMK Date: Tue, 8 Jun 2021 17:26:12 +0800 Subject: [PATCH] fix: setting scene background color not elevated under Dark Mode issue --- Mastodon/Scene/Settings/SettingsViewController.swift | 11 +++++++++-- .../View/Cell/SettingsAppearanceTableViewCell.swift | 2 +- .../Scene/Settings/View/SettingsSectionHeader.swift | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Mastodon/Scene/Settings/SettingsViewController.swift b/Mastodon/Scene/Settings/SettingsViewController.swift index ad85bee8..07705846 100644 --- a/Mastodon/Scene/Settings/SettingsViewController.swift +++ b/Mastodon/Scene/Settings/SettingsViewController.swift @@ -94,7 +94,7 @@ class SettingsViewController: UIViewController, NeedsDependency { tableView.translatesAutoresizingMaskIntoConstraints = false tableView.delegate = self tableView.rowHeight = UITableView.automaticDimension - tableView.backgroundColor = Asset.Colors.Background.systemGroupedBackground.color + tableView.backgroundColor = .clear tableView.register(SettingsAppearanceTableViewCell.self, forCellReuseIdentifier: String(describing: SettingsAppearanceTableViewCell.self)) tableView.register(SettingsToggleTableViewCell.self, forCellReuseIdentifier: String(describing: SettingsToggleTableViewCell.self)) @@ -185,7 +185,14 @@ class SettingsViewController: UIViewController, NeedsDependency { } private func setupView() { - view.backgroundColor = Asset.Colors.Background.secondarySystemBackground.color + view.backgroundColor = UIColor(dynamicProvider: { traitCollection in + switch traitCollection.userInterfaceLevel { + case .elevated where traitCollection.userInterfaceStyle == .dark: + return Asset.Colors.Background.systemElevatedBackground.color + default: + return Asset.Colors.Background.secondarySystemBackground.color + } + }) setupNavigation() view.addSubview(tableView) diff --git a/Mastodon/Scene/Settings/View/Cell/SettingsAppearanceTableViewCell.swift b/Mastodon/Scene/Settings/View/Cell/SettingsAppearanceTableViewCell.swift index a58bebf8..9a9ff745 100644 --- a/Mastodon/Scene/Settings/View/Cell/SettingsAppearanceTableViewCell.swift +++ b/Mastodon/Scene/Settings/View/Cell/SettingsAppearanceTableViewCell.swift @@ -176,7 +176,7 @@ class SettingsAppearanceTableViewCell: UITableViewCell { // MARK: Private methods private func setupUI() { - backgroundColor = Asset.Colors.Background.systemGroupedBackground.color + backgroundColor = .clear selectionStyle = .none contentView.addSubview(stackView) diff --git a/Mastodon/Scene/Settings/View/SettingsSectionHeader.swift b/Mastodon/Scene/Settings/View/SettingsSectionHeader.swift index ccd7fd87..0ce45101 100644 --- a/Mastodon/Scene/Settings/View/SettingsSectionHeader.swift +++ b/Mastodon/Scene/Settings/View/SettingsSectionHeader.swift @@ -39,7 +39,8 @@ class SettingsSectionHeader: UIView { init(frame: CGRect, customView: UIView? = nil) { super.init(frame: frame) - backgroundColor = Asset.Colors.Background.systemGroupedBackground.color + backgroundColor = .clear + stackView.addArrangedSubview(titleLabel) if let view = customView { stackView.addArrangedSubview(view)