This project recreates the iOS 18 flashlight animation on Android using Jetpack Compose. It demonstrates advanced animation techniques and gesture handling to create a fluid, interactive user experience.
The animation is built using several key Jetpack Compose features:
-
State Management:
rememberSaveable
andmutableStateOf
are used to manage the on/off state of the flashlight. -
Animations:
Animatable
is used for smooth transitions of various UI elements. -
Gesture Handling:
pointerInput
detects tap and drag gestures to control the flashlight and animation states. -
Custom Drawing: Custom composables like
CurvedBar
andLightRay
are used to create the visual effects. -
Constraint Layout: Used for precise positioning of UI elements.
The animation responds to user interactions, allowing them to turn the flashlight on/off with a tap or by dragging up/down. The light intensity and spread are controlled by the drag distance, creating a dynamic and engaging user interface.
Here's a comparison of our Android implementation with the original iOS 18 flashlight animation:
Android Implementation | iOS 18 Original |
---|---|
- Tap to toggle flashlight on/off
- Drag to control light intensity and spread
- Animated curved bars to enhance visual feedback
- Dynamic light ray effect
- Smooth transitions between states