diff --git a/examples/todoapp/desktop/build.gradle.kts b/examples/todoapp/desktop/build.gradle.kts index 6fcccab190..e5172dcccc 100755 --- a/examples/todoapp/desktop/build.gradle.kts +++ b/examples/todoapp/desktop/build.gradle.kts @@ -25,6 +25,11 @@ kotlin { implementation(Deps.ArkIvanov.MVIKotlin.mvikotlinMain) implementation(Deps.Badoo.Reaktive.reaktive) implementation(Deps.Badoo.Reaktive.coroutinesInterop) + + // The dependencies below are required only for previews, see https://github.com/JetBrains/compose-jb/issues/908 + implementation(compose.uiTooling) + implementation(project(":common:edit")) + implementation(project(":common:main")) } } } @@ -38,7 +43,7 @@ compose.desktop { targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) packageName = "ComoseDesktopTodo" packageVersion = "1.0.0" - + modules("java.sql") windows { diff --git a/examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/TodoEditPreview.kt b/examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/TodoEditPreview.kt new file mode 100644 index 0000000000..efcf63e0ae --- /dev/null +++ b/examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/TodoEditPreview.kt @@ -0,0 +1,33 @@ +/* + * Should be in the compose-ui module, see https://github.com/JetBrains/compose-jb/issues/908 + */ + +package example.todo.desktop + +import androidx.compose.desktop.ui.tooling.preview.Preview +import androidx.compose.runtime.Composable +import com.arkivanov.decompose.value.MutableValue +import com.arkivanov.decompose.value.Value +import example.todo.common.edit.TodoEdit +import example.todo.common.edit.TodoEdit.Model +import example.todo.common.ui.TodoEditContent + +@Composable +@Preview +fun TodoEditContentPreview() { + TodoEditContent(TodoEditPreview()) +} + +class TodoEditPreview : TodoEdit { + override val models: Value = + MutableValue( + Model( + text = "Some text", + isDone = true + ) + ) + + override fun onTextChanged(text: String) {} + override fun onDoneChanged(isDone: Boolean) {} + override fun onCloseClicked() {} +} diff --git a/examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/TodoMainPreview.kt b/examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/TodoMainPreview.kt new file mode 100644 index 0000000000..89c0702cde --- /dev/null +++ b/examples/todoapp/desktop/src/jvmMain/kotlin/example/todo/desktop/TodoMainPreview.kt @@ -0,0 +1,42 @@ +/* + * Should be in the compose-ui module, see https://github.com/JetBrains/compose-jb/issues/908 + */ + +package example.todo.desktop + +import androidx.compose.desktop.ui.tooling.preview.Preview +import androidx.compose.runtime.Composable +import com.arkivanov.decompose.value.MutableValue +import com.arkivanov.decompose.value.Value +import example.todo.common.main.TodoItem +import example.todo.common.main.TodoMain +import example.todo.common.main.TodoMain.Model +import example.todo.common.ui.TodoMainContent + +@Preview +@Composable +fun TodoMainContentPreview() { + TodoMainContent(TodoMainPreview()) +} + +class TodoMainPreview : TodoMain { + override val models: Value = + MutableValue( + Model( + items = List(5) { index -> + TodoItem( + id = index.toLong(), + text = "Item $index", + isDone = index % 2 == 0 + ) + }, + text = "Some text" + ) + ) + + override fun onItemClicked(id: Long) {} + override fun onItemDoneChanged(id: Long, isDone: Boolean) {} + override fun onItemDeleteClicked(id: Long) {} + override fun onInputTextChanged(text: String) {} + override fun onAddItemClicked() {} +}