IceCubes/IceCubesApp/App/Tabs/AccountTab.swift

33 lines
903 B
Swift
Raw Normal View History

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-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-24 11:50:05 +01:00
@Binding var popToRootTab: IceCubesApp.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 {
AccountDetailView(account: account, isCurrentUser: true)
2022-12-20 16:08:09 +01:00
.withAppRouteur()
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
} 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-20 16:08:09 +01:00
}
}