This project demonstrates how to create an analog clock with digital time using Jetpack Compose, the modern UI toolkit for Android. It showcases drawing custom graphics with Canvas
, handling time updates, and using best practices for state management in Compose.
- Analog Clock: A visually appealing analog clock face with hour, minute, and second hands.
- Digital Time: Displays the current time digitally.
- Custom Drawing: Utilizes Jetpack Compose's
Canvas
to draw the clock face and hands. - Real-time Updates: The clock hands move in real-time, updating every second.
- Clean Code: Follows Kotlin and Jetpack Compose best practices for readability and maintainability.
- Modern Time API: Uses the modern
java.time
API for handling time.
- Android Studio (latest version recommended)
- Android SDK (API level 26 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.
The main composable function is AnalogClockWithDigitalTime()
. You can include it in your Compose
UI like this:
AnalogClockWithDigitalTime.kt
: Contains the main composable function for the analog clock.rememberCurrentTime.kt
: Contains the composable function for getting the current time.
- 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
- 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.
Donald McCaskey - [email protected]
Project Link: https://github.com/forteanjo/jetpack_clock