Skip to content

Commit

Permalink
Clean up waypoint form
Browse files Browse the repository at this point in the history
  • Loading branch information
garthvh committed Sep 3, 2024
1 parent 01e303d commit 5fbb4ec
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
14 changes: 5 additions & 9 deletions Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -4911,15 +4911,8 @@
}
}
},
"Coordinates: %@, %@" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Coordinates: %1$@, %2$@"
}
}
}
"Coordinates:" : {

},
"copy" : {
"localizations" : {
Expand Down Expand Up @@ -10934,6 +10927,9 @@
},
"Location" : {

},
"Location:" : {

},
"Location: %@" : {

Expand Down
23 changes: 17 additions & 6 deletions Meshtastic/Views/Nodes/Helpers/Map/WaypointForm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -124,6 +129,7 @@ struct WaypointForm: View {
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
}
}
.scrollDismissesKeyboard(.immediately)
HStack {
Button {
/// Send a new or exiting waypoint
Expand Down Expand Up @@ -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)
Expand All @@ -250,6 +256,7 @@ struct WaypointForm: View {
} else {
Button {
editMode = true
selectedDetent = .fraction(0.85)
} label: {
Image(systemName: "square.and.pencil" )
.font(.largeTitle)
Expand All @@ -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")
}
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 5fbb4ec

Please sign in to comment.