USB-Meter / USB Meter / SceneDelegate.swift
Newer Older
65 lines | 2.819kb
Bogdan Timofte authored 2 weeks ago
1
//
2
//  SceneDelegate.swift
3
//  USB Meter
4
//
5
//  Created by Bogdan Timofte on 01/03/2020.
6
//  Copyright © 2020 Bogdan Timofte. All rights reserved.
7
//
8

            
9
import UIKit
10
import SwiftUI
11

            
12
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
13

            
14
    var window: UIWindow?
15

            
16

            
17
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
18

            
19
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
20
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
21
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
22

            
23
        let contentView = ContentView()
24
            .environmentObject(appData)
25

            
26
        // Use a UIHostingController as window root view controller.
27
        if let windowScene = scene as? UIWindowScene {
28
            let window = UIWindow(windowScene: windowScene)
29
            window.rootViewController = UIHostingController(rootView: contentView)
30
            self.window = window
31
            window.makeKeyAndVisible()
32
        }
33
    }
34

            
35
    func sceneDidDisconnect(_ scene: UIScene) {
36
        // Called as the scene is being released by the system.
37
        // This occurs shortly after the scene enters the background, or when its session is discarded.
38
        // Release any resources associated with this scene that can be re-created the next time the scene connects.
39
        // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead).
40
    }
41

            
42
    func sceneDidBecomeActive(_ scene: UIScene) {
43
        // Called when the scene has moved from an inactive state to an active state.
44
        // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
45
    }
46

            
47
    func sceneWillResignActive(_ scene: UIScene) {
48
        // Called when the scene will move from an active state to an inactive state.
49
        // This may occur due to temporary interruptions (ex. an incoming phone call).
50
    }
51

            
52
    func sceneWillEnterForeground(_ scene: UIScene) {
53
        // Called as the scene transitions from the background to the foreground.
54
        // Use this method to undo the changes made on entering the background.
55
    }
56

            
57
    func sceneDidEnterBackground(_ scene: UIScene) {
58
        // Called as the scene transitions from the foreground to the background.
59
        // Use this method to save data, release shared resources, and store enough scene-specific state information
60
        // to restore the scene back to its current state.
61

            
62
    }
63

            
64

            
65
}