-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7e2ad58
commit 684c6b9
Showing
9 changed files
with
122 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,5 +59,5 @@ site | |
### Python ### | ||
venv/ | ||
|
||
./calf/ | ||
./calf/* | ||
.calf | ||
.calf/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# File Picker | ||
|
||
## Installation | ||
|
||
[![Maven Central](https://img.shields.io/maven-central/v/com.mohamedrejeb.calf/calf-webview)](https://search.maven.org/search?q=g:%22com.mohamedrejeb.calf%22%20AND%20a:%calf-webview%22) | ||
|
||
Add the following dependency to your module `build.gradle.kts` file: | ||
|
||
```kotlin | ||
implementation("com.mohamedrejeb.calf:calf-webview:0.5.0") | ||
``` | ||
|
||
## Usage | ||
|
||
`WebView` is a view that adapts to the platform it is running on. It is a wrapper around `WebView` on Android, `WKWebView` on iOS and JavaFX `WebView` on Desktop. | ||
|
||
| Android | iOS | | ||
|-------------------------------------------------|-----------------------------------------| | ||
| ![Web View Android](images/WebView-android.png) | ![Web View iOS](images/WebView-ios.png) | | ||
|
||
```kotlin | ||
val state = rememberWebViewState( | ||
url = "https://github.com/MohamedRejeb" | ||
) | ||
|
||
LaunchedEffect(state.isLoading) { | ||
// Get the current loading state | ||
} | ||
|
||
WebView( | ||
state = state, | ||
modifier = Modifier | ||
.fillMaxSize() | ||
) | ||
``` | ||
|
||
#### Web View Settings | ||
|
||
You can customize the web view settings by changing the `WebSettings` object in the `WebViewState`: | ||
|
||
```kotlin | ||
val state = rememberWebViewState( | ||
url = "https://github.com/MohamedRejeb" | ||
) | ||
|
||
LaunchedEffect(Unit) { | ||
// Enable JavaScript | ||
state.settings.javaScriptEnabled = true | ||
|
||
// Enable Zoom in Android | ||
state.settings.androidSettings.supportZoom = true | ||
} | ||
``` | ||
|
||
#### Call JavaScript | ||
|
||
You can call JavaScript functions from the web view by using the `evaluateJavaScript` function: | ||
|
||
```kotlin | ||
val state = rememberWebViewState( | ||
url = "https://github.com/MohamedRejeb" | ||
) | ||
|
||
LaunchedEffect(Unit) { | ||
val jsCode = """ | ||
document.body.style.backgroundColor = "red"; | ||
document.title | ||
""".trimIndent() | ||
|
||
// Evaluate the JavaScript code | ||
state.evaluateJavaScript(jsCode) { | ||
// Do something with the result | ||
println("JS Response: $it") | ||
} | ||
} | ||
``` | ||
|
||
> **Note:** The `evaluateJavaScript` method only works when you enable JavaScript in the web view settings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters