feat(search): add clear all button

This commit is contained in:
2024-11-27 13:04:20 +01:00
parent 1057bad23a
commit 08a5693ae1
2 changed files with 18 additions and 1 deletions

View File

@@ -19,6 +19,9 @@ struct ContentView: View {
// TODO: create a map
// Add navigation to the map
// after you click the navigation button, show the start and end place on the map with a tag or whatever it's called
// add "cancel" button that will hide the route
// add ability to hold on the map to place a mark (end goal)
// Display the calculated distance and how long will it take by walking
// Get walkingStepLength from HealthKit
// Show how many steps does the route take

View File

@@ -21,12 +21,26 @@ struct SearchView: View {
TextField("Search for any location", text: $query)
.autocorrectionDisabled()
.onChange(of: self.query) {
if query.count > 0 {
search(for: self.query)
} else {
self.locations = []
}
}
.onAppear {
// TODO: delete this, it's for debug only
search(for: self.query)
}
.overlay {
HStack{
Spacer()
Image(systemName: "multiply.circle.fill")
.foregroundStyle(.gray)
.onTapGesture {
query = ""
}
}
}
}
.modifier(TextFieldGrayBackgroudColor())
Spacer()