commonMain.sample.HtmlWebViewSample.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of compose-webview-multiplatform Show documentation
Show all versions of compose-webview-multiplatform Show documentation
WebView for JetBrains Compose Multiplatform
package sample
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.heightIn
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import web.WebView
import web.rememberWebViewStateWithHTMLData
/**
* Created By Kevin Zou On 2023/9/8
*/
@Composable
internal fun BasicWebViewWithHTMLSample() {
val html = """
Compose WebView Multiplatform
Compose WebView Multiplatform
""".trimIndent()
val webViewState = rememberWebViewStateWithHTMLData(
data = html
)
MaterialTheme {
Box(Modifier.fillMaxSize()) {
WebView(
state = webViewState,
modifier = Modifier.matchParentSize()
.heightIn(min = 1.dp), // A bottom sheet can't support content with 0 height.
captureBackPresses = false,
)
}
}
}