Skip to content

monsur/LoopTimer

Repository files navigation

Loop Timer for iOS

A minimalist iOS timer app with automatic looping functionality, lock screen integration, and smart persistent state.

Features

  • ⭕ Automatic Looping: Timer automatically restarts when it reaches zero
  • ⏸️ Play/Pause Controls: Start, pause, and resume the timer
  • 🔄 Display Toggle: Switch between time elapsed and time remaining with tap
  • ➕➖ Visual Indicators: Always shows +/- sign to indicate elapsed or remaining time
  • 🎬 Smart Animations: Numbers animate in the correct direction (up for elapsed, down for remaining)
  • 🔔 Chime Sounds: Customizable sounds on loop completion (Bell, Soft Chime)
  • 🔒 Lock Screen: Live Activities show timer on lock screen with live updates
  • 🌙 Background Operation: Timer continues running when app is backgrounded or screen is locked
  • ⚙️ Time Input: Easy picker wheel interface (hours/minutes/seconds)
  • 💾 Persistent Settings: Timer duration and display mode are saved across app launches
  • 🎨 Smart UI: Timer picker hides when active, replaced with duration text; colors adjust based on state
  • 🎯 Minimalist Design: Clean, simple, and focused interface

UI/UX Highlights

  • Tap to Toggle: Tap the timer display to switch between elapsed and remaining time
  • Visual Clarity: Always shows +/- prefix to avoid confusion about elapsed vs remaining time
  • State-Based Colors: Timer display dims when idle or paused, vibrant when running
  • Contextual Interface: Time picker automatically hides when timer is active, showing duration text instead
  • Smooth Transitions: Numbers animate naturally in the correct direction based on counting mode
  • Persistent Preferences: All settings (duration, display mode, sound) automatically save

Requirements

  • iOS 17.0 or later
  • Xcode 15.0 or later
  • Swift 5.9 or later

Quick Start

  1. Clone or download this repository
  2. Follow the SETUP_GUIDE.md for detailed Xcode project setup instructions
  3. Add audio files (see LoopTimer/Resources/AUDIO_FILES_README.md)
  4. Build and run on your device

Project Structure

LoopTimer/
├── Models/              # Data models (DisplayMode, ChimeSound, TimerState)
├── Services/            # Business logic (Timer, Audio, Live Activities)
├── ViewModels/          # MVVM coordinators (TimerViewModel)
├── Views/              # SwiftUI views (TimerView, TimerDisplayView, etc.)
├── Extensions/         # Helper extensions (TimeInterval, Date)
└── Resources/          # Audio files and assets

LoopTimerWidgetExtension/
└── Live Activity widget implementation

Architecture

The app follows MVVM (Model-View-ViewModel) architecture with service layer:

  • Models: Value types and enums (DisplayMode, ChimeSound, TimerState)
  • Services: Core functionality (timer logic, audio, live activities)
  • ViewModels: Coordinate services and manage UI state
  • Views: SwiftUI views (presentation layer)

Key Technical Decisions

Timer Implementation

  • Uses DispatchSourceTimer for better background performance
  • Date-based calculations prevent timer drift
  • State restoration survives app termination

Audio Playback

  • AVAudioSession with .playback category
  • Plays even when device is on silent (like alarm apps)
  • Automatically routes to headphones/speaker

Persistence

  • AppStorage for user preferences (timer duration, display mode, chime sound)
  • UserDefaults for timer state restoration
  • Settings persist across app launches
  • Minimal setup required

Live Activities

  • ActivityKit integration
  • Displays on lock screen and Dynamic Island
  • Auto-updates with timer progress

Testing

See SETUP_GUIDE.md for comprehensive testing checklist including:

  • Basic timer functionality
  • Audio playback
  • Settings persistence
  • Background operation
  • Live Activities (requires physical device)

Implementation Phases

This project was built in 5 phases:

  1. Phase 1: Core timer foundation
  2. Phase 2: Audio integration
  3. Phase 3: Settings persistence & state restoration
  4. Phase 4: Live Activities
  5. Phase 5: Background operation & UI polish

Each phase was tested before moving to the next, ensuring a solid foundation.

Known Limitations

  • Live Activities don't work in iOS Simulator (requires physical device)
  • Live Activities auto-dismiss after 8 hours (iOS limitation)
  • Timer doesn't survive device reboot (expected behavior)

Future Enhancements

Possible features for future versions:

  • UI Updates
  • Change UI in different orientations
  • Home Screen widget
  • Multiple concurrent timers
  • Preset timer buttons (30s, 1m, 5m quick start)
  • Timer history log with session tracking
  • Additional built-in chime sounds
  • Custom chime upload
  • Apple Watch companion app

Contributing

This is a personal project, but suggestions and feedback are welcome. Feel free to fork and modify for your own use.

License

This project is provided as-is for educational and personal use.

Acknowledgments

Built with:

  • SwiftUI
  • ActivityKit
  • AVFoundation
  • DispatchSourceTimer
  • Combine

References:


Built with ❤️ using SwiftUI and modern iOS development practices.

About

A minimalist iOS timer app with automatic looping functionality, lock screen integration, and smart persistent state

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors