Overview
TheSearchView component provides a full-screen modal interface for searching and selecting locations. It features a search bar with real-time city lookup, a “Use Current Location” button, search results list, and a curated list of popular cities.
Visual Display
The search view presents:- Navigation bar with “Search” title and Cancel button
- Rounded search bar with magnifying glass icon
- Clear button (X) when text is entered
- “Use Current Location” button with location icon
- Live search results as user types
- Popular cities list when search is empty
- “No results found” state
Component Definition
Props / Parameters
Observable view model that handles:
searchQuery: Current search text (bound to TextField)searchResults: Array of cities matching the searchsearchCities(): Method to perform city lookupselectCity(): Method to select a city from resultsrequestLocation(): Method to request user’s current locationlocationName: Current location name
Key Features
Search Bar with Auto-focus
Search bar automatically focuses when view appears:Current Location Button
Prominent button to use device location:Live Search Results
Displays matching cities as user types (minimum 2 characters):Popular Cities List
Displays curated list when search is empty:Empty State
Shows when search has no results:iOS Version Compatibility
The component includes version-specific code for iOS 17’s new onChange API:User Flow
- User taps search icon on dashboard
- SearchView presents as modal sheet
- Search bar auto-focuses for immediate typing
- User can:
- Type city name to search (triggers at 2+ characters)
- Tap “Use Current Location” to use GPS
- Select from popular cities list
- Selecting any option dismisses the view and updates dashboard
Navigation Integration
Modal presentation with toolbar:Usage in App
Presented as a sheet from the dashboard:Search Behavior
- Real-time search as user types
- Minimum 2 characters to trigger search
- Search query debounced in view model
- Results include city name and full display name (city, state, country)
- Clear button appears when text is entered
Popular Cities
Default list includes major cities worldwide:- New York, London, Tokyo, Paris, Los Angeles
- And 5+ more major metropolitan areas
Source Location
BreezeApp/Views/Search/SearchView.swift:3