diff options
author | Arturs Artamonovs <arturs.artamonovs@protonmail.com> | 2024-09-04 10:24:38 +0100 |
---|---|---|
committer | Arturs Artamonovs <arturs.artamonovs@protonmail.com> | 2024-09-04 10:24:38 +0100 |
commit | 9070c9e6b7c7ce5671f4fad85e4aefa8c27aad28 (patch) | |
tree | 2f38a62f16478f5e1d48f2231a0cafa5641365d0 /LearnMapKit/ContentView.swift | |
parent | a474815bb7f4f395d3dfeafba85c3fa9e7d880c3 (diff) | |
download | ADSBDecoder-main.tar.gz ADSBDecoder-main.zip |
Plain tracking UI works much bettermain
Diffstat (limited to 'LearnMapKit/ContentView.swift')
-rw-r--r-- | LearnMapKit/ContentView.swift | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/LearnMapKit/ContentView.swift b/LearnMapKit/ContentView.swift index 9f18e30..cbe178f 100644 --- a/LearnMapKit/ContentView.swift +++ b/LearnMapKit/ContentView.swift @@ -8,9 +8,7 @@ import SwiftUI import MapKit import Collections - - - +/* struct FlightView: View { var evilClass: FlightState @@ -34,19 +32,17 @@ struct FlightView: View { } } } -} +}*/ struct ContentView: View { @State private var region = MKCoordinateRegion() @State private var isImporting = false - @Binding var pos_queue: Deque<ADSBLocation> @Binding var net_config: NetworkConfigure - @EnvironmentObject var evilClass: FlightState + @EnvironmentObject var flightState: FlightState @Environment(\.openWindow) private var openWindow - let initialPosition: MapCameraPosition = { let center = CLLocationCoordinate2D(latitude: 55.90159, longitude:-3.53154) let span = MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1) @@ -54,44 +50,59 @@ struct ContentView: View { return .region(region) }() - let position1 = CLLocationCoordinate2D(latitude: 55.80159, longitude:-3.53154) - let position2 = CLLocationCoordinate2D(latitude: 55.99159, longitude:-3.53154) - let position3 = CLLocationCoordinate2D(latitude: 55.80159, longitude:-3.43154) - let position4 = CLLocationCoordinate2D(latitude: 55.80159, longitude:-3.63154) + //let position1 = CLLocationCoordinate2D(latitude: 55.80159, longitude:-3.53154) + //let position2 = CLLocationCoordinate2D(latitude: 55.99159, longitude:-3.53154) + //let position3 = CLLocationCoordinate2D(latitude: 55.80159, longitude:-3.43154) + //let position4 = CLLocationCoordinate2D(latitude: 55.80159, longitude:-3.63154) var body: some View { VStack { Map(initialPosition: initialPosition) { - ForEach(self.evilClass.flight.sorted(by: { $0.key < $1.key} ), id:\.key) { k in - Annotation("\(k.key)", coordinate: CLLocationCoordinate2D(latitude: self.evilClass.flight[k.key]!.lat, longitude:self.evilClass.flight[k.key]!.long)) { - VStack { - ZStack { - RoundedRectangle(cornerRadius: 10) - .fill(.background) - RoundedRectangle(cornerRadius: 10) - .stroke(.secondary,lineWidth: 5) - Image(systemName:"airplane.circle.fill") - .resizable() - .frame(width:20,height: 20) - } - Text("\(k.value.ICAOName)") + ForEach(flightState.flight) { flight in + Annotation(flight.ICAOName, + coordinate: CLLocationCoordinate2D( + latitude: flight.lat, + longitude:flight.long) + ) { + VStack { + /* + ZStack { + RoundedRectangle(cornerRadius: 10) + .fill(.background) + RoundedRectangle(cornerRadius: 10) + .stroke(.secondary,lineWidth: 5) + //Image(systemName:"airplane.circle.fill") + // .resizable() + // .frame(width:20,height: 20) + Text("\(flight.ICAOName)").font(.body) + }*/ + ZStack { + RoundedRectangle(cornerRadius: 10) + .fill(.background) + RoundedRectangle(cornerRadius: 10) + .stroke(.secondary,lineWidth: 5) + Image(systemName:"airplane.circle.fill") + .resizable() + .frame(width:20,height: 20) } - }.annotationTitles(.hidden) + Text("\(flight.ICAOName)").font(.body) + } + }.annotationTitles(.hidden) } } .padding() .border(.green) .layoutPriority(1) .mapStyle(.hybrid(elevation: .realistic)) - .toolbar { + /*.toolbar { ToolbarItem() { Button { isImporting = true } label: { Label("Import file", systemImage: "square.and.arrow.down") } - } + }*//* ToolbarItem { Button { openWindow(id: "net-config") @@ -99,14 +110,14 @@ struct ContentView: View { Label("Network config", systemImage: "network") } } - } .fileImporter(isPresented: $isImporting, allowedContentTypes: [.text], allowsMultipleSelection: false) { + }*/ /*.fileImporter(isPresented: $isImporting, allowedContentTypes: [.text], allowsMultipleSelection: false) { result in switch result { case .success(let files): print(files) case .failure(let error): print(error) } - } + }*/ } |