fix: improve coordinate selection feedback

This commit is contained in:
xweiba
2026-08-07 16:43:34 +08:00
parent 811f9c9343
commit a3f39a93e7
4 changed files with 58 additions and 6 deletions
+12
View File
@@ -160,6 +160,18 @@ final class FavoriteLocationStore: ObservableObject {
defaults.set(id?.uuidString, forKey: Keys.selectedID)
}
@discardableResult
func selectMatching(coordinatePair: CoordinatePair) -> FavoriteLocation? {
let matchingFavorite = favorites.first {
$0.coordinatePair.matchesWGS84(
latitude: coordinatePair.wgs84.latitude,
longitude: coordinatePair.wgs84.longitude
)
}
select(matchingFavorite?.id)
return matchingFavorite
}
func rename(_ id: UUID, to name: String) {
guard let idx = favorites.firstIndex(where: { $0.id == id }) else { return }
favorites[idx].name = name