From e954a886cedea7ead43660fc3c63567a7a2ac619 Mon Sep 17 00:00:00 2001 From: Julien Deudon Date: Wed, 22 Dec 2021 11:27:52 +0100 Subject: [PATCH 1/3] chore(version): upgrade webview_flutter and set optional sourceType --- example/ios/Podfile | 41 ++++++++++++++++++++++++ example/lib/webview_page.dart | 7 ++--- example/pubspec.lock | 48 +++++++++++++++++++++++------ lib/src/controller/impl/mobile.dart | 7 ++--- lib/src/controller/impl/web.dart | 7 ++--- lib/src/controller/interface.dart | 4 +-- pubspec.lock | 48 +++++++++++++++++++++++------ pubspec.yaml | 2 +- 8 files changed, 129 insertions(+), 35 deletions(-) create mode 100644 example/ios/Podfile diff --git a/example/ios/Podfile b/example/ios/Podfile new file mode 100644 index 0000000..1e8c3c9 --- /dev/null +++ b/example/ios/Podfile @@ -0,0 +1,41 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '9.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/example/lib/webview_page.dart b/example/lib/webview_page.dart index 01e41b3..52a10c3 100644 --- a/example/lib/webview_page.dart +++ b/example/lib/webview_page.dart @@ -120,28 +120,27 @@ class _WebViewXPageState extends State { void _setUrl() { webviewController.loadContent( 'https://flutter.dev', - SourceType.url, ); } void _setUrlBypass() { webviewController.loadContent( 'https://news.ycombinator.com/', - SourceType.urlBypass, + sourceType: SourceType.urlBypass, ); } void _setHtml() { webviewController.loadContent( initialContent, - SourceType.html, + sourceType: SourceType.html, ); } void _setHtmlFromAssets() { webviewController.loadContent( 'assets/test.html', - SourceType.html, + sourceType: SourceType.html, fromAssets: true, ); } diff --git a/example/pubspec.lock b/example/pubspec.lock index 9f356e2..139da31 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.8.2" boolean_selector: dependency: transitive description: @@ -21,14 +21,14 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -101,14 +101,14 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" path: dependency: transitive description: @@ -123,6 +123,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.11.0" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" pointer_interceptor: dependency: transitive description: @@ -176,7 +183,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.3" typed_data: dependency: transitive description: @@ -197,14 +204,35 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" webview_flutter: dependency: transitive description: name: webview_flutter url: "https://pub.dartlang.org" source: hosted - version: "2.0.13" + version: "3.0.0" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.2" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + url: "https://pub.dartlang.org" + source: hosted + version: "2.7.1" webviewx: dependency: "direct main" description: @@ -213,5 +241,5 @@ packages: source: path version: "0.2.1" sdks: - dart: ">=2.13.0 <3.0.0" - flutter: ">=2.0.0" + dart: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" diff --git a/lib/src/controller/impl/mobile.dart b/lib/src/controller/impl/mobile.dart index d3c2be9..d5b16b4 100644 --- a/lib/src/controller/impl/mobile.dart +++ b/lib/src/controller/impl/mobile.dart @@ -3,12 +3,11 @@ import 'dart:async' show Future; import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show rootBundle; import 'package:webview_flutter/webview_flutter.dart' as wf; +import 'package:webviewx/src/controller/interface.dart' as i; import 'package:webviewx/src/utils/html_utils.dart'; import 'package:webviewx/src/utils/source_type.dart'; import 'package:webviewx/src/utils/utils.dart'; -import 'package:webviewx/src/controller/interface.dart' as i; - /// Mobile implementation class WebViewXController extends ChangeNotifier implements i.WebViewXController { @@ -73,8 +72,8 @@ class WebViewXController extends ChangeNotifier /// @override Future loadContent( - String content, - SourceType sourceType, { + String content, { + SourceType sourceType = SourceType.url, Map? headers, Object? body, // NO-OP HERE bool fromAssets = false, diff --git a/lib/src/controller/impl/web.dart b/lib/src/controller/impl/web.dart index ec69923..fe87de3 100644 --- a/lib/src/controller/impl/web.dart +++ b/lib/src/controller/impl/web.dart @@ -4,13 +4,12 @@ import 'dart:js' as js; import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show rootBundle; +import 'package:webviewx/src/controller/interface.dart' as i; import 'package:webviewx/src/utils/logger.dart'; import 'package:webviewx/src/utils/source_type.dart'; import 'package:webviewx/src/utils/utils.dart'; import 'package:webviewx/src/utils/web_history.dart'; -import 'package:webviewx/src/controller/interface.dart' as i; - /// Web implementation class WebViewXController extends ChangeNotifier implements i.WebViewXController { @@ -80,8 +79,8 @@ class WebViewXController extends ChangeNotifier /// @override Future loadContent( - String content, - SourceType sourceType, { + String content, { + SourceType sourceType = SourceType.url, Map? headers, Object? body, bool fromAssets = false, diff --git a/lib/src/controller/interface.dart b/lib/src/controller/interface.dart index ebfe75a..e0d8187 100644 --- a/lib/src/controller/interface.dart +++ b/lib/src/controller/interface.dart @@ -39,8 +39,8 @@ abstract class WebViewXController { /// `body` is only used on the WEB version, when clicking on a submit button in a form /// Future loadContent( - String content, - SourceType sourceType, { + String content, { + SourceType sourceType = SourceType.url, Map? headers, Object? body, bool fromAssets = false, diff --git a/pubspec.lock b/pubspec.lock index e1c3fd8..0dfb33b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.8.2" boolean_selector: dependency: transitive description: @@ -21,14 +21,14 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.2.0" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" clock: dependency: transitive description: @@ -94,14 +94,14 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.10" + version: "0.12.11" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0" + version: "1.7.0" path: dependency: "direct main" description: @@ -116,6 +116,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.11.1" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" pointer_interceptor: dependency: "direct main" description: @@ -169,7 +176,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.3" typed_data: dependency: transitive description: @@ -190,14 +197,35 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.1.1" webview_flutter: dependency: "direct main" description: name: webview_flutter url: "https://pub.dartlang.org" source: hosted - version: "2.0.13" + version: "3.0.0" + webview_flutter_android: + dependency: transitive + description: + name: webview_flutter_android + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.2" + webview_flutter_platform_interface: + dependency: transitive + description: + name: webview_flutter_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + webview_flutter_wkwebview: + dependency: transitive + description: + name: webview_flutter_wkwebview + url: "https://pub.dartlang.org" + source: hosted + version: "2.7.1" sdks: - dart: ">=2.13.0 <3.0.0" - flutter: ">=2.0.0" + dart: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" diff --git a/pubspec.yaml b/pubspec.yaml index 7a05af0..615f17b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: path: ^1.8.0 pointer_interceptor: ^0.9.0+1 uuid: ^3.0.4 - webview_flutter: ^2.0.13 + webview_flutter: ^3.0.0 dev_dependencies: flutter_test: From 6c20502cc64847295d131df1f0ed10766e54e114 Mon Sep 17 00:00:00 2001 From: Julien Deudon Date: Wed, 22 Dec 2021 11:29:35 +0100 Subject: [PATCH 2/3] version: update webviewx version --- example/ios/Podfile | 41 ----------------------------------------- pubspec.yaml | 2 +- 2 files changed, 1 insertion(+), 42 deletions(-) delete mode 100644 example/ios/Podfile diff --git a/example/ios/Podfile b/example/ios/Podfile deleted file mode 100644 index 1e8c3c9..0000000 --- a/example/ios/Podfile +++ /dev/null @@ -1,41 +0,0 @@ -# Uncomment this line to define a global platform for your project -# platform :ios, '9.0' - -# CocoaPods analytics sends network stats synchronously affecting flutter build latency. -ENV['COCOAPODS_DISABLE_STATS'] = 'true' - -project 'Runner', { - 'Debug' => :debug, - 'Profile' => :release, - 'Release' => :release, -} - -def flutter_root - generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) - unless File.exist?(generated_xcode_build_settings_path) - raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" - end - - File.foreach(generated_xcode_build_settings_path) do |line| - matches = line.match(/FLUTTER_ROOT\=(.*)/) - return matches[1].strip if matches - end - raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" -end - -require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) - -flutter_ios_podfile_setup - -target 'Runner' do - use_frameworks! - use_modular_headers! - - flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) -end - -post_install do |installer| - installer.pods_project.targets.each do |target| - flutter_additional_ios_build_settings(target) - end -end diff --git a/pubspec.yaml b/pubspec.yaml index 615f17b..57c6023 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: webviewx description: A feature-rich cross-platform webview using webview_flutter for mobile and iframe for web. JS interop-ready. homepage: https://github.com/adrianflutur/webviewx -version: 0.2.1 +version: 0.2.2 environment: sdk: ">=2.12.0 <3.0.0" From 0927866bcd58599d1a7d5f12ca293f062129cbc0 Mon Sep 17 00:00:00 2001 From: Julien Deudon Date: Wed, 22 Dec 2021 11:42:46 +0100 Subject: [PATCH 3/3] chore(changelog): update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f9a350..7d8c107 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.2 + +- Update webview_flutter to 3.0.0 +- Controller loadContent method now have default url sourceType + ## 0.2.1 - Breaking change