Skip to content

Commit 07502be

Browse files
committed
Adding backwards compatible wrapper for WebView.
1 parent e686b54 commit 07502be

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

  • webview/src/commonMain/kotlin/com/multiplatform/webview/web

webview/src/commonMain/kotlin/com/multiplatform/webview/web/WebView.kt

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,43 @@ import kotlinx.coroutines.flow.merge
1616
*/
1717

1818
/**
19+
* Provides a basic WebView composable.
20+
* This version of the function is provided for backwards compatibility by using the older
21+
* onCreated and onDispose callbacks and is missing the factory parameter.
1922
*
20-
* A wrapper around the Android View WebView to provide a basic WebView composable.
23+
* @param state The webview state holder where the Uri to load is defined.
24+
* @param modifier A compose modifier
25+
* @param captureBackPresses Set to true to have this Composable capture back presses and navigate
26+
* the WebView back.
27+
* @param navigator An optional navigator object that can be used to control the WebView's
28+
* navigation from outside the composable.
29+
* @param onCreated Called when the WebView is first created.
30+
* @param onDispose Called when the WebView is destroyed.
31+
* @sample sample.BasicWebViewSample
32+
*/
33+
@Composable
34+
fun WebView(
35+
state: WebViewState,
36+
modifier: Modifier = Modifier,
37+
captureBackPresses: Boolean = true,
38+
navigator: WebViewNavigator = rememberWebViewNavigator(),
39+
webViewJsBridge: WebViewJsBridge? = null,
40+
onCreated: () -> Unit = {},
41+
onDispose: () -> Unit = {},
42+
) {
43+
WebView(
44+
state = state,
45+
modifier = modifier,
46+
captureBackPresses = captureBackPresses,
47+
navigator = navigator,
48+
webViewJsBridge = webViewJsBridge,
49+
onCreated = { _ -> onCreated() },
50+
onDispose = { _ -> onDispose() },
51+
)
52+
}
53+
54+
/**
55+
* Provides a basic WebView composable.
2156
*
2257
* @param state The webview state holder where the Uri to load is defined.
2358
* @param modifier A compose modifier

0 commit comments

Comments
 (0)