mirror of
https://github.com/seemoo-lab/openhaystack.git
synced 2026-02-27 16:03:47 +00:00
Architectural changes discussed with @schmittner: Moving the FindMyController out of the environment and using the AccessoryController as the main entry point, also for downloading reports The AccessoryController is now passed as an Environment Object again
53 lines
1.5 KiB
Swift
53 lines
1.5 KiB
Swift
//
|
||
// OpenHaystack – Tracking personal Bluetooth devices via Apple's Find My network
|
||
//
|
||
// Copyright © 2021 Secure Mobile Networking Lab (SEEMOO)
|
||
// Copyright © 2021 The Open Wireless Link Project
|
||
//
|
||
// SPDX-License-Identifier: AGPL-3.0-only
|
||
//
|
||
|
||
import SwiftUI
|
||
|
||
@main
|
||
struct OpenHaystackApp: App {
|
||
@StateObject var accessoryController: AccessoryController
|
||
|
||
init() {
|
||
let accessoryController: AccessoryController
|
||
if ProcessInfo().arguments.contains("-preview") {
|
||
accessoryController = AccessoryControllerPreview(accessories: PreviewData.accessories, findMyController: FindMyController())
|
||
} else {
|
||
accessoryController = AccessoryController()
|
||
}
|
||
self._accessoryController = StateObject(wrappedValue: accessoryController)
|
||
}
|
||
|
||
var body: some Scene {
|
||
WindowGroup {
|
||
OpenHaystackMainView()
|
||
.environmentObject(self.accessoryController)
|
||
}
|
||
.commands {
|
||
SidebarCommands()
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
//MARK: Environment objects
|
||
private struct FindMyControllerEnvironmentKey: EnvironmentKey {
|
||
static let defaultValue: FindMyController = FindMyController()
|
||
}
|
||
|
||
private struct AccessoryControllerEnvironmentKey: EnvironmentKey {
|
||
static let defaultValue: AccessoryController = {
|
||
if ProcessInfo().arguments.contains("-preview") {
|
||
return AccessoryControllerPreview(accessories: PreviewData.accessories, findMyController: FindMyController())
|
||
} else {
|
||
return AccessoryController()
|
||
}
|
||
}()
|
||
}
|