2022-12-20 16:08:09 +01:00
|
|
|
import SwiftUI
|
2022-12-22 10:53:36 +01:00
|
|
|
import Env
|
2022-12-20 16:08:09 +01:00
|
|
|
import Network
|
|
|
|
import Account
|
|
|
|
import Models
|
|
|
|
import Shimmer
|
|
|
|
|
|
|
|
struct AccountTab: View {
|
2022-12-27 08:31:47 +01:00
|
|
|
@EnvironmentObject private var client: Client
|
2022-12-22 11:19:56 +01:00
|
|
|
@EnvironmentObject private var currentAccount: CurrentAccount
|
2022-12-20 16:08:09 +01:00
|
|
|
@StateObject private var routeurPath = RouterPath()
|
2022-12-27 09:25:26 +01:00
|
|
|
@Binding var popToRootTab: Tab
|
2022-12-20 16:08:09 +01:00
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
NavigationStack(path: $routeurPath.path) {
|
2022-12-22 11:19:56 +01:00
|
|
|
if let account = currentAccount.account {
|
2022-12-27 13:49:54 +01:00
|
|
|
AccountDetailView(account: account)
|
2022-12-20 16:08:09 +01:00
|
|
|
.withAppRouteur()
|
|
|
|
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
|
2022-12-29 17:22:07 +01:00
|
|
|
.toolbar {
|
|
|
|
statusEditorToolbarItem(routeurPath: routeurPath)
|
|
|
|
}
|
2022-12-30 08:36:22 +01:00
|
|
|
.id(account.id)
|
2022-12-20 16:08:09 +01:00
|
|
|
} else {
|
|
|
|
AccountDetailView(account: .placeholder())
|
|
|
|
.redacted(reason: .placeholder)
|
|
|
|
.shimmering()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.environmentObject(routeurPath)
|
2022-12-24 11:50:05 +01:00
|
|
|
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
|
|
|
|
if popToRootTab == .account {
|
|
|
|
routeurPath.path = []
|
|
|
|
}
|
|
|
|
}
|
2022-12-27 08:31:47 +01:00
|
|
|
.onAppear {
|
|
|
|
routeurPath.client = client
|
|
|
|
}
|
2022-12-20 16:08:09 +01:00
|
|
|
}
|
|
|
|
}
|