Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

[webview_flutter] Implement onJSAlert, onJSConfirm, onJSPrompt interface #2499

Closed
wants to merge 5 commits into from

Conversation

j796160836
Copy link

@j796160836 j796160836 commented Feb 4, 2020

Description

Enhance pull request of #2012 .

Implement onJSAlert, onJSConfirm, onJSPrompt interface.

Instead of implement native code, I advocate it handling that Flutter side.
Let developer implement their own alert dialogs at Flutter.
I extract both iOS and Android native callback into three functions.

Native callback

Android iOS
Alert public boolean onJsAlert(WebView view, String url, String message, final JsResult result) webView(_:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:)
Confirm public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) webView(_:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:)
Prompt public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, final JsPromptResult result) webView(_:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:)

Flutter callback

Flutter
Alert JSAlertCallback onJSAlert;
Confirm JSConfirmCallback onJSConfirm;
Prompt JSPromptCallback onJSPrompt;

Also, add working examples.

Related Issues

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md and increment major revision).
  • No, this is not a breaking change.

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to determine that you authored the commits in this PR. Maybe you used a different email address in the git commits than was used to sign the CLA? If someone else authored these commits, then please add them to this pull request and have them confirm that they're okay with them being contributed to Google. If there are co-authors, make sure they're formatted properly.

In order to pass this check, please resolve this problem and then comment@googlebot I fixed it... If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@j796160836
Copy link
Author

@googlebot I fixed it.

@j796160836
Copy link
Author

j796160836 commented Feb 4, 2020

I had signed CLA at 2015 but seems googlebot can't fetch my CLA.
image

@cyanglaz cyanglaz added this to To be reviewed in Plugin PR Triage via automation Jul 29, 2020
@cyanglaz
Copy link
Contributor

I'm going to close the PR because the CLA is not signed. Feel free to ping me when the CLA is signed and I'll re-open the PR. Or you can open a new PR after signing the CLA.

@cyanglaz cyanglaz closed this Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
No open projects
Plugin PR Triage
  
To be reviewed
3 participants