Phase 3.5: Pause/Resume, SwiftData-Persistenz, Kamera-Capture, Fotos zu bestehender Tour
LocationTracker: - isPaused, pausedAt, accumulatedPausedSeconds - pause()/resume()/restore() Methoden - effectiveElapsedSeconds rechnet Pausen raus - restore() für nach App-Crash: Offline-Lücke wird als Pause gezählt ActiveWalk @Model (SwiftData): - startedAt, lastUpdate, pausedAt, accumulatedPausedSeconds, pointsData - Container in BanYaroGoApp registriert TrackingView: - Persistenz alle 5s via Timer - confirmationDialog beim Erscheinen wenn ActiveWalk vorhanden: Fortsetzen / Jetzt speichern / Verwerfen - Pause/Resume-Button + Stop-Button - Floating Kamera-Button rechts unten - Foto-Counter in der Stats-Karte - Pause-Badge oben links bei Pause CameraPicker: UIImagePickerController-Wrapper (Fallback auf Library im Simulator). FinishWalkSheet: initialPhotos: [Data] für Kamera-Fotos während Tour. RouteDetailView: PhotosPicker zum Hinzufügen von Fotos zu bestehender Tour, sequentieller Upload mit Progress, Detail wird nach Upload refreshed. NSCameraUsageDescription in BanYaroGo-Info.plist.
This commit is contained in:
parent
e27fa39620
commit
5473bbf41f
9 changed files with 445 additions and 61 deletions
33
BanYaroGo/Tracking/ActiveWalk.swift
Normal file
33
BanYaroGo/Tracking/ActiveWalk.swift
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import Foundation
|
||||
import SwiftData
|
||||
|
||||
/// Persisted state of an in-progress walk. Lives in SwiftData so a walk
|
||||
/// survives an app crash or kill — on next launch the TrackingView offers
|
||||
/// the user to resume, save, or discard.
|
||||
@Model
|
||||
final class ActiveWalk {
|
||||
var startedAt: Date
|
||||
var lastUpdate: Date
|
||||
var pausedAt: Date?
|
||||
var accumulatedPausedSeconds: Int
|
||||
private var pointsData: Data
|
||||
|
||||
init(startedAt: Date = .now) {
|
||||
self.startedAt = startedAt
|
||||
self.lastUpdate = startedAt
|
||||
self.pausedAt = nil
|
||||
self.accumulatedPausedSeconds = 0
|
||||
self.pointsData = Data("[]".utf8)
|
||||
}
|
||||
|
||||
var points: [GPSPoint] {
|
||||
get {
|
||||
(try? JSONDecoder().decode([GPSPoint].self, from: pointsData)) ?? []
|
||||
}
|
||||
set {
|
||||
pointsData = (try? JSONEncoder().encode(newValue)) ?? Data("[]".utf8)
|
||||
}
|
||||
}
|
||||
|
||||
var isPaused: Bool { pausedAt != nil }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue