Hide reblog and favorite counts by default

This commit is contained in:
Justin Mazzocchi 2021-01-28 22:02:57 -08:00
parent 2efc7b87c4
commit aee0b3e66d
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
4 changed files with 17 additions and 3 deletions

View file

@ -152,6 +152,7 @@
"preferences.position.remember-position" = "Remember position";
"preferences.position.sync-position" = "Sync position with web and other devices";
"preferences.position.newest" = "Load newest";
"preferences.show-reblog-and-favorite-counts" = "Show reblog and favorite counts";
"filters.active" = "Active";
"filters.expired" = "Expired";
"filter.add-new" = "Add New Filter";

View file

@ -133,6 +133,11 @@ public extension AppPreferences {
return notificationsTabBehavior
}
}
var showReblogAndFavoriteCounts: Bool {
get { self[.showReblogAndFavoriteCounts] ?? false }
set { self[.showReblogAndFavoriteCounts] = newValue }
}
}
extension AppPreferences {
@ -160,6 +165,7 @@ private extension AppPreferences {
case homeTimelineBehavior
case notificationsTabBehavior
case defaultEmojiSkinTone
case showReblogAndFavoriteCounts
}
subscript<T>(index: Item) -> T? {

View file

@ -92,6 +92,7 @@ struct PreferencesView: View {
.disabled(reduceMotion)
}
.disabled(reduceMotion)
Toggle("preferences.show-reblog-and-favorite-counts", isOn: $identityContext.appPreferences.showReblogAndFavoriteCounts)
Picker("preferences.home-timeline-position-on-startup",
selection: $identityContext.appPreferences.homeTimelineBehavior) {
ForEach(AppPreferences.PositionBehavior.allCases) { option in

View file

@ -428,8 +428,14 @@ private extension StatusView {
setButtonImages(scale: isContextParent ? .medium : .small)
replyButton.setCountTitle(count: viewModel.repliesCount, isContextParent: isContextParent)
reblogButton.setCountTitle(count: viewModel.reblogsCount, isContextParent: isContextParent)
favoriteButton.setCountTitle(count: viewModel.favoritesCount, isContextParent: isContextParent)
if viewModel.identityContext.appPreferences.showReblogAndFavoriteCounts || isContextParent {
reblogButton.setCountTitle(count: viewModel.reblogsCount, isContextParent: isContextParent)
favoriteButton.setCountTitle(count: viewModel.favoritesCount, isContextParent: isContextParent)
} else {
reblogButton.setTitle(nil, for: .normal)
favoriteButton.setTitle(nil, for: .normal)
}
let reblogColor: UIColor = viewModel.reblogged ? .systemGreen : .secondaryLabel
@ -517,7 +523,7 @@ private extension StatusView {
private extension UIButton {
func setCountTitle(count: Int, isContextParent: Bool) {
setTitle((isContextParent || count == 0) ? "" : String(count), for: .normal)
setTitle((isContextParent || count == 0) ? nil : String(count), for: .normal)
}
}
// swiftlint:enable file_length