2023-01-17 13:02:05 +01:00
|
|
|
import Account
|
|
|
|
import AppAccount
|
|
|
|
import Conversations
|
2023-01-22 06:53:18 +01:00
|
|
|
import DesignSystem
|
2023-01-17 13:02:05 +01:00
|
|
|
import Env
|
|
|
|
import Models
|
|
|
|
import Network
|
|
|
|
import Shimmer
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct ProfileTab: View {
|
2023-01-30 19:14:43 +01:00
|
|
|
@EnvironmentObject private var appAccount: AppAccountsManager
|
2023-01-22 06:53:18 +01:00
|
|
|
@EnvironmentObject private var theme: Theme
|
2023-01-17 13:02:05 +01:00
|
|
|
@EnvironmentObject private var client: Client
|
|
|
|
@EnvironmentObject private var currentAccount: CurrentAccount
|
2023-01-17 15:14:50 +01:00
|
|
|
@StateObject private var routerPath = RouterPath()
|
2023-01-17 13:02:05 +01:00
|
|
|
@Binding var popToRootTab: Tab
|
|
|
|
|
|
|
|
var body: some View {
|
2023-01-17 15:14:50 +01:00
|
|
|
NavigationStack(path: $routerPath.path) {
|
2023-01-17 13:02:05 +01:00
|
|
|
if let account = currentAccount.account {
|
|
|
|
AccountDetailView(account: account)
|
2023-01-17 15:14:50 +01:00
|
|
|
.withAppRouter()
|
|
|
|
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
2023-01-22 06:53:18 +01:00
|
|
|
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
|
2023-01-30 22:24:30 +01:00
|
|
|
.id(account.id)
|
2023-01-17 13:02:05 +01:00
|
|
|
} else {
|
|
|
|
AccountDetailView(account: .placeholder())
|
|
|
|
.redacted(reason: .placeholder)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
|
2023-01-26 07:34:29 +01:00
|
|
|
if popToRootTab == .profile {
|
2023-01-17 15:14:50 +01:00
|
|
|
routerPath.path = []
|
2023-01-17 13:02:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
.onChange(of: currentAccount.account?.id) { _ in
|
2023-01-17 15:14:50 +01:00
|
|
|
routerPath.path = []
|
2023-01-17 13:02:05 +01:00
|
|
|
}
|
|
|
|
.onAppear {
|
2023-01-17 15:14:50 +01:00
|
|
|
routerPath.client = client
|
2023-01-17 13:02:05 +01:00
|
|
|
}
|
2023-01-17 15:14:50 +01:00
|
|
|
.withSafariRouter()
|
|
|
|
.environmentObject(routerPath)
|
2023-01-17 13:02:05 +01:00
|
|
|
}
|
|
|
|
}
|