-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
708 additions
and
629 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ plugins { | |
} | ||
|
||
kotlin { | ||
js(IR) { | ||
js { | ||
browser { | ||
binaries.executable() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ plugins { | |
} | ||
|
||
kotlin { | ||
js(IR) { | ||
js { | ||
browser { | ||
binaries.executable() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import androidx.compose.foundation.layout.* | ||
import androidx.compose.material.* | ||
import androidx.compose.runtime.* | ||
import app.softwork.routingcompose.* | ||
|
||
private const val Answer = 42 | ||
|
||
@Composable | ||
fun RouteBuilder.Demo( | ||
root: Int, | ||
wasMagic42: Boolean, | ||
changeMagic42: (Boolean) -> Unit, | ||
) { | ||
Column { | ||
val params = parameters?.map | ||
if (params != null) { | ||
Text("Parameters: $params") | ||
} | ||
if (wasMagic42) { | ||
route("/answer") { | ||
val router = Router.current | ||
Text("The Answer to the Ultimate Question of Life, the Universe, and Everything is 42.") | ||
Button(onClick = { | ||
router.navigate("/$root") | ||
}) { | ||
Text("Back") | ||
} | ||
} | ||
} | ||
int { | ||
Content(it, wasMagic42) | ||
if (it == Answer) { | ||
LaunchedEffect(it) { | ||
changeMagic42(true) | ||
} | ||
} | ||
} | ||
string { | ||
Column { | ||
val router = Router.current | ||
Text("Hello $it") | ||
Button(onClick = { | ||
router.navigate("/$root") | ||
}) { | ||
Text("Back") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Composable | ||
fun Content(int: Int, wasMagic42: Boolean) { | ||
var name by remember { mutableStateOf("") } | ||
val router = Router.current | ||
Column { | ||
Text("Hello World $int") | ||
TextField(value = name, { | ||
name = it | ||
}) | ||
|
||
if (name.isNotBlank()) { | ||
Button({ | ||
router.navigate("/$name") | ||
}) { | ||
Text("Update name") | ||
} | ||
} | ||
|
||
if (wasMagic42) { | ||
Button({ | ||
router.navigate("/answer") | ||
}) { | ||
Text("Unlocked answer") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
import androidx.compose.runtime.* | ||
import androidx.compose.ui.* | ||
import androidx.compose.ui.window.* | ||
import app.softwork.routingcompose.* | ||
|
||
@ExperimentalComposeUiApi | ||
fun main() = CanvasBasedWindow("WASM Test") { | ||
var wasMagic42 by remember { mutableStateOf(false) } | ||
HashRouter("/1") { | ||
Demo(1, wasMagic42, { wasMagic42 = it }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
</head> | ||
<body> | ||
<canvas id="ComposeTarget"></canvas> | ||
<script type="application/javascript" src="integrationTest.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.