IceCubes/IceCubesApp/App/Tabs/AccountTab.swift
2023-01-02 19:23:44 +01:00

44 lines
1.2 KiB
Swift

import SwiftUI
import Env
import Network
import Account
import Models
import Shimmer
struct AccountTab: View {
@EnvironmentObject private var client: Client
@EnvironmentObject private var currentAccount: CurrentAccount
@StateObject private var routeurPath = RouterPath()
@Binding var popToRootTab: Tab
var body: some View {
NavigationStack(path: $routeurPath.path) {
if let account = currentAccount.account {
AccountDetailView(account: account)
.withAppRouteur()
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
.toolbar {
statusEditorToolbarItem(routeurPath: routeurPath)
}
.id(account.id)
} else {
AccountDetailView(account: .placeholder())
.redacted(reason: .placeholder)
.shimmering()
}
}
.environmentObject(routeurPath)
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
if popToRootTab == .account {
routeurPath.path = []
}
}
.onChange(of: currentAccount.account?.id) { _ in
routeurPath.path = []
}
.onAppear {
routeurPath.client = client
}
}
}