google / accompanist

A collection of extension libraries for Jetpack Compose
https://google.github.io/accompanist
Apache License 2.0
7.31k stars 592 forks source link

[Webview] fit parent width issue #1768

Closed linhttbk97 closed 2 months ago

linhttbk97 commented 2 months ago

Describe the bug

WebView expanded to fit screen width before resize to the parent width

To Reproduce

Example code

val url = flow<
            String> {
        delay(5000)
        emit("https://github.com/google/accompanist/issues/1702")
    }.onStart {
        emit("")
    }
#onCreate 
val webURL by url.collectAsState(initial = "")
Row(Modifier.fillMaxSize()) {
                        Spacer(
                            modifier = Modifier
                                .width(100.dp)
                                .fillMaxHeight()
                                .background(Color.Red)
                        )
                        Box(
                            modifier = Modifier.fillMaxSize(),
                            contentAlignment = Alignment.Center
                        ) {
                            if (webURL.isNotEmpty()) {
                                WebView(state = rememberWebViewState(url = webURL), onCreated = {
                                    it.settings.javaScriptEnabled = true
                                }, modifier = Modifier.fillMaxSize())
                            }
                           Text(text = "sssss")
                        }

                    }

Expected behavior

WebView always fit parent width

Screenshots?

https://github.com/google/accompanist/assets/107523533/724c0c16-ec78-4060-83b1-6d5a54cde01d

Environment:

Additional context

Add any other context about the problem here.

ianhanniballake commented 2 months ago

The Accompanist WebView library has been deprecated and is no longer receiving any updates.