Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinnZou authored Feb 6, 2024
1 parent 50e5372 commit 3e8c4a2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,36 @@ WebView(state)
```
This will display a WebView in your Compose layout that shows the URL provided.

There is a larger sample in the sample app which can be found [here](https://github.com/KevinnZou/compose-webview/blob/main/app/src/main/java/com/kevinnzou/webview/sample/BasicWebViewSample.kt). This sample also shows how to show a loading state.

## WebView settings including JavaScript

By default, JavaScript is disabled in the WebView. To enable it or any other settings you can use the onCreated callback.
```kotlin
WebView(
state = webViewState,
onCreated = { it.settings.javaScriptEnabled = true }
)
```

## Capturing back presses
By default, the WebView will capture back presses/swipes when relevant and navigate the WebView back. This can be disabled via the parameter on the Composable.
```kotlin
WebView(
...
captureBackPresses = false
)
```

## Using a subclass of WebView
If you want to use a subclass of WebView, or simply require more control over its instantiation, you can provide a factory.
```kotlin
WebView(
...
factory = { context -> CustomWebView(context) }
)
```

## Download

[![Maven Central](https://img.shields.io/maven-central/v/io.github.kevinnzou/compose-webview.svg)](https://search.maven.org/artifact/io.github.kevinnzou/compose-webview)
Expand Down

0 comments on commit 3e8c4a2

Please sign in to comment.