Slide 16
Slide 16 text
16
@Composable
fun WebScreen(
url: Uri,
onUrlChanged: (Uri) -> Unit
) {
AndroidView(
factory = { context ->
WebView(context).apply {
webViewClient =
MyWebViewClient(onUrlChanged)
}
},
update = { webView ->
webView.loadUrl(url.toString())
}
)
}
class MyWebViewClient(
private val onUrlChanged: (Uri) -> Unit
) : WebViewClientCompat() {
override fun shouldOverrideUrlLoading(
view: WebView,
request: WebResourceRequest
): Boolean {
onUrlChanged(request.url)
return true
}
}