Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[webview_flutter_wkwebview] Expose the allowsLinkPreview property in WKWebView for iOS #5029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Apr 17, 2025

Conversation

camfrandsen
Copy link
Contributor

Based off of flutter/plugins#5110 So most of the credit goes to @b099l3
Also exposed it through the webview_controller

This PR fixes this issue:

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [relevant style guides] and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the [CLA].
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy], or this PR is [exempt from version changes].
  • I updated CHANGELOG.md to add a description of the change, [following repository CHANGELOG style].
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

Based off of flutter/plugins#5110
Also exposed it through the webview_controller
/// Whether to display a preview of the destination for the link
///
/// This is not supported by all platforms, so it defaults to a noop
Future<void> setAllowsLinkPreview(bool allow) async {}
Copy link
Contributor Author

@camfrandsen camfrandsen Sep 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was better to default this to a noop so it wouldn't break other platforms if it was called. Having said that, I will change it to whatever you would like

@camfrandsen
Copy link
Contributor Author

@cyanglaz @bparrishMines I saw that you reviewed flutter/plugins#5110 the first time. Sorry to make you re-review it... but I would love if you could review this. I did my best to port it over from that pr. Thank you for your help with this!
Note, I checked the Linux and Mac checks, and saw that they had failed on previous pulls that went in, so I am assuming they failing on the main branch? Let me know though if there is something I need to do
@b099l3 I figured you would want to be aware that I have ported your patch over to the new repo

@hellohuanlin hellohuanlin changed the title Expose the allowsLinkPreview property in WKWebView for iOS [web_view]Expose the allowsLinkPreview property in WKWebView for iOS Oct 9, 2023
@MitchellGoodwin
Copy link

cc @bparrishMines

@b099l3
Copy link

b099l3 commented Oct 24, 2023

@camfrandsen No worries, I'm glad it was of some use.

I had a guilt in the back of my mind to come back to it at some point and get it merged. So I can sleep easily now. 😅

@stuartmorgan-g
Copy link
Contributor

@camfrandsen Please see https://github.com/flutter/flutter/wiki/Contributing-to-Plugins-and-Packages#changing-federated-plugins for how to structure this PR so that it will pass tests. Please let us know if you have any issues setting that up!

# Conflicts:
#	packages/webview_flutter/webview_flutter/CHANGELOG.md
#	packages/webview_flutter/webview_flutter/lib/src/webview_controller.dart
#	packages/webview_flutter/webview_flutter/pubspec.yaml
#	packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md
#	packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h
#	packages/webview_flutter/webview_flutter_wkwebview/pigeons/web_kit.dart
#	packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml
#	packages/webview_flutter/webview_flutter_wkwebview/test/src/web_kit/web_kit_test.dart
@camfrandsen
Copy link
Contributor Author

I am splitting this into two pulls since I touched the webview_flutter_platform_interface:
#5292
#5293

@camfrandsen camfrandsen closed this Nov 1, 2023
@stuartmorgan-g
Copy link
Contributor

I am splitting this into two pulls since I touched the webview_flutter_platform_interface

That's step 3 of the process, which should only be done after the previous steps (which include approvals of the combined PR) are complete.

@camfrandsen
Copy link
Contributor Author

@stuartmorgan Ah, sorry about that. I looked at the failures of the checks, and it said that it needed to be broken up... I will re-open this one and close the other two.

@camfrandsen camfrandsen reopened this Nov 1, 2023
Copy link
Contributor

@bparrishMines bparrishMines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The webview_flutter_wkwebview portion of this is blocked by flutter/flutter#134777.

# Conflicts:
#	packages/webview_flutter/webview_flutter/CHANGELOG.md
#	packages/webview_flutter/webview_flutter_wkwebview/CHANGELOG.md
#	packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFGeneratedWebKitApis.h
#	packages/webview_flutter/webview_flutter_wkwebview/ios/Classes/FWFWebViewHostApi.m
#	packages/webview_flutter/webview_flutter_wkwebview/pubspec.yaml
…thod not found: 'FallThroughError'. throw FallThroughError())�dart run pigeon --input pigeons/web_kit.dart
@stuartmorgan-g
Copy link
Contributor

Update from triage: still waiting on the wrapper generator, which is currently under very active development.

@jmagman jmagman removed the request for review from cyanglaz February 7, 2024 21:57
@bparrishMines
Copy link
Contributor

I went ahead and updated the code to the new ProxyApi wrapper. There doesn't seem to be a comparable feature on Android to control preview links.

@stuartmorgan-g
Copy link
Contributor

Sounds like this should be ready for review then.

@stuartmorgan-g stuartmorgan-g marked this pull request as ready for review April 1, 2025 14:17
@stuartmorgan-g stuartmorgan-g requested a review from cbracken as a code owner April 1, 2025 14:17
@bparrishMines bparrishMines changed the title [web_view]Expose the allowsLinkPreview property in WKWebView for iOS [webview_flutter_wkwebvie] Expose the allowsLinkPreview property in WKWebView for iOS Apr 1, 2025

/// If you set this property’s value to true, an iOS user can press links to
/// preview link destinations and detected data such as addresses and phone
/// numbers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all of the instances of comments like this (here, the controller, the Pigeon file), "If you set this property's value to true, an iOS user can press links to preview" should just be "Whether to allow previews for"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion. I forget that just copy/pasting the native docs doesn't always translate well to dart style.

/// This property is available on devices that support 3D Touch.
///
/// Defaults to true.
Future<void> setAllowsLinkPreview(bool allow) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Let's put this right after setAllowsBackForwardNavigationGestures; we should move toward having all methods added at this subclass level being in one location, rather than scattered among the overrides.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved inspectable and onBackChanged as well

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @bparrishMines I believe you can still provide the second approval even though you've pushed changes.

@bparrishMines bparrishMines changed the title [webview_flutter_wkwebvie] Expose the allowsLinkPreview property in WKWebView for iOS [webview_flutter_wkwebview] Expose the allowsLinkPreview property in WKWebView for iOS Apr 17, 2025
Copy link
Contributor

@bparrishMines bparrishMines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bparrishMines bparrishMines added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 17, 2025
@auto-submit auto-submit bot merged commit ef956cc into flutter:main Apr 17, 2025
82 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Apr 21, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Apr 21, 2025
flutter/packages@2fcc403...ac21f53

2025-04-20 [email protected] Roll Flutter from
3ed38e2 to cfb887c (17 revisions) (flutter/packages#9118)
2025-04-19 [email protected] [various] Scrubs pre-SDK-21 Android
code (flutter/packages#9112)
2025-04-18 [email protected] Roll Flutter from
ecabb1a to 3ed38e2 (23 revisions) (flutter/packages#9114)
2025-04-18 [email protected] [flutter_svg] feat: Expose the
`colorMapper` property in `SvgPicture` (flutter/packages#9043)
2025-04-18 [email protected] [tool] Add initial file-based command
skipping (flutter/packages#8928)
2025-04-18 [email protected] [pigeon] Convert test plugins to SPM
(flutter/packages#9105)
2025-04-18 [email protected]
[webview_flutter] Adds support to control overscrolling
(flutter/packages#8451)
2025-04-17 [email protected] [in_app_purchase] add
Storefront.countryCode() and AppStore.sync() (flutter/packages#8900)
2025-04-17 [email protected]
[webview_flutter_wkwebview] Expose the allowsLinkPreview property in
WKWebView for iOS (flutter/packages#5029)
2025-04-17 [email protected]
[webview_flutter_android][webview_flutter_wkwebview] Adds platform
implementations to set over-scroll mode (flutter/packages#9101)
2025-04-17 [email protected]
[shared_preferences] Update AGP to 8.9.1 (flutter/packages#9106)
2025-04-17 [email protected] [pigeon] Adds
Kotlin lint tests to example code and fix lints (flutter/packages#9034)
2025-04-17 [email protected]
[video_player_avfoundation] enable more than 30 fps
(flutter/packages#7466)
2025-04-17 [email protected] Roll Flutter from
aef4718 to ecabb1a (25 revisions) (flutter/packages#9104)
2025-04-16 [email protected] [pigeon] Unify iOS and macOS test
plugins (flutter/packages#9100)
2025-04-16 [email protected] Roll Flutter from
db68c95 to aef4718 (7 revisions) (flutter/packages#9098)
2025-04-16 [email protected]
[webview_flutter_platform_interface] Adds method to set overscroll mode
(flutter/packages#9099)
2025-04-16 [email protected] Update `CODEOWNERS`
(flutter/packages#8984)
2025-04-16 [email protected] [google_sign_is] Update iOS SDK to
8.0 (flutter/packages#9081)
2025-04-16 [email protected] [camera_avfoundation]
Implementation swift migration (flutter/packages#8988)
2025-04-16 [email protected] [go_router]
Adds `caseSensitive` to `GoRoute` (flutter/packages#8992)
2025-04-16 [email protected] Manual roll Flutter from
30e53b0 to db68c95 (98 revisions) (flutter/packages#9092)
2025-04-15 [email protected] [tool] Run config-only build for
iOS/macOS native-test (flutter/packages#9080)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
CodixNinja pushed a commit to CodixNinja/flutter that referenced this pull request May 15, 2025
flutter/packages@2fcc403...ac21f53

2025-04-20 [email protected] Roll Flutter from
409a8ac to cd51fa3 (17 revisions) (flutter/packages#9118)
2025-04-19 [email protected] [various] Scrubs pre-SDK-21 Android
code (flutter/packages#9112)
2025-04-18 [email protected] Roll Flutter from
d0741df to 409a8ac (23 revisions) (flutter/packages#9114)
2025-04-18 [email protected] [flutter_svg] feat: Expose the
`colorMapper` property in `SvgPicture` (flutter/packages#9043)
2025-04-18 [email protected] [tool] Add initial file-based command
skipping (flutter/packages#8928)
2025-04-18 [email protected] [pigeon] Convert test plugins to SPM
(flutter/packages#9105)
2025-04-18 [email protected]
[webview_flutter] Adds support to control overscrolling
(flutter/packages#8451)
2025-04-17 [email protected] [in_app_purchase] add
Storefront.countryCode() and AppStore.sync() (flutter/packages#8900)
2025-04-17 [email protected]
[webview_flutter_wkwebview] Expose the allowsLinkPreview property in
WKWebView for iOS (flutter/packages#5029)
2025-04-17 [email protected]
[webview_flutter_android][webview_flutter_wkwebview] Adds platform
implementations to set over-scroll mode (flutter/packages#9101)
2025-04-17 [email protected]
[shared_preferences] Update AGP to 8.9.1 (flutter/packages#9106)
2025-04-17 [email protected] [pigeon] Adds
Kotlin lint tests to example code and fix lints (flutter/packages#9034)
2025-04-17 [email protected]
[video_player_avfoundation] enable more than 30 fps
(flutter/packages#7466)
2025-04-17 [email protected] Roll Flutter from
9616f9c to d0741df (25 revisions) (flutter/packages#9104)
2025-04-16 [email protected] [pigeon] Unify iOS and macOS test
plugins (flutter/packages#9100)
2025-04-16 [email protected] Roll Flutter from
a7ce7ff to 9616f9c (7 revisions) (flutter/packages#9098)
2025-04-16 [email protected]
[webview_flutter_platform_interface] Adds method to set overscroll mode
(flutter/packages#9099)
2025-04-16 [email protected] Update `CODEOWNERS`
(flutter/packages#8984)
2025-04-16 [email protected] [google_sign_is] Update iOS SDK to
8.0 (flutter/packages#9081)
2025-04-16 [email protected] [camera_avfoundation]
Implementation swift migration (flutter/packages#8988)
2025-04-16 [email protected] [go_router]
Adds `caseSensitive` to `GoRoute` (flutter/packages#8992)
2025-04-16 [email protected] Manual roll Flutter from
f2d54fd to a7ce7ff (98 revisions) (flutter/packages#9092)
2025-04-15 [email protected] [tool] Run config-only build for
iOS/macOS native-test (flutter/packages#9080)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: webview_flutter platform-ios platform-macos
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants