Jul 21 - Update to support photos' timestamp/location
This commit is contained in:
@@ -24,7 +24,9 @@ struct FlagIssueView: View {
|
||||
@State private var description = ""
|
||||
|
||||
// Each entry: (UIImage for display, local file path for storage)
|
||||
@State private var photos: [(image: UIImage, path: String)] = []
|
||||
// CapturedPhoto records the capture moment + GPS fix at shutter time; the
|
||||
// `image` / `path` members match the tuple this replaced.
|
||||
@State private var photos: [CapturedPhoto] = []
|
||||
|
||||
@State private var showCamera = false
|
||||
@State private var showLibrary = false
|
||||
@@ -190,6 +192,9 @@ struct FlagIssueView: View {
|
||||
}
|
||||
.navigationTitle("Flag Issue")
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
// Warm up GPS so a fix exists the instant a photo is taken; the
|
||||
// coordinates are burned into the photo server-side.
|
||||
.onAppear { PhotoLocationProvider.shared.start() }
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
Button("Cancel") { dismiss() }
|
||||
@@ -242,14 +247,14 @@ struct FlagIssueView: View {
|
||||
private func appendPhoto(_ img: UIImage) {
|
||||
guard photos.count < maxPhotos else { return }
|
||||
guard let path = savePhotoToDisk(img) else { return }
|
||||
photos.append((image: img, path: path))
|
||||
photos.append(CapturedPhoto(image: img, path: path))
|
||||
}
|
||||
|
||||
private func appendPhotos(_ images: [UIImage]) {
|
||||
for img in images {
|
||||
guard photos.count < maxPhotos else { break }
|
||||
guard let path = savePhotoToDisk(img) else { continue }
|
||||
photos.append((image: img, path: path))
|
||||
photos.append(CapturedPhoto(image: img, path: path))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,9 +295,12 @@ struct FlagIssueView: View {
|
||||
// Create one PendingPhoto per photo so they all upload independently
|
||||
for photo in photos {
|
||||
let pending = PendingPhoto(
|
||||
localFilePath: photo.path,
|
||||
entityType: "issue",
|
||||
entityLocalId: issue.localId
|
||||
localFilePath: photo.path,
|
||||
entityType: "issue",
|
||||
entityLocalId: issue.localId,
|
||||
capturedAt: photo.capturedAt,
|
||||
captureLatitude: photo.latitude,
|
||||
captureLongitude: photo.longitude
|
||||
)
|
||||
context.insert(pending)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user