From f4a2792b0fc904c4dfc6b195bfd5684bc20467cb Mon Sep 17 00:00:00 2001 From: CMK Date: Fri, 2 Jul 2021 13:21:05 +0800 Subject: [PATCH] chore: update cell highlighted color for Dark Mode --- .../xcschemes/xcschememanagement.plist | 4 +- Mastodon/Coordinator/SceneCoordinator.swift | 5 ++- Mastodon/Diffiable/Section/PollSection.swift | 6 +-- Mastodon/Extension/UIView.swift | 15 +++++++- Mastodon/Generated/Assets.swift | 4 ++ .../Colors/Background/Cell/Contents.json | 9 +++++ .../Cell/highlight.colorset/Contents.json | 38 +++++++++++++++++++ .../Cell/separator.colorset/Contents.json | 38 +++++++++++++++++++ .../Contents.json | 6 +-- .../system.background.colorset/Contents.json | 6 +-- .../Contents.json | 6 +-- .../Contents.json | 6 +-- .../Contents.json | 6 +-- .../Cell/AutoCompleteTableViewCell.swift | 5 +++ .../NotificationStatusTableViewCell.swift | 6 ++- .../NotificationTableViewCell.swift | 5 +++ .../Scene/Search/SearchViewController.swift | 1 + .../TableviewCell/StatusTableViewCell.swift | 7 +++- 18 files changed, 148 insertions(+), 25 deletions(-) create mode 100644 Mastodon/Resources/Assets.xcassets/Colors/Background/Cell/Contents.json create mode 100644 Mastodon/Resources/Assets.xcassets/Colors/Background/Cell/highlight.colorset/Contents.json create mode 100644 Mastodon/Resources/Assets.xcassets/Colors/Background/Cell/separator.colorset/Contents.json diff --git a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist index f1135b12e..da1d80e90 100644 --- a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist @@ -12,7 +12,7 @@ CoreDataStack.xcscheme_^#shared#^_ orderHint - 20 + 21 Mastodon - ASDK.xcscheme_^#shared#^_ @@ -37,7 +37,7 @@ NotificationService.xcscheme_^#shared#^_ orderHint - 21 + 20 SuppressBuildableAutocreation diff --git a/Mastodon/Coordinator/SceneCoordinator.swift b/Mastodon/Coordinator/SceneCoordinator.swift index a12a72d93..fbe0ced5c 100644 --- a/Mastodon/Coordinator/SceneCoordinator.swift +++ b/Mastodon/Coordinator/SceneCoordinator.swift @@ -279,7 +279,10 @@ private extension SceneCoordinator { scheme == "http" || scheme == "https" else { return nil } - viewController = SFSafariViewController(url: url) + let _viewController = SFSafariViewController(url: url) + _viewController.preferredControlTintColor = Asset.Colors.brandBlue.color + viewController = _viewController + case .alertController(let alertController): if let popoverPresentationController = alertController.popoverPresentationController { assert( diff --git a/Mastodon/Diffiable/Section/PollSection.swift b/Mastodon/Diffiable/Section/PollSection.swift index 3c31d9b93..581620c0c 100644 --- a/Mastodon/Diffiable/Section/PollSection.swift +++ b/Mastodon/Diffiable/Section/PollSection.swift @@ -67,13 +67,13 @@ extension PollSection { cell.pollOptionView.checkmarkBackgroundView.isHidden = true cell.pollOptionView.checkmarkImageView.isHidden = true case .off: - cell.pollOptionView.checkmarkBackgroundView.backgroundColor = .systemBackground - cell.pollOptionView.checkmarkBackgroundView.layer.borderColor = UIColor.systemGray3.cgColor + cell.pollOptionView.checkmarkBackgroundView.backgroundColor = Asset.Colors.Background.tertiarySystemBackground.color + cell.pollOptionView.checkmarkBackgroundView.layer.borderColor = Asset.Colors.Background.Cell.highlight.color.withAlphaComponent(0.3).cgColor cell.pollOptionView.checkmarkBackgroundView.layer.borderWidth = 1 cell.pollOptionView.checkmarkBackgroundView.isHidden = false cell.pollOptionView.checkmarkImageView.isHidden = true case .on: - cell.pollOptionView.checkmarkBackgroundView.backgroundColor = .systemBackground + cell.pollOptionView.checkmarkBackgroundView.backgroundColor = Asset.Colors.Background.tertiarySystemBackground.color cell.pollOptionView.checkmarkBackgroundView.layer.borderColor = UIColor.clear.cgColor cell.pollOptionView.checkmarkBackgroundView.layer.borderWidth = 0 cell.pollOptionView.checkmarkBackgroundView.isHidden = false diff --git a/Mastodon/Extension/UIView.swift b/Mastodon/Extension/UIView.swift index 05940f7bc..50dd08f17 100644 --- a/Mastodon/Extension/UIView.swift +++ b/Mastodon/Extension/UIView.swift @@ -7,12 +7,23 @@ import UIKit -// MARK: - Convinience view creation method +// MARK: - Convenience view creation method extension UIView { + + static let separatorColor: UIColor = { + UIColor(dynamicProvider: { collection in + switch collection.userInterfaceStyle { + case .dark: + return Asset.Colors.Background.Cell.separator.color + default: + return .separator + } + }) + }() static var separatorLine: UIView { let line = UIView() - line.backgroundColor = .separator + line.backgroundColor = UIView.separatorColor return line } diff --git a/Mastodon/Generated/Assets.swift b/Mastodon/Generated/Assets.swift index 4740c938a..da2eee466 100644 --- a/Mastodon/Generated/Assets.swift +++ b/Mastodon/Generated/Assets.swift @@ -32,6 +32,10 @@ internal enum Asset { } internal enum Colors { internal enum Background { + internal enum Cell { + internal static let highlight = ColorAsset(name: "Colors/Background/Cell/highlight") + internal static let separator = ColorAsset(name: "Colors/Background/Cell/separator") + } internal enum Poll { internal static let disabled = ColorAsset(name: "Colors/Background/Poll/disabled") } diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/Cell/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/Background/Cell/Contents.json new file mode 100644 index 000000000..6e965652d --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/Colors/Background/Cell/Contents.json @@ -0,0 +1,9 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + }, + "properties" : { + "provides-namespace" : true + } +} diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/Cell/highlight.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/Background/Cell/highlight.colorset/Contents.json new file mode 100644 index 000000000..da756e551 --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/Colors/Background/Cell/highlight.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "214", + "green" : "209", + "red" : "209" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x6E", + "green" : "0x57", + "red" : "0x4F" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/Cell/separator.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/Background/Cell/separator.colorset/Contents.json new file mode 100644 index 000000000..8ae75b24c --- /dev/null +++ b/Mastodon/Resources/Assets.xcassets/Colors/Background/Cell/separator.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.839", + "green" : "0.820", + "red" : "0.820" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.431", + "green" : "0.341", + "red" : "0.310" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/secondary.grouped.system.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/Background/secondary.grouped.system.background.colorset/Contents.json index acd80352b..697525877 100644 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/secondary.grouped.system.background.colorset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/Colors/Background/secondary.grouped.system.background.colorset/Contents.json @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "67", - "green" : "53", - "red" : "49" + "blue" : "0x43", + "green" : "0x35", + "red" : "0x31" } }, "idiom" : "universal" diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/system.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/Background/system.background.colorset/Contents.json index 01c3e3ff1..f09411b71 100644 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/system.background.colorset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/Colors/Background/system.background.colorset/Contents.json @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "55", - "green" : "44", - "red" : "40" + "blue" : "0x37", + "green" : "0x2C", + "red" : "0x28" } }, "idiom" : "universal" diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/system.elevated.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/Background/system.elevated.background.colorset/Contents.json index dd6cbfd91..147cca83c 100644 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/system.elevated.background.colorset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/Colors/Background/system.elevated.background.colorset/Contents.json @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "55", - "green" : "44", - "red" : "40" + "blue" : "0x37", + "green" : "0x2C", + "red" : "0x28" } }, "idiom" : "universal" diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.background.colorset/Contents.json index 9fa2b261b..b769998d0 100644 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.background.colorset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.background.colorset/Contents.json @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0x3C", - "green" : "0x3A", - "red" : "0x3A" + "blue" : "0.216", + "green" : "0.173", + "red" : "0.157" } }, "idiom" : "universal" diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.grouped.background.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.grouped.background.colorset/Contents.json index 5da572b1d..06932c34f 100644 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.grouped.background.colorset/Contents.json +++ b/Mastodon/Resources/Assets.xcassets/Colors/Background/tertiary.system.grouped.background.colorset/Contents.json @@ -23,9 +23,9 @@ "color-space" : "srgb", "components" : { "alpha" : "1.000", - "blue" : "0x3C", - "green" : "0x3A", - "red" : "0x3A" + "blue" : "0.263", + "green" : "0.208", + "red" : "0.192" } }, "idiom" : "universal" diff --git a/Mastodon/Scene/Compose/AutoComplete/Cell/AutoCompleteTableViewCell.swift b/Mastodon/Scene/Compose/AutoComplete/Cell/AutoCompleteTableViewCell.swift index 6b996ba1c..f150dd754 100644 --- a/Mastodon/Scene/Compose/AutoComplete/Cell/AutoCompleteTableViewCell.swift +++ b/Mastodon/Scene/Compose/AutoComplete/Cell/AutoCompleteTableViewCell.swift @@ -74,6 +74,11 @@ extension AutoCompleteTableViewCell { private func _init() { backgroundColor = .clear + selectedBackgroundView = { + let view = UIView() + view.backgroundColor = Asset.Colors.Background.Cell.highlight.color + return view + }() let topPaddingView = UIView() let bottomPaddingView = UIView() diff --git a/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift b/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift index f4138f092..d2231d4f6 100644 --- a/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift +++ b/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift @@ -112,7 +112,11 @@ final class NotificationStatusTableViewCell: UITableViewCell, StatusCell { extension NotificationStatusTableViewCell { func configure() { backgroundColor = Asset.Colors.Background.systemBackground.color - + selectedBackgroundView = { + let view = UIView() + view.backgroundColor = Asset.Colors.Background.Cell.highlight.color + return view + }() let containerStackView = UIStackView() containerStackView.axis = .horizontal containerStackView.alignment = .top diff --git a/Mastodon/Scene/Notification/TableViewCell/NotificationTableViewCell.swift b/Mastodon/Scene/Notification/TableViewCell/NotificationTableViewCell.swift index 375e4c2b3..15fa21c6a 100644 --- a/Mastodon/Scene/Notification/TableViewCell/NotificationTableViewCell.swift +++ b/Mastodon/Scene/Notification/TableViewCell/NotificationTableViewCell.swift @@ -130,6 +130,11 @@ final class NotificationTableViewCell: UITableViewCell { extension NotificationTableViewCell { func configure() { backgroundColor = Asset.Colors.Background.systemBackground.color + selectedBackgroundView = { + let view = UIView() + view.backgroundColor = Asset.Colors.Background.Cell.highlight.color + return view + }() let containerStackView = UIStackView() containerStackView.axis = .vertical diff --git a/Mastodon/Scene/Search/SearchViewController.swift b/Mastodon/Scene/Search/SearchViewController.swift index 9a256fb58..51b88e120 100644 --- a/Mastodon/Scene/Search/SearchViewController.swift +++ b/Mastodon/Scene/Search/SearchViewController.swift @@ -103,6 +103,7 @@ final class SearchViewController: UIViewController, NeedsDependency { tableView.rowHeight = UITableView.automaticDimension tableView.separatorStyle = .singleLine tableView.separatorInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) + tableView.separatorColor = UIView.separatorColor return tableView }() diff --git a/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift b/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift index ceb211a7b..262304538 100644 --- a/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift +++ b/Mastodon/Scene/Share/View/TableviewCell/StatusTableViewCell.swift @@ -103,7 +103,12 @@ extension StatusTableViewCell { private func _init() { backgroundColor = Asset.Colors.Background.systemBackground.color - + selectedBackgroundView = { + let view = UIView() + view.backgroundColor = Asset.Colors.Background.Cell.highlight.color + return view + }() + statusView.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(statusView) NSLayoutConstraint.activate([