Today I mainly focused on HealthKit support.
I did however, make some minor UI improvements. I fixed the alignment of the drink breakup for the Logs screen and added the date in the logs screen when week is selected. I also gave the Units selection a UI consistent to the rest of the Settings. I decided to rename the Hydration tab to the Stats tab.
HealthKit support was a little complicated for me to wrap my head around at first. The SwiftUI tutorial in the announcement post for this challenge for the most part got me through, but what got me was the interval to check data at.
From the video, the interval was by the day, so the data was lumped together. If I drank 15 oz and 9 oz of water on the same day, it would combine this data (you can see this in the second log from the top). It took me a little to figure out if I changed it to by the minute, I could get the exact time and prevent the data from being combined.
When a drink from Health is added, I check to make sure the amount consumed isn’t 0 mL/oz and that it doesn’t already exist within the app. The second check is by comparing the amount, drink type, date, and time of a Health drink against the app.
I’m not sure how much more data I can pull/write to Health. There aren’t any metrics for soda and juice consumption and there is only a metric for caffeine intake, which can vary depending on what type of coffee you drink and is measured in milligrams, which doesn’t measure fluids. I’d have to ask what type of coffee was consumed and use an average caffeine content to put it in Health.
So far, the app only reads from Health, not writes. My next step will be getting the app to write data to Health.