WIP
This commit is contained in:
@@ -11,8 +11,10 @@ import Combine
|
||||
@main
|
||||
struct Werkout_iosApp: App {
|
||||
let persistenceController = PersistenceController.shared
|
||||
@ObservedObject var bridgeModule = BridgeModule.shared
|
||||
@State var additionalWindows: [UIWindow] = []
|
||||
@State private var tabSelection = 1
|
||||
|
||||
let pub = NotificationCenter.default.publisher(for: NSNotification.Name("CreatedNewWorkout"))
|
||||
|
||||
private var screenDidConnectPublisher: AnyPublisher<UIScreen, Never> {
|
||||
NotificationCenter.default
|
||||
@@ -32,9 +34,8 @@ struct Werkout_iosApp: App {
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
TabView {
|
||||
TabView(selection: $tabSelection) {
|
||||
AllWorkoutsView()
|
||||
.environmentObject(bridgeModule)
|
||||
.onReceive(
|
||||
screenDidConnectPublisher,
|
||||
perform: screenDidConnect
|
||||
@@ -46,25 +47,32 @@ struct Werkout_iosApp: App {
|
||||
.tabItem {
|
||||
Label("All Workouts", systemImage: "figure.strengthtraining.traditional")
|
||||
}
|
||||
.tag(1)
|
||||
|
||||
CreateWorkoutMainView()
|
||||
.tabItem {
|
||||
Label("Create Workout", systemImage: "plus.app.fill")
|
||||
}
|
||||
.tag(2)
|
||||
|
||||
AccountView()
|
||||
.tabItem {
|
||||
Label("Accounts", systemImage: "person.fill.turn.down")
|
||||
}
|
||||
.tag(3)
|
||||
}
|
||||
.onAppear{
|
||||
DataStore.shared.fetchAllData()
|
||||
}
|
||||
.onReceive(pub) { (output) in
|
||||
self.tabSelection = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func screenDidDisconnect(_ screen: UIScreen) {
|
||||
additionalWindows.removeAll { $0.screen == screen }
|
||||
bridgeModule.isShowingOnExternalDisplay = false
|
||||
BridgeModule.shared.isShowingOnExternalDisplay = false
|
||||
}
|
||||
|
||||
private func screenDidConnect(_ screen: UIScreen) {
|
||||
@@ -75,11 +83,10 @@ struct Werkout_iosApp: App {
|
||||
as? UIWindowScene
|
||||
|
||||
let view = ExternalWorkoutDetailView()
|
||||
.environmentObject(bridgeModule)
|
||||
let controller = UIHostingController(rootView: view)
|
||||
window.rootViewController = controller
|
||||
window.isHidden = false
|
||||
additionalWindows.append(window)
|
||||
bridgeModule.isShowingOnExternalDisplay = true
|
||||
BridgeModule.shared.isShowingOnExternalDisplay = true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user