Add preference for status reply icons

This commit is contained in:
Shadowfacts 2020-06-17 17:45:34 -04:00
parent 3aef7d4d93
commit 00bf99334f
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
3 changed files with 17 additions and 2 deletions

View File

@ -41,6 +41,7 @@ class Preferences: Codable, ObservableObject {
self.showRepliesInProfiles = try container.decode(Bool.self, forKey: .showRepliesInProfiles) self.showRepliesInProfiles = try container.decode(Bool.self, forKey: .showRepliesInProfiles)
self.avatarStyle = try container.decode(AvatarStyle.self, forKey: .avatarStyle) self.avatarStyle = try container.decode(AvatarStyle.self, forKey: .avatarStyle)
self.hideCustomEmojiInUsernames = try container.decode(Bool.self, forKey: .hideCustomEmojiInUsernames) self.hideCustomEmojiInUsernames = try container.decode(Bool.self, forKey: .hideCustomEmojiInUsernames)
self.showIsStatusReplyIcon = try container.decode(Bool.self, forKey: .showIsStatusReplyIcon)
self.defaultPostVisibility = try container.decode(Status.Visibility.self, forKey: .defaultPostVisibility) self.defaultPostVisibility = try container.decode(Status.Visibility.self, forKey: .defaultPostVisibility)
self.automaticallySaveDrafts = try container.decode(Bool.self, forKey: .automaticallySaveDrafts) self.automaticallySaveDrafts = try container.decode(Bool.self, forKey: .automaticallySaveDrafts)
@ -69,6 +70,7 @@ class Preferences: Codable, ObservableObject {
try container.encode(showRepliesInProfiles, forKey: .showRepliesInProfiles) try container.encode(showRepliesInProfiles, forKey: .showRepliesInProfiles)
try container.encode(avatarStyle, forKey: .avatarStyle) try container.encode(avatarStyle, forKey: .avatarStyle)
try container.encode(hideCustomEmojiInUsernames, forKey: .hideCustomEmojiInUsernames) try container.encode(hideCustomEmojiInUsernames, forKey: .hideCustomEmojiInUsernames)
try container.encode(showIsStatusReplyIcon, forKey: .showIsStatusReplyIcon)
try container.encode(defaultPostVisibility, forKey: .defaultPostVisibility) try container.encode(defaultPostVisibility, forKey: .defaultPostVisibility)
try container.encode(automaticallySaveDrafts, forKey: .automaticallySaveDrafts) try container.encode(automaticallySaveDrafts, forKey: .automaticallySaveDrafts)
@ -95,6 +97,7 @@ class Preferences: Codable, ObservableObject {
@Published var showRepliesInProfiles = false @Published var showRepliesInProfiles = false
@Published var avatarStyle = AvatarStyle.roundRect @Published var avatarStyle = AvatarStyle.roundRect
@Published var hideCustomEmojiInUsernames = false @Published var hideCustomEmojiInUsernames = false
@Published var showIsStatusReplyIcon = false
// MARK: Composing // MARK: Composing
@Published var defaultPostVisibility = Status.Visibility.public @Published var defaultPostVisibility = Status.Visibility.public
@ -125,6 +128,7 @@ class Preferences: Codable, ObservableObject {
case showRepliesInProfiles case showRepliesInProfiles
case avatarStyle case avatarStyle
case hideCustomEmojiInUsernames case hideCustomEmojiInUsernames
case showIsStatusReplyIcon
case defaultPostVisibility case defaultPostVisibility
case automaticallySaveDrafts case automaticallySaveDrafts

View File

@ -39,6 +39,9 @@ struct AppearancePrefsView : View {
Toggle(isOn: $preferences.hideCustomEmojiInUsernames) { Toggle(isOn: $preferences.hideCustomEmojiInUsernames) {
Text("Hide Custom Emoji in Usernames") Text("Hide Custom Emoji in Usernames")
} }
Toggle(isOn: $preferences.showIsStatusReplyIcon) {
Text("Show Status Reply Icons")
}
} }
.listStyle(GroupedListStyle()) .listStyle(GroupedListStyle())
.navigationBarTitle(Text("Appearance")) .navigationBarTitle(Text("Appearance"))

View File

@ -90,15 +90,19 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
pinImageView.isHidden = !pinned pinImageView.isHidden = !pinned
} }
replyImageView.isHidden = !showReplyIndicator || status.inReplyToID == nil updateStatusIcons(status)
} }
@objc override func preferencesChanged() { @objc override func preferencesChanged() {
super.preferencesChanged() super.preferencesChanged()
if let rebloggerID = rebloggerID, if let rebloggerID = rebloggerID,
let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) { let reblogger = mastodonController.persistentContainer.account(for: rebloggerID) {
updateRebloggerLabel(reblogger: reblogger) updateRebloggerLabel(reblogger: reblogger)
} }
guard let status = mastodonController.persistentContainer.status(for: statusID) else { return }
updateStatusIcons(status)
} }
private func updateRebloggerLabel(reblogger: AccountMO) { private func updateRebloggerLabel(reblogger: AccountMO) {
@ -111,6 +115,10 @@ class TimelineStatusTableViewCell: BaseStatusTableViewCell {
} }
} }
private func updateStatusIcons(_ status: StatusMO) {
replyImageView.isHidden = !Preferences.shared.showIsStatusReplyIcon || !showReplyIndicator || status.inReplyToID == nil
}
func updateTimestamp() { 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 // 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 // so we bail out immediately, since there's nothing to update