diff --git a/Tusker/Preferences/Preferences.swift b/Tusker/Preferences/Preferences.swift index 4c0e349e..86dfd0ea 100644 --- a/Tusker/Preferences/Preferences.swift +++ b/Tusker/Preferences/Preferences.swift @@ -47,6 +47,7 @@ class Preferences: Codable, ObservableObject { self.contentWarningCopyMode = try container.decode(ContentWarningCopyMode.self, forKey: .contentWarningCopyMode) self.openLinksInApps = try container.decode(Bool.self, forKey: .openLinksInApps) + self.showFavoriteAndReblogCounts = try container.decode(Bool.self, forKey: .showFavoriteAndReblogCounts) self.defaultNotificationsMode = try container.decode(NotificationsMode.self, forKey: .defaultNotificationsType) self.silentActions = try container.decode([String: Permission].self, forKey: .silentActions) @@ -65,6 +66,7 @@ class Preferences: Codable, ObservableObject { try container.encode(contentWarningCopyMode, forKey: .contentWarningCopyMode) try container.encode(openLinksInApps, forKey: .openLinksInApps) + try container.encode(showFavoriteAndReblogCounts, forKey: .showFavoriteAndReblogCounts) try container.encode(defaultNotificationsMode, forKey: .defaultNotificationsType) try container.encode(silentActions, forKey: .silentActions) @@ -86,6 +88,7 @@ class Preferences: Codable, ObservableObject { @Published var openLinksInApps = true // MARK: - Digital Wellness + @Published var showFavoriteAndReblogCounts = true @Published var defaultNotificationsMode = NotificationsMode.allNotifications // MARK: - Advanced @@ -102,6 +105,7 @@ class Preferences: Codable, ObservableObject { case contentWarningCopyMode case openLinksInApps + case showFavoriteAndReblogCounts case defaultNotificationsType case silentActions diff --git a/Tusker/Screens/Preferences/WellnessPrefsView.swift b/Tusker/Screens/Preferences/WellnessPrefsView.swift index 4c3ae3a7..b127a488 100644 --- a/Tusker/Screens/Preferences/WellnessPrefsView.swift +++ b/Tusker/Screens/Preferences/WellnessPrefsView.swift @@ -9,14 +9,29 @@ import SwiftUI struct WellnessPrefsView: View { + @Preference(\.showFavoriteAndReblogCounts) var showFavoriteAndReblogCounts: Bool @Preference(\.defaultNotificationsMode) var defaultNotificationsMode: NotificationsMode + var body: some View { List { + showFavAndReblogCountSection notificationsModeSection }.listStyle(GroupedListStyle()) .navigationBarTitle(Text("Digital Wellness")) } + var showFavAndReblogCountSection: some View { + Section(footer: showFavAndReblogCountFooter) { + Toggle(isOn: _showFavoriteAndReblogCounts.binding) { + Text("Show Favorite and Reblog Counts") + } + } + } + + var showFavAndReblogCountFooter: some View { + Text("Control whether total favorite and reblog counts are shown for the main post in conversations.") + } + var notificationsModeSection: some View { Section(footer: notificationsModeFooter) { Picker(selection: _defaultNotificationsMode.binding, label: Text("Default Notifications Mode")) { diff --git a/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift b/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift index 243b7501..b353b4ac 100644 --- a/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift +++ b/Tusker/Views/Status/ConversationMainStatusTableViewCell.swift @@ -31,6 +31,7 @@ class ConversationMainStatusTableViewCell: UITableViewCell { @IBOutlet weak var collapseButton: UIButton! @IBOutlet weak var contentLabel: StatusContentLabel! @IBOutlet weak var avatarImageView: UIImageView! + @IBOutlet weak var favoriteAndReblogCountStackView: UIStackView! @IBOutlet weak var totalFavoritesButton: UIButton! @IBOutlet weak var totalReblogsButton: UIButton! @IBOutlet weak var timestampAndClientLabel: UILabel! @@ -158,6 +159,7 @@ class ConversationMainStatusTableViewCell: UITableViewCell { avatarImageView.layer.cornerRadius = Preferences.shared.avatarStyle.cornerRadius(for: avatarImageView) displayNameLabel.text = account.realDisplayName + favoriteAndReblogCountStackView.isHidden = !Preferences.shared.showFavoriteAndReblogCounts } override func prepareForReuse() {