From 59755b6d70b4f5541f6a693e2bfc57a0603fb5d7 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Sat, 4 Nov 2023 23:19:40 +0100 Subject: [PATCH] Adjust fonts, icon and colors for updated verified-design (IOS-130) --- .../Profile/ProfileFieldSection.swift | 36 +++++++++---------- .../Cell/ProfileFieldCollectionViewCell.swift | 22 ++---------- ...eFieldCollectionViewHeaderFooterView.swift | 13 +------ .../MastodonUI/Extension/MetaLabel.swift | 2 +- 4 files changed, 21 insertions(+), 52 deletions(-) diff --git a/Mastodon/Diffable/Profile/ProfileFieldSection.swift b/Mastodon/Diffable/Profile/ProfileFieldSection.swift index c7d530f2b..0303cf89d 100644 --- a/Mastodon/Diffable/Profile/ProfileFieldSection.swift +++ b/Mastodon/Diffable/Profile/ProfileFieldSection.swift @@ -35,28 +35,26 @@ extension ProfileFieldSection { let fieldCellRegistration = UICollectionView.CellRegistration { cell, indexPath, item in let key, value: String let emojiMeta: MastodonContent.Emojis - let verified: Bool switch item { - case .field(field: let field): - key = field.name.value - value = field.value.value - emojiMeta = field.emojiMeta - verified = field.verifiedAt.value != nil - case .createdAt(date: let date): - key = L10n.Scene.Profile.Fields.joined - let formatter = DateFormatter() - formatter.dateStyle = .medium - formatter.timeStyle = .none - formatter.timeZone = TimeZone(identifier: "UTC") - value = formatter.string(from: date) - emojiMeta = [:] - verified = false - default: return + case .field(field: let field): + key = field.name.value + value = field.value.value + emojiMeta = field.emojiMeta + + case .createdAt(date: let date): + key = L10n.Scene.Profile.Fields.joined + let formatter = DateFormatter() + formatter.dateStyle = .medium + formatter.timeStyle = .none + formatter.timeZone = TimeZone(identifier: "UTC") + value = formatter.string(from: date) + emojiMeta = [:] + case .addEntry, .editField(_): return } // set key - let keyColor = verified ? Asset.Scene.Profile.About.bioAboutFieldVerifiedText.color : Asset.Colors.Label.secondary.color + let keyColor = Asset.Colors.Label.secondary.color do { let mastodonContent = MastodonContent(content: key, emojis: emojiMeta) let metaContent = try MastodonMetaContent.convert(document: mastodonContent) @@ -69,7 +67,7 @@ extension ProfileFieldSection { } // set value - let linkColor = verified ? Asset.Scene.Profile.About.bioAboutFieldVerifiedText.color : Asset.Colors.Brand.blurple.color + let linkColor = Asset.Colors.Brand.blurple.color do { let mastodonContent = MastodonContent(content: value, emojis: emojiMeta) let metaContent = try MastodonMetaContent.convert(document: mastodonContent) @@ -83,7 +81,7 @@ extension ProfileFieldSection { // set background var backgroundConfiguration = UIBackgroundConfiguration.listPlainCell() - backgroundConfiguration.backgroundColor = verified ? Asset.Scene.Profile.About.bioAboutFieldVerifiedBackground.color : UIColor.secondarySystemBackground + backgroundConfiguration.backgroundColor = UIColor.secondarySystemBackground cell.backgroundConfiguration = backgroundConfiguration // set checkmark and edit menu label diff --git a/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift b/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift index 099799c6e..de9b88335 100644 --- a/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift +++ b/Mastodon/Scene/Profile/About/Cell/ProfileFieldCollectionViewCell.swift @@ -25,7 +25,7 @@ final class ProfileFieldCollectionViewCell: UICollectionViewCell { let keyMetaLabel = MetaLabel(style: .profileFieldName) let valueMetaLabel = MetaLabel(style: .profileFieldValue) - let checkmark = UIImageView(image: Asset.Editing.checkmark.image.withRenderingMode(.alwaysTemplate)) + let checkmark = UIImageView(image: UIImage(systemName: "checkmark.seal")) var checkmarkPopoverString: String? = nil; let tapGesture = UITapGestureRecognizer(); var editMenuInteraction: UIEditMenuInteraction! @@ -55,7 +55,7 @@ extension ProfileFieldCollectionViewCell { editMenuInteraction = UIEditMenuInteraction(delegate: self) // Setup colors - checkmark.tintColor = Asset.Scene.Profile.About.bioAboutFieldVerifiedText.color; + checkmark.tintColor = Asset.Colors.Brand.blurple.color // Setup gestures tapGesture.addTarget(self, action: #selector(ProfileFieldCollectionViewCell.didTapCheckmark(_:))) @@ -145,24 +145,6 @@ extension ProfileFieldCollectionViewCell { } } -// UIMenuController boilerplate -@available(iOS, deprecated: 16, message: "Can be removed when target version is >=16 -- boilerplate to maintain compatibility with UIMenuController") -extension ProfileFieldCollectionViewCell { - override var canBecomeFirstResponder: Bool { true } - - override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool { - if action == #selector(dismissVerifiedMenu) { - return true - } - - return super.canPerformAction(action, withSender: sender) - } - - @objc public func dismissVerifiedMenu() { - UIMenuController.shared.hideMenu() - } -} - // MARK: - MetaLabelDelegate extension ProfileFieldCollectionViewCell: MetaLabelDelegate { func metaLabel(_ metaLabel: MetaLabel, didSelectMeta meta: Meta) { diff --git a/Mastodon/Scene/Profile/Header/View/ProfileFieldCollectionViewHeaderFooterView.swift b/Mastodon/Scene/Profile/Header/View/ProfileFieldCollectionViewHeaderFooterView.swift index 8a0d3c6d6..8795dfd23 100644 --- a/Mastodon/Scene/Profile/Header/View/ProfileFieldCollectionViewHeaderFooterView.swift +++ b/Mastodon/Scene/Profile/Header/View/ProfileFieldCollectionViewHeaderFooterView.swift @@ -14,18 +14,7 @@ final class ProfileFieldCollectionViewHeaderFooterView: UICollectionReusableView override init(frame: CGRect) { super.init(frame: frame) - _init() - } - - required init?(coder: NSCoder) { - super.init(coder: coder) - _init() } -} - -extension ProfileFieldCollectionViewHeaderFooterView { - private func _init() { - - } + required init?(coder: NSCoder) { fatalError("Not implemented") } } diff --git a/MastodonSDK/Sources/MastodonUI/Extension/MetaLabel.swift b/MastodonSDK/Sources/MastodonUI/Extension/MetaLabel.swift index cee24e98b..d69342d81 100644 --- a/MastodonSDK/Sources/MastodonUI/Extension/MetaLabel.swift +++ b/MastodonSDK/Sources/MastodonUI/Extension/MetaLabel.swift @@ -78,7 +78,7 @@ extension MetaLabel { textColor = Asset.Colors.Label.secondary.color case .profileFieldName: - font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 13, weight: .semibold)) + font = UIFontMetrics(forTextStyle: .headline).scaledFont(for: .systemFont(ofSize: 13, weight: .regular)) textColor = Asset.Colors.Label.secondary.color case .profileFieldValue: