import SwiftUI

@main
struct CountoutApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    
    var body: some Scene {
        WindowGroup {
            TabView {
                MainView()
                    .tabItem { Label("Countdown", systemImage: "stopwatch") }
                    .onAppear { CountdownTimer.shared.isScheduled = false }
                DateView()
                    .tabItem { Label("Schedule", systemImage: "calendar") }
                    .onAppear { CountdownTimer.shared.isScheduled = true }
            }
        }
    }
}

import SwiftUI

@main
struct CountoutApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    
    @State private var tabSelection = 0
    
    var body: some Scene {
        WindowGroup {
            TabView(selection: $tabSelection) {
                MainView()
                    .tabItem { Label("Countdown", systemImage: "stopwatch") }.tag(0)
                DateView()
                    .tabItem { Label("Schedule", systemImage: "calendar") }.tag(1)
            }
            .onChange(of: tabSelection) { tabIndex in
                CountdownTimer.shared.isScheduled = tabIndex == 1
            }
        }
    }
}

Update isScheduled on tab selection as .onAppear seems to get called on init.
Update isScheduled on tab selection as .onAppear seems to get called on init.
