Marketplace

kotlin-compose

Jetpack Compose - composables, state, effects, theming

$ 安裝

git clone https://github.com/pluginagentmarketplace/custom-plugin-kotlin /tmp/custom-plugin-kotlin && cp -r /tmp/custom-plugin-kotlin/skills/kotlin-compose ~/.claude/skills/custom-plugin-kotlin

// tip: Run this command in your terminal to install the skill


name: kotlin-compose description: Jetpack Compose - composables, state, effects, theming version: "1.0.0" sasmp_version: "1.3.0" bonded_agent: 02-kotlin-android bond_type: PRIMARY_BOND

execution: timeout_ms: 30000 retry: max_attempts: 3 backoff: exponential initial_delay_ms: 1000

parameters: required: - name: topic type: string validation: "^(composables|state|effects|theming|testing)$" optional: - name: compose_version type: string default: "1.6.0"

logging: level: info events: [skill_invoked, topic_loaded, error_occurred]

Kotlin Compose Skill

Build modern UIs with Jetpack Compose declarative patterns.

Topics Covered

State Management

@Composable
fun Counter() {
    var count by remember { mutableIntStateOf(0) }
    Button(onClick = { count++ }) { Text("Count: $count") }
}

// Derived state
val isValid by remember { derivedStateOf { email.isNotBlank() && password.length >= 8 } }

Side Effects

@Composable
fun UserScreen(userId: String) {
    LaunchedEffect(userId) {
        viewModel.loadUser(userId)
    }

    DisposableEffect(Unit) {
        val listener = viewModel.addListener()
        onDispose { listener.remove() }
    }
}

Modifiers

Box(
    modifier = Modifier
        .fillMaxSize()
        .padding(16.dp)
        .background(MaterialTheme.colorScheme.surface)
        .clickable { onClick() }
)

Material 3 Theming

@Composable
fun AppTheme(content: @Composable () -> Unit) {
    val colorScheme = if (isSystemInDarkTheme()) darkColorScheme() else lightColorScheme()
    MaterialTheme(colorScheme = colorScheme, typography = Typography, content = content)
}

Troubleshooting

IssueResolution
Infinite recompositionUse remember or derivedStateOf
State lost on rotationUse rememberSaveable or ViewModel

Usage

Skill("kotlin-compose")