Example project with SwiftUI, Combine and Widgets, using Apple Fitness app UI as the base
ℹ️ What is this project?
This project will try to help you understand the basics behind SwiftUI and Combine (+ some Widgets and HealthKit!).
It contains different branches that will incrementally add functionality, from the most basic state, to the addition of widgets and more configuration.
🧐 Why did I started this project?
I love Apple Fitness workout views but sadly (as today), those same views are not offered as widgets for the home screen. So I am replicating those ones, and adding the widget-capability myself. By open sourcing it, I thought It could be a great example for other developers to see how to deploy a basic structure of SwiftUI-Combine + Widgets and HealthKit with clear and concise code.
Feel free to open PR or issues to improve it!
🏋️♀️ The workout widgets
More and more views will be included. As of today, workout views are implemented and a example widget is already done:
🧠 High level design
The main app struct
Workout_CompanionApp, contains a
WorkoutManager which is responsible of:
- Providing that data through
@Publishers into anyone observing
The main app inits this
WorkoutManager as a
@StateObject property that will be injected via
environmentObject into the main view tree.
The main view will use specific publishers from the
WorkoutManager to feed specific views/widgets down the UI tree. This publishers will emit specifc
ViewModels for each view that needs to consume them.