summaryrefslogtreecommitdiff
path: root/LearnMapKit/LearnMapKitApp.swift
blob: 5fa170acb60ee59ba879c5527aeeb31246705f68 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
//  LearnMapKitApp.swift
//  LearnMapKit
//
//  Created by Jacky Jack on 05/06/2024.
//

import SwiftUI
import Collections

//https://www.hackingwithswift.com/quick-start/swiftui/how-to-run-code-when-your-app-launches



@main
struct LearnMapKitApp: App {
    
    @State var queue: Deque<ADSBLocation> = []
    
    @StateObject private var flightState = FlightState()
    
    init() {
        print("Init app")
        var update_postions: Deque<ADSBLocation> = []
        DispatchQueue.global(qos: .background).sync {
            print("Dispatch")
            //var count = 0
            
            
            //let ADSBtask = ADSBRunner()
            //queue.append(MapADSBData(lat: 0.0, long: 0.0, alt: 1))
            /*
            let timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { timer in
                print("Timer fired! \(count)")
                ADSBtask.runFromFile()
                update_postions.append(MapADSBData(lat: 0.0, long: 0.0, alt: 1))
                print(update_postions.count)
                count += 1
            }*/
            print("Exit dispatch")
        }
        
        //push all new data to state queue from a runner
        DispatchQueue.global(qos: .background).sync {
            // Update the UI on the main thread
            let c = queue.count
        }
    }
    
    
    
    var body: some Scene {
        WindowGroup {
            ContentView(pos_queue: $queue)
        }.environmentObject(flightState)
    }
    
}