feat(search): add clear all button
This commit is contained in:
@@ -19,6 +19,9 @@ struct ContentView: View {
|
|||||||
|
|
||||||
// TODO: create a map
|
// TODO: create a map
|
||||||
// Add navigation to the 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
|
// Display the calculated distance and how long will it take by walking
|
||||||
// Get walkingStepLength from HealthKit
|
// Get walkingStepLength from HealthKit
|
||||||
// Show how many steps does the route take
|
// Show how many steps does the route take
|
||||||
|
|||||||
@@ -21,12 +21,26 @@ struct SearchView: View {
|
|||||||
TextField("Search for any location", text: $query)
|
TextField("Search for any location", text: $query)
|
||||||
.autocorrectionDisabled()
|
.autocorrectionDisabled()
|
||||||
.onChange(of: self.query) {
|
.onChange(of: self.query) {
|
||||||
|
if query.count > 0 {
|
||||||
search(for: self.query)
|
search(for: self.query)
|
||||||
|
} else {
|
||||||
|
self.locations = []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
// TODO: delete this, it's for debug only
|
// TODO: delete this, it's for debug only
|
||||||
search(for: self.query)
|
search(for: self.query)
|
||||||
}
|
}
|
||||||
|
.overlay {
|
||||||
|
HStack{
|
||||||
|
Spacer()
|
||||||
|
Image(systemName: "multiply.circle.fill")
|
||||||
|
.foregroundStyle(.gray)
|
||||||
|
.onTapGesture {
|
||||||
|
query = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.modifier(TextFieldGrayBackgroudColor())
|
.modifier(TextFieldGrayBackgroudColor())
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|||||||
Reference in New Issue
Block a user