2 min read
Step 3: Check Off
Mark habits complete each day.
Where We Are
You can add habits. Now let’s make them checkable.
Track Completions
Update the Habit model to track which dates it was completed.
Add a Set<String> of date strings (like "2025-01-15") to each habit.
Add a method to check if a habit was completed today.
Add a method to toggle today's completion.
Add Checkmarks to the List
Update each row in the habit list to show:
- A circle on the left (empty if not done, filled with a checkmark if done)
- The habit name
- Tapping the row toggles today's completion
Use SF Symbols: "circle" for unchecked, "checkmark.circle.fill" for checked.
Use a green color for the checked state.
Test It
- Run the app
- Add a few habits
- Tap a habit row — the circle should fill
- Tap again — it should unfill
- The check state should reflect “today” only
Show Today’s Date
Add a header at the top showing today's date.
Format it like "Monday, January 15".
This helps the user know what day they're checking off.
Checkpoint
By now you should have:
- Habits show checkmarks
- Tapping toggles completion for today
- Today’s date is visible
- Visual feedback is clear (green checkmark)
What You Learned
- Working with dates in Swift
- SF Symbols for icons
- Toggle state patterns
- Visual feedback for interactions