Overview
The Dashboard is the central hub of Breeze iOS, providing users with a comprehensive view of current air quality, pollen levels, pollutants, and climate trends for their selected location. Built with SwiftUI, it offers a clean, scrollable interface with pull-to-refresh functionality.Architecture
The dashboard follows the MVVM (Model-View-ViewModel) pattern:- View:
DashboardView.swift- The main UI component - ViewModel:
DashboardViewModel.swift- Manages state and data fetching - Models: Various models for air quality, pollutants, pollen, and climate data
Key Components
The dashboard is composed of several reusable components:- Location Header - Displays current location and date
- AQI Card - Shows the US Air Quality Index with visual indicators
- Pollen Section - Allergy tracker with pollen data (when available)
- Pollutants Grid - Detailed breakdown of individual pollutants
- Climate Chart - Historical temperature trends
Implementation
DashboardView Structure
The main view is built with aScrollView containing a vertical stack of components:
DashboardView.swift
ViewModel Data Management
TheDashboardViewModel manages all dashboard state using @Published properties:
DashboardViewModel.swift
Features
Pull-to-Refresh
The dashboard supports pull-to-refresh using SwiftUI’s.refreshable modifier:
Dynamic Content
Components are conditionally displayed based on data availability:- Pollen section only appears when
pollenItemsis not empty - Climate chart only appears when
climateDatais available - Error states are handled through the
errorMessageproperty
Location Display
The location header shows:- Current location name (city, country)
- Current date in complete format
- Updates automatically when location changes
Data Flow
- User opens the app or changes location
DashboardViewModel.fetchAllData()is called with coordinates- Multiple API services fetch data concurrently:
AirQualityServicefor AQI and pollutantsPollenServicefor pollen dataClimateServicefor historical temperature data
- View updates reactively as data arrives
- Components render based on available data
Related Components
AQI Card
Visual representation of air quality index
Pollutants Grid
Detailed pollutant measurements
Pollen Tracking
Allergy and pollen information
Climate Data
Historical temperature trends
File Locations
- View:
BreezeApp/Views/Dashboard/DashboardView.swift - ViewModel:
BreezeApp/ViewModels/DashboardViewModel.swift - AQI Card:
BreezeApp/Views/Dashboard/AQICard.swift - Pollutants:
BreezeApp/Views/Dashboard/PollutantsGrid.swift