Menu

Building an iPhone Focus Timer That Gives Short Sessions Full Credit
📰

Building an iPhone Focus Timer That Gives Short Sessions Full Credit

DEV Community: swift·Og Hiro·12 days ago
#IQtTCEYw
#devtoswift#devto#dev#minutes#seconds
Long article (502 words) — no AI summary yet.
Reading 0:00
15s threshold

A user focuses for 3 minutes and 40 seconds, stops to answer the door, and later does another 2 minutes and 20 seconds. How many whole minutes of work should your app show? Six. Round down each session independently and you get five. It’s a small bug until the missing minute is the one someone needed to unlock something.

I make Focusgotchi, an iPhone focus timer where a pixel pet grows as you work. The same interval matters in three places: the countdown, the pet’s growth, and the coins on the session receipt. Here are two implementation decisions behind that little room on the screen.

A countdown needs a deadline

A repeating UI callback is useful for drawing the seconds. Depending on a callback firing exactly once per second makes it a poor record of elapsed work. Think about what should happen when a user starts a 25-minute session, locks the phone, and returns ten minutes later.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.