twostraws / ControlRoom

A macOS app to control the Xcode Simulator.
MIT License
5.77k stars 304 forks source link

Preferences object #50

Closed davedelong closed 4 years ago

davedelong commented 4 years ago

This adds a Preferences object to the app, which is exposed to all SwiftUI views via:

@EnvironmentObject var preferences: Preferences

This object makes it trivial (one-line declaration) to define a value that gets saved into UserDefaults. Since it's an ObservableObject, it can be used for bindings into UI elements, replacing the previous combination of @State + onChange bindings.

This change also adds a couple of new persisted states: