project habittracker
Step 3: Check Off
System Text-to-Speech Ready
Slide: 0:00 / 0:00
Slide 1 of 0Interactive Deck
Full Lesson Reference
Mark habits complete each day.
Where We Are
You can add habits. Now let's make them checkable.
Track Completions
terminal
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
terminal
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
terminal
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
Exercises
- Paste the "Track Completions" and "Add Checkmarks" prompts, then tap a row on and off to confirm the green checkmark toggles for today only.
- Add the date header and verify it reads like "Monday, January 15" for the current day.
- Ask Claude to swap the checked-state SF Symbol or color (e.g., a blue
checkmark.seal.fill) and decide which version feels clearer — practice directing visual intent.