A simple stopwatch app built with Jetpack Compose, demonstrating modern Android development practices.
- Features
- Screenshots
- Getting Started
- Usage
- Code Structure
- Dependencies
- Contributing
- License
- Acknowledgements
- Contact
- Project Link
- Flow-based Time Capture: Uses Kotlin Flows to emit time updates, providing a reactive and efficient way to track elapsed time.
- MVVM Architecture: Implements the Model-View-ViewModel architectural pattern for a clean separation of concerns and testability.
- Koin for Dependency Injection: Leverages Koin for dependency injection, making the code more modular and easier to manage (although it might be considered a bit overkill for this specific project's size).
- Jetpack Compose UI: Built entirely with Jetpack Compose, the modern UI toolkit for Android.
- Start/Stop/Reset: The user can start, stop and reset the stopwatch.
- Android Studio (latest version recommended)
- Android SDK (API level 21 or higher)
- Basic knowledge of Kotlin and Jetpack Compose
-
Clone the repository:
-
Open in Android Studio:
- Open Android Studio and select "Open an existing Android Studio project."
- Navigate to the cloned repository directory and select it.
-
Build and Run:
- Connect an Android device or start an emulator.
- Click the "Run" button in Android Studio.
Once the app is running, you'll see a simple stopwatch interface.
- Start: Tap the "Start" button to begin the stopwatch.
- Stop: Tap the "Stop" button to pause the stopwatch.
- Reset: Tap the "Reset" button to reset the stopwatch to zero.
MainActivity.kt
: The main activity that hosts the Compose UI.StopwatchViewModel.kt
: The ViewModel responsible for managing the stopwatch logic and state.StopwatchState.kt
: Data class representing the state of the stopwatch.Stopwatch.kt
: Contains the composable function for the stopwatch.KoinModule.kt
: Contains the Koin module for dependency injection.
- Jetpack Compose:
androidx.compose.ui:ui
androidx.compose.material:material
androidx.compose.ui:ui-tooling-preview
androidx.compose.ui:ui-graphics
- Kotlin Coroutines:
org.jetbrains.kotlinx:kotlinx-coroutines-android
- Koin:
io.insert-koin:koin-android
- Android Core KTX:
androidx.core:core-ktx
Contributions are welcome! If you'd like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push your changes to your forked repository.
- Submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
This project is based on the original article by Dharma Kshetri: https://medium.com/@dharmakshetri/stopwatch-app-with-mvvm-coroutines-and-jetpack-compose-aa033e2ec042
Donald McCaskey - forteanjo@sky.com