From adeb83aa2b38157b5d8815f619de673bf4402fa6 Mon Sep 17 00:00:00 2001 From: Bosco Ho Date: Fri, 6 Oct 2023 18:47:00 -0700 Subject: [PATCH] - Fix build errors after rebase. --- .../Views/Shared/Accounts/Accounts Page.swift | 23 ++++++++++++------- .../Community List/Community List View.swift | 6 ++--- .../Tabs/Feeds/Components/Sidebar View.swift | 3 +-- Mlem/Views/Tabs/Feeds/Feed View.swift | 11 +-------- Mlem/Views/Tabs/Profile/User View.swift | 2 +- .../Community/CommunitySettingsView.swift | 4 ++-- .../Appearance/User/UserSettingsView.swift | 4 ++-- 7 files changed, 25 insertions(+), 28 deletions(-) diff --git a/Mlem/Views/Shared/Accounts/Accounts Page.swift b/Mlem/Views/Shared/Accounts/Accounts Page.swift index 0d6daedba..2353cb00e 100644 --- a/Mlem/Views/Shared/Accounts/Accounts Page.swift +++ b/Mlem/Views/Shared/Accounts/Accounts Page.swift @@ -25,22 +25,22 @@ struct AccountsPage: View { let instances = Array(accountsTracker.accountsByInstance.keys).sorted() Group { - if instances.isEmpty || isShowingInstanceAdditionSheet { + if instances.isEmpty { AddSavedInstanceView(onboarding: false) } else { List { ForEach(instances, id: \.self) { instance in Section(header: Text(instance)) { ForEach(accountsTracker.accountsByInstance[instance] ?? []) { account in - Button(account.username) { - dismiss() + Button(account.nickname) { setFlow(using: account) + dismiss() } + .disabled(isActiveAccount(account)) .swipeActions { Button("Remove", role: .destructive) { - dismiss() accountsTracker.removeAccount(account: account) - if account == appState.currentActiveAccount { + if isActiveAccount(account) { // if we just deleted the current account we (currently!) have a decision to make if let first = accountsTracker.savedAccounts.first { // if we have another account available, go to that... @@ -54,6 +54,8 @@ struct AccountsPage: View { // no accounts, so go to onboarding setFlow(using: nil) } + + dismiss() } } } @@ -65,15 +67,15 @@ struct AccountsPage: View { Button { isShowingInstanceAdditionSheet = true } label: { - Label("Add Account", systemImage: AppConstants.switchUserSymbolName) + Label("Add Account", systemImage: Icons.switchUser) } .accessibilityLabel("Add a new account.") - + if let account = appState.currentActiveAccount { Button(role: .destructive) { accountForDeletion = account } label: { - Label("Delete Current Account", systemImage: "trash") + Label("Delete Current Account", systemImage: Icons.delete) .foregroundColor(.red) } } @@ -94,6 +96,11 @@ struct AccountsPage: View { return account == currentAccount ? .secondary : .primary } + private func isActiveAccount(_ account: SavedAccount) -> Bool { + guard let currentAccount = appState.currentActiveAccount else { return false } + return account == currentAccount + } + private func setFlow(using account: SavedAccount?) { // this tiny delay prevents the modal dismiss animation from being cancelled DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) { diff --git a/Mlem/Views/Tabs/Feeds/Community List/Community List View.swift b/Mlem/Views/Tabs/Feeds/Community List/Community List View.swift index aa96498c2..19a51b1fe 100644 --- a/Mlem/Views/Tabs/Feeds/Community List/Community List View.swift +++ b/Mlem/Views/Tabs/Feeds/Community List/Community List View.swift @@ -41,7 +41,7 @@ struct CommunityListView: View { List(selection: $selectedCommunity) { HomepageFeedRowView( feedType: .subscribed, - iconName: AppConstants.subscribedFeedSymbolNameFill, + iconName: Icons.subscribedFeedFill, iconColor: .red, description: "Subscribed communities from all servers", navigationContext: .sidebar @@ -49,14 +49,14 @@ struct CommunityListView: View { .id("top") // For "scroll to top" sidebar item HomepageFeedRowView( feedType: .local, - iconName: AppConstants.localFeedSymbolNameFill, + iconName: Icons.localFeedFill, iconColor: .green, description: "Local communities from your server", navigationContext: .sidebar ) HomepageFeedRowView( feedType: .all, - iconName: AppConstants.federatedFeedSymbolNameFill, + iconName: Icons.federatedFeedFill, iconColor: .blue, description: "All communities that federate with your server", navigationContext: .sidebar diff --git a/Mlem/Views/Tabs/Feeds/Components/Sidebar View.swift b/Mlem/Views/Tabs/Feeds/Components/Sidebar View.swift index 8185fa378..23cce6b8c 100644 --- a/Mlem/Views/Tabs/Feeds/Components/Sidebar View.swift +++ b/Mlem/Views/Tabs/Feeds/Components/Sidebar View.swift @@ -72,8 +72,7 @@ struct CommunitySidebarView: View { avatarSubtext: .constant("Created \(getRelativeTime(date: communityDetails.communityView.community.published))"), bannerURL: shouldShowCommunityHeaders ? communityDetails.communityView.community.bannerUrl : nil, avatarUrl: communityDetails.communityView.community.iconUrl, - label1: "\(communityDetails.communityView.counts.subscribers) Subscribers", - avatarType: .community + label1: "\(communityDetails.communityView.counts.subscribers) Subscribers" ) Picker(selection: $selectionSection, label: Text("Profile Section")) { diff --git a/Mlem/Views/Tabs/Feeds/Feed View.swift b/Mlem/Views/Tabs/Feeds/Feed View.swift index 94dd5b8b1..fe15be91f 100644 --- a/Mlem/Views/Tabs/Feeds/Feed View.swift +++ b/Mlem/Views/Tabs/Feeds/Feed View.swift @@ -93,19 +93,10 @@ struct FeedView: View { @State private var scrollToTopAppeared = false private var scrollToTopId: Int? { postTracker.items.first?.id + } @Environment(\.horizontalSizeClass) private var horizontalSizeClass - // MARK: Destructive confirmation - - @State private var isPresentingConfirmDestructive: Bool = false - @State private var confirmationMenuFunction: StandardMenuFunction? - - func confirmDestructive(destructiveFunction: StandardMenuFunction) { - confirmationMenuFunction = destructiveFunction - isPresentingConfirmDestructive = true - } - // MARK: - Main Views var body: some View { diff --git a/Mlem/Views/Tabs/Profile/User View.swift b/Mlem/Views/Tabs/Profile/User View.swift index adcbdeeea..ceb483ecf 100644 --- a/Mlem/Views/Tabs/Profile/User View.swift +++ b/Mlem/Views/Tabs/Profile/User View.swift @@ -118,7 +118,7 @@ struct UserView: View { Button { isPresentingAccountSwitcher = true } label: { - Image(systemName: AppConstants.switchUserSymbolName) + Image(systemName: Icons.switchUser) } } } 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 a903c4ae5..4e6768e9a 100644 --- a/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Community/CommunitySettingsView.swift +++ b/Mlem/Views/Tabs/Settings/Components/Views/Appearance/Community/CommunitySettingsView.swift @@ -15,12 +15,12 @@ struct CommunitySettingsView: View { var body: some View { Form { SwitchableSettingsItem( - settingPictureSystemName: AppConstants.communitySymbolName, + settingPictureSystemName: Icons.community, settingName: "Show Avatars", isTicked: $shouldShowCommunityIcons ) SwitchableSettingsItem( - settingPictureSystemName: AppConstants.bannerSymbolName, + settingPictureSystemName: Icons.banner, settingName: "Show Banners", isTicked: $shouldShowCommunityHeaders ) 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 2a4e6460f..ed99a090f 100644 --- a/Mlem/Views/Tabs/Settings/Components/Views/Appearance/User/UserSettingsView.swift +++ b/Mlem/Views/Tabs/Settings/Components/Views/Appearance/User/UserSettingsView.swift @@ -17,12 +17,12 @@ struct UserSettingsView: View { var body: some View { Form { SwitchableSettingsItem( - settingPictureSystemName: AppConstants.userSymbolName, + settingPictureSystemName: Icons.user, settingName: "Show Avatars", isTicked: $shouldShowUserAvatars ) SwitchableSettingsItem( - settingPictureSystemName: AppConstants.bannerSymbolName, + settingPictureSystemName: Icons.banner, settingName: "Show Banners", isTicked: $shouldShowUserHeaders )