From 097204c68a11b3762afc8ca994246294592c6e84 Mon Sep 17 00:00:00 2001 From: Konstantin Yeftifeyev Date: Fri, 27 Jan 2023 14:15:07 +0200 Subject: [PATCH] feat: Update Flutter WebView to v4 --- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Podfile | 2 +- example/ios/Podfile.lock | 26 ++++++++--------- example/ios/Runner.xcodeproj/project.pbxproj | 10 ++++--- example/ios/Runner/Info.plist | 4 +++ example/lib/main.dart | 7 +++++ packages/flutter_html_all/pubspec.yaml | 4 ++- packages/flutter_html_audio/pubspec.yaml | 2 +- .../lib/iframe_mobile.dart | 28 +++++++++++++------ packages/flutter_html_iframe/pubspec.yaml | 6 ++-- packages/flutter_html_math/pubspec.yaml | 2 +- packages/flutter_html_svg/pubspec.yaml | 2 +- packages/flutter_html_table/pubspec.yaml | 2 +- packages/flutter_html_video/pubspec.yaml | 6 ++-- pubspec.yaml | 2 +- 15 files changed, 65 insertions(+), 40 deletions(-) diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index f2872cf474..4f8d4d2456 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 9.0 + 11.0 diff --git a/example/ios/Podfile b/example/ios/Podfile index f7d6a5e68c..d207307f86 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '9.0' +# platform :ios, '11.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index ba2cda3073..f155351fe7 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,34 +1,34 @@ PODS: - Flutter (1.0.0) - - video_player (0.0.1): + - video_player_avfoundation (0.0.1): - Flutter - wakelock (0.0.1): - Flutter - - webview_flutter (0.0.1): + - webview_flutter_wkwebview (0.0.1): - Flutter DEPENDENCIES: - Flutter (from `Flutter`) - - video_player (from `.symlinks/plugins/video_player/ios`) + - video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/ios`) - wakelock (from `.symlinks/plugins/wakelock/ios`) - - webview_flutter (from `.symlinks/plugins/webview_flutter/ios`) + - webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`) EXTERNAL SOURCES: Flutter: :path: Flutter - video_player: - :path: ".symlinks/plugins/video_player/ios" + video_player_avfoundation: + :path: ".symlinks/plugins/video_player_avfoundation/ios" wakelock: :path: ".symlinks/plugins/wakelock/ios" - webview_flutter: - :path: ".symlinks/plugins/webview_flutter/ios" + webview_flutter_wkwebview: + :path: ".symlinks/plugins/webview_flutter_wkwebview/ios" SPEC CHECKSUMS: - Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a - video_player: 9cc823b1d9da7e8427ee591e8438bfbcde500e6e + Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 + video_player_avfoundation: e489aac24ef5cf7af82702979ed16f2a5ef84cff wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f - webview_flutter: 9f491a9b5a66f2573946a389b2677987b0ff8c0b + webview_flutter_wkwebview: b7e70ef1ddded7e69c796c7390ee74180182971f -PODFILE CHECKSUM: 8e679eca47255a8ca8067c4c67aab20e64cb974d +PODFILE CHECKSUM: 663715e941f9adb426e33bf9376914006f9ea95b -COCOAPODS: 1.11.2 +COCOAPODS: 1.11.3 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 8baf84a2b7..9398e43aea 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 50; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -211,6 +211,7 @@ /* Begin PBXShellScriptBuildPhase section */ 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -247,6 +248,7 @@ }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -335,7 +337,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -414,7 +416,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -463,7 +465,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 6641e74e9e..6a0b77fdac 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -43,5 +43,9 @@ io.flutter.embedded_views_preview YES + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + diff --git a/example/lib/main.dart b/example/lib/main.dart index 8ff39ed120..861e5c7402 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -37,6 +37,13 @@ const htmlData = r"""

Header 4

Header 5
Header 6
+

Iframe Support:

+

Ruby Support:

diff --git a/packages/flutter_html_all/pubspec.yaml b/packages/flutter_html_all/pubspec.yaml index 1dcd3b9910..cd14521161 100644 --- a/packages/flutter_html_all/pubspec.yaml +++ b/packages/flutter_html_all/pubspec.yaml @@ -11,13 +11,15 @@ dependencies: flutter: sdk: flutter html: '>=0.15.0 <1.0.0' - flutter_html: ^3.0.0-alpha.6 + flutter_html: ^3.0.0-alpha.7 flutter_html_audio: ^3.0.0-alpha.4 flutter_html_iframe: ^3.0.0-alpha.4 flutter_html_math: ^3.0.0-alpha.4 flutter_html_svg: ^3.0.0-alpha.4 flutter_html_table: ^3.0.0-alpha.4 flutter_html_video: ^3.0.0-alpha.5 +# flutter_html: +# path: ../.. # flutter_html_audio: # path: ../flutter_html_audio # flutter_html_iframe: diff --git a/packages/flutter_html_audio/pubspec.yaml b/packages/flutter_html_audio/pubspec.yaml index 94c9026752..0951e49f7d 100644 --- a/packages/flutter_html_audio/pubspec.yaml +++ b/packages/flutter_html_audio/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: flutter: sdk: flutter html: '>=0.15.0 <1.0.0' - flutter_html: ^3.0.0-alpha.6 + flutter_html: ^3.0.0-alpha.7 # flutter_html: # path: ../.. diff --git a/packages/flutter_html_iframe/lib/iframe_mobile.dart b/packages/flutter_html_iframe/lib/iframe_mobile.dart index f6fb7eb683..1cc6cc6da1 100644 --- a/packages/flutter_html_iframe/lib/iframe_mobile.dart +++ b/packages/flutter_html_iframe/lib/iframe_mobile.dart @@ -12,23 +12,33 @@ CustomRender iframeRender({NavigationDelegate? navigationDelegate}) => double.tryParse(context.tree.element?.attributes['width'] ?? ""); final givenHeight = double.tryParse(context.tree.element?.attributes['height'] ?? ""); + final controller = WebViewController() + ..setJavaScriptMode( + sandboxMode == null || sandboxMode == "allow-scripts" + ? JavaScriptMode.unrestricted + : JavaScriptMode.disabled, + ) + ..loadRequest( + Uri.parse(context.tree.element?.attributes['src'] ?? 'about:blank'), + ); + + if (navigationDelegate != null) { + controller.setNavigationDelegate(navigationDelegate); + } + return SizedBox( width: givenWidth ?? (givenHeight ?? 150) * 2, height: givenHeight ?? (givenWidth ?? 300) / 2, child: CssBoxWidget( style: context.style, childIsReplaced: true, - child: WebView( - initialUrl: context.tree.element?.attributes['src'], + child: WebViewWidget( key: key, - javascriptMode: - sandboxMode == null || sandboxMode == "allow-scripts" - ? JavascriptMode.unrestricted - : JavascriptMode.disabled, - navigationDelegate: navigationDelegate, - gestureRecognizers: { + controller: controller, + gestureRecognizers: >{ Factory( - () => VerticalDragGestureRecognizer()) + () => VerticalDragGestureRecognizer(), + ), }, ), ), diff --git a/packages/flutter_html_iframe/pubspec.yaml b/packages/flutter_html_iframe/pubspec.yaml index 5d281948e3..3e56fbf234 100644 --- a/packages/flutter_html_iframe/pubspec.yaml +++ b/packages/flutter_html_iframe/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_html_iframe description: This extension package allows the