KevinnZou / compose-webview-multiplatform

WebView for JetBrains Compose Multiplatform
https://kevinnzou.github.io/compose-webview-multiplatform/
Apache License 2.0
318 stars 40 forks source link

Navigator.loadHtml not working on Android #62

Closed mikedawson closed 5 months ago

mikedawson commented 5 months ago

Hi,

I want to update HTML from a UiState. I tested this:

val state = rememberWebViewStateWithHTMLData("initial")

    val navigator = rememberWebViewNavigator()

    LaunchedEffect(Unit) {
        delay(2000)
        navigator.loadHtml("<html><body>New HTML</body></html>")
    }

Which would be expected to first show "initial", then change to New HTML. It doesn't change.

The problem seems to be in WebViewNavigator line 130 which has this code (collecting the flow):

loadHtml(
                            event.baseUrl,
                            event.html,
                            event.mimeType,
                            event.encoding,
                            event.historyUrl,
                        )

But in AndroidWebView.kt (line 25) the arguments are in different order:

override fun loadHtml(
        html: String?,
        baseUrl: String?,
        mimeType: String?,
        encoding: String?,
        historyUrl: String?,
    )

It seems like baseUrl and html have changed places.

Is that something that can be fixed, or should I send a pull request? Thanks!

KevinnZou commented 5 months ago

@mikedawson Hi, thanks for your feedback! You are correct, and I apologize for the mistake. I have fixed it and will release it with the next version. Thanks again!

mikedawson commented 5 months ago

Thank you @KevinnZou !