From 780025a3ceee83cb5cbccf1d596a942982ae9100 Mon Sep 17 00:00:00 2001 From: sunxiaojian Date: Fri, 16 Apr 2021 22:58:36 +0800 Subject: [PATCH] chore: use systemBackground color --- Mastodon/Generated/Assets.swift | 1 - .../Background/pure.colorset/Contents.json | 38 ------------------- .../NotificationViewController.swift | 2 +- .../NotificationStatusTableViewCell.swift | 13 ++++--- .../NotificationTableViewCell.swift | 18 +++------ .../Scene/Search/SearchViewController.swift | 2 +- 6 files changed, 15 insertions(+), 59 deletions(-) delete mode 100644 Mastodon/Resources/Assets.xcassets/Colors/Background/pure.colorset/Contents.json diff --git a/Mastodon/Generated/Assets.swift b/Mastodon/Generated/Assets.swift index 0e0869f0..2ffc882b 100644 --- a/Mastodon/Generated/Assets.swift +++ b/Mastodon/Generated/Assets.swift @@ -44,7 +44,6 @@ internal enum Asset { internal static let mediaTypeIndicotor = ColorAsset(name: "Colors/Background/media.type.indicotor") internal static let navigationBar = ColorAsset(name: "Colors/Background/navigationBar") internal static let onboardingBackground = ColorAsset(name: "Colors/Background/onboarding.background") - internal static let pure = ColorAsset(name: "Colors/Background/pure") internal static let secondaryGroupedSystemBackground = ColorAsset(name: "Colors/Background/secondary.grouped.system.background") internal static let secondarySystemBackground = ColorAsset(name: "Colors/Background/secondary.system.background") internal static let systemBackground = ColorAsset(name: "Colors/Background/system.background") diff --git a/Mastodon/Resources/Assets.xcassets/Colors/Background/pure.colorset/Contents.json b/Mastodon/Resources/Assets.xcassets/Colors/Background/pure.colorset/Contents.json deleted file mode 100644 index 82edd034..00000000 --- a/Mastodon/Resources/Assets.xcassets/Colors/Background/pure.colorset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "colors" : [ - { - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "1.000", - "green" : "1.000", - "red" : "1.000" - } - }, - "idiom" : "universal" - }, - { - "appearances" : [ - { - "appearance" : "luminosity", - "value" : "dark" - } - ], - "color" : { - "color-space" : "srgb", - "components" : { - "alpha" : "1.000", - "blue" : "30", - "green" : "28", - "red" : "28" - } - }, - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - } -} diff --git a/Mastodon/Scene/Notification/NotificationViewController.swift b/Mastodon/Scene/Notification/NotificationViewController.swift index 3fb86259..7dccb423 100644 --- a/Mastodon/Scene/Notification/NotificationViewController.swift +++ b/Mastodon/Scene/Notification/NotificationViewController.swift @@ -45,7 +45,7 @@ final class NotificationViewController: UIViewController, NeedsDependency { extension NotificationViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = Asset.Colors.Background.pure.color + view.backgroundColor = Asset.Colors.Background.systemBackground.color navigationItem.titleView = segmentControl segmentControl.addTarget(self, action: #selector(NotificationViewController.segmentedControlValueChanged(_:)), for: .valueChanged) view.addSubview(tableView) diff --git a/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift b/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift index 5d1a14be..cdde9dbe 100644 --- a/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift +++ b/Mastodon/Scene/Notification/TableViewCell/NotificationStatusTableViewCell.swift @@ -26,7 +26,7 @@ final class NotificationStatusTableViewCell: UITableViewCell { let actionImageView: UIImageView = { let imageView = UIImageView() - imageView.tintColor = Asset.Colors.Background.pure.color + imageView.tintColor = Asset.Colors.Background.systemBackground.color return imageView }() @@ -36,8 +36,8 @@ final class NotificationStatusTableViewCell: UITableViewCell { view.layer.cornerCurve = .continuous view.clipsToBounds = true view.layer.borderWidth = NotificationStatusTableViewCell.actionImageBorderWidth - view.layer.borderColor = Asset.Colors.Background.pure.color.cgColor - view.tintColor = Asset.Colors.Background.pure.color + view.layer.borderColor = Asset.Colors.Background.systemBackground.color.cgColor + view.tintColor = Asset.Colors.Background.systemBackground.color return view }() @@ -157,7 +157,7 @@ extension NotificationStatusTableViewCell { let actionStackView = UIStackView() actionStackView.axis = .horizontal - actionStackView.distribution = .fillProportionally + actionStackView.distribution = .fill actionStackView.spacing = 4 actionStackView.translatesAutoresizingMaskIntoConstraints = false @@ -166,7 +166,8 @@ extension NotificationStatusTableViewCell { actionLabel.translatesAutoresizingMaskIntoConstraints = false actionStackView.addArrangedSubview(actionLabel) nameLabel.setContentCompressionResistancePriority(.required - 1, for: .vertical) - + nameLabel.setContentHuggingPriority(.defaultHigh, for: .horizontal) + actionLabel.setContentHuggingPriority(.defaultLow, for: .horizontal) let statusStackView = UIStackView() statusStackView.axis = .vertical @@ -205,6 +206,6 @@ extension NotificationStatusTableViewCell { override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { super.traitCollectionDidChange(previousTraitCollection) statusBorder.layer.borderColor = Asset.Colors.Border.notification.color.cgColor - actionImageBackground.layer.borderColor = Asset.Colors.Background.pure.color.cgColor + actionImageBackground.layer.borderColor = Asset.Colors.Background.systemBackground.color.cgColor } } diff --git a/Mastodon/Scene/Notification/TableViewCell/NotificationTableViewCell.swift b/Mastodon/Scene/Notification/TableViewCell/NotificationTableViewCell.swift index 1b7560a7..60b43ac3 100644 --- a/Mastodon/Scene/Notification/TableViewCell/NotificationTableViewCell.swift +++ b/Mastodon/Scene/Notification/TableViewCell/NotificationTableViewCell.swift @@ -35,7 +35,7 @@ final class NotificationTableViewCell: UITableViewCell { let actionImageView: UIImageView = { let imageView = UIImageView() - imageView.tintColor = Asset.Colors.Background.pure.color + imageView.tintColor = Asset.Colors.Background.systemBackground.color return imageView }() @@ -45,8 +45,8 @@ final class NotificationTableViewCell: UITableViewCell { view.layer.cornerCurve = .continuous view.clipsToBounds = true view.layer.borderWidth = NotificationTableViewCell.actionImageBorderWidth - view.layer.borderColor = Asset.Colors.Background.pure.color.cgColor - view.tintColor = Asset.Colors.Background.pure.color + view.layer.borderColor = Asset.Colors.Background.systemBackground.color.cgColor + view.tintColor = Asset.Colors.Background.systemBackground.color return view }() @@ -137,25 +137,19 @@ extension NotificationTableViewCell { actionImageView.centerXAnchor.constraint(equalTo: actionImageBackground.centerXAnchor), actionImageView.centerYAnchor.constraint(equalTo: actionImageBackground.centerYAnchor) ]) - - - let actionStackView = UIStackView() - actionStackView.axis = .horizontal - actionStackView.distribution = .fillProportionally - actionStackView.spacing = 4 - actionStackView.translatesAutoresizingMaskIntoConstraints = false nameLabel.translatesAutoresizingMaskIntoConstraints = false containerStackView.addArrangedSubview(nameLabel) actionLabel.translatesAutoresizingMaskIntoConstraints = false containerStackView.addArrangedSubview(actionLabel) nameLabel.setContentCompressionResistancePriority(.required - 1, for: .vertical) - containerStackView.addArrangedSubview(actionStackView) + nameLabel.setContentHuggingPriority(.defaultHigh, for: .horizontal) + actionLabel.setContentHuggingPriority(.defaultLow, for: .horizontal) } override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { super.traitCollectionDidChange(previousTraitCollection) - actionImageBackground.layer.borderColor = Asset.Colors.Background.pure.color.cgColor + actionImageBackground.layer.borderColor = Asset.Colors.Background.systemBackground.color.cgColor } } diff --git a/Mastodon/Scene/Search/SearchViewController.swift b/Mastodon/Scene/Search/SearchViewController.swift index 4fee226b..710808b5 100644 --- a/Mastodon/Scene/Search/SearchViewController.swift +++ b/Mastodon/Scene/Search/SearchViewController.swift @@ -82,7 +82,7 @@ final class SearchViewController: UIViewController, NeedsDependency { // searching let searchingTableView: UITableView = { let tableView = UITableView() - tableView.backgroundColor = Asset.Colors.Background.pure.color + tableView.backgroundColor = Asset.Colors.Background.systemBackground.color tableView.rowHeight = UITableView.automaticDimension tableView.separatorStyle = .singleLine tableView.separatorInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)