//
// IceGlassApp.swift
// IceGlass-iOS
//
// Copyright 2026 Rouslan Zenetl. All Rights Reserved.
//

import SwiftUI

@main
struct IceGlassApp: App {
    @State private var viewModel = ScoreboardViewModel()
    @Environment(\.scenePhase) private var scenePhase

    var body: some Scene {
        WindowGroup {
            ContentView()
                .environment(viewModel)
                .onAppear { viewModel.attach() }
                .onChange(of: scenePhase) { _, newPhase in
                    switch newPhase {
                    case .active:
                        viewModel.handleScenePhaseActive()
                    case .background, .inactive:
                        viewModel.handleScenePhaseInactive()
                    @unknown default:
                        break
                    }
                }
        }
    }
}
