Langsung ke konten
Skillpedia
Aplikasi mobile10k Β· #11925

navigation-event

Fungsinya

Skill ini memandu penangkapan gestur kembali dan animasi predictive back di aplikasi Jetpack Compose Android. Skill juga mencakup wadah bersarang seperti tab dan perpindahan dari BackHandler yang lebih lama. Skill ditujukan bagi pengembang Android yang membutuhkan perilaku kembali yang khusus.

Kapan dipakai

  • βœ“Saat Anda perlu mencegat gestur kembali di layar Compose.
  • βœ“Ketika Anda ingin animasi predictive back di aplikasi Android Anda.
  • βœ“Ketika Anda perlu memindahkan kode BackHandler lama ke pustaka NavigationEvent.

Link skill

https://github.com/android/skills/blob/main/navigation/navigation-event/SKILL.md

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/android/skills/blob/main/navigation/navigation-event/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œBuat gestur kembali menutup bottom sheet saya lebih dulu di aplikasi Compose, dengan animasi predictive back.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Skill mengatur dispatcher activity dan back handler Compose, lalu membatasi masing-masing ke layar, tab, atau dialog yang tepat. Skill juga mencakup migrasi kode BackHandler lama di versi Android yang lebih baru.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.

Common guidelines

  • For architecture concepts : To understand the foundational architecture, continuous gesture event lifecycles, or class definitions of the Navigation Event library, read Navigation Event overview.
  • For Android target : If compile SDK is lower than 36, set it to 36 or higher in build.gradle.kts.
  • For Compose Android target: The project must use Jetpack Compose for Compose-specific APIs. This skill is scoped exclusively to Compose Android (Android Views and non-Compose implementations are excluded).
  • For activity dispatchers : ComponentActivity automatically implements NavigationEventDispatcherOwner out-of-the-box. You must use the built-in navigationEventDispatcher without creating anonymous delegate owners or overriding member properties.
  • For dialog scoping : Floating windows (Compose Dialog, ModalBottomSheet, ComponentDialog) automatically provide a NavigationEventDispatcherOwner. You don't need manual CompositionLocalProvider propagation for dialogs.
  • For parent-child dispatcher hierarchies : When scoping navigation handling to ViewPagers, tabbed interfaces, or nested navigation containers in Compose, use rememberNavigationEventDispatcherOwner() to create a child owner linked to the parent. Disabling the owner (enabled = false) automatically cascades to disable all child handlers.
  • For Compose handlers : A one-to-one relationship between NavigationEventState and handlers is strictly enforced. Never bind the same NavigationEventState to multiple active NavigationBackHandler instances (IllegalArgumentException).

Step 1: Plan

To complete this step, you MUST ensure the following:

  1. Identify the target platform : Verify the app is targeting Compose Android. If compileSdk is lower than 36, set it to 36 or higher in build.gradle.kts.
  2. Navigation check: Check if Navigation 3 is in use. If it is in use, use Navigation 3's built-in back navigation support rather than manually implementing low-level dispatchers from this skill.
  3. Hierarchy check : Identify host Activities, ViewPagers, tabbed interfaces, or nested navigation hosts that require back gesture interception or parent-child dispatcher linking.
  4. Migration check : Check if the project is migrating from back handling (OnBackPressedCallback, BackHandler, onBackPresser) to NavigationEvent and NavigationBackHandler.
  5. Input interception : Detect where the app is intercepting navigation events from gestures or hardware button presses requiring translation to NavigationEvent.

Step 2: Set up dependencies

To complete this step, you MUST ensure the following:

  • For setting up compile SDKs, declaring catalog versions, and adding dependencies, follow setup guide.

Step 3: Configure dispatcher and inputs

To complete this step, you MUST ensure the following:

  • To configure your dispatcher, leverage automatic ComponentActivity or ComponentDialog owner resolution.
  • Link parent-child dispatchers in Compose following dispatcher guide.

Step 4: Handle back navigation and UI transitions

To complete this step, you MUST ensure the following:

  • To create navigation event handlers, integrate back gesture interception in Compose, animate UI components during swipes, and migrate from legacy back handlers, follow handle back guide.

Step 5: Clean up resources

[!WARNING] Warning: Compose APIs perform teardown automatically. When using Compose APIs such as NavigationBackHandler and rememberNavigationEventDispatcherOwner(), handler removal and dispatcher disposal occur automatically when the composable leaves the composition.

You MUST perform explicit manual cleanup only when managing custom dispatchers or non-Compose handlers:

  • Call remove() on active handlers during teardown.
  • Call isEnabled = false to temporarily disable navigation subtrees.
  • Call dispose() on dispatcher instances when hosting components are destroyed. Disposing a parent dispatcher automatically cascades to all child dispatchers.

Core troubleshooting guidelines

1. Activity dispatcher setup (StackOverflowError recursion)

ComponentActivity im

Pertanyaan umum

Apakah ini berfungsi untuk aplikasi Android Views?

Tidak. Skill terbatas pada aplikasi Android Compose, dan View dikecualikan.

Target Android apa yang dibutuhkan?

Jika compile SDK aplikasi di bawah 36, skill akan menaikkannya menjadi 36 atau lebih tinggi.

Apakah dialog memerlukan pengaturan tambahan?

Tidak. Dialog dan bottom sheet menyediakan dispatcher sendiri, sehingga tidak perlu penyambungan tambahan.

Detail

Deskripsi asli dari pembuat

Intercept back gestures and run Predictive Back animations using the NavigationEvent (androidx.navigationevent) library in Compose Android. Handles Activity setup, parent-child dispatcher scoping in `ViewPagers` or tabs, Compose `NavigationBackHandler`, and migration from legacy `BackHandler` on SDK 36+.

repo: android/skills

Popularitas

Bintang GitHub
10k
Peringkat
#11925
Lisensi
Apache-2.0
Diperbarui
29/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa