IceCubesApp/IceCubesApp/App/Tabs/MessagesTab.swift
David Walter 76d7d23379
Support In-App Safari (#44)
* Support In-App Safari

* Fix "View in Browser"

* Force external Safari on Account Creation

* Fix SafariRouteur issues

Attach to NavigationStack
Find top-most ViewController

* Make Preferred Browser a Picker choice
2023-01-08 19:56:16 +01:00

45 lines
1.2 KiB
Swift

import SwiftUI
import Env
import Network
import Account
import Models
import Shimmer
import Conversations
import Env
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 {
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
watcher.unreadMessagesCount = 0
}
.withSafariRouteur()
.environmentObject(routeurPath)
}
}