Skip to main content

Overview

The SearchView 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

DashboardViewModel
required
Observable view model that handles:
  • searchQuery: Current search text (bound to TextField)
  • searchResults: Array of cities matching the search
  • searchCities(): Method to perform city lookup
  • selectCity(): Method to select a city from results
  • requestLocation(): Method to request user’s current location
  • locationName: 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):
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

  1. User taps search icon on dashboard
  2. SearchView presents as modal sheet
  3. Search bar auto-focuses for immediate typing
  4. User can:
    • Type city name to search (triggers at 2+ characters)
    • Tap “Use Current Location” to use GPS
    • Select from popular cities list
  5. Selecting any option dismisses the view and updates dashboard
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
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