-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[webview] Add macOS support in implementation package #6221
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bparrishMines I'm curious what you think of this approach to handle the fact that WKWebView
has a different base class on iOS vs macOS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this approach for sharing code between the platforms. Especially the part of creating a platform agnostic WKWebView
class. I can also see this working if we need to add the NSView
class for macOS. Although I'm not sure how this translates for the Pigeon wrapper generator since the Dart classes would become completely generated.
const WebKitProxy({ | ||
this.createWebView = WKWebView.new, | ||
WebKitProxy({ | ||
WebViewConstructor? createWebView, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bparrishMines Unfortunately I had to make this non-const because of the Platform
switch. Better ideas welcome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to set this with a constant Function. Either by putting (Platform.isIOS ? WKWebViewIOS.new : WKWebViewMacOS.new);
in a static method or a top-level function.
I've also have been waiting for this feature! : dart-lang/language#1048
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tip! I've re-added the consts I removed.
Unfortunately I had to duplicate all the arguments, because I couldn't make a static function that returned Platform.isIOS ? WKWebViewIOS.new : WKWebViewMacOS.new
and then call that because it still didn't want me calling the function in the const constructor, so I had to instead make it a wrapper that calls the right constructor each time, passing all the args through. (If I missed a way to make that work please let me know!)
Future<String?> getCustomUserAgent() { | ||
return _webViewApi.getCustomUserAgentForInstances(this); | ||
/// The iOS version of a WKWebView. | ||
class WKWebViewIOS extends WKWebView implements UIView { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bparrishMines This is the other half of how I'm handling the different parenting: the non-abstract classes are these subclasses which are different for the two platforms.
f2854bf
to
ad794b4
Compare
This is blocked on Flutter |
@stuartmorgan Does this mean that the branch will be merged into a future version of Flutter, not 3.24? We're looking forward to using macos webview in one of our projects, so I'm trying to understand the future of it to adjust our own expectations or start looking for a workaround. Thank you very much. |
|
@stuartmorgan they mean when will the package |
I'm not going to assume that I know that someone means something very different from what they said, so I answered the question they actually asked.
It will land when it's no longer blocked; see my recent comment. |
what do you expected the version number to be on the branch main? @stuartmorgan |
flutter/packages@7c1a05c...4d2d2e3 2024-08-20 [email protected] [webview] Add macOS support in implementation package (flutter/packages#6221) 2024-08-19 [email protected] Roll Flutter from a0c0453 to 6a28048 (22 revisions) (flutter/packages#7449) 2024-08-19 [email protected] [ci] Remove scorecard action (flutter/packages#7450) 2024-08-19 [email protected] [camerax] Re-land SurfaceProducer migration with fix for camera preview rotation (flutter/packages#6856) 2024-08-19 49699333+dependabot[bot]@users.noreply.github.com [camera]: Bump com.google.guava:guava from 33.2.1-android to 33.3.0-android in /packages/camera/camera_android_camerax/android (flutter/packages#7441) 2024-08-19 49699333+dependabot[bot]@users.noreply.github.com [sign_in]: Bump com.google.guava:guava from 33.2.1-android to 33.3.0-android in /packages/google_sign_in/google_sign_in_android/android (flutter/packages#7442) 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],[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
Bump Xcode analyze minimum check version iOS 13 -> iOS 14 and macOS 12.3 -> macOS 13. - Hit StoreKit2 deprecations. Exclude `in_app_purchase_storekit` to work around StoreKit 1 deprecation warnings. Added a TODO to remove the exclusion when StoreKit2 is adopted (this should happen in the next few weeks) flutter/flutter#116383. - Hit flutter/flutter#153587, fixed in #7513 - Hit flutter/flutter#125901 which was `#pragma`'d out in #6221 See related flutter/plugins#5778 and flutter/flutter#102835
flutter/packages@7c1a05c...4d2d2e3 2024-08-20 [email protected] [webview] Add macOS support in implementation package (flutter/packages#6221) 2024-08-19 [email protected] Roll Flutter from a0c0453 to 6a28048 (22 revisions) (flutter/packages#7449) 2024-08-19 [email protected] [ci] Remove scorecard action (flutter/packages#7450) 2024-08-19 [email protected] [camerax] Re-land SurfaceProducer migration with fix for camera preview rotation (flutter/packages#6856) 2024-08-19 49699333+dependabot[bot]@users.noreply.github.com [camera]: Bump com.google.guava:guava from 33.2.1-android to 33.3.0-android in /packages/camera/camera_android_camerax/android (flutter/packages#7441) 2024-08-19 49699333+dependabot[bot]@users.noreply.github.com [sign_in]: Bump com.google.guava:guava from 33.2.1-android to 33.3.0-android in /packages/google_sign_in/google_sign_in_android/android (flutter/packages#7442) 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],[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
Adds initial support for macOS.
Known limitations:
Since many use cases don't require these features, my preference is to land this without that support, rather than blocking on having full parity, and then the specific features can be added later based on community interest (demand and/or contributions).
This requires 3.24, as 3.22 does not yet have gesture support for macOS platform views, and pushing this to users without gesture support would be very confusing.
Part of flutter/flutter#41725