Compose Multiplatform and Jetpack Compose patterns for KMP — state management, navigation, theming, performance, and platform-specific UI. USE WHEN building shared Compose UI across Android/iOS/Desktop/Web, managing Compose state, or optimizing recomposition.
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Une commande directe contourne le prompt de vérification. Examinez la source avant de l'exécuter.
Compose Multiplatform and Jetpack Compose patterns for KMP — state management, navigation, theming, performance, and platform-specific UI. USE WHEN building shared Compose UI across Android/iOS/Desktop/Web, managing Compose state, or optimizing recomposition.
cluster
jvm
version
1.0.0
Compose Multiplatform Patterns
Patterns for building shared UI across Android, iOS, Desktop, and Web using Compose Multiplatform and Jetpack Compose. Covers state management, navigation, theming, and performance.
When to Activate
Building Compose UI (Jetpack Compose or Compose Multiplatform)
Managing UI state with ViewModels and Compose state
Implementing navigation in KMP or Android projects
Designing reusable composables and design systems
Optimizing recomposition and rendering performance
State Management
ViewModel + Single State Object
Use a single data class for screen state. Expose it as StateFlow and collect in Compose:
@ComposablefunItemListScreen(viewModel: ItemListViewModel = koinViewModel()) {
val state by viewModel.state.collectAsStateWithLifecycle()
ItemListContent(
state = state,
onSearch = viewModel::onSearch
)
}
@ComposableprivatefunItemListContent(
state: ItemListState,
onSearch: (String) -> Unit
) {
// Stateless composable — easy to preview and test
}
Event Sink Pattern
For complex screens, use a sealed interface for events instead of multiple callback lambdas:
sealedinterfaceItemListEvent {
dataclassSearch(val query: String) : ItemListEvent
dataclassDelete(val itemId: String) : ItemListEvent
dataobject Refresh : ItemListEvent
}
// In ViewModelfunonEvent(event: ItemListEvent) {
when (event) {
is ItemListEvent.Search -> onSearch(event.query)
is ItemListEvent.Delete -> deleteItem(event.itemId)
is ItemListEvent.Refresh -> loadItems(_state.value.searchQuery)
}
}
// In Composable — single lambda instead of many
ItemListContent(
state = state,
onEvent = viewModel::onEvent
)