File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed
src/androidMain/kotlin/com/example/kmp/snippets Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -64,9 +64,15 @@ kotlin {
6464
6565 androidMain {
6666 dependencies {
67- // Add Android-specific dependencies here. Note that this source set depends on
68- // commonMain by default and will correctly pull the Android artifacts of any KMP
69- // dependencies declared in commonMain.
67+ val composeBom = project.dependencies.platform(libs.androidx.compose.bom)
68+ implementation(composeBom)
69+ implementation(libs.androidx.compose.runtime)
70+ implementation(libs.androidx.compose.foundation)
71+ implementation(libs.androidx.compose.foundation.layout)
72+ implementation(libs.androidx.compose.ui.util)
73+ implementation(libs.androidx.compose.material)
74+ implementation(libs.androidx.lifecycle.runtime)
75+ implementation(libs.androidx.lifecycle.viewModelCompose)
7076 }
7177 }
7278
Original file line number Diff line number Diff line change 1+ package com.example.kmp.snippets
2+
3+ import androidx.compose.runtime.Composable
4+ import androidx.lifecycle.viewmodel.compose.viewModel
5+
6+
7+ // [START android_kmp_viewmodel_screen]
8+ // androidApp/ui/MainScreen.kt
9+
10+ @Composable
11+ fun MainScreen (
12+ viewModel : MainViewModel = viewModel(
13+ factory = mainViewModelFactory,
14+ ),
15+ ) {
16+ // observe the viewModel state
17+ }
18+ // [END android_kmp_viewmodel_screen]
You can’t perform that action at this time.
0 commit comments