From 124e914855dee50948edfb44b7ee70aa0774eb5b Mon Sep 17 00:00:00 2001 From: Eric Andrews Date: Wed, 13 Sep 2023 10:00:04 -0400 Subject: [PATCH] Fixed settings icon regression (#598) --- Mlem/App Constants.swift | 7 +++++- .../Settings/Components/Settings Item.swift | 16 ++++++++++---- .../AccessibilitySettingsView.swift | 19 +++++++++++++--- .../Comment/CommentSettingsView.swift | 16 +++++++++----- .../Community/CommunitySettingsView.swift | 18 ++++++++------- .../Appearance/Post/PostSettingsView.swift | 9 +++++--- .../Appearance/User/UserSettingsView.swift | 18 ++++++++------- .../Views/Filters/FiltersSettingsView.swift | 22 +++++++++++++++---- .../Views/General/GeneralSettingsView.swift | 14 +++++++++--- 9 files changed, 100 insertions(+), 39 deletions(-) diff --git a/Mlem/App Constants.swift b/Mlem/App Constants.swift index 74a1eb4fd..e6813c8e6 100644 --- a/Mlem/App Constants.swift +++ b/Mlem/App Constants.swift @@ -25,7 +25,8 @@ struct AppConstants { static let keychain: Keychain = .init(service: "com.hanners.Mlem-keychain") // MARK: - Text Fields - static let textFieldVariableLineLimit: ClosedRange = 1...10 + + static let textFieldVariableLineLimit: ClosedRange = 1 ... 10 // MARK: - Sizes @@ -147,6 +148,10 @@ struct AppConstants { static let transparencySymbolName: String = "square.on.square.intersection.dashed" static let presentSymbolName: String = "circle.fill" static let absentSymbolName: String = "circle" + static let iconSymbolName: String = "fleuron" + static let userSymbolName: String = "person.circle" + static let bannerSymbolName: String = "flag" + static let communitySymbolName: String = "building.2.crop.circle" // MARK: - Other diff --git a/Mlem/Views/Tabs/Settings/Components/Settings Item.swift b/Mlem/Views/Tabs/Settings/Components/Settings Item.swift index ea41cc4fb..2bfe828b0 100644 --- a/Mlem/Views/Tabs/Settings/Components/Settings Item.swift +++ b/Mlem/Views/Tabs/Settings/Components/Settings Item.swift @@ -8,6 +8,8 @@ import SwiftUI struct SwitchableSettingsItem: View { + @AppStorage("showSettingsIcons") var showSettingsIcons: Bool = true + let settingPictureSystemName: String let settingPictureColor: Color let settingName: String @@ -32,14 +34,18 @@ struct SwitchableSettingsItem: View { Label { Text(settingName) } icon: { - Image(systemName: settingPictureSystemName) - .foregroundColor(settingPictureColor) + if showSettingsIcons { + Image(systemName: settingPictureSystemName) + .foregroundColor(settingPictureColor) + } } } } } struct SelectableSettingsItem: View { + @AppStorage("showSettingsIcons") var showSettingsIcons: Bool = true + let settingIconSystemName: String let settingName: String @Binding var currentValue: T @@ -56,8 +62,10 @@ struct SelectableSettingsItem: View { Label { Text(settingName) } icon: { - Image(systemName: settingIconSystemName) - .foregroundColor(.pink) + if showSettingsIcons { + Image(systemName: settingIconSystemName) + .foregroundColor(.pink) + } } } } diff --git a/Mlem/Views/Tabs/Settings/Components/Views/Accessibility/AccessibilitySettingsView.swift b/Mlem/Views/Tabs/Settings/Components/Views/Accessibility/AccessibilitySettingsView.swift index eb19f4ddd..aa2982afd 100644 --- a/Mlem/Views/Tabs/Settings/Components/Views/Accessibility/AccessibilitySettingsView.swift +++ b/Mlem/Views/Tabs/Settings/Components/Views/Accessibility/AccessibilitySettingsView.swift @@ -12,6 +12,7 @@ struct AccessibilitySettingsView: View { @AppStorage("reakMarkStyle") var readMarkStyle: ReadMarkStyle = .bar @AppStorage("readBarThickness") var readBarThickness: Int = 3 @AppStorage("hasTranslucentInsets") var hasTranslucentInsets: Bool = true + @AppStorage("showSettingsIcons") var showSettingsIcons: Bool = true @State private var readBarThicknessSlider: CGFloat = 3.0 @@ -30,9 +31,11 @@ struct AccessibilitySettingsView: View { Label { Text("Bar Thickness") } icon: { - Image(systemName: "rectangle.leftthird.inset.filled") - .foregroundColor(.pink) - .opacity(readMarkStyle == .bar ? 1 : 0.4) + if showSettingsIcons { + Image(systemName: "rectangle.leftthird.inset.filled") + .foregroundColor(.pink) + .opacity(readMarkStyle == .bar ? 1 : 0.4) + } } Spacer() @@ -75,6 +78,16 @@ struct AccessibilitySettingsView: View { } header: { Text("Transparency") } + + Section { + SwitchableSettingsItem( + settingPictureSystemName: AppConstants.iconSymbolName, + settingName: "Show Settings Icons", + isTicked: $showSettingsIcons + ) + } header: { + Text("Icons") + } } .fancyTabScrollCompatible() .navigationTitle("Accessibility") diff --git a/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Comment/CommentSettingsView.swift b/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Comment/CommentSettingsView.swift index de45588e2..08e7de673 100644 --- a/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Comment/CommentSettingsView.swift +++ b/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Comment/CommentSettingsView.swift @@ -27,6 +27,8 @@ struct CommentSettingsView: View { @EnvironmentObject var layoutWidgetTracker: LayoutWidgetTracker @AppStorage("compactComments") var compactComments: Bool = false + @AppStorage("showSettingsIcons") var showSettingsIcons: Bool = true + // interactions and info @AppStorage("shouldShowScoreInCommentBar") var shouldShowScoreInCommentBar: Bool = false @AppStorage("showCommentDownvotesSeparately") var showCommentDownvotesSeparately: Bool = false @@ -51,8 +53,10 @@ struct CommentSettingsView: View { Label { Text("Customize Widgets") } icon: { - Image(systemName: "wand.and.stars") - .foregroundColor(.pink) + if showSettingsIcons { + Image(systemName: "wand.and.stars") + .foregroundColor(.pink) + } } } } footer: { @@ -93,9 +97,11 @@ struct CommentSettingsView: View { } Section { - SwitchableSettingsItem(settingPictureSystemName: "circle", - settingName: "Show Jump Button", - isTicked: $showCommentJumpButton) + SwitchableSettingsItem( + settingPictureSystemName: "chevron.down.circle", + settingName: "Show Jump Button", + isTicked: $showCommentJumpButton + ) SelectableSettingsItem( settingIconSystemName: "arrow.left.arrow.right", settingName: "Side", diff --git a/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Community/CommunitySettingsView.swift b/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Community/CommunitySettingsView.swift index 0e178bc7f..a424a640e 100644 --- a/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Community/CommunitySettingsView.swift +++ b/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Community/CommunitySettingsView.swift @@ -11,14 +11,16 @@ struct CommunitySettingsView: View { var body: some View { Form { - Section { - Toggle("Show Avatars", isOn: $shouldShowCommunityIcons) - } - Section { - Toggle("Show Banners", isOn: $shouldShowCommunityHeaders) - } footer: { - Text("The community banner is shown in the community sidebar menu.") - } + SwitchableSettingsItem( + settingPictureSystemName: AppConstants.communitySymbolName, + settingName: "Show Avatars", + isTicked: $shouldShowCommunityIcons + ) + SwitchableSettingsItem( + settingPictureSystemName: AppConstants.bannerSymbolName, + settingName: "Show Banners", + isTicked: $shouldShowCommunityHeaders + ) } .fancyTabScrollCompatible() .navigationTitle("Communities") diff --git a/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Post/PostSettingsView.swift b/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Post/PostSettingsView.swift index 160b3d3aa..4239fba9e 100644 --- a/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Post/PostSettingsView.swift +++ b/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Post/PostSettingsView.swift @@ -12,6 +12,7 @@ struct PostSettingsView: View { @EnvironmentObject var layoutWidgetTracker: LayoutWidgetTracker @AppStorage("postSize") var postSize: PostSize = .headline + @AppStorage("showSettingsIcons") var showSettingsIcons: Bool = true // Thumbnails @AppStorage("shouldShowPostThumbnails") var shouldShowPostThumbnails: Bool = true @@ -52,8 +53,10 @@ struct PostSettingsView: View { Label { Text("Customize Widgets") } icon: { - Image(systemName: "wand.and.stars") - .foregroundColor(.pink) + if showSettingsIcons { + Image(systemName: "wand.and.stars") + .foregroundColor(.pink) + } } } @@ -156,7 +159,7 @@ struct PostSettingsView: View { .padding(.horizontal) SwitchableSettingsItem( - settingPictureSystemName: "network", + settingPictureSystemName: "link", settingName: "Show Website Address", isTicked: $shouldShowWebsiteHost ) diff --git a/Mlem/Views/Tabs/Settings/Components/Views/Appearance/User/UserSettingsView.swift b/Mlem/Views/Tabs/Settings/Components/Views/Appearance/User/UserSettingsView.swift index b9e2c5250..c3d4d6919 100644 --- a/Mlem/Views/Tabs/Settings/Components/Views/Appearance/User/UserSettingsView.swift +++ b/Mlem/Views/Tabs/Settings/Components/Views/Appearance/User/UserSettingsView.swift @@ -13,14 +13,16 @@ struct UserSettingsView: View { var body: some View { Form { - Section { - Toggle("Show Avatars", isOn: $shouldShowUserAvatars) - } - Section { - Toggle("Show Banners", isOn: $shouldShowUserHeaders) - } footer: { - Text("Show a user's banner on their profile.") - } + SwitchableSettingsItem( + settingPictureSystemName: AppConstants.userSymbolName, + settingName: "Show Avatars", + isTicked: $shouldShowUserAvatars + ) + SwitchableSettingsItem( + settingPictureSystemName: AppConstants.bannerSymbolName, + settingName: "Show Banners", + isTicked: $shouldShowUserHeaders + ) } .fancyTabScrollCompatible() .navigationTitle("Users") diff --git a/Mlem/Views/Tabs/Settings/Components/Views/Filters/FiltersSettingsView.swift b/Mlem/Views/Tabs/Settings/Components/Views/Filters/FiltersSettingsView.swift index 7e62de135..0ed3775f7 100644 --- a/Mlem/Views/Tabs/Settings/Components/Views/Filters/FiltersSettingsView.swift +++ b/Mlem/Views/Tabs/Settings/Components/Views/Filters/FiltersSettingsView.swift @@ -9,6 +9,8 @@ import Dependencies import SwiftUI struct FiltersSettingsView: View { + @AppStorage("showSettingsIcons") var showSettingsIcons: Bool = true + @Dependency(\.errorHandler) var errorHandler @Dependency(\.persistenceRepository) var persistenceRepository @@ -53,7 +55,13 @@ struct FiltersSettingsView: View { Button { isShowingKeywordImporter = true } label: { - Label("Import Filters", systemImage: "square.and.arrow.down") + Label { + Text("Import Filters") + } icon: { + if showSettingsIcons { + Image(systemName: "square.and.arrow.down") + } + } } .fileImporter(isPresented: $isShowingKeywordImporter, allowedContentTypes: [.json]) { result in do { @@ -99,9 +107,15 @@ struct FiltersSettingsView: View { Button(role: .destructive) { isShowingFilterDeletionConfirmation = true } label: { - Label("Delete All Filters", systemImage: "trash") - .foregroundColor(.red) - .opacity(filtersTracker.filteredKeywords.isEmpty ? 0.6 : 1) + Label { + Text("Delete All Filters") + } icon: { + if showSettingsIcons { + Image(systemName: "trash") + } + } + .foregroundColor(.red) + .opacity(filtersTracker.filteredKeywords.isEmpty ? 0.6 : 1) } .disabled(filtersTracker.filteredKeywords.isEmpty) .confirmationDialog( diff --git a/Mlem/Views/Tabs/Settings/Components/Views/General/GeneralSettingsView.swift b/Mlem/Views/Tabs/Settings/Components/Views/General/GeneralSettingsView.swift index d756431b1..59546ceb7 100644 --- a/Mlem/Views/Tabs/Settings/Components/Views/General/GeneralSettingsView.swift +++ b/Mlem/Views/Tabs/Settings/Components/Views/General/GeneralSettingsView.swift @@ -21,6 +21,8 @@ struct GeneralSettingsView: View { @AppStorage("hapticLevel") var hapticLevel: HapticPriority = .low @AppStorage("upvoteOnSave") var upvoteOnSave: Bool = false + + @AppStorage("showSettingsIcons") var showSettingsIcons: Bool = false @EnvironmentObject var appState: AppState @@ -107,9 +109,15 @@ struct GeneralSettingsView: View { Button(role: .destructive) { isShowingFavoritesDeletionConfirmation.toggle() } label: { - Label("Delete Community Favorites", systemImage: "trash") - .foregroundColor(.red) - .opacity(favoriteCommunitiesTracker.favoritesForCurrentAccount.isEmpty ? 0.6 : 1) + Label { + Text("Delete Community Favorites") + } icon: { + if showSettingsIcons { + Image(systemName: "trash") + } + } + .foregroundColor(.red) + .opacity(favoriteCommunitiesTracker.favoritesForCurrentAccount.isEmpty ? 0.6 : 1) } .disabled(favoriteCommunitiesTracker.favoritesForCurrentAccount.isEmpty) .confirmationDialog(