diff --git a/Tusker/Preferences/Preferences.swift b/Tusker/Preferences/Preferences.swift index 674e93d0..26ecf5e4 100644 --- a/Tusker/Preferences/Preferences.swift +++ b/Tusker/Preferences/Preferences.swift @@ -42,6 +42,7 @@ class Preferences: Codable, ObservableObject { self.hideCustomEmojiInUsernames = try container.decode(Bool.self, forKey: .hideCustomEmojiInUsernames) self.showIsStatusReplyIcon = try container.decode(Bool.self, forKey: .showIsStatusReplyIcon) self.alwaysShowStatusVisibilityIcon = try container.decode(Bool.self, forKey: .alwaysShowStatusVisibilityIcon) + self.hideActionsInTimeline = try container.decodeIfPresent(Bool.self, forKey: .hideActionsInTimeline) ?? false self.defaultPostVisibility = try container.decode(Status.Visibility.self, forKey: .defaultPostVisibility) self.automaticallySaveDrafts = try container.decode(Bool.self, forKey: .automaticallySaveDrafts) @@ -81,6 +82,7 @@ class Preferences: Codable, ObservableObject { try container.encode(hideCustomEmojiInUsernames, forKey: .hideCustomEmojiInUsernames) try container.encode(showIsStatusReplyIcon, forKey: .showIsStatusReplyIcon) try container.encode(alwaysShowStatusVisibilityIcon, forKey: .alwaysShowStatusVisibilityIcon) + try container.encode(hideActionsInTimeline, forKey: .hideActionsInTimeline) try container.encode(defaultPostVisibility, forKey: .defaultPostVisibility) try container.encode(automaticallySaveDrafts, forKey: .automaticallySaveDrafts) @@ -118,6 +120,7 @@ class Preferences: Codable, ObservableObject { @Published var hideCustomEmojiInUsernames = false @Published var showIsStatusReplyIcon = false @Published var alwaysShowStatusVisibilityIcon = false + @Published var hideActionsInTimeline = false // MARK: Composing @Published var defaultPostVisibility = Status.Visibility.public @@ -160,6 +163,7 @@ class Preferences: Codable, ObservableObject { case hideCustomEmojiInUsernames case showIsStatusReplyIcon case alwaysShowStatusVisibilityIcon + case hideActionsInTimeline case defaultPostVisibility case automaticallySaveDrafts diff --git a/Tusker/Screens/Preferences/AppearancePrefsView.swift b/Tusker/Screens/Preferences/AppearancePrefsView.swift index ef9e4698..61bde691 100644 --- a/Tusker/Screens/Preferences/AppearancePrefsView.swift +++ b/Tusker/Screens/Preferences/AppearancePrefsView.swift @@ -56,6 +56,9 @@ struct AppearancePrefsView : View { Toggle(isOn: $preferences.alwaysShowStatusVisibilityIcon) { Text("Always Show Status Visibility Icons") } + Toggle(isOn: $preferences.hideActionsInTimeline) { + Text("Hide Actions on Timeline") + } } } } diff --git a/Tusker/Views/Status/TimelineStatusTableViewCell.swift b/Tusker/Views/Status/TimelineStatusTableViewCell.swift index 26e96138..af78f8c0 100644 --- a/Tusker/Views/Status/TimelineStatusTableViewCell.swift +++ b/Tusker/Views/Status/TimelineStatusTableViewCell.swift @@ -22,6 +22,10 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell { @IBOutlet weak var reblogLabel: EmojiLabel! @IBOutlet weak var timestampLabel: UILabel! @IBOutlet weak var pinImageView: UIImageView! + @IBOutlet weak var actionsContainerView: UIView! + @IBOutlet weak var actionsContainerHeightConstraint: NSLayoutConstraint! + @IBOutlet weak var verticalStackToActionsContainerConstraint: NSLayoutConstraint! + @IBOutlet weak var verticalStackToSuperviewConstraint: NSLayoutConstraint! var reblogStatusID: String? var rebloggerID: String? @@ -51,6 +55,8 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell { contentTextView.defaultFont = .systemFont(ofSize: 16) avatarImageView.addInteraction(UIContextMenuInteraction(delegate: self)) + + updateActionsVisibility() } override func createObserversIfNecessary() { @@ -121,9 +127,31 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell { } else { metaIndicatorsView.allowedIndicators = .all.subtracting(.reply) } + + let oldState = actionsContainerView.isHidden + if oldState != Preferences.shared.hideActionsInTimeline { + updateActionsVisibility() + // not really accurate, but it notifies the vc our height has changed + delegate?.statusCellCollapsedStateChanged(self) + } + super.updateStatusIconsForPreferences(status) } + private func updateActionsVisibility() { + if Preferences.shared.hideActionsInTimeline { + actionsContainerView.isHidden = true + actionsContainerHeightConstraint.isActive = false + verticalStackToSuperviewConstraint.isActive = true + verticalStackToActionsContainerConstraint.isActive = false + } else { + actionsContainerView.isHidden = false + actionsContainerHeightConstraint.isActive = true + verticalStackToSuperviewConstraint.isActive = false + verticalStackToActionsContainerConstraint.isActive = true + } + } + private func updateTimestamp() { // if the mastodonController is nil (i.e. the delegate is nil), then the screen this cell was a part of has been deallocated // so we bail out immediately, since there's nothing to update diff --git a/Tusker/Views/Status/TimelineStatusTableViewCell.xib b/Tusker/Views/Status/TimelineStatusTableViewCell.xib index d015a92d..70fc1bdb 100644 --- a/Tusker/Views/Status/TimelineStatusTableViewCell.xib +++ b/Tusker/Views/Status/TimelineStatusTableViewCell.xib @@ -1,9 +1,9 @@ - + - + @@ -218,11 +218,17 @@ + + + + + + @@ -240,6 +246,8 @@ + + @@ -257,6 +265,8 @@ + +