Slide 1

Slide 1 text

Jetpack Compose Animations: Bringing UIs to Life By Su Thwe Thwe Tun DevFest 2024

Slide 2

Slide 2 text

SU THWE THWE TUN MOBILE APPLICATION DEVELOPER @USA I’m passionate about building mobile apps to achieve easier and better lifestyles in our everyday lives. I have been working as a mobile developer for 10 years with Android and Flutter.

Slide 3

Slide 3 text

AGENDA Why Animations Matter Overview of Jetpack Compose Animation APIs Basic Animation Concepts Advanced Animations Best Practices for Performance Real-World Use cases

Slide 4

Slide 4 text

WHY ANIMATIONS MATTER Enhance User Experience Provide Feedback Guide User Attention Make Apps Engaging

Slide 5

Slide 5 text

Key Animation APIs in Jetpack Compose animate*AsState for animating values. 1. AnimatedVisibility for showing/hiding elements. 2. rememberInfiniteTransition for looping animations. 3. Transition for combining multiple animations. 4. Modifier.graphicsLayer for low-level transformations. 5. Modifier.pointerInput for gesture-based animations. 6.

Slide 6

Slide 6 text

animate*AsState Animate a single property value (e.g., color, size, offset).

Slide 7

Slide 7 text

animate*AsState

Slide 8

Slide 8 text

AnimatedVisibility Animates the appearance and disappearance of composables.

Slide 9

Slide 9 text

AnimatedVisibility

Slide 10

Slide 10 text

rememberInfiniteTransition Creates infinite animations for elements that repeat continuously.

Slide 11

Slide 11 text

rememberInfiniteTransition

Slide 12

Slide 12 text

Transition Manages multiple animations that are synchronized based on a target state.

Slide 13

Slide 13 text

Transition

Slide 14

Slide 14 text

Modifier.graphicsLayer Provides low-level control over visual transformations like scaling, rotation, and opacity.

Slide 15

Slide 15 text

Modifier.graphicsLayer

Slide 16

Slide 16 text

Gestures with Animations Combine Modifier.pointerInput with animations.

Slide 17

Slide 17 text

Real-World Use Cases for Jetpack Compose Animations

Slide 18

Slide 18 text

Real-World Use Cases for Animations Onboarding Flows Dynamic Themes Interactive Elements Loaders and Progress Indicators

Slide 19

Slide 19 text

Onboarding Flows with Animated Transitions Onboarding is often the first interaction users have with your app. Animations help make this experience smooth and engaging. Real-World example: Google Drive’s onboarding flow

Slide 20

Slide 20 text

Dynamic Themes with Smooth Color Transitions Dynamic theming lets users switch between themes (e.g., light/dark mode) or customize app colors. Real-World example: Twitter’s dynamic theme switch

Slide 21

Slide 21 text

Interactive Elements: Expandable Lists and FAB Animations Animations make interactive elements like expandable lists or Floating Action Buttons (FAB) feel intuitive and polished. Real-World example: Google Play Store uses expandable cards for app details. Gmail’s FAB animations make actions accessible and engaging.

Slide 22

Slide 22 text

Engaging Loaders and Progress Indicators Loaders and progress indicators provide feedback for ongoing tasks Real-World example: Google Photos uses subtle animations in its progress indicators during uploads.

Slide 23

Slide 23 text

BEST PRACTICES FOR COMPOSE ANIMATIONS Optimize Animation Performance: 1. Use animate*AsState for lightweight, state-driven animations. Leverage Profiling Tools: 2. Use Layout Inspector and CPU Profiler Consider User Accessibility: 3. Avoid overwhelming animations that may distract or confuse users. Keep Animations Purposeful: 4. Ensure every animation serves a clear purpose

Slide 24

Slide 24 text

Sample code

Slide 25

Slide 25 text

Practices Compose samples https://github.com/android/compose-samples/tree/main?tab=readme-ov-file Jetpack Compose GraphicsLayer Modifier https://medium.com/mobile-app-development-publication/have-fun-with- jetpack-compose-graphicslayer-modifier-e39c12a4791f Jetpack Compose Animations https://medium.com/@rahnuma.sharib786/jetpack-compose-animations- 88edde7ba4c6

Slide 26

Slide 26 text

THANK YOU