From 15be4a9ce3766c4da35ab2c0052c3d84d0d6a6bb Mon Sep 17 00:00:00 2001 From: CMK Date: Fri, 27 May 2022 00:01:31 +0800 Subject: [PATCH] fix: account notification badge color only set to Dark Mode style issue --- .../Account/Cell/AccountListTableViewCell.swift | 1 - Mastodon/Scene/Account/View/BadgeButton.swift | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Mastodon/Scene/Account/Cell/AccountListTableViewCell.swift b/Mastodon/Scene/Account/Cell/AccountListTableViewCell.swift index 2b480464d..96111d9f8 100644 --- a/Mastodon/Scene/Account/Cell/AccountListTableViewCell.swift +++ b/Mastodon/Scene/Account/Cell/AccountListTableViewCell.swift @@ -23,7 +23,6 @@ final class AccountListTableViewCell: UITableViewCell { let checkmarkImageView: UIImageView = { let image = UIImage(systemName: "checkmark", withConfiguration: UIImage.SymbolConfiguration(pointSize: 17, weight: .semibold)) let imageView = UIImageView(image: image) - imageView.tintColor = .label return imageView }() let separatorLine = UIView.separatorLine diff --git a/Mastodon/Scene/Account/View/BadgeButton.swift b/Mastodon/Scene/Account/View/BadgeButton.swift index 785053be9..c4fd28e89 100644 --- a/Mastodon/Scene/Account/View/BadgeButton.swift +++ b/Mastodon/Scene/Account/View/BadgeButton.swift @@ -26,10 +26,14 @@ final class BadgeButton: UIButton { extension BadgeButton { private func _init() { titleLabel?.font = UIFontMetrics(forTextStyle: .caption1).scaledFont(for: .systemFont(ofSize: 13, weight: .medium)) - setBackgroundColor(.systemBackground, for: .normal) - setTitleColor(.label, for: .normal) - contentEdgeInsets = UIEdgeInsets(top: 6, left: 6, bottom: 6, right: 6) + setAppearance() + } + + override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { + super.traitCollectionDidChange(previousTraitCollection) + + setAppearance() } override func layoutSubviews() { @@ -39,6 +43,12 @@ extension BadgeButton { layer.cornerRadius = frame.height * 0.5 } + private func setAppearance() { + setBackgroundColor(Asset.Colors.Label.primary.color, for: .normal) + setTitleColor(Asset.Colors.Label.primaryReverse.color, for: .normal) + tintColor = Asset.Colors.Label.primary.color + } + func setBadge(number: Int) { let number = min(99, max(0, number)) setTitle("\(number)", for: .normal)