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

Fix LocalUriHandler not present exception #52

Merged
merged 2 commits into from
Oct 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ package io.spine.internal.dependency

// https://github.com/spine-examples/Pingh
public object Pingh {
private const val version = "1.0.0-SNAPSHOT.11"
private const val version = "1.0.0-SNAPSHOT.12"
private const val group = "io.spine.examples.pingh"

public const val client: String = "$group:client:$version"
Expand Down
30 changes: 19 additions & 11 deletions desktop/src/main/kotlin/io/spine/examples/pingh/desktop/Window.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,23 @@ import io.spine.examples.pingh.client.PinghApplication
*
* @param state The state of the application window.
* @param app Manages the logic for the Pingh app.
* @param uriHandler The `CompositionLocal` that provides functionality for handling URL,
* such as opening a URI.
* @param uriHandler Provides functionality for handling URL, such as opening a URI.
* @see [PlatformWindow]
*/
@Composable
internal fun Window(
state: WindowState,
app: PinghApplication,
uriHandler: UriHandler = LocalUriHandler.current
uriHandler: UriHandler? = null
) {
PlatformWindow(
title = state.title,
isShown = state.isShown,
onClose = state::hide
) {
CompositionLocalProvider(LocalUriHandler provides uriHandler) {
Box(
modifier = Modifier
.fillMaxSize()
.clip(MaterialTheme.shapes.small)
) {
CurrentPage(app)
}
val localUriHandler = uriHandler ?: LocalUriHandler.current
CompositionLocalProvider(LocalUriHandler provides localUriHandler) {
WindowContent(app)
}
}
}
Expand Down Expand Up @@ -111,6 +105,20 @@ private fun PlatformWindow(
)
}

/**
* Displays a content in the Pingh window.
*/
@Composable
private fun WindowContent(app: PinghApplication) {
Box(
modifier = Modifier
.fillMaxSize()
.clip(MaterialTheme.shapes.small)
) {
CurrentPage(app)
}
}

/**
* State of [Window].
*/
Expand Down
2 changes: 1 addition & 1 deletion version.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
/**
* The version of the `Pingh` to publish.
*/
val pinghVersion: String by extra("1.0.0-SNAPSHOT.11")
val pinghVersion: String by extra("1.0.0-SNAPSHOT.12")
Loading