Jetpack Compose Codelabs

repository·main·Indexed 23 days ago

https://github.com/android/codelab-android-compose

A collection of Android Studio projects providing hands-on codelabs for learning Jetpack Compose. Topics range from basics, layouts, and state management to advanced subjects including performance, testing, adaptive layouts, accessibility, navigation, and Material 3 theming.

Tokens
3.6K
Snippets
7
Records
27
Agent score
82%

What's inside android-codelab-android-compose

  1. Overview of State in Jetpack Compose Codelab

    main

    This codelab focuses on managing state and events within a declarative UI framework using Jetpack Compose. By building a 'Wellness' application, you learn how to handle state changes and UI updates.

    Key concepts covered include:

    • Thinking about state and events in a declarative paradigm.
    • Using Compose APIs like mutableStateOf to track state changes and trigger UI recompositions.
    • Integrating ViewModels into a Compose-based application to manage business logic and state lifecycle.
  2. Explore Jetpack Compose Codelabs

    main

    This repository provides several specialized codelabs to master different aspects of Jetpack Compose. You can choose a codelab based on your current learning goals:

    • Fundamentals: Learn declarative UI, state, layouts, and theming via the Basics codelab.
    • Layouts: Implement real-world designs using composables and modifiers in the Basic layouts codelab.
    • State Management: Understand declarative state patterns in the State codelab.
    • Design & Theming: Implement Material Design (colors, typography, shapes) and light/dark themes in the Theming codelab.
    • Interoperability: Learn how to mix Compose with existing View-based UIs in the Migration codelab.
    • Motion & UI: Master the Animation APIs in the Animation codelab.
    • Navigation: Use the Jetpack Navigation library, handle arguments, deep-links, and testing in the Navigation codelab.
    • Optimization: Measure and improve runtime performance in the Performance codelab.
    • Testing: Learn to test UIs, use the semantics tree, and handle test synchronization in the Testing codelab.
    • Accessibility: Improve touch targets, content descriptions, and custom actions in the Accessibility codelab.
    • Adaptability: Build apps for phones, tablets, and foldables using Material navigation components in the Adaptive codelab.
  3. Learn Jetpack Compose Theming

    main

    This codelab provides hands-on experience with Jetpack Compose's theming APIs. You will learn how to customize and apply consistent styling across an application by managing three core pillars:

    1. Colors: Defining color schemes for different modes (e.g., Light and Dark themes).
    2. Shapes: Standardizing the corner radius and shape styles for UI components.
    3. Typography: Setting up consistent text styles (font family, weight, size) throughout the app.

    The goal is to ensure that these styles are used consistently and that the application can seamlessly support multiple themes, such as light and dark modes.

  4. Set up the Migrating to Jetpack Compose codelab

    main

    To use this codelab, which demonstrates migrating parts of the Sunflower app to Jetpack Compose, follow these steps:

    1. Install Android Studio: Ensure you have the latest Android Studio canary version installed.
    2. Download and Import: Download the sample repository and import it into Android Studio.
    3. Build and Run: Build the project and run it on an emulator or physical device.

    Branching Strategy:

    • Use the main branch as your starting point for the migration exercises.
    • Use the end branch to view the completed solution.

    Prerequisites: