mirror of
https://github.com/seemoo-lab/openhaystack.git
synced 2026-02-14 17:49:54 +00:00
Updating preview for better control of Screenshots
This commit is contained in:
@@ -19,10 +19,10 @@ struct PreviewData {
|
||||
static let latitude: Double = 49.878046
|
||||
static let longitude: Double = 8.656993
|
||||
|
||||
static func randomLocation() -> CLLocation {
|
||||
static func randomLocation(lat: Double = latitude, lng: Double = longitude, distance: Double = 0.005) -> CLLocation {
|
||||
return CLLocation(
|
||||
latitude: latitude + Double.random(in: 0..<0.005) * (Bool.random() ? -1 : 1),
|
||||
longitude: longitude + Double.random(in: 0..<0.005) * (Bool.random() ? -1 : 1)
|
||||
latitude: lat + Double.random(in: 0..<distance) * (Bool.random() ? -1 : 1),
|
||||
longitude: lng + Double.random(in: 0..<distance) * (Bool.random() ? -1 : 1)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -37,6 +37,16 @@ struct PreviewData {
|
||||
accessory.isDeployed = true
|
||||
accessory.isActive = true
|
||||
accessory.isNearby = Bool.random()
|
||||
//Generate recent locations
|
||||
let startDate = Date().addingTimeInterval(-60 * 60 * 24)
|
||||
var date = startDate
|
||||
var locations: [FindMyLocationReport] = []
|
||||
while date < Date() {
|
||||
let location = randomLocation(lat: accessory.lastLocation!.coordinate.latitude, lng: accessory.lastLocation!.coordinate.longitude, distance: 0.0005)
|
||||
locations.append(FindMyLocationReport(lat: location.coordinate.latitude, lng: location.coordinate.longitude, acc: 10, dP: date, t: date, c: 0))
|
||||
date += 30 * 60
|
||||
}
|
||||
accessory.locations = locations
|
||||
return accessory
|
||||
}
|
||||
|
||||
|
||||
@@ -13,12 +13,16 @@ import SwiftUI
|
||||
struct OpenHaystackApp: App {
|
||||
@StateObject var accessoryController: AccessoryController
|
||||
var accessoryNearbyMonitor: AccessoryNearbyMonitor?
|
||||
var frameWidth: CGFloat? = nil
|
||||
var frameHeight: CGFloat? = nil
|
||||
|
||||
init() {
|
||||
let accessoryController: AccessoryController
|
||||
if ProcessInfo().arguments.contains("-preview") {
|
||||
accessoryController = AccessoryControllerPreview(accessories: PreviewData.accessories, findMyController: FindMyController())
|
||||
self.accessoryNearbyMonitor = nil
|
||||
// self.frameWidth = 1920
|
||||
// self.frameHeight = 1080
|
||||
} else {
|
||||
accessoryController = AccessoryController()
|
||||
self.accessoryNearbyMonitor = AccessoryNearbyMonitor(accessoryController: accessoryController)
|
||||
@@ -30,6 +34,7 @@ struct OpenHaystackApp: App {
|
||||
WindowGroup {
|
||||
OpenHaystackMainView()
|
||||
.environmentObject(self.accessoryController)
|
||||
.frame(width: self.frameWidth, height: self.frameHeight)
|
||||
}
|
||||
.commands {
|
||||
SidebarCommands()
|
||||
|
||||
Reference in New Issue
Block a user