From 92ca2a006c974e55f64ff15711cd6656230c3509 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Wed, 20 Sep 2023 21:04:49 +0200 Subject: [PATCH] Fix colors for hashtag-follow-button --- Mastodon.xcodeproj/project.pbxproj | 4 -- .../HashtagTimelineHeaderView.swift | 29 +++++++----- ...ashtagTimelineHeaderViewActionButton.swift | 47 ------------------- 3 files changed, 18 insertions(+), 62 deletions(-) delete mode 100644 Mastodon/Scene/HashtagTimeline/HashtagTimelineHeaderViewActionButton.swift diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index 20af38cce..26b20f229 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -44,7 +44,6 @@ 2A72812E297EA9D8004138C5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2A72812D297EA9D8004138C5 /* Assets.xcassets */; }; 2A728134297EA9D8004138C5 /* WidgetExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 2A728120297EA9D7004138C5 /* WidgetExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 2A72813F297EC762004138C5 /* WidgetExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A72813E297EC762004138C5 /* WidgetExtension.swift */; }; - 2A76F75C2930D94700B3388D /* HashtagTimelineHeaderViewActionButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A76F75B2930D94700B3388D /* HashtagTimelineHeaderViewActionButton.swift */; }; 2A82294F29262EE000D2A1F7 /* AppContext+NextAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A82294E29262EE000D2A1F7 /* AppContext+NextAccount.swift */; }; 2A86A14629892944007F1062 /* MultiFollowersCountIntentHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A86A14529892944007F1062 /* MultiFollowersCountIntentHandler.swift */; }; 2A86A14929892B3A007F1062 /* MultiFollowersCountWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2A86A14829892B3A007F1062 /* MultiFollowersCountWidget.swift */; }; @@ -639,7 +638,6 @@ 2A72812D297EA9D8004138C5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 2A72812F297EA9D8004138C5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 2A72813E297EC762004138C5 /* WidgetExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WidgetExtension.swift; sourceTree = ""; }; - 2A76F75B2930D94700B3388D /* HashtagTimelineHeaderViewActionButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HashtagTimelineHeaderViewActionButton.swift; sourceTree = ""; }; 2A82294E29262EE000D2A1F7 /* AppContext+NextAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AppContext+NextAccount.swift"; sourceTree = ""; }; 2A86A14529892944007F1062 /* MultiFollowersCountIntentHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiFollowersCountIntentHandler.swift; sourceTree = ""; }; 2A86A14829892B3A007F1062 /* MultiFollowersCountWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultiFollowersCountWidget.swift; sourceTree = ""; }; @@ -1323,7 +1321,6 @@ 0F20220626134DA4000C64BF /* HashtagTimelineViewModel+Diffable.swift */, 0F20222C261457EE000C64BF /* HashtagTimelineViewModel+State.swift */, 2A506CF5292D040100059C37 /* HashtagTimelineHeaderView.swift */, - 2A76F75B2930D94700B3388D /* HashtagTimelineHeaderViewActionButton.swift */, ); path = HashtagTimeline; sourceTree = ""; @@ -3881,7 +3878,6 @@ DBCC3B30261440A50045B23D /* UITabBarController.swift in Sources */, DB3E6FE42806A5B800B035AE /* DiscoverySection.swift in Sources */, DB8190C62601FF0400020C08 /* AttachmentContainerView.swift in Sources */, - 2A76F75C2930D94700B3388D /* HashtagTimelineHeaderViewActionButton.swift in Sources */, DB697DDB278F4DE3004EF2F7 /* DataSourceProvider+StatusTableViewCellDelegate.swift in Sources */, DB87D4512609CF1E00D12C0D /* ComposeStatusPollOptionAppendEntryCollectionViewCell.swift in Sources */, DBB45B5627B39FC9002DC5A7 /* MediaPreviewVideoViewController.swift in Sources */, diff --git a/Mastodon/Scene/HashtagTimeline/HashtagTimelineHeaderView.swift b/Mastodon/Scene/HashtagTimeline/HashtagTimelineHeaderView.swift index 3af2cf07b..96bc4ed13 100644 --- a/Mastodon/Scene/HashtagTimeline/HashtagTimelineHeaderView.swift +++ b/Mastodon/Scene/HashtagTimeline/HashtagTimelineHeaderView.swift @@ -69,10 +69,13 @@ final class HashtagTimelineHeaderView: UIView { var onButtonTapped: (() -> Void)? let followButton: UIButton = { - let button = HashtagTimelineHeaderViewActionButton() - button.cornerRadius = 10 - button.contentEdgeInsets = UIEdgeInsets(top: 6, left: 16, bottom: 5, right: 16) // set 28pt height - button.titleLabel?.font = .systemFont(ofSize: 14, weight: .bold) + let button = UIButton(configuration: .tinted()) + button.configuration?.background.cornerRadius = 10 + button.configuration?.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer({ incoming in + var outgoing = incoming + outgoing.font = UIFontMetrics(forTextStyle: .subheadline).scaledFont(for: .boldSystemFont(ofSize: 15)) + return outgoing + }) return button }() @@ -153,14 +156,18 @@ private extension HashtagTimelineHeaderView { extension HashtagTimelineHeaderView { func update(_ entity: HashtagTimelineHeaderView.Data) { titleLabel.text = "#\(entity.name)" - followButton.setTitle(entity.following == true ? L10n.Scene.FollowedTags.Actions.unfollow : L10n.Scene.FollowedTags.Actions.follow, for: .normal) - followButton.backgroundColor = entity.following == true ? Asset.Colors.Button.tagUnfollow.color : Asset.Colors.Button.tagFollow.color - - followButton.setTitleColor( - entity.following == true ? Asset.Colors.Button.tagFollow.color : Asset.Colors.Button.tagUnfollow.color, - for: .normal - ) + if entity.following { + followButton.configuration?.background.backgroundColor = Asset.Colors.Button.userFollowing.color + followButton.configuration?.baseForegroundColor = Asset.Colors.Button.userFollowingTitle.color + followButton.configuration?.title = L10n.Scene.FollowedTags.Actions.unfollow + } else { + followButton.configuration?.background.backgroundColor = Asset.Colors.Button.userFollow.color + followButton.configuration?.baseForegroundColor = .white + followButton.configuration?.title = L10n.Scene.FollowedTags.Actions.follow + } + + followButton.configuration?.contentInsets = NSDirectionalEdgeInsets(top: 6, leading: 16, bottom: 5, trailing: 16) postCountLabel.text = String(entity.postCount) participantsLabel.text = String(entity.participantsCount) diff --git a/Mastodon/Scene/HashtagTimeline/HashtagTimelineHeaderViewActionButton.swift b/Mastodon/Scene/HashtagTimeline/HashtagTimelineHeaderViewActionButton.swift deleted file mode 100644 index 7efeb15d0..000000000 --- a/Mastodon/Scene/HashtagTimeline/HashtagTimelineHeaderViewActionButton.swift +++ /dev/null @@ -1,47 +0,0 @@ -// -// HashtagTimelineHeaderViewActionButton.swift -// Mastodon -// -// Created by Marcus Kida on 25.11.22. -// - -import UIKit -import MastodonUI -import MastodonAsset - -class HashtagTimelineHeaderViewActionButton: RoundedEdgesButton { - - init() { - super.init(frame: .zero) - } - - required init?(coder: NSCoder) { - fatalError("init(coder:) has not been implemented") - } - - public override func layoutSubviews() { - super.layoutSubviews() - - let shadowColor: UIColor = { - switch traitCollection.userInterfaceStyle { - case .dark: - return .darkGray - default: - return .lightGray - } - }() - - layer.setupShadow( - color: shadowColor, - alpha: 1, - x: 0, - y: 1, - blur: 2, - spread: 0, - roundedRect: bounds, - byRoundingCorners: .allCorners, - cornerRadii: CGSize(width: cornerRadius, height: cornerRadius) - ) - } -} -