Clean up waypoint form

This commit is contained in:
Garth Vander Houwen 2024-09-03 07:12:15 -07:00
parent 01e303d74b
commit 5fbb4ecec9
2 changed files with 22 additions and 15 deletions

View file

@ -4911,15 +4911,8 @@
}
}
},
"Coordinates: %@, %@" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Coordinates: %1$@, %2$@"
}
}
}
"Coordinates:" : {
},
"copy" : {
"localizations" : {
@ -10934,6 +10927,9 @@
},
"Location" : {
},
"Location:" : {
},
"Location: %@" : {

View file

@ -28,6 +28,8 @@ struct WaypointForm: View {
@State private var expire: Date = Date.now.addingTimeInterval(60 * 480) // 1 minute * 480 = 8 Hours
@State private var locked: Bool = false
@State private var lockedTo: Int64 = 0
@State private var detents: Set<PresentationDetent> = [.medium, .fraction(0.85)]
@State private var selectedDetent: PresentationDetent = .medium
var body: some View {
NavigationStack {
@ -39,9 +41,12 @@ struct WaypointForm: View {
let distance = CLLocation(latitude: LocationHelper.currentLocation.latitude, longitude: LocationHelper.currentLocation.longitude).distance(from: CLLocation(latitude: waypoint.coordinate.latitude, longitude: waypoint.coordinate.longitude ))
Section(header: Text("Coordinate") ) {
HStack {
Text("Location: \(String(format: "%.5f", waypoint.coordinate.latitude) + "," + String(format: "%.5f", waypoint.coordinate.longitude))")
Text("Location:")
.foregroundColor(.secondary)
Text("\(String(format: "%.5f", waypoint.coordinate.latitude) + "," + String(format: "%.5f", waypoint.coordinate.longitude))")
.textSelection(.enabled)
.foregroundColor(Color.gray)
.foregroundColor(.secondary)
.font(.caption)
}
HStack {
if waypoint.coordinate.latitude != 0 && waypoint.coordinate.longitude != 0 {
@ -124,6 +129,7 @@ struct WaypointForm: View {
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
}
}
.scrollDismissesKeyboard(.immediately)
HStack {
Button {
/// Send a new or exiting waypoint
@ -239,7 +245,7 @@ struct WaypointForm: View {
} else {
VStack {
HStack {
CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange, circleSize: 65)
CircleText(text: String(UnicodeScalar(Int(waypoint.icon)) ?? "📍"), color: Color.orange, circleSize: 50)
Spacer()
Text(waypoint.name ?? "?")
.font(.largeTitle)
@ -250,6 +256,7 @@ struct WaypointForm: View {
} else {
Button {
editMode = true
selectedDetent = .fraction(0.85)
} label: {
Image(systemName: "square.and.pencil" )
.font(.largeTitle)
@ -274,9 +281,12 @@ struct WaypointForm: View {
}
/// Coordinate
Label {
Text("Coordinates: \(String(format: "%.6f", waypoint.coordinate.latitude)), \(String(format: "%.6f", waypoint.coordinate.longitude))")
.textSelection(.enabled)
Text("Coordinates:")
.foregroundColor(.primary)
Text("\(String(format: "%.6f", waypoint.coordinate.latitude)), \(String(format: "%.6f", waypoint.coordinate.longitude))")
.textSelection(.enabled)
.foregroundColor(.secondary)
.font(.caption2)
} icon: {
Image(systemName: "mappin.circle")
}
@ -381,7 +391,8 @@ struct WaypointForm: View {
longitude = waypoint.coordinate.longitude
}
}
.presentationDetents([.fraction(0.75)])
.presentationDetents(detents, selection: $selectedDetent)
.presentationBackgroundInteraction(.enabled(upThrough: .fraction(0.85)))
.presentationDragIndicator(.visible)
}
}