IceCubesApp/IceCubesApp/App/Tabs/MessagesTab.swift
Thomas Ricouard 7f6419ebae Swiftformat
2023-01-17 11:36:01 +01:00

46 lines
1.2 KiB
Swift

import Account
import AppAccount
import Conversations
import Env
import Models
import Network
import Shimmer
import SwiftUI
struct MessagesTab: View {
@EnvironmentObject private var watcher: StreamWatcher
@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) {
ConversationsListView()
.withAppRouteur()
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
.toolbar {
if UIDevice.current.userInterfaceIdiom != .pad {
ToolbarItem(placement: .navigationBarLeading) {
AppAccountsSelectorView(routeurPath: routeurPath)
}
}
}
.id(currentAccount.account?.id)
}
.onChange(of: $popToRootTab.wrappedValue) { popToRootTab in
if popToRootTab == .messages {
routeurPath.path = []
}
}
.onChange(of: currentAccount.account?.id) { _ in
routeurPath.path = []
}
.onAppear {
routeurPath.client = client
}
.withSafariRouteur()
.environmentObject(routeurPath)
}
}