Files
sing-box-for-apple/SFT/MainView.swift
T
2023-11-09 15:45:08 +08:00

38 lines
1.0 KiB
Swift

import ApplicationLibrary
import Libbox
import Library
import SwiftUI
struct MainView: View {
@Environment(\.scenePhase) private var scenePhase
@EnvironmentObject private var environments: ExtensionEnvironments
@State private var selection = NavigationPage.dashboard
var body: some View {
TabView(selection: $selection) {
ForEach(NavigationPage.allCases, id: \.self) { page in
NavigationStackCompat {
page.contentView
.focusSection()
}
.tag(page)
.tabItem { page.label }
}
}
.onAppear {
environments.postReload()
}
.onChangeCompat(of: scenePhase) { newValue in
if newValue == .active {
environments.postReload()
}
}
.onChangeCompat(of: selection) { newValue in
if newValue == .logs {
environments.connectLog()
}
}
.environment(\.selection, $selection)
}
}