When navigating with the screen, the tab selection should be updated accordingly but it does not. I try with the observable protocol or with the state property wrapper, same results...
import SwiftUI
import SwiftData
struct MainView: View {
@Environment(\.modelContext) private var db
@Environment(NavigationObservable.self) private var navigationObservable
// @State private var tab:String = "tab1"
var body: some View {
TabView(
selection:Binding(
get: { navigationObservable.tab },
set: { newValue in navigationObservable.tab = newValue }
)
) {
// TabView(
// selection:$tab
// ) {
Text("tab1")
.tag("tab1")
Text("tab2")
.tag("tab2")
}
.tabViewStyle(.page(indexDisplayMode:.never))
.onChange(of: navigationObservable.tab) {
print(navigationObservable.tab)
}
// .onChange(of: tab) {
// print(tab)
// }
}
}