mirror of
https://github.com/jayanezj/traccar-client-macos.git
synced 2026-11-05 03:00:46 +01:00
feat: add native local location capture (#4)
Add explicit permission handling, independent continuous and single capture, location status and deterministic CI coverage. Final decisions and validation: https://github.com/jayanezj/traccar-client-macos/issues/4#issuecomment-6399189792
This commit is contained in:
18 files changed
+1030
-38
No files matched your search
@@ -5,21 +5,39 @@ import SwiftUI
|
||||
struct TraccarClientApp: App {
|
||||
@NSApplicationDelegateAdaptor(ApplicationDelegate.self) private var delegate
|
||||
|
||||
@State private var configuration = ConfigurationModel.live()
|
||||
@State private var configuration: ConfigurationModel
|
||||
@State private var location: LocationModel
|
||||
|
||||
init() {
|
||||
let storage = PreferencesConfigurationStorage.live()
|
||||
let capture = LocationModel(provider: CoreLocationProvider(), readAccuracy: {
|
||||
try storage.loadTrackingPreferences().accuracy
|
||||
})
|
||||
_location = State(initialValue: capture)
|
||||
_configuration = State(initialValue: ConfigurationModel(storage: storage, beforeConnectionChange: { _, _ in
|
||||
capture.shutdown()
|
||||
}))
|
||||
}
|
||||
|
||||
var body: some Scene {
|
||||
MenuBarExtra {
|
||||
TrackingMenu()
|
||||
TrackingMenu(location: location)
|
||||
} label: {
|
||||
Image("MenuBarIcon")
|
||||
.renderingMode(.template)
|
||||
.accessibilityLabel("Traccar Client — Paused")
|
||||
.accessibilityLabel("Traccar Client — \(location.status)")
|
||||
}
|
||||
.menuBarExtraStyle(.menu)
|
||||
|
||||
Settings {
|
||||
SettingsView(model: configuration)
|
||||
SettingsView(model: configuration, location: location)
|
||||
}
|
||||
|
||||
Window("Location capture", id: "location-capture") {
|
||||
LocationStatusView(location: location)
|
||||
}
|
||||
.windowResizability(.contentSize)
|
||||
.defaultLaunchBehavior(.suppressed)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user