Add access to profile from account selector
This commit is contained in:
parent
8152db745d
commit
bfc1f61e4b
|
@ -88,7 +88,8 @@ struct SideBarView<Content: View>: View {
|
|||
}
|
||||
} label: {
|
||||
ZStack(alignment: .topTrailing) {
|
||||
AppAccountView(viewModel: .init(appAccount: account, isCompact: true))
|
||||
AppAccountView(viewModel: .init(appAccount: account, isCompact: true),
|
||||
isParentPresented: .constant(false))
|
||||
if showBadge,
|
||||
let token = account.oauthToken,
|
||||
let notificationsCount = userPreferences.notificationsCount[token],
|
||||
|
|
|
@ -101,7 +101,7 @@ struct SettingsTabs: View {
|
|||
.tint(.red)
|
||||
}
|
||||
}
|
||||
AppAccountView(viewModel: .init(appAccount: account))
|
||||
AppAccountView(viewModel: .init(appAccount: account), isParentPresented: .constant(false))
|
||||
}
|
||||
}
|
||||
.onDelete { indexSet in
|
||||
|
|
|
@ -12,8 +12,11 @@ public struct AppAccountView: View {
|
|||
|
||||
@State var viewModel: AppAccountViewModel
|
||||
|
||||
public init(viewModel: AppAccountViewModel) {
|
||||
@Binding var isParentPresented: Bool
|
||||
|
||||
public init(viewModel: AppAccountViewModel, isParentPresented: Binding<Bool>) {
|
||||
self.viewModel = viewModel
|
||||
_isParentPresented = isParentPresented
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
|
@ -47,8 +50,14 @@ public struct AppAccountView: View {
|
|||
if appAccounts.currentAccount.id == viewModel.appAccount.id,
|
||||
let account = viewModel.account
|
||||
{
|
||||
routerPath.navigate(to: .accountSettingsWithAccount(account: account, appAccount: viewModel.appAccount))
|
||||
HapticManager.shared.fireHaptic(.buttonPress)
|
||||
if viewModel.isInSettings {
|
||||
routerPath.navigate(to: .accountSettingsWithAccount(account: account, appAccount: viewModel.appAccount))
|
||||
HapticManager.shared.fireHaptic(.buttonPress)
|
||||
} else {
|
||||
isParentPresented = false
|
||||
routerPath.navigate(to: .accountDetailWithAccount(account: account))
|
||||
HapticManager.shared.fireHaptic(.buttonPress)
|
||||
}
|
||||
} else {
|
||||
var transation = Transaction()
|
||||
transation.disablesAnimations = true
|
||||
|
@ -100,7 +109,7 @@ public struct AppAccountView: View {
|
|||
.foregroundStyle(Color.secondary)
|
||||
}
|
||||
}
|
||||
if viewModel.isInNavigation {
|
||||
if viewModel.isInSettings {
|
||||
Spacer()
|
||||
Image(systemName: "chevron.right")
|
||||
.foregroundStyle(.secondary)
|
||||
|
|
|
@ -13,7 +13,7 @@ import SwiftUI
|
|||
var appAccount: AppAccount
|
||||
let client: Client
|
||||
let isCompact: Bool
|
||||
let isInNavigation: Bool
|
||||
let isInSettings: Bool
|
||||
let showBadge: Bool
|
||||
|
||||
var account: Account? {
|
||||
|
@ -32,10 +32,10 @@ import SwiftUI
|
|||
}
|
||||
}
|
||||
|
||||
public init(appAccount: AppAccount, isCompact: Bool = false, isInNavigation: Bool = true, showBadge: Bool = false) {
|
||||
public init(appAccount: AppAccount, isCompact: Bool = false, isInSettings: Bool = true, showBadge: Bool = false) {
|
||||
self.appAccount = appAccount
|
||||
self.isCompact = isCompact
|
||||
self.isInNavigation = isInNavigation
|
||||
self.isInSettings = isInSettings
|
||||
self.showBadge = showBadge
|
||||
client = .init(server: appAccount.server, oauthToken: appAccount.oauthToken)
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ public struct AppAccountsSelectorView: View {
|
|||
List {
|
||||
Section {
|
||||
ForEach(accountsViewModel.sorted { $0.acct < $1.acct }, id: \.appAccount.id) { viewModel in
|
||||
AppAccountView(viewModel: viewModel)
|
||||
AppAccountView(viewModel: viewModel, isParentPresented: $isPresented)
|
||||
}
|
||||
addAccountButton
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ public struct AppAccountsSelectorView: View {
|
|||
private func refreshAccounts() {
|
||||
accountsViewModel = []
|
||||
for account in appAccounts.availableAccounts {
|
||||
let viewModel: AppAccountViewModel = .init(appAccount: account, isInNavigation: false, showBadge: true)
|
||||
let viewModel: AppAccountViewModel = .init(appAccount: account, isInSettings: false, showBadge: true)
|
||||
accountsViewModel.append(viewModel)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue