diff --git a/Mlem/App State.swift b/Mlem/App State.swift index 4c8f99300..209476936 100644 --- a/Mlem/App State.swift +++ b/Mlem/App State.swift @@ -15,6 +15,7 @@ class AppState: ObservableObject { @AppStorage("defaultAccountId") var defaultAccountId: Int? @AppStorage("profileTabLabel") var profileTabLabel: ProfileTabLabel = .username + @AppStorage("showUserAvatarOnProfileTab") var showUserAvatar: Bool = true @Published private(set) var currentActiveAccount: SavedAccount? @@ -36,6 +37,15 @@ class AppState: ObservableObject { } } + /// A variable representing the remote location to load the user profile avatar from if applicable + var profileTabRemoteSymbolUrl: URL? { + guard profileTabLabel != .anonymous, showUserAvatar else { + return nil + } + + return currentActiveAccount?.avatarUrl + } + /// A method to set the current active account, any changes to the account will be propogated to the persistence layer /// - Important: If you wish to _clear_ the current active account please use the `\.setAppFlow` method available via the environment to reset to our `.onboarding` flow /// - Parameter account: The `SavedAccount` which should become the active account diff --git a/Mlem/ContentView.swift b/Mlem/ContentView.swift index 19dcdb4a5..63061076e 100644 --- a/Mlem/ContentView.swift +++ b/Mlem/ContentView.swift @@ -67,7 +67,7 @@ struct ContentView: View { symbolConfiguration: .init( symbol: FancyTabBarLabel.SymbolConfiguration.profile.symbol, activeSymbol: FancyTabBarLabel.SymbolConfiguration.profile.activeSymbol, - remoteSymbolUrl: appState.currentActiveAccount?.avatarUrl + remoteSymbolUrl: appState.profileTabRemoteSymbolUrl ) ) .simultaneousGesture(accountSwitchLongPress) diff --git a/Mlem/Views/Tabs/Settings/Components/Views/Appearance/TabBar/TabBarSettingsView.swift b/Mlem/Views/Tabs/Settings/Components/Views/Appearance/TabBar/TabBarSettingsView.swift index fb505e64c..87a9cccdd 100644 --- a/Mlem/Views/Tabs/Settings/Components/Views/Appearance/TabBar/TabBarSettingsView.swift +++ b/Mlem/Views/Tabs/Settings/Components/Views/Appearance/TabBar/TabBarSettingsView.swift @@ -12,6 +12,7 @@ struct TabBarSettingsView: View { @AppStorage("profileTabLabel") var profileTabLabel: ProfileTabLabel = .username @AppStorage("showTabNames") var showTabNames: Bool = true @AppStorage("showInboxUnreadBadge") var showInboxUnreadBadge: Bool = true + @AppStorage("showUserAvatarOnProfileTab") var showUserAvatar: Bool = true @EnvironmentObject var appState: AppState @@ -71,6 +72,14 @@ struct TabBarSettingsView: View { settingName: "Show Unread Count", isTicked: $showInboxUnreadBadge ) + + SwitchableSettingsItem( + settingPictureSystemName: "person.fill.questionmark", + settingName: "Show User Avatar", + // if `.anonymous` is selected the toggle here should always be false + isTicked: profileTabLabel == .anonymous ? .constant(false) : $showUserAvatar + ) + .disabled(profileTabLabel == .anonymous) } } .fancyTabScrollCompatible()