forked from androidx/androidx
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce navigation support to wasm and web demos (#1697)
- Loading branch information
Showing
4 changed files
with
26 additions
and
5 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
14 changes: 13 additions & 1 deletion
14
compose/mpp/demo/src/jsMain/kotlin/androidx/compose/mpp/demo/main.js.kt
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 |
---|---|---|
@@ -1,16 +1,28 @@ | ||
package androidx.compose.mpp.demo | ||
|
||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.ExperimentalComposeUiApi | ||
import androidx.compose.ui.window.ComposeViewport | ||
import androidx.navigation.ExperimentalBrowserHistoryApi | ||
import androidx.navigation.compose.rememberNavController | ||
import androidx.navigation.bindToNavigation | ||
import org.jetbrains.skiko.wasm.onWasmReady | ||
import kotlinx.browser.window | ||
|
||
@OptIn(ExperimentalComposeUiApi::class) | ||
@ExperimentalBrowserHistoryApi | ||
fun main() { | ||
onWasmReady { | ||
ComposeViewport(viewportContainerId = "composeApplication") { | ||
val navController = rememberNavController() | ||
|
||
val app = remember { App() } | ||
app.Content() | ||
app.Content(navController) | ||
|
||
LaunchedEffect(Unit) { | ||
window.bindToNavigation(navController) | ||
} | ||
} | ||
} | ||
} |
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