From 3101b44c371b321e76c8ba5a2b541753c51db96b Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Tue, 22 Nov 2022 22:40:45 +0100 Subject: [PATCH] All PrintJobSettings properties are optionals, All PullToRefreshSettings properties are optionals, All WebAuthenticationSessionSettings properties are optionals, Automatically infer useShouldOverrideUrlLoading, useOnLoadResource, useOnDownloadStart, useShouldInterceptAjaxRequest, useShouldInterceptFetchRequest, useShouldInterceptRequest, useOnRenderProcessGone, useOnNavigationResponse settings if their value is null and the corresponding event is implemented by the WebView (InAppWebView and HeadlessInAppWebView, not InAppBrowser) before it's native initialization --- CHANGELOG.md | 19 + .../intercept_ajax_request.dart | 4 - .../intercept_fetch_request.dart | 4 - .../on_download_start_request.dart | 2 +- .../in_app_webview/on_load_resource.dart | 2 +- .../on_navigation_response.dart | 4 +- .../should_intercept_request.dart | 2 +- .../should_override_url_loading.dart | 4 - example/lib/in_app_webiew_example.screen.dart | 1 - .../headless_in_app_webview.dart | 43 +- lib/src/in_app_webview/in_app_webview.dart | 45 +- .../in_app_webview_settings.dart | 65 ++- .../in_app_webview_settings.g.dart | 82 ++- lib/src/print_job/main.dart | 2 +- lib/src/print_job/print_job_settings.dart | 202 ++----- lib/src/print_job/print_job_settings.g.dart | 539 ++++++++++++++++++ lib/src/pull_to_refresh/main.dart | 3 +- .../pull_to_refresh_settings.dart | 63 +- .../pull_to_refresh_settings.g.dart | 114 ++++ lib/src/web_authentication_session/main.dart | 3 +- .../web_authenticate_session_settings.dart | 35 +- .../web_authenticate_session_settings.g.dart | 65 +++ pubspec.yaml | 2 +- 23 files changed, 1022 insertions(+), 283 deletions(-) create mode 100644 lib/src/print_job/print_job_settings.g.dart create mode 100644 lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart create mode 100644 lib/src/web_authentication_session/web_authenticate_session_settings.g.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 17c23f50..77bc63d8 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## 6.0.0-beta.15 + +- Automatically infer `useShouldOverrideUrlLoading`, `useOnLoadResource`, `useOnDownloadStart`, `useShouldInterceptAjaxRequest`, `useShouldInterceptFetchRequest`, `useShouldInterceptRequest`, `useOnRenderProcessGone`, `useOnNavigationResponse` settings if their value is `null` and the corresponding event is implemented by the WebView (`InAppWebView` and `HeadlessInAppWebView`, not `InAppBrowser`) before it's native initialization. + +### BREAKING CHANGES + +- All `PrintJobSettings` properties are optionals +- All `PullToRefreshSettings` properties are optionals +- All `WebAuthenticationSessionSettings` properties are optionals + ## 6.0.0-beta.14 - Fixed User Script remove methods @@ -135,6 +145,15 @@ - Removed `URLProtectionSpace.iosIsProxy` property - `historyUrl` and `baseUrl` of `InAppWebViewInitialData` can be `null` +## 5.7.1+2 + +- Fixed Android `NullPointerException` on `InAppBrowserActivity.dispose` + +## 5.7.1+1 + +- Fixed User Script remove methods +- Fixed missing `break` statement on Android when parsing `ChromeCustomTabsOptions.displayMode` in Java code + ## 5.7.1 - Exposed "shared" property of HttpServer bind method to support more use-cases. (thanks to [LugonjaAleksandar](https://github.com/LugonjaAleksandar)) diff --git a/example/integration_test/in_app_webview/intercept_ajax_request.dart b/example/integration_test/in_app_webview/intercept_ajax_request.dart index 99c255b1..d65462ba 100644 --- a/example/integration_test/in_app_webview/intercept_ajax_request.dart +++ b/example/integration_test/in_app_webview/intercept_ajax_request.dart @@ -56,7 +56,6 @@ void interceptAjaxRequest() { """), initialSettings: InAppWebViewSettings( clearCache: true, - useShouldInterceptAjaxRequest: true, ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); @@ -146,7 +145,6 @@ void interceptAjaxRequest() { """), initialSettings: InAppWebViewSettings( clearCache: true, - useShouldInterceptAjaxRequest: true, ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); @@ -236,7 +234,6 @@ void interceptAjaxRequest() { """), initialSettings: InAppWebViewSettings( clearCache: true, - useShouldInterceptAjaxRequest: true, ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); @@ -324,7 +321,6 @@ void interceptAjaxRequest() { """), initialSettings: InAppWebViewSettings( clearCache: true, - useShouldInterceptAjaxRequest: true, ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); diff --git a/example/integration_test/in_app_webview/intercept_fetch_request.dart b/example/integration_test/in_app_webview/intercept_fetch_request.dart index 724a65fa..eb3a3979 100644 --- a/example/integration_test/in_app_webview/intercept_fetch_request.dart +++ b/example/integration_test/in_app_webview/intercept_fetch_request.dart @@ -65,7 +65,6 @@ void interceptFetchRequest() { """), initialSettings: InAppWebViewSettings( clearCache: true, - useShouldInterceptFetchRequest: true, ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); @@ -148,7 +147,6 @@ void interceptFetchRequest() { """), initialSettings: InAppWebViewSettings( clearCache: true, - useShouldInterceptFetchRequest: true, ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); @@ -231,7 +229,6 @@ void interceptFetchRequest() { """), initialSettings: InAppWebViewSettings( clearCache: true, - useShouldInterceptFetchRequest: true, ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); @@ -310,7 +307,6 @@ void interceptFetchRequest() { """), initialSettings: InAppWebViewSettings( clearCache: true, - useShouldInterceptFetchRequest: true, ), onWebViewCreated: (controller) { controllerCompleter.complete(controller); diff --git a/example/integration_test/in_app_webview/on_download_start_request.dart b/example/integration_test/in_app_webview/on_download_start_request.dart index 7343db4d..8801f03e 100644 --- a/example/integration_test/in_app_webview/on_download_start_request.dart +++ b/example/integration_test/in_app_webview/on_download_start_request.dart @@ -46,7 +46,7 @@ void onDownloadStartRequest() { """), initialSettings: - InAppWebViewSettings(clearCache: true, useOnDownloadStart: true), + InAppWebViewSettings(clearCache: true), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, diff --git a/example/integration_test/in_app_webview/on_load_resource.dart b/example/integration_test/in_app_webview/on_load_resource.dart index 8e744bc3..52dd9a4c 100644 --- a/example/integration_test/in_app_webview/on_load_resource.dart +++ b/example/integration_test/in_app_webview/on_load_resource.dart @@ -33,7 +33,7 @@ void onLoadResource() { initialFile: "test_assets/in_app_webview_on_load_resource_test.html", initialSettings: - InAppWebViewSettings(clearCache: true, useOnLoadResource: true), + InAppWebViewSettings(clearCache: true), onLoadStop: (controller, url) { pageLoaded.complete(); }, diff --git a/example/integration_test/in_app_webview/on_navigation_response.dart b/example/integration_test/in_app_webview/on_navigation_response.dart index 625cc53d..61c6f660 100644 --- a/example/integration_test/in_app_webview/on_navigation_response.dart +++ b/example/integration_test/in_app_webview/on_navigation_response.dart @@ -30,7 +30,7 @@ void onNavigationResponse() { key: GlobalKey(), initialUrlRequest: URLRequest(url: TEST_URL_1), initialSettings: - InAppWebViewSettings(useOnNavigationResponse: true), + InAppWebViewSettings(), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -65,7 +65,7 @@ void onNavigationResponse() { key: GlobalKey(), initialUrlRequest: URLRequest(url: TEST_URL_1), initialSettings: - InAppWebViewSettings(useOnNavigationResponse: true), + InAppWebViewSettings(), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, diff --git a/example/integration_test/in_app_webview/should_intercept_request.dart b/example/integration_test/in_app_webview/should_intercept_request.dart index 9cda2d28..e4c91259 100644 --- a/example/integration_test/in_app_webview/should_intercept_request.dart +++ b/example/integration_test/in_app_webview/should_intercept_request.dart @@ -46,7 +46,7 @@ void shouldInterceptRequest() { """), initialSettings: - InAppWebViewSettings(useShouldInterceptRequest: true), + InAppWebViewSettings(), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, diff --git a/example/integration_test/in_app_webview/should_override_url_loading.dart b/example/integration_test/in_app_webview/should_override_url_loading.dart index 9552e1d3..2f8681d1 100644 --- a/example/integration_test/in_app_webview/should_override_url_loading.dart +++ b/example/integration_test/in_app_webview/should_override_url_loading.dart @@ -39,7 +39,6 @@ void shouldOverrideUrlLoading() { }, initialSettings: InAppWebViewSettings( javaScriptEnabled: true, - useShouldOverrideUrlLoading: true, ), shouldOverrideUrlLoading: (controller, navigationAction) async { return (navigationAction.request.url!.host @@ -92,7 +91,6 @@ void shouldOverrideUrlLoading() { }, initialSettings: InAppWebViewSettings( javaScriptEnabled: true, - useShouldOverrideUrlLoading: true, ), shouldOverrideUrlLoading: (controller, navigationAction) async { var isFirstLoad = navigationAction.request.url!.scheme == "data"; @@ -151,7 +149,6 @@ void shouldOverrideUrlLoading() { }, initialSettings: InAppWebViewSettings( javaScriptEnabled: true, - useShouldOverrideUrlLoading: true, ), shouldOverrideUrlLoading: (controller, navigationAction) async { return (navigationAction.request.url!.host @@ -203,7 +200,6 @@ void shouldOverrideUrlLoading() { }, initialSettings: InAppWebViewSettings( javaScriptEnabled: true, - useShouldOverrideUrlLoading: true, ), shouldOverrideUrlLoading: (controller, navigationAction) async { var action = NavigationActionPolicy.CANCEL; diff --git a/example/lib/in_app_webiew_example.screen.dart b/example/lib/in_app_webiew_example.screen.dart index 2c704c19..2f56f4c7 100755 --- a/example/lib/in_app_webiew_example.screen.dart +++ b/example/lib/in_app_webiew_example.screen.dart @@ -17,7 +17,6 @@ class _InAppWebViewExampleScreenState extends State { InAppWebViewController? webViewController; InAppWebViewSettings settings = InAppWebViewSettings( - useShouldOverrideUrlLoading: true, mediaPlaybackRequiresUserGesture: false, allowsInlineMediaPlayback: true, iframeAllow: "camera; microphone", diff --git a/lib/src/in_app_webview/headless_in_app_webview.dart b/lib/src/in_app_webview/headless_in_app_webview.dart index 901b7df9..231342d0 100644 --- a/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/lib/src/in_app_webview/headless_in_app_webview.dart @@ -214,7 +214,12 @@ class HeadlessInAppWebView implements WebView, Disposable { } _started = true; - Map initialSettings = this.initialSettings?.toMap() ?? + final initialSettings = this.initialSettings; + if (initialSettings != null) { + _inferInitialSettings(initialSettings); + } + + Map settingsMap = initialSettings?.toMap() ?? // ignore: deprecated_member_use_from_same_package this.initialOptions?.toMap() ?? {}; @@ -233,7 +238,7 @@ class HeadlessInAppWebView implements WebView, Disposable { 'initialUrlRequest': this.initialUrlRequest?.toMap(), 'initialFile': this.initialFile, 'initialData': this.initialData?.toMap(), - 'initialSettings': initialSettings, + 'initialSettings': settingsMap, 'contextMenu': this.contextMenu?.toMap() ?? {}, 'windowId': this.windowId, 'implementation': this.implementation.toNativeValue(), @@ -246,6 +251,40 @@ class HeadlessInAppWebView implements WebView, Disposable { _running = true; } + void _inferInitialSettings(InAppWebViewSettings settings) { + if (this.shouldOverrideUrlLoading != null && + settings.useShouldOverrideUrlLoading == null) { + settings.useShouldOverrideUrlLoading = true; + } + if (this.onLoadResource != null && settings.useOnLoadResource == null) { + settings.useOnLoadResource = true; + } + if (this.onDownloadStartRequest != null && + settings.useOnDownloadStart == null) { + settings.useOnDownloadStart = true; + } + if (this.shouldInterceptAjaxRequest != null && + settings.useShouldInterceptAjaxRequest == null) { + settings.useShouldInterceptAjaxRequest = true; + } + if (this.shouldInterceptFetchRequest != null && + settings.useShouldInterceptFetchRequest == null) { + settings.useShouldInterceptFetchRequest = true; + } + if (this.shouldInterceptRequest != null && + settings.useShouldInterceptRequest == null) { + settings.useShouldInterceptRequest = true; + } + if (this.onRenderProcessGone != null && + settings.useOnRenderProcessGone == null) { + settings.useOnRenderProcessGone = true; + } + if (this.onNavigationResponse != null && + settings.useOnNavigationResponse == null) { + settings.useOnNavigationResponse = true; + } + } + ///Disposes the headless WebView. /// ///**Supported Platforms/Implementations**: diff --git a/lib/src/in_app_webview/in_app_webview.dart b/lib/src/in_app_webview/in_app_webview.dart index d27247fb..1e6de21b 100755 --- a/lib/src/in_app_webview/in_app_webview.dart +++ b/lib/src/in_app_webview/in_app_webview.dart @@ -624,7 +624,12 @@ class _InAppWebViewState extends State { @override Widget build(BuildContext context) { - Map initialSettings = widget.initialSettings?.toMap() ?? + final initialSettings = widget.initialSettings; + if (initialSettings != null) { + _inferInitialSettings(initialSettings); + } + + Map settingsMap = initialSettings?.toMap() ?? // ignore: deprecated_member_use_from_same_package widget.initialOptions?.toMap() ?? {}; @@ -692,7 +697,7 @@ class _InAppWebViewState extends State { 'initialUrlRequest': widget.initialUrlRequest?.toMap(), 'initialFile': widget.initialFile, 'initialData': widget.initialData?.toMap(), - 'initialSettings': initialSettings, + 'initialSettings': settingsMap, 'contextMenu': widget.contextMenu?.toMap() ?? {}, 'windowId': widget.windowId, 'headlessWebViewId': widget.headlessWebView?.isRunning() ?? false @@ -722,7 +727,7 @@ class _InAppWebViewState extends State { 'initialUrlRequest': widget.initialUrlRequest?.toMap(), 'initialFile': widget.initialFile, 'initialData': widget.initialData?.toMap(), - 'initialSettings': initialSettings, + 'initialSettings': settingsMap, 'contextMenu': widget.contextMenu?.toMap() ?? {}, 'windowId': widget.windowId, 'headlessWebViewId': widget.headlessWebView?.isRunning() ?? false @@ -801,4 +806,38 @@ class _InAppWebViewState extends State { widget.onWebViewCreated!(_controller!); } } + + void _inferInitialSettings(InAppWebViewSettings settings) { + if (widget.shouldOverrideUrlLoading != null && + settings.useShouldOverrideUrlLoading == null) { + settings.useShouldOverrideUrlLoading = true; + } + if (widget.onLoadResource != null && settings.useOnLoadResource == null) { + settings.useOnLoadResource = true; + } + if (widget.onDownloadStartRequest != null && + settings.useOnDownloadStart == null) { + settings.useOnDownloadStart = true; + } + if (widget.shouldInterceptAjaxRequest != null && + settings.useShouldInterceptAjaxRequest == null) { + settings.useShouldInterceptAjaxRequest = true; + } + if (widget.shouldInterceptFetchRequest != null && + settings.useShouldInterceptFetchRequest == null) { + settings.useShouldInterceptFetchRequest = true; + } + if (widget.shouldInterceptRequest != null && + settings.useShouldInterceptRequest == null) { + settings.useShouldInterceptRequest = true; + } + if (widget.onRenderProcessGone != null && + settings.useOnRenderProcessGone == null) { + settings.useOnRenderProcessGone = true; + } + if (widget.onNavigationResponse != null && + settings.useOnNavigationResponse == null) { + settings.useOnNavigationResponse = true; + } + } } diff --git a/lib/src/in_app_webview/in_app_webview_settings.dart b/lib/src/in_app_webview/in_app_webview_settings.dart index 00914197..91fabfa9 100755 --- a/lib/src/in_app_webview/in_app_webview_settings.dart +++ b/lib/src/in_app_webview/in_app_webview_settings.dart @@ -32,6 +32,7 @@ import 'webview.dart'; import '../android/webview_feature.dart'; import '../in_app_webview/in_app_webview_controller.dart'; import '../context_menu.dart'; +import '../in_app_browser/in_app_browser.dart'; part 'in_app_webview_settings.g.dart'; @@ -51,7 +52,11 @@ List _deserializeContentBlockers( ///This class represents all the WebView settings available. @ExchangeableObject(copyMethod: true) class InAppWebViewSettings_ { - ///Set to `true` to be able to listen at the [WebView.shouldOverrideUrlLoading] event. The default value is `false`. + ///Set to `true` to be able to listen at the [WebView.shouldOverrideUrlLoading] event. + /// + ///If the [WebView.shouldOverrideUrlLoading] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -59,7 +64,11 @@ class InAppWebViewSettings_ { ///- MacOS bool? useShouldOverrideUrlLoading; - ///Set to `true` to be able to listen at the [WebView.onLoadResource] event. The default value is `false`. + ///Set to `true` to be able to listen at the [WebView.onLoadResource] event. + /// + ///If the [WebView.onLoadResource] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -67,7 +76,11 @@ class InAppWebViewSettings_ { ///- MacOS bool? useOnLoadResource; - ///Set to `true` to be able to listen at the [WebView.onDownloadStartRequest] event. The default value is `false`. + ///Set to `true` to be able to listen at the [WebView.onDownloadStartRequest] event. + /// + ///If the [WebView.onDownloadStartRequest] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -202,7 +215,11 @@ class InAppWebViewSettings_ { ///- MacOS UserPreferredContentMode_? preferredContentMode; - ///Set to `true` to be able to listen at the [WebView.shouldInterceptAjaxRequest] event. The default value is `false`. + ///Set to `true` to be able to listen at the [WebView.shouldInterceptAjaxRequest] event. + /// + ///If the [WebView.shouldInterceptAjaxRequest] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -210,7 +227,11 @@ class InAppWebViewSettings_ { ///- MacOS bool? useShouldInterceptAjaxRequest; - ///Set to `true` to be able to listen at the [WebView.shouldInterceptFetchRequest] event. The default value is `false`. + ///Set to `true` to be able to listen at the [WebView.shouldInterceptFetchRequest] event. + /// + ///If the [WebView.shouldInterceptFetchRequest] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -630,13 +651,21 @@ class InAppWebViewSettings_ { ///- Android native WebView bool? useHybridComposition; - ///Set to `true` to be able to listen at the [WebView.shouldInterceptRequest] event. The default value is `false`. + ///Set to `true` to be able to listen at the [WebView.shouldInterceptRequest] event. + /// + ///If the [WebView.shouldInterceptRequest] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView bool? useShouldInterceptRequest; - ///Set to `true` to be able to listen at the [WebView.onRenderProcessGone] event. The default value is `false`. + ///Set to `true` to be able to listen at the [WebView.onRenderProcessGone] event. + /// + ///If the [WebView.onRenderProcessGone] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -1034,7 +1063,11 @@ class InAppWebViewSettings_ { ///- MacOS bool? limitsNavigationsToAppBoundDomains; - ///Set to `true` to be able to listen to the [WebView.onNavigationResponse] event. The default value is `false`. + ///Set to `true` to be able to listen to the [WebView.onNavigationResponse] event. + /// + ///If the [WebView.onNavigationResponse] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- iOS @@ -1274,9 +1307,9 @@ class InAppWebViewSettings_ { @ExchangeableObjectConstructor() InAppWebViewSettings_({ - this.useShouldOverrideUrlLoading = false, - this.useOnLoadResource = false, - this.useOnDownloadStart = false, + this.useShouldOverrideUrlLoading, + this.useOnLoadResource, + this.useOnDownloadStart, this.clearCache = false, this.userAgent = "", this.applicationNameForUserAgent = "", @@ -1289,8 +1322,8 @@ class InAppWebViewSettings_ { this.resourceCustomSchemes = const [], this.contentBlockers = const [], this.preferredContentMode = UserPreferredContentMode_.RECOMMENDED, - this.useShouldInterceptAjaxRequest = false, - this.useShouldInterceptFetchRequest = false, + this.useShouldInterceptAjaxRequest, + this.useShouldInterceptFetchRequest, this.incognito = false, this.cacheEnabled = true, this.transparentBackground = false, @@ -1342,8 +1375,8 @@ class InAppWebViewSettings_ { this.supportMultipleWindows = false, this.regexToCancelSubFramesLoading, this.useHybridComposition = true, - this.useShouldInterceptRequest = false, - this.useOnRenderProcessGone = false, + this.useShouldInterceptRequest, + this.useOnRenderProcessGone, this.overScrollMode = OverScrollMode_.IF_CONTENT_SCROLLS, this.networkAvailable, this.scrollBarStyle = ScrollBarStyle_.SCROLLBARS_INSIDE_OVERLAY, @@ -1390,7 +1423,7 @@ class InAppWebViewSettings_ { this.mediaType, this.pageZoom = 1.0, this.limitsNavigationsToAppBoundDomains = false, - this.useOnNavigationResponse = false, + this.useOnNavigationResponse, this.applePayAPIEnabled = false, this.allowingReadAccessTo, this.disableLongPressContextMenuOnLinks = false, diff --git a/lib/src/in_app_webview/in_app_webview_settings.g.dart b/lib/src/in_app_webview/in_app_webview_settings.g.dart index 3e9af0ce..5db22865 100644 --- a/lib/src/in_app_webview/in_app_webview_settings.g.dart +++ b/lib/src/in_app_webview/in_app_webview_settings.g.dart @@ -8,7 +8,11 @@ part of 'in_app_webview_settings.dart'; ///This class represents all the WebView settings available. class InAppWebViewSettings { - ///Set to `true` to be able to listen at the [WebView.shouldOverrideUrlLoading] event. The default value is `false`. + ///Set to `true` to be able to listen at the [WebView.shouldOverrideUrlLoading] event. + /// + ///If the [WebView.shouldOverrideUrlLoading] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -16,7 +20,11 @@ class InAppWebViewSettings { ///- MacOS bool? useShouldOverrideUrlLoading; - ///Set to `true` to be able to listen at the [WebView.onLoadResource] event. The default value is `false`. + ///Set to `true` to be able to listen at the [WebView.onLoadResource] event. + /// + ///If the [WebView.onLoadResource] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -24,7 +32,11 @@ class InAppWebViewSettings { ///- MacOS bool? useOnLoadResource; - ///Set to `true` to be able to listen at the [WebView.onDownloadStartRequest] event. The default value is `false`. + ///Set to `true` to be able to listen at the [WebView.onDownloadStartRequest] event. + /// + ///If the [WebView.onDownloadStartRequest] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -158,7 +170,11 @@ class InAppWebViewSettings { ///- MacOS UserPreferredContentMode? preferredContentMode; - ///Set to `true` to be able to listen at the [WebView.shouldInterceptAjaxRequest] event. The default value is `false`. + ///Set to `true` to be able to listen at the [WebView.shouldInterceptAjaxRequest] event. + /// + ///If the [WebView.shouldInterceptAjaxRequest] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -166,7 +182,11 @@ class InAppWebViewSettings { ///- MacOS bool? useShouldInterceptAjaxRequest; - ///Set to `true` to be able to listen at the [WebView.shouldInterceptFetchRequest] event. The default value is `false`. + ///Set to `true` to be able to listen at the [WebView.shouldInterceptFetchRequest] event. + /// + ///If the [WebView.shouldInterceptFetchRequest] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -586,13 +606,21 @@ class InAppWebViewSettings { ///- Android native WebView bool? useHybridComposition; - ///Set to `true` to be able to listen at the [WebView.shouldInterceptRequest] event. The default value is `false`. + ///Set to `true` to be able to listen at the [WebView.shouldInterceptRequest] event. + /// + ///If the [WebView.shouldInterceptRequest] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView bool? useShouldInterceptRequest; - ///Set to `true` to be able to listen at the [WebView.onRenderProcessGone] event. The default value is `false`. + ///Set to `true` to be able to listen at the [WebView.onRenderProcessGone] event. + /// + ///If the [WebView.onRenderProcessGone] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- Android native WebView @@ -990,7 +1018,11 @@ class InAppWebViewSettings { ///- MacOS bool? limitsNavigationsToAppBoundDomains; - ///Set to `true` to be able to listen to the [WebView.onNavigationResponse] event. The default value is `false`. + ///Set to `true` to be able to listen to the [WebView.onNavigationResponse] event. + /// + ///If the [WebView.onNavigationResponse] event is implemented and this value is `null`, + ///it will be automatically inferred as `true`, otherwise, the default value is `false`. + ///This logic will not be applied for [InAppBrowser], where you must set the value manually. /// ///**Supported Platforms/Implementations**: ///- iOS @@ -1228,9 +1260,9 @@ class InAppWebViewSettings { ///- Web String? iframeCsp; InAppWebViewSettings( - {this.useShouldOverrideUrlLoading = false, - this.useOnLoadResource = false, - this.useOnDownloadStart = false, + {this.useShouldOverrideUrlLoading, + this.useOnLoadResource, + this.useOnDownloadStart, this.clearCache = false, this.userAgent = "", this.applicationNameForUserAgent = "", @@ -1243,8 +1275,8 @@ class InAppWebViewSettings { this.resourceCustomSchemes = const [], this.contentBlockers = const [], this.preferredContentMode = UserPreferredContentMode.RECOMMENDED, - this.useShouldInterceptAjaxRequest = false, - this.useShouldInterceptFetchRequest = false, + this.useShouldInterceptAjaxRequest, + this.useShouldInterceptFetchRequest, this.incognito = false, this.cacheEnabled = true, this.transparentBackground = false, @@ -1296,8 +1328,8 @@ class InAppWebViewSettings { this.supportMultipleWindows = false, this.regexToCancelSubFramesLoading, this.useHybridComposition = true, - this.useShouldInterceptRequest = false, - this.useOnRenderProcessGone = false, + this.useShouldInterceptRequest, + this.useOnRenderProcessGone, this.overScrollMode = OverScrollMode.IF_CONTENT_SCROLLS, this.networkAvailable, this.scrollBarStyle = ScrollBarStyle.SCROLLBARS_INSIDE_OVERLAY, @@ -1344,7 +1376,7 @@ class InAppWebViewSettings { this.mediaType, this.pageZoom = 1.0, this.limitsNavigationsToAppBoundDomains = false, - this.useOnNavigationResponse = false, + this.useOnNavigationResponse, this.applePayAPIEnabled = false, this.allowingReadAccessTo, this.disableLongPressContextMenuOnLinks = false, @@ -1393,7 +1425,12 @@ class InAppWebViewSettings { return null; } final instance = InAppWebViewSettings( + useShouldOverrideUrlLoading: map['useShouldOverrideUrlLoading'], + useOnLoadResource: map['useOnLoadResource'], + useOnDownloadStart: map['useOnDownloadStart'], minimumFontSize: map['minimumFontSize'], + useShouldInterceptAjaxRequest: map['useShouldInterceptAjaxRequest'], + useShouldInterceptFetchRequest: map['useShouldInterceptFetchRequest'], webViewAssetLoader: WebViewAssetLoader.fromMap( map['webViewAssetLoader']?.cast()), mixedContentMode: @@ -1403,6 +1440,8 @@ class InAppWebViewSettings { map['disabledActionModeMenuItems']), layoutAlgorithm: LayoutAlgorithm.fromNativeValue(map['layoutAlgorithm']), regexToCancelSubFramesLoading: map['regexToCancelSubFramesLoading'], + useShouldInterceptRequest: map['useShouldInterceptRequest'], + useOnRenderProcessGone: map['useOnRenderProcessGone'], networkAvailable: map['networkAvailable'], scrollBarDefaultDelayBeforeFade: map['scrollBarDefaultDelayBeforeFade'], scrollBarFadeDuration: map['scrollBarFadeDuration'], @@ -1430,6 +1469,7 @@ class InAppWebViewSettings { map['requestedWithHeaderMode']), defaultVideoPoster: map['defaultVideoPoster'], mediaType: map['mediaType'], + useOnNavigationResponse: map['useOnNavigationResponse'], allowingReadAccessTo: map['allowingReadAccessTo'] != null ? WebUri(map['allowingReadAccessTo']) : null, @@ -1451,9 +1491,6 @@ class InAppWebViewSettings { iframeName: map['iframeName'], iframeCsp: map['iframeCsp'], ); - instance.useShouldOverrideUrlLoading = map['useShouldOverrideUrlLoading']; - instance.useOnLoadResource = map['useOnLoadResource']; - instance.useOnDownloadStart = map['useOnDownloadStart']; instance.clearCache = map['clearCache']; instance.userAgent = map['userAgent']; instance.applicationNameForUserAgent = map['applicationNameForUserAgent']; @@ -1470,10 +1507,6 @@ class InAppWebViewSettings { _deserializeContentBlockers(map['contentBlockers']); instance.preferredContentMode = UserPreferredContentMode.fromNativeValue(map['preferredContentMode']); - instance.useShouldInterceptAjaxRequest = - map['useShouldInterceptAjaxRequest']; - instance.useShouldInterceptFetchRequest = - map['useShouldInterceptFetchRequest']; instance.incognito = map['incognito']; instance.cacheEnabled = map['cacheEnabled']; instance.transparentBackground = map['transparentBackground']; @@ -1522,8 +1555,6 @@ class InAppWebViewSettings { instance.hardwareAcceleration = map['hardwareAcceleration']; instance.supportMultipleWindows = map['supportMultipleWindows']; instance.useHybridComposition = map['useHybridComposition']; - instance.useShouldInterceptRequest = map['useShouldInterceptRequest']; - instance.useOnRenderProcessGone = map['useOnRenderProcessGone']; instance.overScrollMode = OverScrollMode.fromNativeValue(map['overScrollMode']); instance.scrollBarStyle = @@ -1577,7 +1608,6 @@ class InAppWebViewSettings { instance.pageZoom = map['pageZoom']; instance.limitsNavigationsToAppBoundDomains = map['limitsNavigationsToAppBoundDomains']; - instance.useOnNavigationResponse = map['useOnNavigationResponse']; instance.applePayAPIEnabled = map['applePayAPIEnabled']; instance.disableLongPressContextMenuOnLinks = map['disableLongPressContextMenuOnLinks']; diff --git a/lib/src/print_job/main.dart b/lib/src/print_job/main.dart index ba85e144..abfefc70 100644 --- a/lib/src/print_job/main.dart +++ b/lib/src/print_job/main.dart @@ -1,2 +1,2 @@ export 'print_job_controller.dart'; -export 'print_job_settings.dart'; +export 'print_job_settings.dart' show PrintJobSettings; diff --git a/lib/src/print_job/print_job_settings.dart b/lib/src/print_job/print_job_settings.dart index 2d06d794..622ee78a 100644 --- a/lib/src/print_job/print_job_settings.dart +++ b/lib/src/print_job/print_job_settings.dart @@ -1,12 +1,26 @@ import 'package:flutter/cupertino.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import '../types/main.dart'; +import '../types/print_job_color_mode.dart'; +import '../types/print_job_disposition.dart'; +import '../types/print_job_duplex_mode.dart'; +import '../types/print_job_media_size.dart'; +import '../types/print_job_orientation.dart'; +import '../types/print_job_output_type.dart'; +import '../types/print_job_page_order.dart'; +import '../types/print_job_pagination_mode.dart'; +import '../types/print_job_rendering_quality.dart'; +import '../types/print_job_resolution.dart'; import '../util.dart'; import '../web_uri.dart'; import 'print_job_controller.dart'; +part 'print_job_settings.g.dart'; + ///Class that represents the settings of a [PrintJobController]. -class PrintJobSettings { +@ExchangeableObject(copyMethod: true) +class PrintJobSettings_ { ///Set this to `true` to handle the [PrintJobController]. ///Otherwise, it will be handled and disposed automatically by the system. ///The default value is `false`. @@ -15,7 +29,7 @@ class PrintJobSettings { ///- Android native WebView ///- iOS ///- MacOS - bool handledByClient; + bool? handledByClient; ///The name of the print job. ///An application should set this property to a name appropriate to the content being printed. @@ -31,7 +45,7 @@ class PrintJobSettings { /// ///**Supported Platforms/Implementations**: ///- iOS - bool animated; + bool? animated; ///The orientation of the printed content, portrait or landscape. /// @@ -39,7 +53,7 @@ class PrintJobSettings { ///- Android native WebView ///- iOS ///- MacOS - PrintJobOrientation? orientation; + PrintJobOrientation_? orientation; ///The number of pages to render. /// @@ -54,7 +68,7 @@ class PrintJobSettings { /// ///**Supported Platforms/Implementations**: ///- iOS - PrintJobRenderingQuality? forceRenderingQuality; + PrintJobRenderingQuality_? forceRenderingQuality; ///The margins for each printed page. ///Margins define the white space around the content where the left margin defines @@ -69,14 +83,14 @@ class PrintJobSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - PrintJobMediaSize? mediaSize; + PrintJobMediaSize_? mediaSize; ///The color mode. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- MacOS - PrintJobColorMode? colorMode; + PrintJobColorMode_? colorMode; ///The duplex mode to use for the print job. /// @@ -85,19 +99,19 @@ class PrintJobSettings { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - PrintJobDuplexMode? duplexMode; + PrintJobDuplexMode_? duplexMode; ///The kind of printable content. /// ///**Supported Platforms/Implementations**: ///- iOS - PrintJobOutputType? outputType; + PrintJobOutputType_? outputType; ///The supported resolution in DPI (dots per inch). /// ///**Supported Platforms/Implementations**: ///- Android native WebView - PrintJobResolution? resolution; + PrintJobResolution_? resolution; ///A Boolean value that determines whether the printing options include the number of copies. ///The default value is `true`. @@ -105,7 +119,7 @@ class PrintJobSettings { ///**Supported Platforms/Implementations**: ///- iOS ///- MacOS - bool showsNumberOfCopies; + bool? showsNumberOfCopies; ///A Boolean value that determines whether the paper selection menu displays. ///The default value of this property is `false`. @@ -114,7 +128,7 @@ class PrintJobSettings { /// ///**Supported Platforms/Implementations**: ///- iOS - bool showsPaperSelectionForLoadedPapers; + bool? showsPaperSelectionForLoadedPapers; ///A Boolean value that determines whether the printing options include the paper orientation control when available. ///The default value is `true`. @@ -124,49 +138,49 @@ class PrintJobSettings { ///**Supported Platforms/Implementations**: ///- iOS ///- MacOS - bool showsPaperOrientation; + bool? showsPaperOrientation; ///A Boolean value that determines whether the print panel includes a control for manipulating the paper size of the printer. ///The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- MacOS - bool showsPaperSize; + bool? showsPaperSize; ///A Boolean value that determines whether the Print panel includes a control for scaling the printed output. ///The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- MacOS - bool showsScaling; + bool? showsScaling; ///A Boolean value that determines whether the Print panel includes a set of fields for manipulating the range of pages being printed. ///The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- MacOS - bool showsPageRange; + bool? showsPageRange; ///A Boolean value that determines whether the Print panel includes a separate accessory view for manipulating the paper size, orientation, and scaling attributes. ///The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- MacOS - bool showsPageSetupAccessory; + bool? showsPageSetupAccessory; ///A Boolean value that determines whether the Print panel displays a built-in preview of the document contents. ///The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- MacOS - bool showsPreview; + bool? showsPreview; ///A Boolean value that determines whether the Print panel includes an additional selection option for paper range. ///The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- MacOS - bool showsPrintSelection; + bool? showsPrintSelection; ///A Boolean value that determines whether the print operation displays a print panel. ///The default value is `true`. @@ -177,7 +191,7 @@ class PrintJobSettings { /// ///**Supported Platforms/Implementations**: ///- MacOS - bool showsPrintPanel; + bool? showsPrintPanel; ///A Boolean value that determines whether the print operation displays a progress panel. ///The default value is `true`. @@ -188,7 +202,7 @@ class PrintJobSettings { /// ///**Supported Platforms/Implementations**: ///- MacOS - bool showsProgressPanel; + bool? showsProgressPanel; ///The height of the page footer. /// @@ -239,7 +253,7 @@ class PrintJobSettings { /// ///**Supported Platforms/Implementations**: ///- MacOS - PrintJobDisposition? jobDisposition; + PrintJobDisposition_? jobDisposition; ///An URL containing the location to which the job file will be saved when the [jobDisposition] is [PrintJobDisposition.SAVE]. /// @@ -257,47 +271,47 @@ class PrintJobSettings { /// ///**Supported Platforms/Implementations**: ///- MacOS - PrintJobPaginationMode? horizontalPagination; + PrintJobPaginationMode_? horizontalPagination; ///The vertical pagination to the specified mode. /// ///**Supported Platforms/Implementations**: ///- MacOS - PrintJobPaginationMode? verticalPagination; + PrintJobPaginationMode_? verticalPagination; ///Indicates whether the image is centered horizontally. ///The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- MacOS - bool isHorizontallyCentered; + bool? isHorizontallyCentered; ///Indicates whether the image is centered vertically. ///The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- MacOS - bool isVerticallyCentered; + bool? isVerticallyCentered; ///The print order for the pages of the operation. /// ///**Supported Platforms/Implementations**: ///- MacOS - PrintJobPageOrder? pageOrder; + PrintJobPageOrder_? pageOrder; ///Whether the print operation should spawn a separate thread in which to run itself. ///The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- MacOS - bool canSpawnSeparateThread; + bool? canSpawnSeparateThread; ///How many copies to print. ///The default value is `1`. /// ///**Supported Platforms/Implementations**: ///- MacOS - int copies; + int? copies; ///An integer value that specifies the first page in the print job. /// @@ -316,7 +330,7 @@ class PrintJobSettings { /// ///**Supported Platforms/Implementations**: ///- MacOS - bool detailedErrorReporting; + bool? detailedErrorReporting; ///A fax number. /// @@ -329,7 +343,7 @@ class PrintJobSettings { /// ///**Supported Platforms/Implementations**: ///- MacOS - bool headerAndFooter; + bool? headerAndFooter; ///If `true`, collates output. /// @@ -355,7 +369,7 @@ class PrintJobSettings { ///- MacOS int? time; - PrintJobSettings( + PrintJobSettings_( {this.handledByClient = false, this.jobName, this.animated = true, @@ -403,128 +417,4 @@ class PrintJobSettings { this.pagesAcross, this.pagesDown, this.time}); - - ///Gets a [PrintJobSettings] instance from a [Map] value. - factory PrintJobSettings.fromMap(Map map) { - return PrintJobSettings( - handledByClient: map["handledByClient"], - jobName: map["jobName"], - animated: map["animated"], - orientation: PrintJobOrientation.fromNativeValue(map["orientation"]), - numberOfPages: map["numberOfPages"], - forceRenderingQuality: PrintJobRenderingQuality.fromNativeValue( - map["forceRenderingQuality"]), - margins: MapEdgeInsets.fromMap(map["margins"]?.cast()), - mediaSize: PrintJobMediaSize.fromMap( - map["mediaSize"]?.cast()), - colorMode: PrintJobColorMode.fromNativeValue(map["colorMode"]), - duplexMode: PrintJobDuplexMode.fromNativeValue(map["duplexMode"]), - outputType: PrintJobOutputType.fromNativeValue(map["outputType"]), - resolution: PrintJobResolution.fromMap( - map["resolution"]?.cast()), - showsNumberOfCopies: map["showsNumberOfCopies"], - showsPaperSelectionForLoadedPapers: - map["showsPaperSelectionForLoadedPapers"], - showsPaperOrientation: map["showsPaperOrientation"], - maximumContentHeight: map["maximumContentHeight"], - maximumContentWidth: map["maximumContentWidth"], - footerHeight: map["footerHeight"], - headerHeight: map["headerHeight"], - showsPaperSize: map["showsPaperSize"], - showsScaling: map["showsScaling"], - showsPageRange: map["showsPageRange"], - showsPageSetupAccessory: map["showsPageSetupAccessory"], - showsPreview: map["showsPreview"], - showsPrintSelection: map["showsPrintSelection"], - scalingFactor: map["scalingFactor"], - showsPrintPanel: map["showsPrintPanel"], - showsProgressPanel: map["showsProgressPanel"], - jobDisposition: - PrintJobDisposition.fromNativeValue(map["jobDisposition"]), - jobSavingURL: - map["jobSavingURL"] != null ? WebUri(map["jobSavingURL"]) : null, - paperName: map["paperName"], - horizontalPagination: - PrintJobPaginationMode.fromNativeValue(map["horizontalPagination"]), - verticalPagination: - PrintJobPaginationMode.fromNativeValue(map["verticalPagination"]), - isHorizontallyCentered: map["isHorizontallyCentered"], - isVerticallyCentered: map["isVerticallyCentered"], - pageOrder: PrintJobPageOrder.fromNativeValue(map["pageOrder"]), - canSpawnSeparateThread: map["canSpawnSeparateThread"], - copies: map["copies"], - firstPage: map["firstPage"], - lastPage: map["lastPage"], - detailedErrorReporting: map["detailedErrorReporting"], - faxNumber: map["faxNumber"], - headerAndFooter: map["headerAndFooter"], - mustCollate: map["mustCollate"], - pagesAcross: map["pagesAcross"], - pagesDown: map["pagesDown"], - time: map["time"]); - } - - Map toMap() { - return { - "handledByClient": handledByClient, - "jobName": jobName, - "animated": animated, - "orientation": orientation?.toNativeValue(), - "numberOfPages": numberOfPages, - "forceRenderingQuality": forceRenderingQuality?.toNativeValue(), - "margins": margins?.toMap(), - "mediaSize": mediaSize?.toMap(), - "colorMode": colorMode?.toNativeValue(), - "duplexMode": duplexMode?.toNativeValue(), - "outputType": outputType?.toNativeValue(), - "resolution": resolution?.toMap(), - "showsNumberOfCopies": showsNumberOfCopies, - "showsPaperSelectionForLoadedPapers": showsPaperSelectionForLoadedPapers, - "showsPaperOrientation": showsPaperOrientation, - "maximumContentHeight": maximumContentHeight, - "maximumContentWidth": maximumContentWidth, - "footerHeight": footerHeight, - "headerHeight": headerHeight, - "showsPaperSize": showsPaperSize, - "showsScaling": showsScaling, - "showsPageRange": showsPageRange, - "showsPageSetupAccessory": showsPageSetupAccessory, - "showsPreview": showsPreview, - "showsPrintSelection": showsPrintSelection, - "scalingFactor": scalingFactor, - "showsPrintPanel": showsPrintPanel, - "showsProgressPanel": showsProgressPanel, - "jobDisposition": jobDisposition?.toNativeValue(), - "jobSavingURL": jobSavingURL.toString(), - "paperName": paperName, - "horizontalPagination": horizontalPagination?.toNativeValue(), - "verticalPagination": verticalPagination?.toNativeValue(), - "isHorizontallyCentered": isHorizontallyCentered, - "isVerticallyCentered": isVerticallyCentered, - "pageOrder": pageOrder?.toNativeValue(), - "canSpawnSeparateThread": canSpawnSeparateThread, - "copies": copies, - "firstPage": firstPage, - "lastPage": lastPage, - "detailedErrorReporting": detailedErrorReporting, - "faxNumber": faxNumber, - "headerAndFooter": headerAndFooter, - "mustCollate": mustCollate, - "pagesAcross": pagesAcross, - "pagesDown": pagesDown, - "time": time - }; - } - - PrintJobSettings copy() { - return PrintJobSettings.fromMap(toMap()); - } - - Map toJson() { - return toMap(); - } - - String toString() { - return toMap().toString(); - } } diff --git a/lib/src/print_job/print_job_settings.g.dart b/lib/src/print_job/print_job_settings.g.dart new file mode 100644 index 00000000..8548a12d --- /dev/null +++ b/lib/src/print_job/print_job_settings.g.dart @@ -0,0 +1,539 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'print_job_settings.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the settings of a [PrintJobController]. +class PrintJobSettings { + ///Set this to `true` to handle the [PrintJobController]. + ///Otherwise, it will be handled and disposed automatically by the system. + ///The default value is `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + bool? handledByClient; + + ///The name of the print job. + ///An application should set this property to a name appropriate to the content being printed. + ///The default job name is the current webpage title concatenated with the "Document" word at the end. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + String? jobName; + + ///`true` to animate the display of the sheet, `false` to display the sheet immediately. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + bool? animated; + + ///The orientation of the printed content, portrait or landscape. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS + PrintJobOrientation? orientation; + + ///The number of pages to render. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + ///- MacOS + int? numberOfPages; + + ///Force rendering quality. + /// + ///**NOTE for iOS**: available only on iOS 14.5+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + PrintJobRenderingQuality? forceRenderingQuality; + + ///The margins for each printed page. + ///Margins define the white space around the content where the left margin defines + ///the amount of white space on the left of the content and so on. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + ///- MacOS + EdgeInsets? margins; + + ///The media size. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + PrintJobMediaSize? mediaSize; + + ///The color mode. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- MacOS + PrintJobColorMode? colorMode; + + ///The duplex mode to use for the print job. + /// + ///**NOTE for Android native WebView**: available only on Android 23+. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + PrintJobDuplexMode? duplexMode; + + ///The kind of printable content. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + PrintJobOutputType? outputType; + + ///The supported resolution in DPI (dots per inch). + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + PrintJobResolution? resolution; + + ///A Boolean value that determines whether the printing options include the number of copies. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + ///- MacOS + bool? showsNumberOfCopies; + + ///A Boolean value that determines whether the paper selection menu displays. + ///The default value of this property is `false`. + ///Setting the value to `true` enables a paper selection menu on printers that support different types of paper and have more than one paper type loaded. + ///On printers where only one paper type is available, no paper selection menu is displayed, regardless of the value of this property. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + bool? showsPaperSelectionForLoadedPapers; + + ///A Boolean value that determines whether the printing options include the paper orientation control when available. + ///The default value is `true`. + /// + ///**NOTE for iOS**: available only on iOS 15.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + ///- MacOS + bool? showsPaperOrientation; + + ///A Boolean value that determines whether the print panel includes a control for manipulating the paper size of the printer. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? showsPaperSize; + + ///A Boolean value that determines whether the Print panel includes a control for scaling the printed output. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? showsScaling; + + ///A Boolean value that determines whether the Print panel includes a set of fields for manipulating the range of pages being printed. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? showsPageRange; + + ///A Boolean value that determines whether the Print panel includes a separate accessory view for manipulating the paper size, orientation, and scaling attributes. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? showsPageSetupAccessory; + + ///A Boolean value that determines whether the Print panel displays a built-in preview of the document contents. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? showsPreview; + + ///A Boolean value that determines whether the Print panel includes an additional selection option for paper range. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? showsPrintSelection; + + ///A Boolean value that determines whether the print operation displays a print panel. + ///The default value is `true`. + /// + ///This property does not affect the display of a progress panel; + ///that operation is controlled by the [showsProgressPanel] property. + ///Operations that generate EPS or PDF data do no display a progress panel, regardless of the value in the flag parameter. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? showsPrintPanel; + + ///A Boolean value that determines whether the print operation displays a progress panel. + ///The default value is `true`. + /// + ///This property does not affect the display of a print panel; + ///that operation is controlled by the [showsPrintPanel] property. + ///Operations that generate EPS or PDF data do no display a progress panel, regardless of the value in the flag parameter. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? showsProgressPanel; + + ///The height of the page footer. + /// + ///The footer is measured in points from the bottom of [printableRect] and is below the content area. + ///The default footer height is `0.0`. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + double? footerHeight; + + ///The height of the page header. + /// + ///The header is measured in points from the top of [printableRect] and is above the content area. + ///The default header height is `0.0`. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + double? headerHeight; + + ///The maximum height of the content area. + /// + ///The Print Formatter uses this value to determine where the content rectangle begins on the first page. + ///It compares the value of this property with the printing rectangle’s height minus the header and footer heights and + ///the top inset value; it uses the lower of the two values. + ///The default value of this property is the maximum float value. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + double? maximumContentHeight; + + ///The maximum width of the content area. + /// + ///The Print Formatter uses this value to determine the maximum width of the content rectangle. + ///It compares the value of this property with the printing rectangle’s width minus the left and right inset values and uses the lower of the two. + ///The default value of this property is the maximum float value. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + double? maximumContentWidth; + + ///The current scaling factor. From `0.0` to `1.0`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + double? scalingFactor; + + ///The action specified for the job. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + PrintJobDisposition? jobDisposition; + + ///An URL containing the location to which the job file will be saved when the [jobDisposition] is [PrintJobDisposition.SAVE]. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + WebUri? jobSavingURL; + + ///The name of the currently selected paper size. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + String? paperName; + + ///The horizontal pagination mode. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + PrintJobPaginationMode? horizontalPagination; + + ///The vertical pagination to the specified mode. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + PrintJobPaginationMode? verticalPagination; + + ///Indicates whether the image is centered horizontally. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? isHorizontallyCentered; + + ///Indicates whether the image is centered vertically. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? isVerticallyCentered; + + ///The print order for the pages of the operation. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + PrintJobPageOrder? pageOrder; + + ///Whether the print operation should spawn a separate thread in which to run itself. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? canSpawnSeparateThread; + + ///How many copies to print. + ///The default value is `1`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? copies; + + ///An integer value that specifies the first page in the print job. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? firstPage; + + ///An integer value that specifies the last page in the print job. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? lastPage; + + ///If `true`, produce detailed reports when an error occurs. + ///The default value is `false`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? detailedErrorReporting; + + ///A fax number. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + String? faxNumber; + + ///If `true`, a standard header and footer are added outside the margins of each page. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? headerAndFooter; + + ///If `true`, collates output. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + bool? mustCollate; + + ///The number of logical pages to be tiled horizontally on a physical sheet of paper. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? pagesAcross; + + ///The number of logical pages to be tiled vertically on a physical sheet of paper. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? pagesDown; + + ///A timestamp that specifies the time at which printing should begin. + /// + ///**Supported Platforms/Implementations**: + ///- MacOS + int? time; + PrintJobSettings( + {this.handledByClient = false, + this.jobName, + this.animated = true, + this.orientation, + this.numberOfPages, + this.forceRenderingQuality, + this.margins, + this.mediaSize, + this.colorMode, + this.duplexMode, + this.outputType, + this.resolution, + this.showsNumberOfCopies = true, + this.showsPaperSelectionForLoadedPapers = false, + this.showsPaperOrientation = true, + this.showsPaperSize = true, + this.showsScaling = true, + this.showsPageRange = true, + this.showsPageSetupAccessory = true, + this.showsPreview = true, + this.showsPrintSelection = true, + this.showsPrintPanel = true, + this.showsProgressPanel = true, + this.footerHeight, + this.headerHeight, + this.maximumContentHeight, + this.maximumContentWidth, + this.scalingFactor, + this.jobDisposition, + this.jobSavingURL, + this.paperName, + this.horizontalPagination, + this.verticalPagination, + this.isHorizontallyCentered = true, + this.isVerticallyCentered = true, + this.pageOrder, + this.canSpawnSeparateThread = true, + this.copies = 1, + this.firstPage, + this.lastPage, + this.detailedErrorReporting = false, + this.faxNumber, + this.headerAndFooter = true, + this.mustCollate, + this.pagesAcross, + this.pagesDown, + this.time}); + + ///Gets a possible [PrintJobSettings] instance from a [Map] value. + static PrintJobSettings? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = PrintJobSettings( + jobName: map['jobName'], + orientation: PrintJobOrientation.fromNativeValue(map['orientation']), + numberOfPages: map['numberOfPages'], + forceRenderingQuality: PrintJobRenderingQuality.fromNativeValue( + map['forceRenderingQuality']), + margins: MapEdgeInsets.fromMap(map['margins']?.cast()), + mediaSize: + PrintJobMediaSize.fromMap(map['mediaSize']?.cast()), + colorMode: PrintJobColorMode.fromNativeValue(map['colorMode']), + duplexMode: PrintJobDuplexMode.fromNativeValue(map['duplexMode']), + outputType: PrintJobOutputType.fromNativeValue(map['outputType']), + resolution: PrintJobResolution.fromMap( + map['resolution']?.cast()), + footerHeight: map['footerHeight'], + headerHeight: map['headerHeight'], + maximumContentHeight: map['maximumContentHeight'], + maximumContentWidth: map['maximumContentWidth'], + scalingFactor: map['scalingFactor'], + jobDisposition: + PrintJobDisposition.fromNativeValue(map['jobDisposition']), + jobSavingURL: + map['jobSavingURL'] != null ? WebUri(map['jobSavingURL']) : null, + paperName: map['paperName'], + horizontalPagination: + PrintJobPaginationMode.fromNativeValue(map['horizontalPagination']), + verticalPagination: + PrintJobPaginationMode.fromNativeValue(map['verticalPagination']), + pageOrder: PrintJobPageOrder.fromNativeValue(map['pageOrder']), + firstPage: map['firstPage'], + lastPage: map['lastPage'], + faxNumber: map['faxNumber'], + mustCollate: map['mustCollate'], + pagesAcross: map['pagesAcross'], + pagesDown: map['pagesDown'], + time: map['time'], + ); + instance.handledByClient = map['handledByClient']; + instance.animated = map['animated']; + instance.showsNumberOfCopies = map['showsNumberOfCopies']; + instance.showsPaperSelectionForLoadedPapers = + map['showsPaperSelectionForLoadedPapers']; + instance.showsPaperOrientation = map['showsPaperOrientation']; + instance.showsPaperSize = map['showsPaperSize']; + instance.showsScaling = map['showsScaling']; + instance.showsPageRange = map['showsPageRange']; + instance.showsPageSetupAccessory = map['showsPageSetupAccessory']; + instance.showsPreview = map['showsPreview']; + instance.showsPrintSelection = map['showsPrintSelection']; + instance.showsPrintPanel = map['showsPrintPanel']; + instance.showsProgressPanel = map['showsProgressPanel']; + instance.isHorizontallyCentered = map['isHorizontallyCentered']; + instance.isVerticallyCentered = map['isVerticallyCentered']; + instance.canSpawnSeparateThread = map['canSpawnSeparateThread']; + instance.copies = map['copies']; + instance.detailedErrorReporting = map['detailedErrorReporting']; + instance.headerAndFooter = map['headerAndFooter']; + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "handledByClient": handledByClient, + "jobName": jobName, + "animated": animated, + "orientation": orientation?.toNativeValue(), + "numberOfPages": numberOfPages, + "forceRenderingQuality": forceRenderingQuality?.toNativeValue(), + "margins": margins?.toMap(), + "mediaSize": mediaSize?.toMap(), + "colorMode": colorMode?.toNativeValue(), + "duplexMode": duplexMode?.toNativeValue(), + "outputType": outputType?.toNativeValue(), + "resolution": resolution?.toMap(), + "showsNumberOfCopies": showsNumberOfCopies, + "showsPaperSelectionForLoadedPapers": showsPaperSelectionForLoadedPapers, + "showsPaperOrientation": showsPaperOrientation, + "showsPaperSize": showsPaperSize, + "showsScaling": showsScaling, + "showsPageRange": showsPageRange, + "showsPageSetupAccessory": showsPageSetupAccessory, + "showsPreview": showsPreview, + "showsPrintSelection": showsPrintSelection, + "showsPrintPanel": showsPrintPanel, + "showsProgressPanel": showsProgressPanel, + "footerHeight": footerHeight, + "headerHeight": headerHeight, + "maximumContentHeight": maximumContentHeight, + "maximumContentWidth": maximumContentWidth, + "scalingFactor": scalingFactor, + "jobDisposition": jobDisposition?.toNativeValue(), + "jobSavingURL": jobSavingURL?.toString(), + "paperName": paperName, + "horizontalPagination": horizontalPagination?.toNativeValue(), + "verticalPagination": verticalPagination?.toNativeValue(), + "isHorizontallyCentered": isHorizontallyCentered, + "isVerticallyCentered": isVerticallyCentered, + "pageOrder": pageOrder?.toNativeValue(), + "canSpawnSeparateThread": canSpawnSeparateThread, + "copies": copies, + "firstPage": firstPage, + "lastPage": lastPage, + "detailedErrorReporting": detailedErrorReporting, + "faxNumber": faxNumber, + "headerAndFooter": headerAndFooter, + "mustCollate": mustCollate, + "pagesAcross": pagesAcross, + "pagesDown": pagesDown, + "time": time, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + ///Returns a copy of PrintJobSettings. + PrintJobSettings copy() { + return PrintJobSettings.fromMap(toMap()) ?? PrintJobSettings(); + } + + @override + String toString() { + return 'PrintJobSettings{handledByClient: $handledByClient, jobName: $jobName, animated: $animated, orientation: $orientation, numberOfPages: $numberOfPages, forceRenderingQuality: $forceRenderingQuality, margins: $margins, mediaSize: $mediaSize, colorMode: $colorMode, duplexMode: $duplexMode, outputType: $outputType, resolution: $resolution, showsNumberOfCopies: $showsNumberOfCopies, showsPaperSelectionForLoadedPapers: $showsPaperSelectionForLoadedPapers, showsPaperOrientation: $showsPaperOrientation, showsPaperSize: $showsPaperSize, showsScaling: $showsScaling, showsPageRange: $showsPageRange, showsPageSetupAccessory: $showsPageSetupAccessory, showsPreview: $showsPreview, showsPrintSelection: $showsPrintSelection, showsPrintPanel: $showsPrintPanel, showsProgressPanel: $showsProgressPanel, footerHeight: $footerHeight, headerHeight: $headerHeight, maximumContentHeight: $maximumContentHeight, maximumContentWidth: $maximumContentWidth, scalingFactor: $scalingFactor, jobDisposition: $jobDisposition, jobSavingURL: $jobSavingURL, paperName: $paperName, horizontalPagination: $horizontalPagination, verticalPagination: $verticalPagination, isHorizontallyCentered: $isHorizontallyCentered, isVerticallyCentered: $isVerticallyCentered, pageOrder: $pageOrder, canSpawnSeparateThread: $canSpawnSeparateThread, copies: $copies, firstPage: $firstPage, lastPage: $lastPage, detailedErrorReporting: $detailedErrorReporting, faxNumber: $faxNumber, headerAndFooter: $headerAndFooter, mustCollate: $mustCollate, pagesAcross: $pagesAcross, pagesDown: $pagesDown, time: $time}'; + } +} diff --git a/lib/src/pull_to_refresh/main.dart b/lib/src/pull_to_refresh/main.dart index cb30f265..34d036cb 100644 --- a/lib/src/pull_to_refresh/main.dart +++ b/lib/src/pull_to_refresh/main.dart @@ -1,2 +1,3 @@ export 'pull_to_refresh_controller.dart'; -export 'pull_to_refresh_settings.dart'; +export 'pull_to_refresh_settings.dart' + show PullToRefreshSettings, PullToRefreshOptions; diff --git a/lib/src/pull_to_refresh/pull_to_refresh_settings.dart b/lib/src/pull_to_refresh/pull_to_refresh_settings.dart index 2347cc3f..c92d48b3 100644 --- a/lib/src/pull_to_refresh/pull_to_refresh_settings.dart +++ b/lib/src/pull_to_refresh/pull_to_refresh_settings.dart @@ -1,39 +1,63 @@ import 'dart:ui'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +import '../types/attributed_string.dart'; +import '../types/pull_to_refresh_size.dart'; import '../util.dart'; import '../types/main.dart'; +part 'pull_to_refresh_settings.g.dart'; + ///Pull-To-Refresh Settings -class PullToRefreshSettings { +@ExchangeableObject(copyMethod: true) +class PullToRefreshSettings_ { ///Sets whether the pull-to-refresh feature is enabled or not. - bool enabled; + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + bool? enabled; ///The color of the refresh control. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS Color? color; ///The background color of the refresh control. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS Color? backgroundColor; ///The distance to trigger a sync in dips. /// - ///**NOTE**: Available only on Android. + ///**Supported Platforms/Implementations**: + ///- Android native WebView int? distanceToTriggerSync; ///The distance in pixels that the refresh indicator can be pulled beyond its resting position. /// - ///**NOTE**: Available only on Android. + ///**Supported Platforms/Implementations**: + ///- Android native WebView int? slingshotDistance; ///The size of the refresh indicator. /// - ///**NOTE**: Available only on Android. - PullToRefreshSize? size; + ///**Supported Platforms/Implementations**: + ///- Android native WebView + PullToRefreshSize_? size; ///The title text to display in the refresh control. /// - ///**NOTE**: Available only on iOS. - AttributedString? attributedTitle; + ///**Supported Platforms/Implementations**: + ///- iOS + AttributedString_? attributedTitle; - PullToRefreshSettings( + PullToRefreshSettings_( {this.enabled = true, this.color, this.backgroundColor, @@ -41,27 +65,6 @@ class PullToRefreshSettings { this.slingshotDistance, this.size, this.attributedTitle}); - - Map toMap() { - return { - "enabled": enabled, - "color": color?.toHex(), - "backgroundColor": backgroundColor?.toHex(), - "distanceToTriggerSync": distanceToTriggerSync, - "slingshotDistance": slingshotDistance, - "size": size?.toNativeValue(), - "attributedTitle": attributedTitle?.toMap() ?? {} - }; - } - - Map toJson() { - return toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } ///Use [PullToRefreshSettings] instead. diff --git a/lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart b/lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart new file mode 100644 index 00000000..99fe4469 --- /dev/null +++ b/lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart @@ -0,0 +1,114 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'pull_to_refresh_settings.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Pull-To-Refresh Settings +class PullToRefreshSettings { + ///Sets whether the pull-to-refresh feature is enabled or not. + ///The default value is `true`. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + bool? enabled; + + ///The color of the refresh control. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + Color? color; + + ///The background color of the refresh control. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + Color? backgroundColor; + + ///The distance to trigger a sync in dips. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + int? distanceToTriggerSync; + + ///The distance in pixels that the refresh indicator can be pulled beyond its resting position. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + int? slingshotDistance; + + ///The size of the refresh indicator. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + PullToRefreshSize? size; + + ///The title text to display in the refresh control. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + AttributedString? attributedTitle; + PullToRefreshSettings( + {this.enabled = true, + this.color, + this.backgroundColor, + this.distanceToTriggerSync, + this.slingshotDistance, + this.size, + this.attributedTitle}); + + ///Gets a possible [PullToRefreshSettings] instance from a [Map] value. + static PullToRefreshSettings? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = PullToRefreshSettings( + color: map['color'] != null + ? UtilColor.fromStringRepresentation(map['color']) + : null, + backgroundColor: map['backgroundColor'] != null + ? UtilColor.fromStringRepresentation(map['backgroundColor']) + : null, + distanceToTriggerSync: map['distanceToTriggerSync'], + slingshotDistance: map['slingshotDistance'], + size: PullToRefreshSize.fromNativeValue(map['size']), + attributedTitle: AttributedString.fromMap( + map['attributedTitle']?.cast()), + ); + instance.enabled = map['enabled']; + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "enabled": enabled, + "color": color?.toHex(), + "backgroundColor": backgroundColor?.toHex(), + "distanceToTriggerSync": distanceToTriggerSync, + "slingshotDistance": slingshotDistance, + "size": size?.toNativeValue(), + "attributedTitle": attributedTitle?.toMap(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + ///Returns a copy of PullToRefreshSettings. + PullToRefreshSettings copy() { + return PullToRefreshSettings.fromMap(toMap()) ?? PullToRefreshSettings(); + } + + @override + String toString() { + return 'PullToRefreshSettings{enabled: $enabled, color: $color, backgroundColor: $backgroundColor, distanceToTriggerSync: $distanceToTriggerSync, slingshotDistance: $slingshotDistance, size: $size, attributedTitle: $attributedTitle}'; + } +} diff --git a/lib/src/web_authentication_session/main.dart b/lib/src/web_authentication_session/main.dart index 9f942e6e..38c587a4 100644 --- a/lib/src/web_authentication_session/main.dart +++ b/lib/src/web_authentication_session/main.dart @@ -1,2 +1,3 @@ export 'web_authenticate_session.dart'; -export 'web_authenticate_session_settings.dart'; +export 'web_authenticate_session_settings.dart' + show WebAuthenticationSessionSettings; diff --git a/lib/src/web_authentication_session/web_authenticate_session_settings.dart b/lib/src/web_authentication_session/web_authenticate_session_settings.dart index 34818929..ced5d74b 100755 --- a/lib/src/web_authentication_session/web_authenticate_session_settings.dart +++ b/lib/src/web_authentication_session/web_authenticate_session_settings.dart @@ -1,8 +1,11 @@ -import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'web_authenticate_session.dart'; +part 'web_authenticate_session_settings.g.dart'; + ///Class that represents the settings that can be used for a [WebAuthenticationSession]. -class WebAuthenticationSessionSettings { +@ExchangeableObject(copyMethod: true) +class WebAuthenticationSessionSettings_ { ///A Boolean value that indicates whether the session should ask the browser for a private authentication session. /// ///Set [prefersEphemeralWebBrowserSession] to `true` to request that the browser @@ -21,9 +24,9 @@ class WebAuthenticationSessionSettings { ///**Supported Platforms/Implementations**: ///- iOS ///- MacOS - bool prefersEphemeralWebBrowserSession; + bool? prefersEphemeralWebBrowserSession; - WebAuthenticationSessionSettings( + WebAuthenticationSessionSettings_( {this.prefersEphemeralWebBrowserSession = false}); Map toMap() { @@ -31,28 +34,4 @@ class WebAuthenticationSessionSettings { "prefersEphemeralWebBrowserSession": prefersEphemeralWebBrowserSession }; } - - static WebAuthenticationSessionSettings fromMap(Map map) { - WebAuthenticationSessionSettings settings = - new WebAuthenticationSessionSettings(); - if (defaultTargetPlatform == TargetPlatform.iOS || - defaultTargetPlatform == TargetPlatform.macOS) { - settings.prefersEphemeralWebBrowserSession = - map["prefersEphemeralWebBrowserSession"]; - } - return settings; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } - - WebAuthenticationSessionSettings copy() { - return WebAuthenticationSessionSettings.fromMap(this.toMap()); - } } diff --git a/lib/src/web_authentication_session/web_authenticate_session_settings.g.dart b/lib/src/web_authentication_session/web_authenticate_session_settings.g.dart new file mode 100644 index 00000000..5601a3a1 --- /dev/null +++ b/lib/src/web_authentication_session/web_authenticate_session_settings.g.dart @@ -0,0 +1,65 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'web_authenticate_session_settings.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the settings that can be used for a [WebAuthenticationSession]. +class WebAuthenticationSessionSettings { + ///A Boolean value that indicates whether the session should ask the browser for a private authentication session. + /// + ///Set [prefersEphemeralWebBrowserSession] to `true` to request that the browser + ///doesn’t share cookies or other browsing data between the authentication session and the user’s normal browser session. + ///Whether the request is honored depends on the user’s default web browser. + ///Safari always honors the request. + /// + ///The value of this property is `false` by default. + /// + ///Set this property before you call [WebAuthenticationSession.start]. Otherwise it has no effect. + /// + ///**NOTE for iOS**: Available only on iOS 13.0+. + /// + ///**NOTE for MacOS**: Available only on iOS 10.15+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + ///- MacOS + bool? prefersEphemeralWebBrowserSession; + WebAuthenticationSessionSettings( + {this.prefersEphemeralWebBrowserSession = false}); + + ///Gets a possible [WebAuthenticationSessionSettings] instance from a [Map] value. + static WebAuthenticationSessionSettings? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = WebAuthenticationSessionSettings(); + instance.prefersEphemeralWebBrowserSession = + map['prefersEphemeralWebBrowserSession']; + return instance; + } + + Map toMap() { + return { + "prefersEphemeralWebBrowserSession": prefersEphemeralWebBrowserSession + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + ///Returns a copy of WebAuthenticationSessionSettings. + WebAuthenticationSessionSettings copy() { + return WebAuthenticationSessionSettings.fromMap(toMap()) ?? + WebAuthenticationSessionSettings(); + } + + @override + String toString() { + return 'WebAuthenticationSessionSettings{prefersEphemeralWebBrowserSession: $prefersEphemeralWebBrowserSession}'; + } +} diff --git a/pubspec.yaml b/pubspec.yaml index 287fa7ec..9339ffcf 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window. -version: 6.0.0-beta.14 +version: 6.0.0-beta.15 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues