[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CS6HK9V55DV2H6SFVNARCK":3,"skill-same:01M7CS6HK9V55DV2H6SFVNARCK":50},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":6,"ownerDescription":34,"updatedAt":35,"install":36,"resources":49},"01M7CS6HK9V55DV2H6SFVNARCK","android-compose-patterns",null,"Use when building native Android with Jetpack Compose - stateless composables, state hoisting, ViewModel-owned state, edge-to-edge, predictive back, adaptive layout, atomic components, and Material theming over hardcoded values","makifbaysal\u002Ftasktrooper","makifbaysal","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F25031940?v=4","01M7CRG3ZCSYZSSEVDMW3DEYC8","Mehmet Akif Baysal","01M7CRG401FJ8YAXH5ER730XYV",122,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fmobile-developer\u002Fskills\u002Fandroid-compose-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: android-compose-patterns\ncategory: architecture\ndescription: Use when building native Android with Jetpack Compose - stateless composables, state hoisting, ViewModel-owned state, edge-to-edge, predictive back, adaptive layout, atomic components, and Material theming over hardcoded values\ntech_stack: Kotlin\nsource: android\u002Fskills (Apache-2.0), skydoves\u002Fandroid-testing-skills (Apache-2.0), adapted\n---\n# Jetpack Compose Patterns\n\n## Overview\n\nNative Android (Jetpack Compose) is chosen when a task needs deep Android integration or the app is already native (see native-vs-flutter-decision). Same discipline as Flutter\u002FSwiftUI: small stateless composables, state hoisted out, reusable atomic components.\n\n**Core principle:** Composables are stateless functions of state. State is hoisted to a `ViewModel`; composables emit events upward.\n\n## Rules\n\n- **Stateless composables + state hoisting.** A composable takes its state as parameters and exposes callbacks (`onXxx`) — it does not own app state. The screen-level composable connects a `ViewModel` to the stateless UI.\n- **`ViewModel` owns state and logic**, exposed as `StateFlow`\u002F`UiState`; the composable collects it with `collectAsStateWithLifecycle()`. Networking\u002Fbusiness rules live in the ViewModel + repository, never in the composable.\n- **Model UI state as a sealed hierarchy:** `Loading | Data | Empty | Error` — `when` over it renders every branch. No happy-path-only screens.\n- **Atomic components:** shared library of reusable composables (atoms → molecules → organisms). Reuse before building; grep before adding.\n- **Material theme, not hardcoded values:** `MaterialTheme.colorScheme` \u002F `typography` \u002F a spacing tokens object (`MaterialTheme.spacing`, see `mobile-design-system-foundation`) — never scattered `Color(0xFF...)` and magic `dp`. Support dark theme + dynamic color.\n- **`remember`\u002F`derivedStateOf`** to avoid recomputation; **hoist** `remember`ed state only when it's genuinely local (scroll, text field).\n- **`@Preview`** reusable composables in their key states, and across the matrix (see below).\n\n## Edge-to-edge (enforced from targetSdk 35)\n\n- Call `enableEdgeToEdge()` before `setContent` in the activity — the opt-out is gone at targetSdk 35+.\n- Consume insets at the `Scaffold`: use its `innerPadding` and `Modifier.consumeWindowInsets(innerPadding)` on the content so a nested scrollable doesn't double-apply it.\n- IME padding: apply `Modifier.imePadding()` once, at the container that should move with the keyboard — applying it a second time further down the tree produces extra empty space.\n- `android:windowSoftInputMode=\"adjustResize\"` in the manifest for screens with text input.\n- `NavigationSuiteScaffold` does **not** automatically propagate its padding to the content slot — apply insets explicitly inside it, don't assume it's handled.\n\n## Predictive back (default at targetSdk 36)\n\n- `onBackPressed()` \u002F `OnBackPressedCallback` without `isEnabled` toggling is not called the same way once predictive back is the default — use `BackHandler` (simple) or `PredictiveBackHandler` (custom transition) in Compose, or Navigation 3's built-in handling.\n- Verify back navigation in this run rather than assuming the old override still fires.\n\n## Adaptive layout\n\n- `currentWindowAdaptiveInfo().windowSizeClass` to branch layout by available width\u002Fheight — never by `Configuration.orientation` or a hardcoded device check.\n- `NavigationSuiteScaffold` switches a bottom nav bar to a nav rail automatically at the window-size-class breakpoint — prefer it over hand-rolling the switch.\n- `GridCells.Adaptive(minWidth)` for grids that should reflow by available width.\n- Android 16 (opt-out via `PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY`) and Android 17\u002FAPI 37 (no opt-out) ignore `screenOrientation`\u002F`resizeableActivity` restrictions on screens ≥600dp — design every screen to work in both orientations and at tablet width; don't rely on an orientation lock to avoid building the wider layout.\n\n## Previews and tests across the matrix\n\n- `@PreviewScreenSizes`, `@PreviewFontScale`, `@PreviewLightDark`, or a custom multi-preview with `Devices.PHONE`\u002F`Devices.TABLET` — see `mobile-visual-self-review` for the full size\u002Ftext-scale\u002Fdark matrix.\n- `DeviceConfigurationOverride(ForcedSize(...) then FontScale(...) then DarkMode(...))` for instrumented matrix tests.\n- `rule.enableAccessibilityChecks()` on an API 34+ device\u002Femulator before UI-mutating test actions (inconclusive on Robolectric — say so if that's all you ran); see `mobile-accessibility`.\n- \"Run screenshot tests but do not update reference images\" to \"fix\" a failure — a changed golden is a visual regression until a human confirms it's intended.\n\n## Semantics\n\n- `contentDescription` on every `Image`\u002F`Icon` that carries meaning; `null` explicitly for a purely decorative one.\n- `Modifier.semantics(mergeDescendants = true)` on a composite row so a screen reader announces it once.\n- Touch targets ≥48dp — `Modifier.size`\u002F`minimumInteractiveComponentSize()`.\n\n## Worked Example\n\n```kotlin\n\u002F\u002F ViewModel owns state + logic (unit-testable, no Compose)\nclass TaskListViewModel(private val repo: TaskRepository) : ViewModel() {\n    private val _state = MutableStateFlow\u003CUiState\u003CList\u003CTask>>>(UiState.Loading)\n    val state: StateFlow\u003CUiState\u003CList\u003CTask>>> = _state\n    fun load() = viewModelScope.launch {\n        _state.value = UiState.Loading\n        _state.value = try {\n            val items = repo.list()\n            if (items.isEmpty()) UiState.Empty else UiState.Data(items)\n        } catch (e: CancellationException) {\n            throw e                              \u002F\u002F never swallow cancellation\n        } catch (e: Exception) {\n            UiState.Error(e)\n        }\n    }\n}\n\n\u002F\u002F stateless composable renders state, emits events\n@Composable\nfun TaskListScreen(state: UiState\u003CList\u003CTask>>, onRetry: () -> Unit) = when (state) {\n    is UiState.Loading -> AppSpinner()\n    is UiState.Error   -> AppErrorView(message = state.cause.message, onRetry = onRetry)\n    is UiState.Data    -> TaskList(tasks = state.value)\n    is UiState.Empty   -> EmptyView()\n}\n```\n\nThe fix from the previous version: `runCatching { }` wrapped around a suspend call inside `viewModelScope.launch` catches `CancellationException` along with real errors, which breaks structured concurrency (a cancelled screen keeps \"loading\" instead of stopping) — use `try\u002Fcatch` and rethrow `CancellationException` explicitly. The `Empty` branch is now actually emitted when the list comes back empty, not just declared and never reached.\n\n## Testing\n\n- Unit-test the `ViewModel` with a fake\u002Fmockk repository and a test dispatcher — no Compose.\n- Compose UI tests (`createComposeRule`) assert visible behavior and clicks. Test-first.\n\n## Common Mistakes\n\n- A composable holding app state or calling the repository.\n- Business logic in the composable instead of the ViewModel.\n- Hardcoded colors\u002Fdp instead of `MaterialTheme` + tokens.\n- Collecting flows without `collectAsStateWithLifecycle` (leaks\u002Fwaste).\n- Only the data branch rendered — `Empty` declared but never emitted.\n- `runCatching` around a suspend call, swallowing `CancellationException`.\n- Assuming edge-to-edge\u002Fpredictive back still behave like targetSdk \u003C35\u002F\u003C36 after a target bump.\n\n## Red Flags\n\n- A `@Composable` that imports a repository or Retrofit service.\n- `Color(0xFF...)`\u002Fmagic `dp` outside the theme.\n- No error\u002Fempty branch in the `when`.\n- `enableEdgeToEdge()` missing from a new or recently targetSdk-bumped activity.\n- A screen that only renders correctly in one orientation.\n","# Jetpack Compose Patterns\n\n## Overview\n\nNative Android (Jetpack Compose) is chosen when a task needs deep Android integration or the app is already native (see native-vs-flutter-decision). Same discipline as Flutter\u002FSwiftUI: small stateless composables, state hoisted out, reusable atomic components.\n\n**Core principle:** Composables are stateless functions of state. State is hoisted to a `ViewModel`; composables emit events upward.\n\n## Rules\n\n- **Stateless composables + state hoisting.** A composable takes its state as parameters and exposes callbacks (`onXxx`) — it does not own app state. The screen-level composable connects a `ViewModel` to the stateless UI.\n- **`ViewModel` owns state and logic**, exposed as `StateFlow`\u002F`UiState`; the composable collects it with `collectAsStateWithLifecycle()`. Networking\u002Fbusiness rules live in the ViewModel + repository, never in the composable.\n- **Model UI state as a sealed hierarchy:** `Loading | Data | Empty | Error` — `when` over it renders every branch. No happy-path-only screens.\n- **Atomic components:** shared library of reusable composables (atoms → molecules → organisms). Reuse before building; grep before adding.\n- **Material theme, not hardcoded values:** `MaterialTheme.colorScheme` \u002F `typography` \u002F a spacing tokens object (`MaterialTheme.spacing`, see `mobile-design-system-foundation`) — never scattered `Color(0xFF...)` and magic `dp`. Support dark theme + dynamic color.\n- **`remember`\u002F`derivedStateOf`** to avoid recomputation; **hoist** `remember`ed state only when it's genuinely local (scroll, text field).\n- **`@Preview`** reusable composables in their key states, and across the matrix (see below).\n\n## Edge-to-edge (enforced from targetSdk 35)\n\n- Call `enableEdgeToEdge()` before `setContent` in the activity — the opt-out is gone at targetSdk 35+.\n- Consume insets at the `Scaffold`: use its `innerPadding` and `Modifier.consumeWindowInsets(innerPadding)` on the content so a nested scrollable doesn't double-apply it.\n- IME padding: apply `Modifier.imePadding()` once, at the container that should move with the keyboard — applying it a second time further down the tree produces extra empty space.\n- `android:windowSoftInputMode=\"adjustResize\"` in the manifest for screens with text input.\n- `NavigationSuiteScaffold` does **not** automatically propagate its padding to the content slot — apply insets explicitly inside it, don't assume it's handled.\n\n## Predictive back (default at targetSdk 36)\n\n- `onBackPressed()` \u002F `OnBackPressedCallback` without `isEnabled` toggling is not called the same way once predictive back is the default — use `BackHandler` (simple) or `PredictiveBackHandler` (custom transition) in Compose, or Navigation 3's built-in handling.\n- Verify back navigation in this run rather than assuming the old override still fires.\n\n## Adaptive layout\n\n- `currentWindowAdaptiveInfo().windowSizeClass` to branch layout by available width\u002Fheight — never by `Configuration.orientation` or a hardcoded device check.\n- `NavigationSuiteScaffold` switches a bottom nav bar to a nav rail automatically at the window-size-class breakpoint — prefer it over hand-rolling the switch.\n- `GridCells.Adaptive(minWidth)` for grids that should reflow by available width.\n- Android 16 (opt-out via `PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY`) and Android 17\u002FAPI 37 (no opt-out) ignore `screenOrientation`\u002F`resizeableActivity` restrictions on screens ≥600dp — design every screen to work in both orientations and at tablet width; don't rely on an orientation lock to avoid building the wider layout.\n\n## Previews and tests across the matrix\n\n- `@PreviewScreenSizes`, `@PreviewFontScale`, `@PreviewLightDark`, or a custom multi-preview with `Devices.PHONE`\u002F`Devices.TABLET` — see `mobile-visual-self-review` for the full size\u002Ftext-scale\u002Fdark matrix.\n- `DeviceConfigurationOverride(ForcedSize(...) then FontScale(...) then DarkMode(...))` for instrumented matrix tests.\n- `rule.enableAccessibilityChecks()` on an API 34+ device\u002Femulator before UI-mutating test actions (inconclusive on Robolectric — say so if that's all you ran); see `mobile-accessibility`.\n- \"Run screenshot tests but do not update reference images\" to \"fix\" a failure — a changed golden is a visual regression until a human confirms it's intended.\n\n## Semantics\n\n- `contentDescription` on every `Image`\u002F`Icon` that carries meaning; `null` explicitly for a purely decorative one.\n- `Modifier.semantics(mergeDescendants = true)` on a composite row so a screen reader announces it once.\n- Touch targets ≥48dp — `Modifier.size`\u002F`minimumInteractiveComponentSize()`.\n\n## Worked Example\n\n```kotlin\n\u002F\u002F ViewModel owns state + logic (unit-testable, no Compose)\nclass TaskListViewModel(private val repo: TaskRepository) : ViewModel() {\n    private val _state = MutableStateFlow\u003CUiState\u003CList\u003CTask>>>(UiState.Loading)\n    val state: StateFlow\u003CUiState\u003CList\u003CTask>>> = _state\n    fun load() = viewModelScope.launch {\n        _state.value = UiState.Loading\n        _state.value = try {\n            val items = repo.list()\n            if (items.isEmpty()) UiState.Empty else UiState.Data(items)\n        } catch (e: CancellationException) {\n            throw e                              \u002F\u002F never swallow cancellation\n        } catch (e: Exception) {\n            UiState.Error(e)\n        }\n    }\n}\n\n\u002F\u002F stateless composable renders state, emits events\n@Composable\nfun TaskListScreen(state: UiState\u003CList\u003CTask>>, onRetry: () -> Unit) = when (state) {\n    is UiState.Loading -> AppSpinner()\n    is UiState.Error   -> AppErrorView(message = state.cause.message, onRetry = onRetry)\n    is UiState.Data    -> TaskList(tasks = state.value)\n    is UiState.Empty   -> EmptyView()\n}\n```\n\nThe fix from the previous version: `runCatching { }` wrapped around a suspend call inside `viewModelScope.launch` catches `CancellationException` along with real errors, which breaks structured concurrency (a cancelled screen keeps \"loading\" instead of stopping) — use `try\u002Fcatch` and rethrow `CancellationException` explicitly. The `Empty` branch is now actually emitted when the list comes back empty, not just declared and never reached.\n\n## Testing\n\n- Unit-test the `ViewModel` with a fake\u002Fmockk repository and a test dispatcher — no Compose.\n- Compose UI tests (`createComposeRule`) assert visible behavior and clicks. Test-first.\n\n## Common Mistakes\n\n- A composable holding app state or calling the repository.\n- Business logic in the composable instead of the ViewModel.\n- Hardcoded colors\u002Fdp instead of `MaterialTheme` + tokens.\n- Collecting flows without `collectAsStateWithLifecycle` (leaks\u002Fwaste).\n- Only the data branch rendered — `Empty` declared but never emitted.\n- `runCatching` around a suspend call, swallowing `CancellationException`.\n- Assuming edge-to-edge\u002Fpredictive back still behave like targetSdk \u003C35\u002F\u003C36 after a target bump.\n\n## Red Flags\n\n- A `@Composable` that imports a repository or Retrofit service.\n- `Color(0xFF...)`\u002Fmagic `dp` outside the theme.\n- No error\u002Fempty branch in the `when`.\n- `enableEdgeToEdge()` missing from a new or recently targetSdk-bumped activity.\n- A screen that only renders correctly in one orientation.\n",{"name":5,"source":24,"category":25,"tech_stack":26,"description":7},"android\u002Fskills (Apache-2.0), skydoves\u002Fandroid-testing-skills (Apache-2.0), adapted","architecture","Kotlin","main","910394a0b6db9fc8c9a8f36328ec421d3ebd8b38","catalog\u002Fagents\u002Fmobile-developer\u002Fskills\u002Fandroid-compose-patterns",18,"https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper","https:\u002F\u002Ftasktrooper.ai","https:\u002F\u002Fgithub.com\u002Fmakifbaysal","Senior Software Developer","2026-11-15 04:50:29",{"source":8,"skillName":5,"commands":37,"prompt":47,"zipAvailable":48},[38,41,44],{"tool":39,"command":40},"npx","npx skills add makifbaysal\u002Ftasktrooper --skill android-compose-patterns",{"tool":42,"command":43},"bunx","bunx skills add makifbaysal\u002Ftasktrooper --skill android-compose-patterns",{"tool":45,"command":46},"pnpm","pnpm dlx skills add makifbaysal\u002Ftasktrooper --skill android-compose-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fmobile-developer\u002Fskills\u002Fandroid-compose-patterns\u002FSKILL.md",true,[],[51,57,64,71,78,85],{"skillNo":52,"name":53,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":19},"01M7CSVEPQW6J6TD6CS2T5FPNZ","visual-craft","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fvisual-craft\u002FSKILL.md",[],[],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M7CSVAQG91ETHQ0HBNZDG5FR","ux-copy","Use when you write any words a user reads in a mockup or a hand-off - content language and voice, buttons, labels, errors, empty states, confirmations, numbers and dates, and the longest-string check","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fux-copy\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7CSV6H0J38659NDXHJQ8396","screen-mockup-html","Use when you draw screens as the design task's HTML mockup - ONE canvas document holding every screen and every variant side by side, the sanitizer-safe recipe, phone and wide frames, the states grid, static control states, and the loopback self-check with screenshots at 375, 768 and 1440 attached to the task","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fscreen-mockup-html\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7CSV3JFRF3BM3XK52M7YEYR","performance-awareness","How the performance score moves for your role. Use when the score context shows a declining trend, or before handing off work you have not self-checked against every criterion.","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fperformance-awareness\u002FSKILL.md",[],[],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7CSTZDH00YRF5SCT7BRT9QD","design-variants","Use when a screen design needs variants - how many, variants as side-by-side rows on the one canvas, what makes two variants genuinely different, recommending one, how the human's choice is read, and narrowing to the chosen one in revision","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fdesign-variants\u002FSKILL.md",[],[],{"skillNo":86,"name":87,"nameZh":6,"description":88,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":89,"categories":90,"keywords":91,"publishedAt":19},"01M7CSTV6P3SM3PAE28DB0RF77","design-system-authoring","Use when you derive, change or extend a design system - where tokens live per stack, the DTCG token tree, role-based names for both themes, base vs layer vs drift, the DESIGN.md section order, the inventory format, the contrast check and the lint every proposal returns","https:\u002F\u002Fgithub.com\u002Fmakifbaysal\u002Ftasktrooper\u002Fblob\u002Fmain\u002Fcatalog\u002Fagents\u002Fui-designer\u002Fskills\u002Fdesign-system-authoring\u002FSKILL.md",[],[]]