From e12a82b47688d768886760eb40819c971b97fdda Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 23 Jan 2022 10:58:36 -0500 Subject: [PATCH] Show local only posts on hometown instances #130 --- Tusker.xcodeproj/project.pbxproj | 4 + .../Status/BaseStatusTableViewCell.swift | 19 ++--- .../ConversationMainStatusTableViewCell.swift | 3 + .../ConversationMainStatusTableViewCell.xib | 32 ++++--- .../Status/StatusMetaIndicatorsView.swift | 85 +++++++++++++++++++ .../Status/TimelineStatusTableViewCell.swift | 9 +- .../Status/TimelineStatusTableViewCell.xib | 45 +++------- 7 files changed, 135 insertions(+), 62 deletions(-) create mode 100644 Tusker/Views/Status/StatusMetaIndicatorsView.swift diff --git a/Tusker.xcodeproj/project.pbxproj b/Tusker.xcodeproj/project.pbxproj index 5aafa842..290817d2 100644 --- a/Tusker.xcodeproj/project.pbxproj +++ b/Tusker.xcodeproj/project.pbxproj @@ -117,6 +117,7 @@ D62D2424217ABF3F005076CC /* NSUserActivity+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D62D2423217ABF3F005076CC /* NSUserActivity+Extensions.swift */; }; D62D2426217ABF63005076CC /* UserActivityType.swift in Sources */ = {isa = PBXBuildFile; fileRef = D62D2425217ABF63005076CC /* UserActivityType.swift */; }; D62E9985279CA23900C26176 /* URLSession+Development.swift in Sources */ = {isa = PBXBuildFile; fileRef = D62E9984279CA23900C26176 /* URLSession+Development.swift */; }; + D62E9987279D094F00C26176 /* StatusMetaIndicatorsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D62E9986279D094F00C26176 /* StatusMetaIndicatorsView.swift */; }; D62FF04823D7CDD700909D6E /* AttributedStringHelperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D62FF04723D7CDD700909D6E /* AttributedStringHelperTests.swift */; }; D6311C5025B3765B00B27539 /* ImageDataCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6311C4F25B3765B00B27539 /* ImageDataCache.swift */; }; D6333B372137838300CE884A /* AttributedString+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6333B362137838300CE884A /* AttributedString+Helpers.swift */; }; @@ -523,6 +524,7 @@ D62D2423217ABF3F005076CC /* NSUserActivity+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSUserActivity+Extensions.swift"; sourceTree = ""; }; D62D2425217ABF63005076CC /* UserActivityType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserActivityType.swift; sourceTree = ""; }; D62E9984279CA23900C26176 /* URLSession+Development.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLSession+Development.swift"; sourceTree = ""; }; + D62E9986279D094F00C26176 /* StatusMetaIndicatorsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusMetaIndicatorsView.swift; sourceTree = ""; }; D62FF04723D7CDD700909D6E /* AttributedStringHelperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AttributedStringHelperTests.swift; sourceTree = ""; }; D6311C4F25B3765B00B27539 /* ImageDataCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageDataCache.swift; sourceTree = ""; }; D6333B362137838300CE884A /* AttributedString+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AttributedString+Helpers.swift"; sourceTree = ""; }; @@ -1222,6 +1224,7 @@ D663625E2135C75500C9CBA2 /* ConversationMainStatusTableViewCell.swift */, D6C1B2072545D1EC00DAAA66 /* StatusCardView.swift */, D6EE63FA2551F7F60065485C /* StatusCollapseButton.swift */, + D62E9986279D094F00C26176 /* StatusMetaIndicatorsView.swift */, ); path = Status; sourceTree = ""; @@ -2256,6 +2259,7 @@ D6BC9DB5232D4CE3002CA326 /* NotificationsMode.swift in Sources */, D68015402401A6BA00D6103B /* ComposingPrefsView.swift in Sources */, D67895BC24671E6D00D4CD9E /* PKDrawing+Render.swift in Sources */, + D62E9987279D094F00C26176 /* StatusMetaIndicatorsView.swift in Sources */, 04D14BB022B34A2800642648 /* GalleryViewController.swift in Sources */, D6C1B2082545D1EC00DAAA66 /* StatusCardView.swift in Sources */, D6412B0524B0227D00F5412E /* ProfileViewController.swift in Sources */, diff --git a/Tusker/Views/Status/BaseStatusTableViewCell.swift b/Tusker/Views/Status/BaseStatusTableViewCell.swift index 0af7cd84..088c6f75 100644 --- a/Tusker/Views/Status/BaseStatusTableViewCell.swift +++ b/Tusker/Views/Status/BaseStatusTableViewCell.swift @@ -28,7 +28,7 @@ class BaseStatusTableViewCell: UITableViewCell, MenuPreviewProvider { @IBOutlet weak var avatarImageView: UIImageView! @IBOutlet weak var displayNameLabel: EmojiLabel! @IBOutlet weak var usernameLabel: UILabel! - @IBOutlet weak var visibilityImageView: UIImageView! + @IBOutlet weak var metaIndicatorsView: StatusMetaIndicatorsView! @IBOutlet weak var contentWarningLabel: EmojiLabel! @IBOutlet weak var collapseButton: UIButton! @IBOutlet weak var contentTextView: StatusContentTextView! @@ -43,27 +43,27 @@ class BaseStatusTableViewCell: UITableViewCell, MenuPreviewProvider { private(set) var nextThreadLinkView: UIView? var statusID: String! - var accountID: String! + private(set) var accountID: String! - var favorited = false { + private var favorited = false { didSet { favoriteButton.tintColor = favorited ? UIColor(displayP3Red: 1, green: 0.8, blue: 0, alpha: 1) : tintColor } } - var reblogged = false { + private var reblogged = false { didSet { reblogButton.tintColor = reblogged ? UIColor(displayP3Red: 1, green: 0.8, blue: 0, alpha: 1) : tintColor } } - var statusState: StatusState! + private(set) var statusState: StatusState! var collapsible = false { didSet { collapseButton.isHidden = !collapsible statusState?.collapsible = collapsible } } - var collapsed = false { + private var collapsed = false { didSet { statusState?.collapsed = collapsed } @@ -242,11 +242,8 @@ class BaseStatusTableViewCell: UITableViewCell, MenuPreviewProvider { } func updateStatusIconsForPreferences(_ status: StatusMO) { - visibilityImageView.isHidden = !Preferences.shared.alwaysShowStatusVisibilityIcon - if Preferences.shared.alwaysShowStatusVisibilityIcon { - visibilityImageView.image = UIImage(systemName: status.visibility.unfilledImageName) - visibilityImageView.accessibilityLabel = String(format: NSLocalizedString("Visibility: %@", comment: "status visibility indicator accessibility label"), status.visibility.displayName) - } + metaIndicatorsView.updateUI(status: status) + let reblogButtonImage: UIImage if Preferences.shared.alwaysShowStatusVisibilityIcon || reblogButton.isEnabled { reblogButtonImage = UIImage(systemName: "repeat")! diff --git a/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift b/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift index 61d9ecda..fabc01ba 100644 --- a/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift +++ b/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift @@ -52,6 +52,9 @@ class ConversationMainStatusTableViewCell: BaseStatusTableViewCell { contentTextView.defaultFont = .systemFont(ofSize: 18) profileDetailContainerView.addInteraction(UIContextMenuInteraction(delegate: self)) + + metaIndicatorsView.allowedIndicators = [.visibility, .localOnly] + metaIndicatorsView.squeezeHorizontal = true } override func doUpdateUI(status: StatusMO, state: StatusState) { diff --git a/Tusker/Views/Status/ConversationMainStatusTableViewCell.xib b/Tusker/Views/Status/ConversationMainStatusTableViewCell.xib index b91edc52..fe52bd1b 100644 --- a/Tusker/Views/Status/ConversationMainStatusTableViewCell.xib +++ b/Tusker/Views/Status/ConversationMainStatusTableViewCell.xib @@ -1,8 +1,9 @@ - + - + + @@ -28,8 +29,8 @@ -