Skip to content

marioeguiluz/swiftui-widgets-fitness

Repository files navigation

Welcome! wave gif

ℹ️ 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:

App demo

🧠 High level design

The main app struct Workout_CompanionApp, contains a WorkoutManager which is responsible of:

  • Gathering HealthKit authorization
  • Gathering HealthKit data
  • 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.

Screenshot 2021-05-10 at 11 43 02

How to connect with me?

  • 🙌🏻 Say hi and add me on my LinkedIn
  • 👾 Dare to challenge me @ Fifa or Warzone!
  • 🐦 Connect on my Twitter

"It was a bright cold day in April, and the clocks were striking thirteen."


About

Example project with SwiftUI, Combine and Widgets, using Apple Fitness app UI as the base

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages