ferdialif02
11/11/2025, 4:19 AM@OptIn(ExperimentalTime::class)
@Composable
fun PagerWkWebViewTest() {
val state = rememberPagerState { 10 }
HorizontalPager(state = state) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
PlatformSpecificWebView(
modifier =
Modifier
.fillMaxWidth()
.height(100.dp)
.background(Color.Transparent)
.clickable {
}.animateContentSize(),
url = {
loadHtmlDataIntoWebView(
"pUnknown/p",
isAnswer = true,
isOptions = true,
)
},
token = "",
popBack = {},
isLiveClass = false,
examMode = true,
backgroundColorExam = Color.White,
optionExamId = -1,
isOption = false,
)
TextField(
value = "",
onValueChange = {},
modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp),
)
}
}
}
val coord =
remember {
WKWebViewExamCoordinator(onSizeChange = {
heightWebView = it.dp
})
}
if (examMode) {
UIKitView(
factory = {
val webView =
wkwebviewInstance(
url = url(),
token = token,
onSizeChange = {},
backgroundColor = Color.Transparent,
)
webView.navigationDelegate = coord
webView.UIDelegate = coord
webView
},
modifier = Modifier.fillMaxWidth().height(heightWebView),
update = { webView ->
webView.backgroundColor = backgroundColor.toUiColor()
webView.loadHTMLString(url(), null)
},
onRelease = {
println("onRelease called on ${url()}")
it.stopLoading()
it.removeFromSuperview()
it.navigationDelegate = null
it.UIDelegate = null
},
properties = UIKitInteropProperties(placedAsOverlay = false),
)