mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-26 15:02:39 +01:00
47 lines
1.3 KiB
Swift
47 lines
1.3 KiB
Swift
import Account
|
|
import AppAccount
|
|
import Conversations
|
|
import DesignSystem
|
|
import Env
|
|
import Models
|
|
import Network
|
|
import Shimmer
|
|
import SwiftUI
|
|
|
|
struct ProfileTab: View {
|
|
@EnvironmentObject private var appAccount: AppAccountsManager
|
|
@EnvironmentObject private var theme: Theme
|
|
@EnvironmentObject private var client: Client
|
|
@EnvironmentObject private var currentAccount: CurrentAccount
|
|
@StateObject private var routerPath = RouterPath()
|
|
@Binding var popToRootTab: Tab
|
|
|
|
var body: some View {
|
|
NavigationStack(path: $routerPath.path) {
|
|
if let account = currentAccount.account {
|
|
AccountDetailView(account: account)
|
|
.withAppRouter()
|
|
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
|
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
|
|
.id(account.id)
|
|
} else {
|
|
AccountDetailView(account: .placeholder())
|
|
.redacted(reason: .placeholder)
|
|
}
|
|
}
|
|
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
|
|
if popToRootTab == .profile {
|
|
routerPath.path = []
|
|
}
|
|
}
|
|
.onChange(of: client.id) { _ in
|
|
routerPath.path = []
|
|
}
|
|
.onAppear {
|
|
routerPath.client = client
|
|
}
|
|
.withSafariRouter()
|
|
.environmentObject(routerPath)
|
|
}
|
|
}
|