Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to share Composables with Web #430

Merged
merged 1 commit into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add possibility to share Composables with Web
  • Loading branch information
hfhbd committed Dec 23, 2021
commit 43805770701dd898337dfaffea7e41f382691be4
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class TodoViewModel(private val scope: CoroutineScope, private val repo: TodoRep
fun create(title: String, until: Instant?) {
scope.launch(Dispatchers.Default) {
repo.create(title = title, until = until)
repo.sync()
}
}

Expand Down
3 changes: 1 addition & 2 deletions web/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ kotlin {
sourceSets {
commonMain {
dependencies {
api(projects.clients) // try composeClients
api(projects.composeClients)
}
}
commonTest {
Expand All @@ -29,7 +29,6 @@ kotlin {

val jsMain by getting {
dependencies {
implementation("app.softwork:bootstrap-compose:0.0.49")
implementation("app.softwork:routing-compose:0.1.5")
implementation(compose.web.core)
implementation(compose.runtime)
Expand Down
6 changes: 4 additions & 2 deletions web/src/jsMain/kotlin/app/softwork/composetodo/login/Login.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package app.softwork.composetodo.login
import androidx.compose.runtime.*
import app.softwork.bootstrapcompose.*
import app.softwork.composetodo.*
import app.softwork.composetodo.Column
import app.softwork.composetodo.Row
import app.softwork.composetodo.Text
import app.softwork.composetodo.viewmodels.*
import kotlinx.coroutines.*
import org.jetbrains.compose.web.attributes.*
import org.jetbrains.compose.web.dom.*

Expand Down Expand Up @@ -37,7 +39,7 @@ fun Login(viewModel: LoginViewModel) {
}
val enableLogin by viewModel.enableLogin.collectAsState(false)

Button("Login $username", disabled = !enableLogin) {
Button("Login $username", enabled = enableLogin) {
viewModel.login()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package app.softwork.composetodo.login
import androidx.compose.runtime.*
import app.softwork.bootstrapcompose.*
import app.softwork.composetodo.*
import app.softwork.composetodo.dto.*
import app.softwork.composetodo.Column
import app.softwork.composetodo.Row
import app.softwork.composetodo.Text
import app.softwork.composetodo.viewmodels.*
import kotlinx.coroutines.*
import org.jetbrains.compose.web.attributes.*
import org.jetbrains.compose.web.dom.*

Expand Down Expand Up @@ -62,7 +63,7 @@ fun Register(viewModel: RegisterViewModel) {

val enableRegisterButton by viewModel.enableRegisterButton.collectAsState(false)

Button("Register", disabled = !enableRegisterButton) {
Button("Register", enabled = enableRegisterButton) {
viewModel.register()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import androidx.compose.runtime.*
import app.softwork.composetodo.*
import app.softwork.composetodo.dto.Todo
import kotlinx.uuid.*
import org.jetbrains.compose.web.dom.*

@Composable
fun Todo(api: API.LoggedIn, todoID: UUID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fun Todos(viewModel: TodoViewModel) {
if (todos.isEmpty()) {
Text("No Todos created")
} else {
Table(data = todos, key = { it.id }) { _, todo ->
Table(data = todos.sortedBy { it.title }, key = { it.id }) { _, todo ->
rowColor = when {
todo.finished -> Color.Success
todo.until?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package app.softwork.composetodo.users

import androidx.compose.runtime.*
import app.softwork.composetodo.*
import org.jetbrains.compose.web.dom.*

@Composable
fun Users(api: API.LoggedIn) {
Expand Down