IceCubesApp/IceCubesApp/App/Tabs/AccountTab.swift

41 lines
1.1 KiB
Swift
Raw Normal View History

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