Building HUD Components

Don't repeat the recipe β€” bottle it

Last lesson's exercise took three lines to style one label. PawWalk has dozens of those labels β€” booking statuses, GPS coordinates, section headers. Retyping the recipe everywhere invites drift: someone forgets the tracking, someone types 0.21, and the design quietly falls apart.

The fix is the heart of SwiftUI: make it a component. You've built view structs since Module 04 β€” a component is just a view struct designed for reuse: properties for everything callers might want to change, default values for everything they usually won't. Call it with one argument and get the standard look; override a property when a screen needs an exception.

Components/HUD.swift holds the two signature HUD components. First, the label you already know how to style.