Skip to content

Commit

Permalink
- Fix build errors after rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
boscojwho committed Oct 7, 2023
1 parent db5834e commit adeb83a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 28 deletions.
23 changes: 15 additions & 8 deletions Mlem/Views/Shared/Accounts/Accounts Page.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand All @@ -54,6 +54,8 @@ struct AccountsPage: View {
// no accounts, so go to onboarding
setFlow(using: nil)
}

dismiss()
}
}
}
Expand All @@ -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)
}
}
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ 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
)
.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
Expand Down
3 changes: 1 addition & 2 deletions Mlem/Views/Tabs/Feeds/Components/Sidebar View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
11 changes: 1 addition & 10 deletions Mlem/Views/Tabs/Feeds/Feed View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Mlem/Views/Tabs/Profile/User View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ struct UserView: View {
Button {
isPresentingAccountSwitcher = true
} label: {
Image(systemName: AppConstants.switchUserSymbolName)
Image(systemName: Icons.switchUser)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit adeb83a

Please sign in to comment.