Skip to content

Commit

Permalink
Adding backwards compatible wrapper for WebView.
Browse files Browse the repository at this point in the history
  • Loading branch information
coderforlife committed Jun 28, 2024
1 parent e686b54 commit 07502be
Showing 1 changed file with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,43 @@ import kotlinx.coroutines.flow.merge
*/

/**
* Provides a basic WebView composable.
* This version of the function is provided for backwards compatibility by using the older
* onCreated and onDispose callbacks and is missing the factory parameter.
*
* A wrapper around the Android View WebView to provide a basic WebView composable.
* @param state The webview state holder where the Uri to load is defined.
* @param modifier A compose modifier
* @param captureBackPresses Set to true to have this Composable capture back presses and navigate
* the WebView back.
* @param navigator An optional navigator object that can be used to control the WebView's
* navigation from outside the composable.
* @param onCreated Called when the WebView is first created.
* @param onDispose Called when the WebView is destroyed.
* @sample sample.BasicWebViewSample
*/
@Composable
fun WebView(
state: WebViewState,
modifier: Modifier = Modifier,
captureBackPresses: Boolean = true,
navigator: WebViewNavigator = rememberWebViewNavigator(),
webViewJsBridge: WebViewJsBridge? = null,
onCreated: () -> Unit = {},
onDispose: () -> Unit = {},
) {
WebView(
state = state,
modifier = modifier,
captureBackPresses = captureBackPresses,
navigator = navigator,
webViewJsBridge = webViewJsBridge,
onCreated = { _ -> onCreated() },
onDispose = { _ -> onDispose() },
)
}

/**
* Provides a basic WebView composable.
*
* @param state The webview state holder where the Uri to load is defined.
* @param modifier A compose modifier
Expand Down

0 comments on commit 07502be

Please sign in to comment.