-
public final class WebViewKt
-
-
Field Summary
Fields Modifier and Type Field Description private final static Saver<WebViewState, Object>WebStateSaver
-
Method Summary
Modifier and Type Method Description final Saver<WebViewState, Object>getWebStateSaver()final static UnitWebView(WebViewState state, Modifier modifier, Boolean captureBackPresses, WebViewNavigator navigator, Function1<WebView, Unit> onCreated, Function1<WebView, Unit> onDispose, AccompanistWebViewClient client, AccompanistWebChromeClient chromeClient, Function1<Context, WebView> factory)A wrapper around the Android View WebView to provide a basic WebView composable. final static UnitWebView(WebViewState state, FrameLayout.LayoutParams layoutParams, Modifier modifier, Boolean captureBackPresses, WebViewNavigator navigator, Function1<WebView, Unit> onCreated, Function1<WebView, Unit> onDispose, AccompanistWebViewClient client, AccompanistWebChromeClient chromeClient, Function1<Context, WebView> factory)A wrapper around the Android View WebView to provide a basic WebView composable. final static WebViewNavigatorrememberWebViewNavigator(CoroutineScope coroutineScope)Creates and remembers a WebViewNavigator using the default CoroutineScope or a provided override. final static WebViewStaterememberWebViewState(String url, Map<String, String> additionalHttpHeaders)Creates a WebView state that is remembered across Compositions. final static WebViewStaterememberWebViewStateWithHTMLData(String data, String baseUrl, String encoding, String mimeType, String historyUrl)Creates a WebView state that is remembered across Compositions. final static WebViewStaterememberSaveableWebViewState()Creates a WebView state that is remembered across Compositions and saved across activity recreation. -
-
Method Detail
-
getWebStateSaver
final Saver<WebViewState, Object> getWebStateSaver()
-
WebView
@Composable() final static Unit WebView(WebViewState state, Modifier modifier, Boolean captureBackPresses, WebViewNavigator navigator, Function1<WebView, Unit> onCreated, Function1<WebView, Unit> onDispose, AccompanistWebViewClient client, AccompanistWebChromeClient chromeClient, Function1<Context, WebView> factory)
A wrapper around the Android View WebView to provide a basic WebView composable.
If you require more customisation you are most likely better rolling your own and using this wrapper as an example.
The WebView attempts to set the layoutParams based on the Compose modifier passed in. If it is incorrectly sizing, use the layoutParams composable function instead.
- Parameters:
state- The webview state holder where the Uri to load is defined.modifier- A compose modifiercaptureBackPresses- Set to true to have this Composable capture back presses and navigate the WebView back.navigator- An optional navigator object that can be used to control the WebView's navigation from outside the composable.onCreated- Called when the WebView is first created, this can be used to set additional settings on the WebView.onDispose- Called when the WebView is destroyed.client- Provides access to WebViewClient via subclassingchromeClient- Provides access to WebChromeClient via subclassingfactory- An optional WebView factory for using a custom subclass of WebView
-
WebView
@Composable() final static Unit WebView(WebViewState state, FrameLayout.LayoutParams layoutParams, Modifier modifier, Boolean captureBackPresses, WebViewNavigator navigator, Function1<WebView, Unit> onCreated, Function1<WebView, Unit> onDispose, AccompanistWebViewClient client, AccompanistWebChromeClient chromeClient, Function1<Context, WebView> factory)
A wrapper around the Android View WebView to provide a basic WebView composable.
If you require more customisation you are most likely better rolling your own and using this wrapper as an example.
The WebView attempts to set the layoutParams based on the Compose modifier passed in. If it is incorrectly sizing, use the layoutParams composable function instead.
- Parameters:
state- The webview state holder where the Uri to load is defined.layoutParams- A FrameLayout.LayoutParams object to custom size the underlying WebView.modifier- A compose modifiercaptureBackPresses- Set to true to have this Composable capture back presses and navigate the WebView back.navigator- An optional navigator object that can be used to control the WebView's navigation from outside the composable.onCreated- Called when the WebView is first created, this can be used to set additional settings on the WebView.onDispose- Called when the WebView is destroyed.client- Provides access to WebViewClient via subclassingchromeClient- Provides access to WebChromeClient via subclassingfactory- An optional WebView factory for using a custom subclass of WebView
-
rememberWebViewNavigator
@Composable() final static WebViewNavigator rememberWebViewNavigator(CoroutineScope coroutineScope)
Creates and remembers a WebViewNavigator using the default CoroutineScope or a provided override.
-
rememberWebViewState
@Composable() final static WebViewState rememberWebViewState(String url, Map<String, String> additionalHttpHeaders)
Creates a WebView state that is remembered across Compositions.
- Parameters:
url- The url to load in the WebViewadditionalHttpHeaders- Optional, additional HTTP headers that are passed to WebView.loadUrl.
-
rememberWebViewStateWithHTMLData
@Composable() final static WebViewState rememberWebViewStateWithHTMLData(String data, String baseUrl, String encoding, String mimeType, String historyUrl)
Creates a WebView state that is remembered across Compositions.
- Parameters:
data- The uri to load in the WebView
-
rememberSaveableWebViewState
@Composable() final static WebViewState rememberSaveableWebViewState()
Creates a WebView state that is remembered across Compositions and saved across activity recreation. When using saved state, you cannot change the URL via recomposition. The only way to load a URL is via a WebViewNavigator.
-
-
-
-