//
//  SceneDelegate.swift
//  Runner
//
//  Created for Even Realities G1 Demo
//

import UIKit
import Flutter

@available(iOS 13.0, *)
class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        guard let windowScene = (scene as? UIWindowScene) else { return }
        
        // Only set up the window if we don't have one already (for modern UIScene lifecycle)
        if window == nil {
            window = UIWindow(windowScene: windowScene)
            
            let flutterEngine = FlutterEngine(name: "my flutter engine")
            flutterEngine.run()
            
            let controller = FlutterViewController(engine: flutterEngine, nibName: nil, bundle: nil)
            
            window?.rootViewController = controller
            window?.makeKeyAndVisible()
        }
    }

    func sceneDidDisconnect(_ scene: UIScene) {
        // Called as the scene is being released by the system.
    }

    func sceneDidBecomeActive(_ scene: UIScene) {
        // Called when the scene has moved from an inactive state to an active state.
        print("Scene became active")
    }

    func sceneWillResignActive(_ scene: UIScene) {
        // Called when the scene will move from an active state to an inactive state.
        print("Scene will resign active")
    }

    func sceneWillEnterForeground(_ scene: UIScene) {
        // Called as the scene transitions from the background to the foreground.
        print("Scene will enter foreground")
    }

    func sceneDidEnterBackground(_ scene: UIScene) {
        // Called as the scene transitions from the foreground to the background.
        print("Scene did enter background")
    }
} 