android-compose-patterns

Featured

Use when building native Android with Jetpack Compose - stateless composables, state hoisting, ViewModel-owned state, atomic components, and Material theming over hardcoded values

AI & Automation 91 stars 13 forks Updated today Apache-2.0

Install

View on GitHub

Quality Score: 89/100

Stars 20%
65
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Jetpack Compose Patterns ## Overview Native 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/SwiftUI: small stateless composables, state hoisted out, reusable atomic components. **Core principle:** Composables are stateless functions of state. State is hoisted to a `ViewModel`; composables emit events upward. ## Rules - **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. - **`ViewModel` owns state and logic**, exposed as `StateFlow`/`UiState`; the composable collects it with `collectAsStateWithLifecycle()`. Networking/business rules live in the ViewModel + repository, never in the composable. - **Model UI state as a sealed hierarchy:** `Loading | Data | Empty | Error` — `when` over it renders every branch. No happy-path-only screens. - **Atomic components:** shared library of reusable composables (atoms → molecules → organisms). Reuse before building; grep before adding. - **Material theme, not hardcoded values:** `MaterialTheme.colorScheme` / `typography` / a spacing tokens object — never scattered `Color(0xFF...)` and magic `dp`. Support dark theme + dynamic color. - **`remember`/`derivedStateOf`** to avoid recomputation; **hoist** `remember`ed state only when it's genuinely local (sc...

Details

Author
makifbaysal
Repository
makifbaysal/tasktrooper
Created
1 weeks ago
Last Updated
today
Language
Go
License
Apache-2.0

Similar Skills

Semantically similar based on skill content — not just same category