From 389cfe5a12dc8965f1cf29a5da7363f494140291 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Thu, 9 Jun 2022 10:36:13 +0200 Subject: [PATCH] converted other exchangable objects and enums --- CHANGELOG.md | 1 + .../webview/WebViewChannelDelegate.java | 5 +- .../src/exchangeable_object_generator.dart | 94 +++- .../test_gen/lib/src/types/test_class.dart | 3 + .../InAppBrowserWebViewController.swift | 2 +- .../FlutterWebViewController.swift | 2 +- .../InAppWebView/WebViewChannelDelegate.swift | 4 +- .../in_app_webview_controller.dart | 22 +- lib/src/types/ajax_request.g.dart | 45 +- lib/src/types/ajax_request_event.g.dart | 11 +- lib/src/types/attributed_string.g.dart | 107 ++--- .../types/call_async_javascript_result.g.dart | 7 +- lib/src/types/client_cert_challenge.dart | 2 +- lib/src/types/client_cert_challenge.g.dart | 15 +- lib/src/types/cookie.g.dart | 15 +- lib/src/types/create_window_action.g.dart | 12 +- .../types/css_link_html_tag_attributes.dart | 37 +- .../types/css_link_html_tag_attributes.g.dart | 93 ++++ lib/src/types/custom_scheme_response.dart | 28 +- lib/src/types/custom_scheme_response.g.dart | 56 +++ lib/src/types/custom_tabs_share_state.dart | 58 +-- lib/src/types/custom_tabs_share_state.g.dart | 85 ++++ lib/src/types/data_detector_types.dart | 134 ++---- lib/src/types/data_detector_types.g.dart | 220 +++++++++ lib/src/types/dismiss_button_style.dart | 112 +---- lib/src/types/dismiss_button_style.g.dart | 168 +++++++ lib/src/types/download_start_request.dart | 48 +- lib/src/types/download_start_request.g.dart | 79 +++ lib/src/types/favicon.dart | 29 +- lib/src/types/favicon.g.dart | 57 +++ lib/src/types/fetch_request.dart | 98 ++-- lib/src/types/fetch_request.g.dart | 115 +++++ lib/src/types/fetch_request_action.dart | 23 +- lib/src/types/fetch_request_action.g.dart | 79 +++ lib/src/types/fetch_request_credential.dart | 32 +- lib/src/types/fetch_request_credential.g.dart | 42 ++ .../fetch_request_credential_default.dart | 37 +- .../fetch_request_credential_default.g.dart | 44 ++ .../fetch_request_federated_credential.dart | 48 +- .../fetch_request_federated_credential.g.dart | 71 +++ .../fetch_request_password_credential.dart | 46 +- .../fetch_request_password_credential.g.dart | 61 +++ lib/src/types/force_dark.dart | 112 +---- lib/src/types/force_dark.g.dart | 169 +++++++ lib/src/types/force_dark_strategy.dart | 58 +-- lib/src/types/force_dark_strategy.g.dart | 97 ++++ lib/src/types/form_resubmission_action.dart | 38 +- lib/src/types/form_resubmission_action.g.dart | 79 +++ lib/src/types/frame_info.g.dart | 14 +- ...ation_permission_show_prompt_response.dart | 24 +- ...ion_permission_show_prompt_response.g.dart | 55 +++ lib/src/types/http_auth_response.dart | 34 +- lib/src/types/http_auth_response.g.dart | 60 +++ lib/src/types/http_auth_response_action.dart | 26 +- .../types/http_auth_response_action.g.dart | 86 ++++ .../types/http_authentication_challenge.dart | 68 +-- .../http_authentication_challenge.g.dart | 97 ++++ .../types/in_app_webview_hit_test_result.dart | 37 +- .../in_app_webview_hit_test_result.g.dart | 47 ++ .../in_app_webview_hit_test_result_type.dart | 83 +--- ...in_app_webview_hit_test_result_type.g.dart | 116 +++++ .../types/in_app_webview_initial_data.dart | 75 +-- .../types/in_app_webview_initial_data.g.dart | 80 ++++ lib/src/types/in_app_webview_rect.dart | 39 +- lib/src/types/in_app_webview_rect.g.dart | 63 +++ lib/src/types/js_alert_request.dart | 53 +- lib/src/types/js_alert_request.g.dart | 66 +++ lib/src/types/js_alert_response.dart | 33 +- lib/src/types/js_alert_response.g.dart | 60 +++ lib/src/types/js_alert_response_action.dart | 21 +- lib/src/types/js_alert_response_action.g.dart | 73 +++ lib/src/types/js_before_unload_request.dart | 35 +- lib/src/types/js_before_unload_request.g.dart | 47 ++ lib/src/types/js_before_unload_response.dart | 34 +- .../types/js_before_unload_response.g.dart | 67 +++ .../js_before_unload_response_action.dart | 23 +- .../js_before_unload_response_action.g.dart | 79 +++ lib/src/types/js_confirm_request.dart | 52 +- lib/src/types/js_confirm_request.g.dart | 66 +++ lib/src/types/js_confirm_response.dart | 32 +- lib/src/types/js_confirm_response.g.dart | 66 +++ lib/src/types/js_confirm_response_action.dart | 23 +- .../types/js_confirm_response_action.g.dart | 79 +++ lib/src/types/js_prompt_request.dart | 54 +-- lib/src/types/js_prompt_request.g.dart | 72 +++ lib/src/types/js_prompt_response.dart | 36 +- lib/src/types/js_prompt_response.g.dart | 79 +++ lib/src/types/js_prompt_response_action.dart | 23 +- .../types/js_prompt_response_action.g.dart | 79 +++ lib/src/types/layout_algorithm.dart | 97 +--- lib/src/types/layout_algorithm.g.dart | 159 ++++++ .../types/layout_in_display_cutout_mode.dart | 124 +---- .../layout_in_display_cutout_mode.g.dart | 197 ++++++++ lib/src/types/loaded_resource.dart | 41 +- lib/src/types/loaded_resource.g.dart | 58 +++ lib/src/types/login_request.dart | 36 +- lib/src/types/login_request.g.dart | 53 ++ lib/src/types/media_capture_state.dart | 58 +-- lib/src/types/media_capture_state.g.dart | 85 ++++ lib/src/types/media_playback_state.dart | 63 +-- lib/src/types/media_playback_state.g.dart | 91 ++++ lib/src/types/meta_tag.dart | 26 +- lib/src/types/meta_tag.g.dart | 53 ++ lib/src/types/meta_tag_attribute.dart | 27 +- lib/src/types/meta_tag_attribute.g.dart | 47 ++ lib/src/types/mixed_content_mode.dart | 112 +---- lib/src/types/mixed_content_mode.g.dart | 184 +++++++ lib/src/types/modal_presentation_style.dart | 182 ++----- lib/src/types/modal_presentation_style.g.dart | 254 ++++++++++ lib/src/types/modal_transition_style.dart | 121 +---- lib/src/types/modal_transition_style.g.dart | 189 ++++++++ lib/src/types/navigation_action.g.dart | 33 +- lib/src/types/navigation_action_policy.dart | 32 +- lib/src/types/navigation_action_policy.g.dart | 88 ++++ lib/src/types/navigation_response.dart | 81 +--- lib/src/types/navigation_response.g.dart | 106 ++++ lib/src/types/navigation_response_action.dart | 56 +-- .../types/navigation_response_action.g.dart | 163 +++++++ lib/src/types/over_scroll_mode.dart | 114 +---- lib/src/types/over_scroll_mode.g.dart | 168 +++++++ lib/src/types/pdf_configuration.dart | 48 +- lib/src/types/pdf_configuration.g.dart | 86 ++++ lib/src/types/permission_request.dart | 54 +-- lib/src/types/permission_request.g.dart | 57 +++ lib/src/types/permission_resource_type.dart | 182 +++---- lib/src/types/permission_resource_type.g.dart | 171 +++++++ lib/src/types/permission_response.dart | 57 +-- lib/src/types/permission_response.g.dart | 94 ++++ lib/src/types/permission_response_action.dart | 54 +-- .../types/permission_response_action.g.dart | 173 +++++++ lib/src/types/print_job_attributes.dart | 137 ++---- lib/src/types/print_job_attributes.g.dart | 171 +++++++ lib/src/types/print_job_color_mode.dart | 53 +- lib/src/types/print_job_color_mode.g.dart | 79 +++ lib/src/types/print_job_duplex_mode.dart | 92 +--- lib/src/types/print_job_duplex_mode.g.dart | 123 +++++ lib/src/types/print_job_info.dart | 56 +-- lib/src/types/print_job_info.g.dart | 108 +++++ lib/src/types/print_job_media_size.dart | 233 ++++----- lib/src/types/print_job_media_size.g.dart | 452 ++++++++++++++++++ lib/src/types/print_job_orientation.dart | 53 +- lib/src/types/print_job_orientation.g.dart | 79 +++ lib/src/types/print_job_output_type.dart | 63 +-- lib/src/types/print_job_output_type.g.dart | 101 ++++ .../types/print_job_rendering_quality.dart | 53 +- .../types/print_job_rendering_quality.g.dart | 80 ++++ lib/src/types/print_job_resolution.dart | 43 +- lib/src/types/print_job_resolution.g.dart | 69 +++ lib/src/types/print_job_state.dart | 159 +++--- lib/src/types/print_job_state.g.dart | 215 +++++++++ lib/src/types/proxy_rule.dart | 35 +- lib/src/types/proxy_rule.g.dart | 47 ++ lib/src/types/proxy_scheme_filter.dart | 48 +- lib/src/types/proxy_scheme_filter.g.dart | 77 +++ lib/src/types/pull_to_refresh_size.dart | 102 +--- lib/src/types/pull_to_refresh_size.g.dart | 153 ++++++ lib/src/types/referrer_policy.dart | 63 +-- lib/src/types/referrer_policy.g.dart | 110 +++++ lib/src/types/render_process_gone_detail.dart | 41 +- .../types/render_process_gone_detail.g.dart | 53 ++ lib/src/types/renderer_priority.dart | 58 +-- lib/src/types/renderer_priority.g.dart | 86 ++++ lib/src/types/renderer_priority_policy.dart | 41 +- lib/src/types/renderer_priority_policy.g.dart | 54 +++ .../types/request_focus_node_href_result.dart | 24 +- .../request_focus_node_href_result.g.dart | 52 ++ lib/src/types/request_image_ref_result.dart | 26 +- lib/src/types/request_image_ref_result.g.dart | 42 ++ lib/src/types/safe_browsing_response.dart | 28 +- lib/src/types/safe_browsing_response.g.dart | 49 ++ .../types/safe_browsing_response_action.dart | 25 +- .../safe_browsing_response_action.g.dart | 85 ++++ lib/src/types/safe_browsing_threat.dart | 68 +-- lib/src/types/safe_browsing_threat.g.dart | 105 ++++ lib/src/types/sandbox.dart | 75 ++- lib/src/types/sandbox.g.dart | 136 ++++++ lib/src/types/screenshot_configuration.dart | 38 +- lib/src/types/screenshot_configuration.g.dart | 93 ++++ lib/src/types/script_html_tag_attributes.dart | 43 +- .../types/script_html_tag_attributes.g.dart | 131 +++++ lib/src/types/scrollbar_style.dart | 122 +---- lib/src/types/scrollbar_style.g.dart | 205 ++++++++ ...iew_content_inset_adjustment_behavior.dart | 122 +---- ...w_content_inset_adjustment_behavior.g.dart | 191 ++++++++ .../types/scrollview_deceleration_rate.dart | 86 +--- .../types/scrollview_deceleration_rate.g.dart | 144 ++++++ lib/src/types/security_origin.dart | 62 +-- lib/src/types/security_origin.g.dart | 104 ++++ lib/src/types/selection_granularity.dart | 102 +--- lib/src/types/selection_granularity.g.dart | 153 ++++++ lib/src/types/server_trust_auth_response.dart | 26 +- .../types/server_trust_auth_response.g.dart | 42 ++ .../server_trust_auth_response_action.dart | 23 +- .../server_trust_auth_response_action.g.dart | 79 +++ lib/src/types/server_trust_challenge.dart | 20 +- lib/src/types/server_trust_challenge.g.dart | 43 ++ .../types/url_authentication_challenge.dart | 2 +- .../types/url_authentication_challenge.g.dart | 9 +- lib/src/types/url_credential.dart | 116 ++--- lib/src/types/url_credential.g.dart | 86 ++++ lib/src/types/url_credential_persistence.dart | 120 +---- .../types/url_credential_persistence.g.dart | 179 +++++++ lib/src/types/url_protection_space.g.dart | 40 +- lib/src/types/url_request.g.dart | 66 ++- lib/src/types/url_response.dart | 96 +--- lib/src/types/url_response.g.dart | 152 ++++++ lib/src/types/window_features.g.dart | 38 +- lib/src/web/in_app_web_view_web_element.dart | 2 +- 208 files changed, 11260 insertions(+), 4707 deletions(-) create mode 100644 lib/src/types/css_link_html_tag_attributes.g.dart create mode 100644 lib/src/types/custom_scheme_response.g.dart create mode 100644 lib/src/types/custom_tabs_share_state.g.dart create mode 100644 lib/src/types/data_detector_types.g.dart create mode 100644 lib/src/types/dismiss_button_style.g.dart create mode 100644 lib/src/types/download_start_request.g.dart create mode 100644 lib/src/types/favicon.g.dart create mode 100644 lib/src/types/fetch_request.g.dart create mode 100644 lib/src/types/fetch_request_action.g.dart create mode 100644 lib/src/types/fetch_request_credential.g.dart create mode 100644 lib/src/types/fetch_request_credential_default.g.dart create mode 100644 lib/src/types/fetch_request_federated_credential.g.dart create mode 100644 lib/src/types/fetch_request_password_credential.g.dart create mode 100644 lib/src/types/force_dark.g.dart create mode 100644 lib/src/types/force_dark_strategy.g.dart create mode 100644 lib/src/types/form_resubmission_action.g.dart create mode 100644 lib/src/types/geolocation_permission_show_prompt_response.g.dart create mode 100644 lib/src/types/http_auth_response.g.dart create mode 100644 lib/src/types/http_auth_response_action.g.dart create mode 100644 lib/src/types/http_authentication_challenge.g.dart create mode 100644 lib/src/types/in_app_webview_hit_test_result.g.dart create mode 100644 lib/src/types/in_app_webview_hit_test_result_type.g.dart create mode 100644 lib/src/types/in_app_webview_initial_data.g.dart create mode 100644 lib/src/types/in_app_webview_rect.g.dart create mode 100644 lib/src/types/js_alert_request.g.dart create mode 100644 lib/src/types/js_alert_response.g.dart create mode 100644 lib/src/types/js_alert_response_action.g.dart create mode 100644 lib/src/types/js_before_unload_request.g.dart create mode 100644 lib/src/types/js_before_unload_response.g.dart create mode 100644 lib/src/types/js_before_unload_response_action.g.dart create mode 100644 lib/src/types/js_confirm_request.g.dart create mode 100644 lib/src/types/js_confirm_response.g.dart create mode 100644 lib/src/types/js_confirm_response_action.g.dart create mode 100644 lib/src/types/js_prompt_request.g.dart create mode 100644 lib/src/types/js_prompt_response.g.dart create mode 100644 lib/src/types/js_prompt_response_action.g.dart create mode 100644 lib/src/types/layout_algorithm.g.dart create mode 100644 lib/src/types/layout_in_display_cutout_mode.g.dart create mode 100644 lib/src/types/loaded_resource.g.dart create mode 100644 lib/src/types/login_request.g.dart create mode 100644 lib/src/types/media_capture_state.g.dart create mode 100644 lib/src/types/media_playback_state.g.dart create mode 100644 lib/src/types/meta_tag.g.dart create mode 100644 lib/src/types/meta_tag_attribute.g.dart create mode 100644 lib/src/types/mixed_content_mode.g.dart create mode 100644 lib/src/types/modal_presentation_style.g.dart create mode 100644 lib/src/types/modal_transition_style.g.dart create mode 100644 lib/src/types/navigation_action_policy.g.dart create mode 100644 lib/src/types/navigation_response.g.dart create mode 100644 lib/src/types/navigation_response_action.g.dart create mode 100644 lib/src/types/over_scroll_mode.g.dart create mode 100644 lib/src/types/pdf_configuration.g.dart create mode 100644 lib/src/types/permission_request.g.dart create mode 100644 lib/src/types/permission_resource_type.g.dart create mode 100644 lib/src/types/permission_response.g.dart create mode 100644 lib/src/types/permission_response_action.g.dart create mode 100644 lib/src/types/print_job_attributes.g.dart create mode 100644 lib/src/types/print_job_color_mode.g.dart create mode 100644 lib/src/types/print_job_duplex_mode.g.dart create mode 100644 lib/src/types/print_job_info.g.dart create mode 100644 lib/src/types/print_job_media_size.g.dart create mode 100644 lib/src/types/print_job_orientation.g.dart create mode 100644 lib/src/types/print_job_output_type.g.dart create mode 100644 lib/src/types/print_job_rendering_quality.g.dart create mode 100644 lib/src/types/print_job_resolution.g.dart create mode 100644 lib/src/types/print_job_state.g.dart create mode 100644 lib/src/types/proxy_rule.g.dart create mode 100644 lib/src/types/proxy_scheme_filter.g.dart create mode 100644 lib/src/types/pull_to_refresh_size.g.dart create mode 100644 lib/src/types/referrer_policy.g.dart create mode 100644 lib/src/types/render_process_gone_detail.g.dart create mode 100644 lib/src/types/renderer_priority.g.dart create mode 100644 lib/src/types/renderer_priority_policy.g.dart create mode 100644 lib/src/types/request_focus_node_href_result.g.dart create mode 100644 lib/src/types/request_image_ref_result.g.dart create mode 100644 lib/src/types/safe_browsing_response.g.dart create mode 100644 lib/src/types/safe_browsing_response_action.g.dart create mode 100644 lib/src/types/safe_browsing_threat.g.dart create mode 100644 lib/src/types/sandbox.g.dart create mode 100644 lib/src/types/screenshot_configuration.g.dart create mode 100644 lib/src/types/script_html_tag_attributes.g.dart create mode 100644 lib/src/types/scrollbar_style.g.dart create mode 100644 lib/src/types/scrollview_content_inset_adjustment_behavior.g.dart create mode 100644 lib/src/types/scrollview_deceleration_rate.g.dart create mode 100644 lib/src/types/security_origin.g.dart create mode 100644 lib/src/types/selection_granularity.g.dart create mode 100644 lib/src/types/server_trust_auth_response.g.dart create mode 100644 lib/src/types/server_trust_auth_response_action.g.dart create mode 100644 lib/src/types/server_trust_challenge.g.dart create mode 100644 lib/src/types/url_credential.g.dart create mode 100644 lib/src/types/url_credential_persistence.g.dart create mode 100644 lib/src/types/url_response.g.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index bf48d2e3..9a5a9bca 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - On Android, the `InAppWebView` widget uses hybrid composition by default (`useHybridComposition: true`) - All properties of `GeolocationPermissionShowPromptResponse` cannot be `null` - Removed `URLProtectionSpace.iosIsProxy` property +- `historyUrl` and `baseUrl` of `InAppWebViewInitialData` can be `null` ## 5.4.3+7 diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegate.java b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegate.java index cd4744a5..66687315 100644 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegate.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegate.java @@ -925,8 +925,7 @@ public class WebViewChannelDelegate extends ChannelDelegateImpl { @Nullable @Override public NavigationActionPolicy decodeResult(@Nullable Object obj) { - Integer action = Util.getOrDefault((Map) obj, - "action", NavigationActionPolicy.CANCEL.rawValue()); + Integer action = obj instanceof Integer ? (Integer) obj : NavigationActionPolicy.CANCEL.rawValue(); return NavigationActionPolicy.fromValue(action); } } @@ -1067,7 +1066,7 @@ public class WebViewChannelDelegate extends ChannelDelegateImpl { @Nullable @Override public Integer decodeResult(@Nullable Object obj) { - return obj != null ? (Integer) ((Map) obj).get("action") : null; + return obj instanceof Integer ? (Integer) obj : null; } } diff --git a/dev_packages/generators/lib/src/exchangeable_object_generator.dart b/dev_packages/generators/lib/src/exchangeable_object_generator.dart index 56844ae7..aa567f4a 100644 --- a/dev_packages/generators/lib/src/exchangeable_object_generator.dart +++ b/dev_packages/generators/lib/src/exchangeable_object_generator.dart @@ -95,6 +95,15 @@ class ExchangeableObjectGenerator classBuffer.writeln( "@Deprecated('${_coreCheckerDeprecated.firstAnnotationOfExact(fieldElement)?.getField("message")?.toStringValue()}')"); } + if (fieldElement.isStatic) { + classBuffer.write("static "); + } + if (fieldElement.isFinal) { + classBuffer.write("final "); + } + if (fieldElement.isConst) { + classBuffer.write("const "); + } // remove class reference terminating with "_" classBuffer .write("${fieldElement.type.toString().replaceFirst("_", "")} "); @@ -104,7 +113,11 @@ class ExchangeableObjectGenerator ParsedLibraryResult parsed = fieldElement.session ?.getParsedLibraryByElement(fieldElement.library) as ParsedLibraryResult; - final fieldBody = parsed.getElementDeclaration(fieldElement)?.node; + final fieldBody = parsed + .getElementDeclaration(fieldElement) + ?.node + .toString() + .replaceAll(className, extClassName); classBuffer.writeln("$fieldBody;"); } } @@ -161,9 +174,15 @@ class ExchangeableObjectGenerator .replaceAll("@ExchangeableObjectConstructor()", "")); } } else if (constructorFields.length > 0) { + if (visitor.constructor.isConst) { + classBuffer.write('const '); + } classBuffer.writeln('$extClassName({'); classBuffer.writeln(constructorFields.join(', ')); } else { + if (visitor.constructor.isConst) { + classBuffer.write('const '); + } classBuffer.writeln('$extClassName('); } @@ -201,15 +220,21 @@ class ExchangeableObjectGenerator classBuffer.write('$fieldName = $fieldName ?? '); if (fieldTypeElement != null && deprecatedFieldTypeElement != null) { final isNullable = Util.typeIsNullable(fieldElement.type); - final deprecatedIsNullable = Util.typeIsNullable(deprecatedField.type); + final deprecatedIsNullable = + Util.typeIsNullable(deprecatedField.type); final hasFromMap = hasFromMapMethod(fieldTypeElement); - final hasFromNativeValue = hasFromNativeValueMethod(fieldTypeElement); + final hasFromNativeValue = + hasFromNativeValueMethod(fieldTypeElement); final hasFromValue = hasFromValueMethod(fieldTypeElement); - final deprecatedHasToMap = hasFromMapMethod(deprecatedFieldTypeElement); - final deprecatedHasToNativeValue = hasToNativeValueMethod(deprecatedFieldTypeElement); - final deprecatedHasToValue = hasToValueMethod(deprecatedFieldTypeElement); + final deprecatedHasToMap = + hasFromMapMethod(deprecatedFieldTypeElement); + final deprecatedHasToNativeValue = + hasToNativeValueMethod(deprecatedFieldTypeElement); + final deprecatedHasToValue = + hasToValueMethod(deprecatedFieldTypeElement); if (hasFromMap && deprecatedHasToMap) { - final hasNullableFromMap = hasNullableFromMapFactory(fieldTypeElement); + final hasNullableFromMap = + hasNullableFromMapFactory(fieldTypeElement); classBuffer.write(fieldTypeElement.name!.replaceFirst("_", "") + ".fromMap($deprecatedFieldName${deprecatedIsNullable ? '?' : ''}.toMap())${!isNullable && hasNullableFromMap ? '!' : ''}"); } else if (hasFromNativeValue && deprecatedHasToNativeValue) { @@ -254,7 +279,9 @@ class ExchangeableObjectGenerator final requiredFields = []; for (final fieldElement in fieldElements) { final fieldName = fieldElement.name; - if (!fieldElement.isPrivate) { + if (!fieldElement.isPrivate && + !fieldElement.isStatic && + !fieldElement.type.isDartCoreFunction) { var value = "map['$fieldName']"; final deprecationMessage = _coreCheckerDeprecated .firstAnnotationOfExact(fieldElement) @@ -273,19 +300,21 @@ class ExchangeableObjectGenerator ?.getField("deserializer") ?.toFunctionValue(); if (customDeserializer != null) { - final deserializerClassName = customDeserializer.enclosingElement.name; + final deserializerClassName = + customDeserializer.enclosingElement.name; if (deserializerClassName != null) { - value = "$deserializerClassName.${customDeserializer.name}($value)"; + value = + "$deserializerClassName.${customDeserializer.name}($value)"; } else { value = "${customDeserializer.name}($value)"; } } else { value = getFromMapValue(value, fieldElement.type); } - final constructorParameter = - visitor.constructorParameters[fieldName]; + final constructorParameter = visitor.constructorParameters[fieldName]; final isRequiredParameter = constructorParameter != null && (constructorParameter.isRequiredNamed || + constructorParameter.isFinal || !Util.typeIsNullable(constructorParameter.type)) && !constructorParameter.hasDefaultValue; if (isRequiredParameter) { @@ -332,19 +361,28 @@ class ExchangeableObjectGenerator final fieldElements = []; if (superClass != null) { for (final fieldElement in superClass.element.fields) { - if (!fieldElement.isPrivate && !fieldElement.hasDeprecated) { + if (!fieldElement.isPrivate && + !fieldElement.hasDeprecated && + !fieldElement.isStatic && + !fieldElement.type.isDartCoreFunction) { fieldElements.add(fieldElement); } } } for (final entry in visitor.fields.entries) { final fieldElement = entry.value; - if (!fieldElement.isPrivate && !fieldElement.hasDeprecated) { + if (!fieldElement.isPrivate && + !fieldElement.hasDeprecated && + !fieldElement.isStatic && + !fieldElement.type.isDartCoreFunction) { fieldElements.add(fieldElement); } } for (final fieldElement in fieldElements) { - if (!fieldElement.isPrivate && !fieldElement.hasDeprecated) { + if (!fieldElement.isPrivate && + !fieldElement.hasDeprecated && + !fieldElement.isStatic && + !fieldElement.type.isDartCoreFunction) { final fieldName = fieldElement.name; var mapValue = fieldName; final customSerializer = _coreCheckerObjectProperty @@ -354,7 +392,8 @@ class ExchangeableObjectGenerator if (customSerializer != null) { final serializerClassName = customSerializer.enclosingElement.name; if (serializerClassName != null) { - mapValue = "$serializerClassName.${customSerializer.name}($mapValue)"; + mapValue = + "$serializerClassName.${customSerializer.name}($mapValue)"; } else { mapValue = "${customSerializer.name}($mapValue)"; } @@ -386,7 +425,10 @@ class ExchangeableObjectGenerator if (superClass != null) { for (final fieldElement in superClass.element.fields) { final fieldName = fieldElement.name; - if (!fieldElement.isPrivate && !fieldElement.hasDeprecated) { + if (!fieldElement.isPrivate && + !fieldElement.hasDeprecated && + !fieldElement.isStatic && + !fieldElement.type.isDartCoreFunction) { fieldNames.add('$fieldName: \$$fieldName'); } } @@ -394,7 +436,10 @@ class ExchangeableObjectGenerator for (final entry in visitor.fields.entries) { final fieldName = entry.key; final fieldElement = entry.value; - if (!fieldElement.isPrivate && !fieldElement.hasDeprecated) { + if (!fieldElement.isPrivate && + !fieldElement.hasDeprecated && + !fieldElement.isStatic && + !fieldElement.type.isDartCoreFunction) { fieldNames.add('$fieldName: \$$fieldName'); } } @@ -412,7 +457,7 @@ class ExchangeableObjectGenerator final isNullable = Util.typeIsNullable(elementType); if (elementType.getDisplayString(withNullability: false) == "Uri") { if (!isNullable) { - return "Uri.parse($value)!"; + return "Uri.parse($value)"; } else { return "$value != null ? Uri.parse($value) : null"; } @@ -423,6 +468,11 @@ class ExchangeableObjectGenerator } else { return "$value != null ? UtilColor.fromStringRepresentation($value) : null"; } + } else if (elementType.getDisplayString(withNullability: false) == + "EdgeInsets") { + return "MapEdgeInsets.fromMap($value?.cast())${isNullable ? '!' : ''}"; + } else if (elementType.getDisplayString(withNullability: false) == "Size") { + return "MapSize.fromMap($value?.cast())${isNullable ? '!' : ''}"; } else if (elementType.getDisplayString(withNullability: false) == "DateTime") { if (!isNullable) { @@ -480,6 +530,11 @@ class ExchangeableObjectGenerator } else if (elementType.getDisplayString(withNullability: false) == "Color") { return fieldName + (isNullable ? '?' : '') + '.toHex()'; + } else if (elementType.getDisplayString(withNullability: false) == + "EdgeInsets") { + return fieldName + (isNullable ? '?' : '') + '.toMap()'; + } else if (elementType.getDisplayString(withNullability: false) == "Size") { + return fieldName + (isNullable ? '?' : '') + '.toMap()'; } else if (elementType.getDisplayString(withNullability: false) == "DateTime") { return fieldName + (isNullable ? '?' : '') + '.millisecondsSinceEpoch'; @@ -493,7 +548,6 @@ class ExchangeableObjectGenerator getToMapValue('$genericTypeFieldName', genericType) + ').toList()'; } else { - return fieldName; } } else if (fieldTypeElement != null && hasToMapMethod(fieldTypeElement)) { diff --git a/dev_packages/test_gen/lib/src/types/test_class.dart b/dev_packages/test_gen/lib/src/types/test_class.dart index 9f5556d1..a34064fb 100644 --- a/dev_packages/test_gen/lib/src/types/test_class.dart +++ b/dev_packages/test_gen/lib/src/types/test_class.dart @@ -28,6 +28,8 @@ class TestClass_ extends TestClass3_ { List? colors; + Function? onLoad; + ///Docs 3 @SupportedPlatforms(platforms: [ AndroidPlatform( @@ -55,6 +57,7 @@ class TestClass_ extends TestClass3_ { class TestClass3_ { String asd; + Function? onLoad; TestClass3_({required this.asd}); } diff --git a/ios/Classes/InAppBrowser/InAppBrowserWebViewController.swift b/ios/Classes/InAppBrowser/InAppBrowserWebViewController.swift index 07733470..3801196e 100755 --- a/ios/Classes/InAppBrowser/InAppBrowserWebViewController.swift +++ b/ios/Classes/InAppBrowser/InAppBrowserWebViewController.swift @@ -163,7 +163,7 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega } } else if let initialData = initialData { - let baseUrl = URL(string: initialBaseUrl!)! + let baseUrl = URL(string: initialBaseUrl ?? "about:blank")! var allowingReadAccessToURL: URL? = nil if let allowingReadAccessTo = webView?.settings?.allowingReadAccessTo, baseUrl.scheme == "file" { allowingReadAccessToURL = URL(string: allowingReadAccessTo) diff --git a/ios/Classes/InAppWebView/FlutterWebViewController.swift b/ios/Classes/InAppWebView/FlutterWebViewController.swift index bdabaa1e..a8e94268 100755 --- a/ios/Classes/InAppWebView/FlutterWebViewController.swift +++ b/ios/Classes/InAppWebView/FlutterWebViewController.swift @@ -148,7 +148,7 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView, Disposable let data = initialData["data"]! let mimeType = initialData["mimeType"]! let encoding = initialData["encoding"]! - let baseUrl = URL(string: initialData["baseUrl"]!)! + let baseUrl = URL(string: initialData["baseUrl"] ?? "about:blank")! var allowingReadAccessToURL: URL? = nil if let allowingReadAccessTo = webView.settings?.allowingReadAccessTo, baseUrl.scheme == "file" { allowingReadAccessToURL = URL(string: allowingReadAccessTo) diff --git a/ios/Classes/InAppWebView/WebViewChannelDelegate.swift b/ios/Classes/InAppWebView/WebViewChannelDelegate.swift index 78f83b89..761bc337 100644 --- a/ios/Classes/InAppWebView/WebViewChannelDelegate.swift +++ b/ios/Classes/InAppWebView/WebViewChannelDelegate.swift @@ -828,7 +828,7 @@ public class WebViewChannelDelegate : ChannelDelegate { override init() { super.init() self.decodeResult = { (obj: Any?) in - if let obj = obj as? [String: Any?], let action = obj["action"] as? Int { + if let action = obj as? Int { return WKNavigationActionPolicy.init(rawValue: action) ?? WKNavigationActionPolicy.cancel } return WKNavigationActionPolicy.cancel @@ -987,7 +987,7 @@ public class WebViewChannelDelegate : ChannelDelegate { override init() { super.init() self.decodeResult = { (obj: Any?) in - if let obj = obj as? [String: Any?], let action = obj["action"] as? Int { + if let action = obj as? Int { return WKNavigationResponsePolicy.init(rawValue: action) ?? WKNavigationResponsePolicy.cancel } return WKNavigationResponsePolicy.cancel diff --git a/lib/src/in_app_webview/in_app_webview_controller.dart b/lib/src/in_app_webview/in_app_webview_controller.dart index 385364f8..41d6bb74 100644 --- a/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/lib/src/in_app_webview/in_app_webview_controller.dart @@ -243,10 +243,10 @@ class InAppWebViewController { if (_webview != null && _webview!.shouldOverrideUrlLoading != null) return (await _webview!.shouldOverrideUrlLoading!( this, navigationAction)) - ?.toMap(); + ?.toNativeValue(); return (await _inAppBrowser! .shouldOverrideUrlLoading(navigationAction)) - ?.toMap(); + ?.toNativeValue(); } break; case "onConsoleMessage": @@ -525,17 +525,17 @@ class InAppWebViewController { if (_webview != null) { if (_webview!.onFormResubmission != null) - return (await _webview!.onFormResubmission!(this, uri))?.toMap(); + return (await _webview!.onFormResubmission!(this, uri))?.toNativeValue(); else { // ignore: deprecated_member_use_from_same_package return (await _webview!.androidOnFormResubmission!(this, uri)) - ?.toMap(); + ?.toNativeValue(); } } else { return ((await _inAppBrowser!.onFormResubmission(uri)) ?? // ignore: deprecated_member_use_from_same_package (await _inAppBrowser!.androidOnFormResubmission(uri))) - ?.toMap(); + ?.toNativeValue(); } } break; @@ -924,21 +924,21 @@ class InAppWebViewController { if (_webview!.onNavigationResponse != null) return (await _webview!.onNavigationResponse!( this, navigationResponse)) - ?.toMap(); + ?.toNativeValue(); else { // ignore: deprecated_member_use_from_same_package return (await _webview!.iosOnNavigationResponse!( this, iosOnNavigationResponse)) - ?.toMap(); + ?.toNativeValue(); } } else { return (await _inAppBrowser! .onNavigationResponse(navigationResponse)) - ?.toMap() ?? + ?.toNativeValue() ?? (await _inAppBrowser! // ignore: deprecated_member_use_from_same_package .iosOnNavigationResponse(iosOnNavigationResponse)) - ?.toMap(); + ?.toNativeValue(); } } break; @@ -3337,7 +3337,7 @@ class InAppWebViewController { ///- iOS ([Official API - WKWebView.setCameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763097-setcameracapturestate)). Future setCameraCaptureState({required MediaCaptureState state}) async { Map args = {}; - args.putIfAbsent('state', () => state.toValue()); + args.putIfAbsent('state', () => state.toNativeValue()); await _channel.invokeMethod('setCameraCaptureState', args); } @@ -3362,7 +3362,7 @@ class InAppWebViewController { Future setMicrophoneCaptureState( {required MediaCaptureState state}) async { Map args = {}; - args.putIfAbsent('state', () => state.toValue()); + args.putIfAbsent('state', () => state.toNativeValue()); await _channel.invokeMethod('setMicrophoneCaptureState', args); } diff --git a/lib/src/types/ajax_request.g.dart b/lib/src/types/ajax_request.g.dart index 224c5d37..6bc219c2 100644 --- a/lib/src/types/ajax_request.g.dart +++ b/lib/src/types/ajax_request.g.dart @@ -100,29 +100,28 @@ class AjaxRequest { if (map == null) { return null; } - final instance = AjaxRequest(); - instance.data = map['data']; - instance.method = map['method']; - instance.url = map['url'] != null ? Uri.parse(map['url']) : null; - instance.isAsync = map['isAsync']; - instance.user = map['user']; - instance.password = map['password']; - instance.withCredentials = map['withCredentials']; - instance.headers = - AjaxRequestHeaders.fromMap(map['headers']?.cast()); - instance.readyState = - AjaxRequestReadyState.fromNativeValue(map['readyState']); - instance.status = map['status']; - instance.responseURL = - map['responseURL'] != null ? Uri.parse(map['responseURL']) : null; - instance.responseType = map['responseType']; - instance.response = map['response']; - instance.responseText = map['responseText']; - instance.responseXML = map['responseXML']; - instance.statusText = map['statusText']; - instance.responseHeaders = map['responseHeaders']; - instance.event = - AjaxRequestEvent.fromMap(map['event']?.cast()); + final instance = AjaxRequest( + data: map['data'], + method: map['method'], + url: map['url'] != null ? Uri.parse(map['url']) : null, + isAsync: map['isAsync'], + user: map['user'], + password: map['password'], + withCredentials: map['withCredentials'], + headers: + AjaxRequestHeaders.fromMap(map['headers']?.cast()), + readyState: AjaxRequestReadyState.fromNativeValue(map['readyState']), + status: map['status'], + responseURL: + map['responseURL'] != null ? Uri.parse(map['responseURL']) : null, + responseType: map['responseType'], + response: map['response'], + responseText: map['responseText'], + responseXML: map['responseXML'], + statusText: map['statusText'], + responseHeaders: map['responseHeaders'], + event: AjaxRequestEvent.fromMap(map['event']?.cast()), + ); instance.action = AjaxRequestAction.fromNativeValue(map['action']); return instance; } diff --git a/lib/src/types/ajax_request_event.g.dart b/lib/src/types/ajax_request_event.g.dart index c37d23aa..baee27bb 100644 --- a/lib/src/types/ajax_request_event.g.dart +++ b/lib/src/types/ajax_request_event.g.dart @@ -30,11 +30,12 @@ class AjaxRequestEvent { if (map == null) { return null; } - final instance = AjaxRequestEvent(); - instance.type = AjaxRequestEventType.fromNativeValue(map['type']); - instance.lengthComputable = map['lengthComputable']; - instance.loaded = map['loaded']; - instance.total = map['total']; + final instance = AjaxRequestEvent( + type: AjaxRequestEventType.fromNativeValue(map['type']), + lengthComputable: map['lengthComputable'], + loaded: map['loaded'], + total: map['total'], + ); return instance; } diff --git a/lib/src/types/attributed_string.g.dart b/lib/src/types/attributed_string.g.dart index 9e019ed8..674bd46e 100644 --- a/lib/src/types/attributed_string.g.dart +++ b/lib/src/types/attributed_string.g.dart @@ -130,34 +130,33 @@ class AttributedString { } final instance = AttributedString( string: map['string'], + backgroundColor: map['backgroundColor'] != null + ? UtilColor.fromStringRepresentation(map['backgroundColor']) + : null, + baselineOffset: map['baselineOffset'], + expansion: map['expansion'], + foregroundColor: map['foregroundColor'] != null + ? UtilColor.fromStringRepresentation(map['foregroundColor']) + : null, + kern: map['kern'], + ligature: map['ligature'], + obliqueness: map['obliqueness'], + strikethroughColor: map['strikethroughColor'] != null + ? UtilColor.fromStringRepresentation(map['strikethroughColor']) + : null, + strikethroughStyle: + UnderlineStyle.fromNativeValue(map['strikethroughStyle']), + strokeColor: map['strokeColor'] != null + ? UtilColor.fromStringRepresentation(map['strokeColor']) + : null, + strokeWidth: map['strokeWidth'], + textEffect: + AttributedStringTextEffectStyle.fromNativeValue(map['textEffect']), + underlineColor: map['underlineColor'] != null + ? UtilColor.fromStringRepresentation(map['underlineColor']) + : null, + underlineStyle: UnderlineStyle.fromNativeValue(map['underlineStyle']), ); - instance.backgroundColor = map['backgroundColor'] != null - ? UtilColor.fromStringRepresentation(map['backgroundColor']) - : null; - instance.baselineOffset = map['baselineOffset']; - instance.expansion = map['expansion']; - instance.foregroundColor = map['foregroundColor'] != null - ? UtilColor.fromStringRepresentation(map['foregroundColor']) - : null; - instance.kern = map['kern']; - instance.ligature = map['ligature']; - instance.obliqueness = map['obliqueness']; - instance.strikethroughColor = map['strikethroughColor'] != null - ? UtilColor.fromStringRepresentation(map['strikethroughColor']) - : null; - instance.strikethroughStyle = - UnderlineStyle.fromNativeValue(map['strikethroughStyle']); - instance.strokeColor = map['strokeColor'] != null - ? UtilColor.fromStringRepresentation(map['strokeColor']) - : null; - instance.strokeWidth = map['strokeWidth']; - instance.textEffect = - AttributedStringTextEffectStyle.fromNativeValue(map['textEffect']); - instance.underlineColor = map['underlineColor'] != null - ? UtilColor.fromStringRepresentation(map['underlineColor']) - : null; - instance.underlineStyle = - UnderlineStyle.fromNativeValue(map['underlineStyle']); return instance; } @@ -319,34 +318,34 @@ class IOSNSAttributedString { } final instance = IOSNSAttributedString( string: map['string'], + backgroundColor: map['backgroundColor'] != null + ? UtilColor.fromStringRepresentation(map['backgroundColor']) + : null, + baselineOffset: map['baselineOffset'], + expansion: map['expansion'], + foregroundColor: map['foregroundColor'] != null + ? UtilColor.fromStringRepresentation(map['foregroundColor']) + : null, + kern: map['kern'], + ligature: map['ligature'], + obliqueness: map['obliqueness'], + strikethroughColor: map['strikethroughColor'] != null + ? UtilColor.fromStringRepresentation(map['strikethroughColor']) + : null, + strikethroughStyle: + IOSNSUnderlineStyle.fromNativeValue(map['strikethroughStyle']), + strokeColor: map['strokeColor'] != null + ? UtilColor.fromStringRepresentation(map['strokeColor']) + : null, + strokeWidth: map['strokeWidth'], + textEffect: IOSNSAttributedStringTextEffectStyle.fromNativeValue( + map['textEffect']), + underlineColor: map['underlineColor'] != null + ? UtilColor.fromStringRepresentation(map['underlineColor']) + : null, + underlineStyle: + IOSNSUnderlineStyle.fromNativeValue(map['underlineStyle']), ); - instance.backgroundColor = map['backgroundColor'] != null - ? UtilColor.fromStringRepresentation(map['backgroundColor']) - : null; - instance.baselineOffset = map['baselineOffset']; - instance.expansion = map['expansion']; - instance.foregroundColor = map['foregroundColor'] != null - ? UtilColor.fromStringRepresentation(map['foregroundColor']) - : null; - instance.kern = map['kern']; - instance.ligature = map['ligature']; - instance.obliqueness = map['obliqueness']; - instance.strikethroughColor = map['strikethroughColor'] != null - ? UtilColor.fromStringRepresentation(map['strikethroughColor']) - : null; - instance.strikethroughStyle = - IOSNSUnderlineStyle.fromNativeValue(map['strikethroughStyle']); - instance.strokeColor = map['strokeColor'] != null - ? UtilColor.fromStringRepresentation(map['strokeColor']) - : null; - instance.strokeWidth = map['strokeWidth']; - instance.textEffect = - IOSNSAttributedStringTextEffectStyle.fromNativeValue(map['textEffect']); - instance.underlineColor = map['underlineColor'] != null - ? UtilColor.fromStringRepresentation(map['underlineColor']) - : null; - instance.underlineStyle = - IOSNSUnderlineStyle.fromNativeValue(map['underlineStyle']); return instance; } diff --git a/lib/src/types/call_async_javascript_result.g.dart b/lib/src/types/call_async_javascript_result.g.dart index 6c1cce43..a20c7c83 100644 --- a/lib/src/types/call_async_javascript_result.g.dart +++ b/lib/src/types/call_async_javascript_result.g.dart @@ -20,9 +20,10 @@ class CallAsyncJavaScriptResult { if (map == null) { return null; } - final instance = CallAsyncJavaScriptResult(); - instance.value = map['value']; - instance.error = map['error']; + final instance = CallAsyncJavaScriptResult( + value: map['value'], + error: map['error'], + ); return instance; } diff --git a/lib/src/types/client_cert_challenge.dart b/lib/src/types/client_cert_challenge.dart index 2de0e39c..f38ed0b0 100644 --- a/lib/src/types/client_cert_challenge.dart +++ b/lib/src/types/client_cert_challenge.dart @@ -39,7 +39,7 @@ class ClientCertChallenge_ extends URLAuthenticationChallenge_ { List? keyTypes; ClientCertChallenge_( - {required URLProtectionSpace protectionSpace, + {required URLProtectionSpace_ protectionSpace, @Deprecated('Use principals instead') this.androidPrincipals, this.principals, @Deprecated('Use keyTypes instead') this.androidKeyTypes, diff --git a/lib/src/types/client_cert_challenge.g.dart b/lib/src/types/client_cert_challenge.g.dart index 15d39c97..33fbfe5e 100644 --- a/lib/src/types/client_cert_challenge.g.dart +++ b/lib/src/types/client_cert_challenge.g.dart @@ -33,7 +33,7 @@ class ClientCertChallenge extends URLAuthenticationChallenge { this.principals, @Deprecated('Use keyTypes instead') this.androidKeyTypes, this.keyTypes, - dynamic protectionSpace}) + required URLProtectionSpace protectionSpace}) : super(protectionSpace: protectionSpace) { principals = principals ?? androidPrincipals; keyTypes = keyTypes ?? androidKeyTypes; @@ -45,19 +45,20 @@ class ClientCertChallenge extends URLAuthenticationChallenge { return null; } final instance = ClientCertChallenge( - protectionSpace: map['protectionSpace'], + protectionSpace: URLProtectionSpace.fromMap( + map['protectionSpace']?.cast())!, + androidPrincipals: map['principals'], + principals: map['principals'], + androidKeyTypes: map['keyTypes'], + keyTypes: map['keyTypes'], ); - instance.androidPrincipals = map['principals']; - instance.principals = map['principals']; - instance.androidKeyTypes = map['keyTypes']; - instance.keyTypes = map['keyTypes']; return instance; } ///Converts instance to a map. Map toMap() { return { - "protectionSpace": protectionSpace, + "protectionSpace": protectionSpace.toMap(), "principals": principals, "keyTypes": keyTypes, }; diff --git a/lib/src/types/cookie.g.dart b/lib/src/types/cookie.g.dart index 6994beb3..33897362 100644 --- a/lib/src/types/cookie.g.dart +++ b/lib/src/types/cookie.g.dart @@ -67,15 +67,14 @@ class Cookie { final instance = Cookie( name: map['name'], value: map['value'], + expiresDate: map['expiresDate'], + isSessionOnly: map['isSessionOnly'], + domain: map['domain'], + sameSite: HTTPCookieSameSitePolicy.fromNativeValue(map['sameSite']), + isSecure: map['isSecure'], + isHttpOnly: map['isHttpOnly'], + path: map['path'], ); - instance.expiresDate = map['expiresDate']; - instance.isSessionOnly = map['isSessionOnly']; - instance.domain = map['domain']; - instance.sameSite = - HTTPCookieSameSitePolicy.fromNativeValue(map['sameSite']); - instance.isSecure = map['isSecure']; - instance.isHttpOnly = map['isHttpOnly']; - instance.path = map['path']; return instance; } diff --git a/lib/src/types/create_window_action.g.dart b/lib/src/types/create_window_action.g.dart index d1a4ecdc..8bce1e67 100644 --- a/lib/src/types/create_window_action.g.dart +++ b/lib/src/types/create_window_action.g.dart @@ -84,6 +84,12 @@ class CreateWindowAction extends NavigationAction { request: URLRequest.fromMap(map['request']?.cast())!, isForMainFrame: map['isForMainFrame'], windowId: map['windowId'], + androidIsDialog: map['isDialog'], + isDialog: map['isDialog'], + iosWindowFeatures: IOSWKWindowFeatures.fromMap( + map['windowFeatures']?.cast()), + windowFeatures: WindowFeatures.fromMap( + map['windowFeatures']?.cast()), ); instance.androidHasGesture = map['hasGesture']; instance.hasGesture = map['hasGesture']; @@ -102,12 +108,6 @@ class CreateWindowAction extends NavigationAction { instance.targetFrame = FrameInfo.fromMap(map['targetFrame']?.cast()); instance.shouldPerformDownload = map['shouldPerformDownload']; - instance.androidIsDialog = map['isDialog']; - instance.isDialog = map['isDialog']; - instance.iosWindowFeatures = IOSWKWindowFeatures.fromMap( - map['windowFeatures']?.cast()); - instance.windowFeatures = - WindowFeatures.fromMap(map['windowFeatures']?.cast()); return instance; } diff --git a/lib/src/types/css_link_html_tag_attributes.dart b/lib/src/types/css_link_html_tag_attributes.dart index bb681a52..aa60a465 100644 --- a/lib/src/types/css_link_html_tag_attributes.dart +++ b/lib/src/types/css_link_html_tag_attributes.dart @@ -1,9 +1,14 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/in_app_webview_controller.dart'; import 'cross_origin.dart'; import 'referrer_policy.dart'; +part 'css_link_html_tag_attributes.g.dart'; + ///Class that represents the possible CSS stylesheet `` HTML attributes to be set used by [InAppWebViewController.injectCSSFileFromUrl]. -class CSSLinkHtmlTagAttributes { +@ExchangeableObject() +class CSSLinkHtmlTagAttributes_ { ///The HTML [id] attribute is used to specify a unique id for the `` HTML element. String? id; @@ -13,13 +18,13 @@ class CSSLinkHtmlTagAttributes { ///Normal script elements pass minimal information to the `window.onerror` for scripts which do not pass the standard CORS checks. ///To allow error logging for sites which use a separate domain for static media, use this attribute. - CrossOrigin? crossOrigin; + CrossOrigin_? crossOrigin; ///This attribute contains inline metadata that a user agent can use to verify that a fetched resource has been delivered free of unexpected manipulation. String? integrity; ///Indicates which referrer to send when fetching the script, or resources fetched by the script. - ReferrerPolicy? referrerPolicy; + ReferrerPolicy_? referrerPolicy; ///The [disabled] Boolean attribute indicates whether or not the described stylesheet should be loaded and applied to the document. ///If [disabled] is specified in the HTML when it is loaded, the stylesheet will not be loaded during page load. @@ -36,7 +41,7 @@ class CSSLinkHtmlTagAttributes { ///Incorrectly using it may cause the stylesheet to be ignored. String? title; - CSSLinkHtmlTagAttributes( + CSSLinkHtmlTagAttributes_( {this.id, this.media, this.crossOrigin, @@ -45,28 +50,4 @@ class CSSLinkHtmlTagAttributes { this.disabled, this.alternate, this.title}); - - ///Converts instance to a map. - Map toMap() { - return { - "id": this.id, - "media": this.media, - "crossOrigin": this.crossOrigin?.toValue(), - "integrity": this.integrity, - "referrerPolicy": this.referrerPolicy?.toValue(), - "disabled": this.disabled, - "alternate": this.alternate, - "title": this.title, - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } \ No newline at end of file diff --git a/lib/src/types/css_link_html_tag_attributes.g.dart b/lib/src/types/css_link_html_tag_attributes.g.dart new file mode 100644 index 00000000..1ac069b8 --- /dev/null +++ b/lib/src/types/css_link_html_tag_attributes.g.dart @@ -0,0 +1,93 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'css_link_html_tag_attributes.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the possible CSS stylesheet `` HTML attributes to be set used by [InAppWebViewController.injectCSSFileFromUrl]. +class CSSLinkHtmlTagAttributes { + ///The HTML [id] attribute is used to specify a unique id for the `` HTML element. + String? id; + + ///This attribute specifies the media that the linked resource applies to. Its value must be a media type / media query. + ///This attribute is mainly useful when linking to external stylesheets — it allows the user agent to pick the best adapted one for the device it runs on. + String? media; + + ///Normal script elements pass minimal information to the `window.onerror` for scripts which do not pass the standard CORS checks. + ///To allow error logging for sites which use a separate domain for static media, use this attribute. + CrossOrigin? crossOrigin; + + ///This attribute contains inline metadata that a user agent can use to verify that a fetched resource has been delivered free of unexpected manipulation. + String? integrity; + + ///Indicates which referrer to send when fetching the script, or resources fetched by the script. + ReferrerPolicy? referrerPolicy; + + ///The [disabled] Boolean attribute indicates whether or not the described stylesheet should be loaded and applied to the document. + ///If [disabled] is specified in the HTML when it is loaded, the stylesheet will not be loaded during page load. + ///Instead, the stylesheet will be loaded on-demand, if and when the [disabled] attribute is changed to `false` or removed. + /// + ///Setting the [disabled] property in the DOM causes the stylesheet to be removed from the document's `DocumentOrShadowRoot.styleSheets` list. + bool? disabled; + + ///Specify alternative style sheets. + bool? alternate; + + ///The title attribute has special semantics on the `` element. + ///When used on a `` it defines a preferred or an alternate stylesheet. + ///Incorrectly using it may cause the stylesheet to be ignored. + String? title; + CSSLinkHtmlTagAttributes( + {this.id, + this.media, + this.crossOrigin, + this.integrity, + this.referrerPolicy, + this.disabled, + this.alternate, + this.title}); + + ///Gets a possible [CSSLinkHtmlTagAttributes] instance from a [Map] value. + static CSSLinkHtmlTagAttributes? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = CSSLinkHtmlTagAttributes( + id: map['id'], + media: map['media'], + crossOrigin: CrossOrigin.fromNativeValue(map['crossOrigin']), + integrity: map['integrity'], + referrerPolicy: ReferrerPolicy.fromNativeValue(map['referrerPolicy']), + disabled: map['disabled'], + alternate: map['alternate'], + title: map['title'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "id": id, + "media": media, + "crossOrigin": crossOrigin?.toNativeValue(), + "integrity": integrity, + "referrerPolicy": referrerPolicy?.toNativeValue(), + "disabled": disabled, + "alternate": alternate, + "title": title, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'CSSLinkHtmlTagAttributes{id: $id, media: $media, crossOrigin: $crossOrigin, integrity: $integrity, referrerPolicy: $referrerPolicy, disabled: $disabled, alternate: $alternate, title: $title}'; + } +} diff --git a/lib/src/types/custom_scheme_response.dart b/lib/src/types/custom_scheme_response.dart index 508b32c2..a777fc7b 100644 --- a/lib/src/types/custom_scheme_response.dart +++ b/lib/src/types/custom_scheme_response.dart @@ -1,10 +1,15 @@ import 'dart:typed_data'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; +part 'custom_scheme_response.g.dart'; + ///Class representing the response returned by the [WebView.onLoadResourceWithCustomScheme] event. ///It allows to load a specific resource. The resource data must be encoded to `base64`. -class CustomSchemeResponse { +@ExchangeableObject() +class CustomSchemeResponse_ { ///Data enconded to 'base64'. Uint8List data; @@ -14,27 +19,8 @@ class CustomSchemeResponse { ///Content-Encoding of the data, such as `utf-8`. String contentEncoding; - CustomSchemeResponse( + CustomSchemeResponse_( {required this.data, required this.contentType, this.contentEncoding = 'utf-8'}); - - ///Converts instance to a map. - Map toMap() { - return { - 'contentType': contentType, - 'contentEncoding': contentEncoding, - 'data': data - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } \ No newline at end of file diff --git a/lib/src/types/custom_scheme_response.g.dart b/lib/src/types/custom_scheme_response.g.dart new file mode 100644 index 00000000..ac831322 --- /dev/null +++ b/lib/src/types/custom_scheme_response.g.dart @@ -0,0 +1,56 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'custom_scheme_response.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class representing the response returned by the [WebView.onLoadResourceWithCustomScheme] event. +///It allows to load a specific resource. The resource data must be encoded to `base64`. +class CustomSchemeResponse { + ///Data enconded to 'base64'. + Uint8List data; + + ///Content-Type of the data, such as `image/png`. + String contentType; + + ///Content-Encoding of the data, such as `utf-8`. + String contentEncoding; + CustomSchemeResponse( + {required this.data, + required this.contentType, + this.contentEncoding = 'utf-8'}); + + ///Gets a possible [CustomSchemeResponse] instance from a [Map] value. + static CustomSchemeResponse? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = CustomSchemeResponse( + data: map['data'], + contentType: map['contentType'], + ); + instance.contentEncoding = map['contentEncoding']; + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "data": data, + "contentType": contentType, + "contentEncoding": contentEncoding, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'CustomSchemeResponse{data: $data, contentType: $contentType, contentEncoding: $contentEncoding}'; + } +} diff --git a/lib/src/types/custom_tabs_share_state.dart b/lib/src/types/custom_tabs_share_state.dart index 7a6de43c..d8d79f5d 100644 --- a/lib/src/types/custom_tabs_share_state.dart +++ b/lib/src/types/custom_tabs_share_state.dart @@ -1,56 +1,20 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'custom_tabs_share_state.g.dart'; + ///Class representing the share state that should be applied to the custom tab. -class CustomTabsShareState { +@ExchangeableEnum() +class CustomTabsShareState_ { + // ignore: unused_field final int _value; - - const CustomTabsShareState._internal(this._value); - - ///Set of all values of [CustomTabsShareState]. - static final Set values = [ - CustomTabsShareState.SHARE_STATE_DEFAULT, - CustomTabsShareState.SHARE_STATE_ON, - CustomTabsShareState.SHARE_STATE_OFF, - ].toSet(); - - ///Gets a possible [CustomTabsShareState] instance from an [int] value. - static CustomTabsShareState? fromValue(int? value) { - if (value != null) { - try { - return CustomTabsShareState.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "SHARE_STATE_ON"; - case 2: - return "SHARE_STATE_OFF"; - case 0: - default: - return "SHARE_STATE_DEFAULT"; - } - } + const CustomTabsShareState_._internal(this._value); ///Applies the default share settings depending on the browser. - static const SHARE_STATE_DEFAULT = const CustomTabsShareState._internal(0); + static const SHARE_STATE_DEFAULT = const CustomTabsShareState_._internal(0); ///Shows a share option in the tab. - static const SHARE_STATE_ON = const CustomTabsShareState._internal(1); + static const SHARE_STATE_ON = const CustomTabsShareState_._internal(1); ///Explicitly does not show a share option in the tab. - static const SHARE_STATE_OFF = const CustomTabsShareState._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const SHARE_STATE_OFF = const CustomTabsShareState_._internal(2); } \ No newline at end of file diff --git a/lib/src/types/custom_tabs_share_state.g.dart b/lib/src/types/custom_tabs_share_state.g.dart new file mode 100644 index 00000000..5c6e6c55 --- /dev/null +++ b/lib/src/types/custom_tabs_share_state.g.dart @@ -0,0 +1,85 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'custom_tabs_share_state.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class representing the share state that should be applied to the custom tab. +class CustomTabsShareState { + final int _value; + final int _nativeValue; + const CustomTabsShareState._internal(this._value, this._nativeValue); +// ignore: unused_element + factory CustomTabsShareState._internalMultiPlatform( + int value, Function nativeValue) => + CustomTabsShareState._internal(value, nativeValue()); + + ///Applies the default share settings depending on the browser. + static const SHARE_STATE_DEFAULT = CustomTabsShareState._internal(0, 0); + + ///Shows a share option in the tab. + static const SHARE_STATE_ON = CustomTabsShareState._internal(1, 1); + + ///Explicitly does not show a share option in the tab. + static const SHARE_STATE_OFF = CustomTabsShareState._internal(2, 2); + + ///Set of all values of [CustomTabsShareState]. + static final Set values = [ + CustomTabsShareState.SHARE_STATE_DEFAULT, + CustomTabsShareState.SHARE_STATE_ON, + CustomTabsShareState.SHARE_STATE_OFF, + ].toSet(); + + ///Gets a possible [CustomTabsShareState] instance from [int] value. + static CustomTabsShareState? fromValue(int? value) { + if (value != null) { + try { + return CustomTabsShareState.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [CustomTabsShareState] instance from a native value. + static CustomTabsShareState? fromNativeValue(int? value) { + if (value != null) { + try { + return CustomTabsShareState.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'SHARE_STATE_DEFAULT'; + case 1: + return 'SHARE_STATE_ON'; + case 2: + return 'SHARE_STATE_OFF'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/data_detector_types.dart b/lib/src/types/data_detector_types.dart index b57c7b90..a45bb28d 100644 --- a/lib/src/types/data_detector_types.dart +++ b/lib/src/types/data_detector_types.dart @@ -1,81 +1,48 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'data_detector_types.g.dart'; + ///Class used to specify a `dataDetectoryTypes` value that adds interactivity to web content that matches the value. -class DataDetectorTypes { +@ExchangeableEnum() +class DataDetectorTypes_ { + // ignore: unused_field final String _value; - - const DataDetectorTypes._internal(this._value); - - ///Set of all values of [DataDetectorTypes]. - static final Set values = [ - DataDetectorTypes.NONE, - DataDetectorTypes.PHONE_NUMBER, - DataDetectorTypes.LINK, - DataDetectorTypes.ADDRESS, - DataDetectorTypes.CALENDAR_EVENT, - DataDetectorTypes.TRACKING_NUMBER, - DataDetectorTypes.FLIGHT_NUMBER, - DataDetectorTypes.LOOKUP_SUGGESTION, - DataDetectorTypes.SPOTLIGHT_SUGGESTION, - DataDetectorTypes.ALL, - ].toSet(); - - ///Gets a possible [DataDetectorTypes] instance from a [String] value. - static DataDetectorTypes? fromValue(String? value) { - if (value != null) { - try { - return DataDetectorTypes.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [String] value. - String toValue() => _value; - - @override - String toString() => _value; + const DataDetectorTypes_._internal(this._value); ///No detection is performed. - static const NONE = const DataDetectorTypes._internal("NONE"); + static const NONE = const DataDetectorTypes_._internal("NONE"); ///Phone numbers are detected and turned into links. - static const PHONE_NUMBER = const DataDetectorTypes._internal("PHONE_NUMBER"); + static const PHONE_NUMBER = const DataDetectorTypes_._internal("PHONE_NUMBER"); ///URLs in text are detected and turned into links. - static const LINK = const DataDetectorTypes._internal("LINK"); + static const LINK = const DataDetectorTypes_._internal("LINK"); ///Addresses are detected and turned into links. - static const ADDRESS = const DataDetectorTypes._internal("ADDRESS"); + static const ADDRESS = const DataDetectorTypes_._internal("ADDRESS"); ///Dates and times that are in the future are detected and turned into links. static const CALENDAR_EVENT = - const DataDetectorTypes._internal("CALENDAR_EVENT"); + const DataDetectorTypes_._internal("CALENDAR_EVENT"); ///Tracking numbers are detected and turned into links. static const TRACKING_NUMBER = - const DataDetectorTypes._internal("TRACKING_NUMBER"); + const DataDetectorTypes_._internal("TRACKING_NUMBER"); ///Flight numbers are detected and turned into links. static const FLIGHT_NUMBER = - const DataDetectorTypes._internal("FLIGHT_NUMBER"); + const DataDetectorTypes_._internal("FLIGHT_NUMBER"); ///Lookup suggestions are detected and turned into links. static const LOOKUP_SUGGESTION = - const DataDetectorTypes._internal("LOOKUP_SUGGESTION"); + const DataDetectorTypes_._internal("LOOKUP_SUGGESTION"); ///Spotlight suggestions are detected and turned into links. static const SPOTLIGHT_SUGGESTION = - const DataDetectorTypes._internal("SPOTLIGHT_SUGGESTION"); + const DataDetectorTypes_._internal("SPOTLIGHT_SUGGESTION"); ///All of the above data types are turned into links when detected. Choosing this value will automatically include any new detection type that is added. - static const ALL = const DataDetectorTypes._internal("ALL"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const ALL = const DataDetectorTypes_._internal("ALL"); } ///An iOS-specific class used to specify a `dataDetectoryTypes` value that adds interactivity to web content that matches the value. @@ -84,82 +51,45 @@ class DataDetectorTypes { /// ///Use [DataDetectorTypes] instead. @Deprecated("Use DataDetectorTypes instead") -class IOSWKDataDetectorTypes { +@ExchangeableEnum() +class IOSWKDataDetectorTypes_ { + // ignore: unused_field final String _value; - - const IOSWKDataDetectorTypes._internal(this._value); - - ///Set of all values of [IOSWKDataDetectorTypes]. - static final Set values = [ - IOSWKDataDetectorTypes.NONE, - IOSWKDataDetectorTypes.PHONE_NUMBER, - IOSWKDataDetectorTypes.LINK, - IOSWKDataDetectorTypes.ADDRESS, - IOSWKDataDetectorTypes.CALENDAR_EVENT, - IOSWKDataDetectorTypes.TRACKING_NUMBER, - IOSWKDataDetectorTypes.FLIGHT_NUMBER, - IOSWKDataDetectorTypes.LOOKUP_SUGGESTION, - IOSWKDataDetectorTypes.SPOTLIGHT_SUGGESTION, - IOSWKDataDetectorTypes.ALL, - ].toSet(); - - ///Gets a possible [IOSWKDataDetectorTypes] instance from a [String] value. - static IOSWKDataDetectorTypes? fromValue(String? value) { - if (value != null) { - try { - return IOSWKDataDetectorTypes.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [String] value. - String toValue() => _value; - - @override - String toString() => _value; + const IOSWKDataDetectorTypes_._internal(this._value); ///No detection is performed. - static const NONE = const IOSWKDataDetectorTypes._internal("NONE"); + static const NONE = const IOSWKDataDetectorTypes_._internal("NONE"); ///Phone numbers are detected and turned into links. static const PHONE_NUMBER = - const IOSWKDataDetectorTypes._internal("PHONE_NUMBER"); + const IOSWKDataDetectorTypes_._internal("PHONE_NUMBER"); ///URLs in text are detected and turned into links. - static const LINK = const IOSWKDataDetectorTypes._internal("LINK"); + static const LINK = const IOSWKDataDetectorTypes_._internal("LINK"); ///Addresses are detected and turned into links. - static const ADDRESS = const IOSWKDataDetectorTypes._internal("ADDRESS"); + static const ADDRESS = const IOSWKDataDetectorTypes_._internal("ADDRESS"); ///Dates and times that are in the future are detected and turned into links. static const CALENDAR_EVENT = - const IOSWKDataDetectorTypes._internal("CALENDAR_EVENT"); + const IOSWKDataDetectorTypes_._internal("CALENDAR_EVENT"); ///Tracking numbers are detected and turned into links. static const TRACKING_NUMBER = - const IOSWKDataDetectorTypes._internal("TRACKING_NUMBER"); + const IOSWKDataDetectorTypes_._internal("TRACKING_NUMBER"); ///Flight numbers are detected and turned into links. static const FLIGHT_NUMBER = - const IOSWKDataDetectorTypes._internal("FLIGHT_NUMBER"); + const IOSWKDataDetectorTypes_._internal("FLIGHT_NUMBER"); ///Lookup suggestions are detected and turned into links. static const LOOKUP_SUGGESTION = - const IOSWKDataDetectorTypes._internal("LOOKUP_SUGGESTION"); + const IOSWKDataDetectorTypes_._internal("LOOKUP_SUGGESTION"); ///Spotlight suggestions are detected and turned into links. static const SPOTLIGHT_SUGGESTION = - const IOSWKDataDetectorTypes._internal("SPOTLIGHT_SUGGESTION"); + const IOSWKDataDetectorTypes_._internal("SPOTLIGHT_SUGGESTION"); ///All of the above data types are turned into links when detected. Choosing this value will automatically include any new detection type that is added. - static const ALL = const IOSWKDataDetectorTypes._internal("ALL"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const ALL = const IOSWKDataDetectorTypes_._internal("ALL"); } \ No newline at end of file diff --git a/lib/src/types/data_detector_types.g.dart b/lib/src/types/data_detector_types.g.dart new file mode 100644 index 00000000..6cb7ab61 --- /dev/null +++ b/lib/src/types/data_detector_types.g.dart @@ -0,0 +1,220 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'data_detector_types.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used to specify a `dataDetectoryTypes` value that adds interactivity to web content that matches the value. +class DataDetectorTypes { + final String _value; + final String _nativeValue; + const DataDetectorTypes._internal(this._value, this._nativeValue); +// ignore: unused_element + factory DataDetectorTypes._internalMultiPlatform( + String value, Function nativeValue) => + DataDetectorTypes._internal(value, nativeValue()); + + ///No detection is performed. + static const NONE = DataDetectorTypes._internal('NONE', 'NONE'); + + ///Phone numbers are detected and turned into links. + static const PHONE_NUMBER = + DataDetectorTypes._internal('PHONE_NUMBER', 'PHONE_NUMBER'); + + ///URLs in text are detected and turned into links. + static const LINK = DataDetectorTypes._internal('LINK', 'LINK'); + + ///Addresses are detected and turned into links. + static const ADDRESS = DataDetectorTypes._internal('ADDRESS', 'ADDRESS'); + + ///Dates and times that are in the future are detected and turned into links. + static const CALENDAR_EVENT = + DataDetectorTypes._internal('CALENDAR_EVENT', 'CALENDAR_EVENT'); + + ///Tracking numbers are detected and turned into links. + static const TRACKING_NUMBER = + DataDetectorTypes._internal('TRACKING_NUMBER', 'TRACKING_NUMBER'); + + ///Flight numbers are detected and turned into links. + static const FLIGHT_NUMBER = + DataDetectorTypes._internal('FLIGHT_NUMBER', 'FLIGHT_NUMBER'); + + ///Lookup suggestions are detected and turned into links. + static const LOOKUP_SUGGESTION = + DataDetectorTypes._internal('LOOKUP_SUGGESTION', 'LOOKUP_SUGGESTION'); + + ///Spotlight suggestions are detected and turned into links. + static const SPOTLIGHT_SUGGESTION = DataDetectorTypes._internal( + 'SPOTLIGHT_SUGGESTION', 'SPOTLIGHT_SUGGESTION'); + + ///All of the above data types are turned into links when detected. Choosing this value will automatically include any new detection type that is added. + static const ALL = DataDetectorTypes._internal('ALL', 'ALL'); + + ///Set of all values of [DataDetectorTypes]. + static final Set values = [ + DataDetectorTypes.NONE, + DataDetectorTypes.PHONE_NUMBER, + DataDetectorTypes.LINK, + DataDetectorTypes.ADDRESS, + DataDetectorTypes.CALENDAR_EVENT, + DataDetectorTypes.TRACKING_NUMBER, + DataDetectorTypes.FLIGHT_NUMBER, + DataDetectorTypes.LOOKUP_SUGGESTION, + DataDetectorTypes.SPOTLIGHT_SUGGESTION, + DataDetectorTypes.ALL, + ].toSet(); + + ///Gets a possible [DataDetectorTypes] instance from [String] value. + static DataDetectorTypes? fromValue(String? value) { + if (value != null) { + try { + return DataDetectorTypes.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [DataDetectorTypes] instance from a native value. + static DataDetectorTypes? fromNativeValue(String? value) { + if (value != null) { + try { + return DataDetectorTypes.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [String] native value. + String toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} + +///An iOS-specific class used to specify a `dataDetectoryTypes` value that adds interactivity to web content that matches the value. +/// +///**NOTE**: available on iOS 10.0+. +/// +///Use [DataDetectorTypes] instead. +@Deprecated('Use DataDetectorTypes instead') +class IOSWKDataDetectorTypes { + final String _value; + final String _nativeValue; + const IOSWKDataDetectorTypes._internal(this._value, this._nativeValue); +// ignore: unused_element + factory IOSWKDataDetectorTypes._internalMultiPlatform( + String value, Function nativeValue) => + IOSWKDataDetectorTypes._internal(value, nativeValue()); + + ///No detection is performed. + static const NONE = IOSWKDataDetectorTypes._internal('NONE', 'NONE'); + + ///Phone numbers are detected and turned into links. + static const PHONE_NUMBER = + IOSWKDataDetectorTypes._internal('PHONE_NUMBER', 'PHONE_NUMBER'); + + ///URLs in text are detected and turned into links. + static const LINK = IOSWKDataDetectorTypes._internal('LINK', 'LINK'); + + ///Addresses are detected and turned into links. + static const ADDRESS = IOSWKDataDetectorTypes._internal('ADDRESS', 'ADDRESS'); + + ///Dates and times that are in the future are detected and turned into links. + static const CALENDAR_EVENT = + IOSWKDataDetectorTypes._internal('CALENDAR_EVENT', 'CALENDAR_EVENT'); + + ///Tracking numbers are detected and turned into links. + static const TRACKING_NUMBER = + IOSWKDataDetectorTypes._internal('TRACKING_NUMBER', 'TRACKING_NUMBER'); + + ///Flight numbers are detected and turned into links. + static const FLIGHT_NUMBER = + IOSWKDataDetectorTypes._internal('FLIGHT_NUMBER', 'FLIGHT_NUMBER'); + + ///Lookup suggestions are detected and turned into links. + static const LOOKUP_SUGGESTION = IOSWKDataDetectorTypes._internal( + 'LOOKUP_SUGGESTION', 'LOOKUP_SUGGESTION'); + + ///Spotlight suggestions are detected and turned into links. + static const SPOTLIGHT_SUGGESTION = IOSWKDataDetectorTypes._internal( + 'SPOTLIGHT_SUGGESTION', 'SPOTLIGHT_SUGGESTION'); + + ///All of the above data types are turned into links when detected. Choosing this value will automatically include any new detection type that is added. + static const ALL = IOSWKDataDetectorTypes._internal('ALL', 'ALL'); + + ///Set of all values of [IOSWKDataDetectorTypes]. + static final Set values = [ + IOSWKDataDetectorTypes.NONE, + IOSWKDataDetectorTypes.PHONE_NUMBER, + IOSWKDataDetectorTypes.LINK, + IOSWKDataDetectorTypes.ADDRESS, + IOSWKDataDetectorTypes.CALENDAR_EVENT, + IOSWKDataDetectorTypes.TRACKING_NUMBER, + IOSWKDataDetectorTypes.FLIGHT_NUMBER, + IOSWKDataDetectorTypes.LOOKUP_SUGGESTION, + IOSWKDataDetectorTypes.SPOTLIGHT_SUGGESTION, + IOSWKDataDetectorTypes.ALL, + ].toSet(); + + ///Gets a possible [IOSWKDataDetectorTypes] instance from [String] value. + static IOSWKDataDetectorTypes? fromValue(String? value) { + if (value != null) { + try { + return IOSWKDataDetectorTypes.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [IOSWKDataDetectorTypes] instance from a native value. + static IOSWKDataDetectorTypes? fromNativeValue(String? value) { + if (value != null) { + try { + return IOSWKDataDetectorTypes.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [String] native value. + String toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} diff --git a/lib/src/types/dismiss_button_style.dart b/lib/src/types/dismiss_button_style.dart index c6caa67c..156a63ba 100644 --- a/lib/src/types/dismiss_button_style.dart +++ b/lib/src/types/dismiss_button_style.dart @@ -1,58 +1,22 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'dismiss_button_style.g.dart'; + ///Class used to set the custom style for the dismiss button. -class DismissButtonStyle { +@ExchangeableEnum() +class DismissButtonStyle_ { + // ignore: unused_field final int _value; - - const DismissButtonStyle._internal(this._value); - - ///Set of all values of [DismissButtonStyle]. - static final Set values = [ - DismissButtonStyle.DONE, - DismissButtonStyle.CLOSE, - DismissButtonStyle.CANCEL, - ].toSet(); - - ///Gets a possible [DismissButtonStyle] instance from an [int] value. - static DismissButtonStyle? fromValue(int? value) { - if (value != null) { - try { - return DismissButtonStyle.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "CLOSE"; - case 2: - return "CANCEL"; - case 0: - default: - return "DONE"; - } - } + const DismissButtonStyle_._internal(this._value); ///Makes the button title the localized string "Done". - static const DONE = const DismissButtonStyle._internal(0); + static const DONE = const DismissButtonStyle_._internal(0); ///Makes the button title the localized string "Close". - static const CLOSE = const DismissButtonStyle._internal(1); + static const CLOSE = const DismissButtonStyle_._internal(1); ///Makes the button title the localized string "Cancel". - static const CANCEL = const DismissButtonStyle._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const CANCEL = const DismissButtonStyle_._internal(2); } ///An iOS-specific class used to set the custom style for the dismiss button. @@ -61,58 +25,18 @@ class DismissButtonStyle { /// ///Use [DismissButtonStyle] instead. @Deprecated("Use DismissButtonStyle instead") -class IOSSafariDismissButtonStyle { +@ExchangeableEnum() +class IOSSafariDismissButtonStyle_ { + // ignore: unused_field final int _value; - - const IOSSafariDismissButtonStyle._internal(this._value); - - ///Set of all values of [IOSSafariDismissButtonStyle]. - static final Set values = [ - IOSSafariDismissButtonStyle.DONE, - IOSSafariDismissButtonStyle.CLOSE, - IOSSafariDismissButtonStyle.CANCEL, - ].toSet(); - - ///Gets a possible [IOSSafariDismissButtonStyle] instance from an [int] value. - static IOSSafariDismissButtonStyle? fromValue(int? value) { - if (value != null) { - try { - return IOSSafariDismissButtonStyle.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "CLOSE"; - case 2: - return "CANCEL"; - case 0: - default: - return "DONE"; - } - } + const IOSSafariDismissButtonStyle_._internal(this._value); ///Makes the button title the localized string "Done". - static const DONE = const IOSSafariDismissButtonStyle._internal(0); + static const DONE = const IOSSafariDismissButtonStyle_._internal(0); ///Makes the button title the localized string "Close". - static const CLOSE = const IOSSafariDismissButtonStyle._internal(1); + static const CLOSE = const IOSSafariDismissButtonStyle_._internal(1); ///Makes the button title the localized string "Cancel". - static const CANCEL = const IOSSafariDismissButtonStyle._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const CANCEL = const IOSSafariDismissButtonStyle_._internal(2); } \ No newline at end of file diff --git a/lib/src/types/dismiss_button_style.g.dart b/lib/src/types/dismiss_button_style.g.dart new file mode 100644 index 00000000..d94b428f --- /dev/null +++ b/lib/src/types/dismiss_button_style.g.dart @@ -0,0 +1,168 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'dismiss_button_style.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used to set the custom style for the dismiss button. +class DismissButtonStyle { + final int _value; + final int _nativeValue; + const DismissButtonStyle._internal(this._value, this._nativeValue); +// ignore: unused_element + factory DismissButtonStyle._internalMultiPlatform( + int value, Function nativeValue) => + DismissButtonStyle._internal(value, nativeValue()); + + ///Makes the button title the localized string "Done". + static const DONE = DismissButtonStyle._internal(0, 0); + + ///Makes the button title the localized string "Close". + static const CLOSE = DismissButtonStyle._internal(1, 1); + + ///Makes the button title the localized string "Cancel". + static const CANCEL = DismissButtonStyle._internal(2, 2); + + ///Set of all values of [DismissButtonStyle]. + static final Set values = [ + DismissButtonStyle.DONE, + DismissButtonStyle.CLOSE, + DismissButtonStyle.CANCEL, + ].toSet(); + + ///Gets a possible [DismissButtonStyle] instance from [int] value. + static DismissButtonStyle? fromValue(int? value) { + if (value != null) { + try { + return DismissButtonStyle.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [DismissButtonStyle] instance from a native value. + static DismissButtonStyle? fromNativeValue(int? value) { + if (value != null) { + try { + return DismissButtonStyle.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'DONE'; + case 1: + return 'CLOSE'; + case 2: + return 'CANCEL'; + } + return _value.toString(); + } +} + +///An iOS-specific class used to set the custom style for the dismiss button. +/// +///**NOTE**: available on iOS 11.0+. +/// +///Use [DismissButtonStyle] instead. +@Deprecated('Use DismissButtonStyle instead') +class IOSSafariDismissButtonStyle { + final int _value; + final int _nativeValue; + const IOSSafariDismissButtonStyle._internal(this._value, this._nativeValue); +// ignore: unused_element + factory IOSSafariDismissButtonStyle._internalMultiPlatform( + int value, Function nativeValue) => + IOSSafariDismissButtonStyle._internal(value, nativeValue()); + + ///Makes the button title the localized string "Done". + static const DONE = IOSSafariDismissButtonStyle._internal(0, 0); + + ///Makes the button title the localized string "Close". + static const CLOSE = IOSSafariDismissButtonStyle._internal(1, 1); + + ///Makes the button title the localized string "Cancel". + static const CANCEL = IOSSafariDismissButtonStyle._internal(2, 2); + + ///Set of all values of [IOSSafariDismissButtonStyle]. + static final Set values = [ + IOSSafariDismissButtonStyle.DONE, + IOSSafariDismissButtonStyle.CLOSE, + IOSSafariDismissButtonStyle.CANCEL, + ].toSet(); + + ///Gets a possible [IOSSafariDismissButtonStyle] instance from [int] value. + static IOSSafariDismissButtonStyle? fromValue(int? value) { + if (value != null) { + try { + return IOSSafariDismissButtonStyle.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [IOSSafariDismissButtonStyle] instance from a native value. + static IOSSafariDismissButtonStyle? fromNativeValue(int? value) { + if (value != null) { + try { + return IOSSafariDismissButtonStyle.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'DONE'; + case 1: + return 'CLOSE'; + case 2: + return 'CANCEL'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/download_start_request.dart b/lib/src/types/download_start_request.dart index cf47728a..abdf3aff 100644 --- a/lib/src/types/download_start_request.dart +++ b/lib/src/types/download_start_request.dart @@ -1,7 +1,12 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; +part 'download_start_request.g.dart'; + ///Class representing a download request of the WebView used by the event [WebView.onDownloadStartRequest]. -class DownloadStartRequest { +@ExchangeableObject() +class DownloadStartRequest_ { ///The full url to the content that should be downloaded. Uri url; @@ -23,7 +28,7 @@ class DownloadStartRequest { ///The name of the text encoding of the receiver, or `null` if no text encoding was specified. String? textEncodingName; - DownloadStartRequest( + DownloadStartRequest_( {required this.url, this.userAgent, this.contentDisposition, @@ -31,43 +36,4 @@ class DownloadStartRequest { required this.contentLength, this.suggestedFilename, this.textEncodingName}); - - ///Gets a possible [DownloadStartRequest] instance from a [Map] value. - static DownloadStartRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - - return DownloadStartRequest( - url: Uri.parse(map["url"]), - userAgent: map["userAgent"], - contentDisposition: map["contentDisposition"], - mimeType: map["mimeType"], - contentLength: map["contentLength"], - suggestedFilename: map["suggestedFilename"], - textEncodingName: map["textEncodingName"]); - } - - ///Converts instance to a map. - Map toMap() { - return { - "url": url.toString(), - "userAgent": userAgent, - "contentDisposition": contentDisposition, - "mimeType": mimeType, - "contentLength": contentLength, - "suggestedFilename": suggestedFilename, - "textEncodingName": textEncodingName - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } \ No newline at end of file diff --git a/lib/src/types/download_start_request.g.dart b/lib/src/types/download_start_request.g.dart new file mode 100644 index 00000000..b9483292 --- /dev/null +++ b/lib/src/types/download_start_request.g.dart @@ -0,0 +1,79 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'download_start_request.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class representing a download request of the WebView used by the event [WebView.onDownloadStartRequest]. +class DownloadStartRequest { + ///The full url to the content that should be downloaded. + Uri url; + + ///the user agent to be used for the download. + String? userAgent; + + ///Content-disposition http header, if present. + String? contentDisposition; + + ///The mimetype of the content reported by the server. + String? mimeType; + + ///The file size reported by the server. + int contentLength; + + ///A suggested filename to use if saving the resource to disk. + String? suggestedFilename; + + ///The name of the text encoding of the receiver, or `null` if no text encoding was specified. + String? textEncodingName; + DownloadStartRequest( + {required this.url, + this.userAgent, + this.contentDisposition, + this.mimeType, + required this.contentLength, + this.suggestedFilename, + this.textEncodingName}); + + ///Gets a possible [DownloadStartRequest] instance from a [Map] value. + static DownloadStartRequest? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = DownloadStartRequest( + url: Uri.parse(map['url']), + userAgent: map['userAgent'], + contentDisposition: map['contentDisposition'], + mimeType: map['mimeType'], + contentLength: map['contentLength'], + suggestedFilename: map['suggestedFilename'], + textEncodingName: map['textEncodingName'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "url": url.toString(), + "userAgent": userAgent, + "contentDisposition": contentDisposition, + "mimeType": mimeType, + "contentLength": contentLength, + "suggestedFilename": suggestedFilename, + "textEncodingName": textEncodingName, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'DownloadStartRequest{url: $url, userAgent: $userAgent, contentDisposition: $contentDisposition, mimeType: $mimeType, contentLength: $contentLength, suggestedFilename: $suggestedFilename, textEncodingName: $textEncodingName}'; + } +} diff --git a/lib/src/types/favicon.dart b/lib/src/types/favicon.dart index 89792dc7..4109919c 100644 --- a/lib/src/types/favicon.dart +++ b/lib/src/types/favicon.dart @@ -1,7 +1,12 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/in_app_webview_controller.dart'; +part 'favicon.g.dart'; + ///Class that represents a favicon of a website. It is used by [InAppWebViewController.getFavicons] method. -class Favicon { +@ExchangeableObject() +class Favicon_ { ///The url of the favicon image. Uri url; @@ -14,25 +19,5 @@ class Favicon { ///The height of the favicon image. int? height; - Favicon({required this.url, this.rel, this.width, this.height}); - - ///Converts instance to a map. - Map toMap() { - return { - "url": url.toString(), - "rel": rel, - "width": width, - "height": height - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + Favicon_({required this.url, this.rel, this.width, this.height}); } \ No newline at end of file diff --git a/lib/src/types/favicon.g.dart b/lib/src/types/favicon.g.dart new file mode 100644 index 00000000..8c4f644b --- /dev/null +++ b/lib/src/types/favicon.g.dart @@ -0,0 +1,57 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'favicon.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents a favicon of a website. It is used by [InAppWebViewController.getFavicons] method. +class Favicon { + ///The url of the favicon image. + Uri url; + + ///The relationship between the current web page and the favicon image. + String? rel; + + ///The width of the favicon image. + int? width; + + ///The height of the favicon image. + int? height; + Favicon({required this.url, this.rel, this.width, this.height}); + + ///Gets a possible [Favicon] instance from a [Map] value. + static Favicon? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = Favicon( + url: Uri.parse(map['url']), + rel: map['rel'], + width: map['width'], + height: map['height'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "url": url.toString(), + "rel": rel, + "width": width, + "height": height, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'Favicon{url: $url, rel: $rel, width: $width, height: $height}'; + } +} diff --git a/lib/src/types/fetch_request.dart b/lib/src/types/fetch_request.dart index 08ce2559..75b000e7 100644 --- a/lib/src/types/fetch_request.dart +++ b/lib/src/types/fetch_request.dart @@ -1,3 +1,5 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'fetch_request_action.dart'; import 'fetch_request_credential.dart'; import 'fetch_request_credential_default.dart'; @@ -5,8 +7,26 @@ import 'fetch_request_federated_credential.dart'; import 'fetch_request_password_credential.dart'; import 'referrer_policy.dart'; +part 'fetch_request.g.dart'; + +FetchRequestCredential? _fetchRequestCredentialDeserializer(dynamic value) { + Map? credentialMap = value?.cast(); + FetchRequestCredential? credentials; + if (credentialMap != null) { + if (credentialMap["type"] == "default") { + credentials = FetchRequestCredentialDefault.fromMap(credentialMap); + } else if (credentialMap["type"] == "federated") { + credentials = FetchRequestFederatedCredential.fromMap(credentialMap); + } else if (credentialMap["type"] == "password") { + credentials = FetchRequestPasswordCredential.fromMap(credentialMap); + } + } + return credentials; +} + ///Class that represents a HTTP request created with JavaScript using the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch). -class FetchRequest { +@ExchangeableObject() +class FetchRequest_ { ///The URL of the request. Uri? url; @@ -23,7 +43,10 @@ class FetchRequest { String? mode; ///The request credentials used by the request. - FetchRequestCredential? credentials; + @ExchangeableObjectProperty( + deserializer: _fetchRequestCredentialDeserializer + ) + FetchRequestCredential_? credentials; ///The cache mode used by the request. String? cache; @@ -35,7 +58,7 @@ class FetchRequest { String? referrer; ///The value of the referer HTTP header. - ReferrerPolicy? referrerPolicy; + ReferrerPolicy_? referrerPolicy; ///Contains the subresource integrity value of the request. String? integrity; @@ -44,9 +67,9 @@ class FetchRequest { bool? keepalive; ///Indicates the [FetchRequestAction] that can be used to control the request. - FetchRequestAction? action; + FetchRequestAction_? action; - FetchRequest( + FetchRequest_( {this.url, this.method, this.headers, @@ -59,68 +82,5 @@ class FetchRequest { this.referrerPolicy, this.integrity, this.keepalive, - this.action = FetchRequestAction.PROCEED}); - - ///Gets a possible [FetchRequest] instance from a [Map] value. - static FetchRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - - Map? credentialMap = - map["credentials"]?.cast(); - FetchRequestCredential? credentials; - if (credentialMap != null) { - if (credentialMap["type"] == "default") { - credentials = FetchRequestCredentialDefault.fromMap(credentialMap); - } else if (credentialMap["type"] == "federated") { - credentials = FetchRequestFederatedCredential.fromMap(credentialMap); - } else if (credentialMap["type"] == "password") { - credentials = FetchRequestPasswordCredential.fromMap(credentialMap); - } - } - - return FetchRequest( - url: map["url"] != null ? Uri.parse(map["url"]) : null, - method: map["method"], - headers: map["headers"]?.cast(), - body: map["body"], - mode: map["mode"], - credentials: credentials, - cache: map["cache"], - redirect: map["redirect"], - referrer: map["referrer"], - referrerPolicy: ReferrerPolicy.fromValue(map["referrerPolicy"]), - integrity: map["integrity"], - keepalive: map["keepalive"]); - } - - ///Converts instance to a map. - Map toMap() { - return { - "url": url?.toString(), - "method": method, - "headers": headers, - "body": body, - "mode": mode, - "credentials": credentials?.toMap(), - "cache": cache, - "redirect": redirect, - "referrer": referrer, - "referrerPolicy": referrerPolicy?.toValue(), - "integrity": integrity, - "keepalive": keepalive, - "action": action?.toValue() - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + this.action = FetchRequestAction_.PROCEED}); } \ No newline at end of file diff --git a/lib/src/types/fetch_request.g.dart b/lib/src/types/fetch_request.g.dart new file mode 100644 index 00000000..a242803d --- /dev/null +++ b/lib/src/types/fetch_request.g.dart @@ -0,0 +1,115 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'fetch_request.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents a HTTP request created with JavaScript using the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch). +class FetchRequest { + ///The URL of the request. + Uri? url; + + ///The HTTP request method used of the request. + String? method; + + ///The HTTP request headers. + Map? headers; + + ///Body of the request. + dynamic body; + + ///The mode used by the request. + String? mode; + + ///The request credentials used by the request. + FetchRequestCredential? credentials; + + ///The cache mode used by the request. + String? cache; + + ///The redirect mode used by the request. + String? redirect; + + ///A String specifying no-referrer, client, or a URL. + String? referrer; + + ///The value of the referer HTTP header. + ReferrerPolicy? referrerPolicy; + + ///Contains the subresource integrity value of the request. + String? integrity; + + ///The keepalive option used to allow the request to outlive the page. + bool? keepalive; + + ///Indicates the [FetchRequestAction] that can be used to control the request. + FetchRequestAction? action; + FetchRequest( + {this.url, + this.method, + this.headers, + this.body, + this.mode, + this.credentials, + this.cache, + this.redirect, + this.referrer, + this.referrerPolicy, + this.integrity, + this.keepalive, + this.action = FetchRequestAction.PROCEED}); + + ///Gets a possible [FetchRequest] instance from a [Map] value. + static FetchRequest? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = FetchRequest( + url: map['url'] != null ? Uri.parse(map['url']) : null, + method: map['method'], + headers: map['headers'], + body: map['body'], + mode: map['mode'], + credentials: _fetchRequestCredentialDeserializer(map['credentials']), + cache: map['cache'], + redirect: map['redirect'], + referrer: map['referrer'], + referrerPolicy: ReferrerPolicy.fromNativeValue(map['referrerPolicy']), + integrity: map['integrity'], + keepalive: map['keepalive'], + ); + instance.action = FetchRequestAction.fromNativeValue(map['action']); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "url": url?.toString(), + "method": method, + "headers": headers, + "body": body, + "mode": mode, + "credentials": credentials?.toMap(), + "cache": cache, + "redirect": redirect, + "referrer": referrer, + "referrerPolicy": referrerPolicy?.toNativeValue(), + "integrity": integrity, + "keepalive": keepalive, + "action": action?.toNativeValue(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'FetchRequest{url: $url, method: $method, headers: $headers, body: $body, mode: $mode, credentials: $credentials, cache: $cache, redirect: $redirect, referrer: $referrer, referrerPolicy: $referrerPolicy, integrity: $integrity, keepalive: $keepalive, action: $action}'; + } +} diff --git a/lib/src/types/fetch_request_action.dart b/lib/src/types/fetch_request_action.dart index 05b7b59f..62b983c3 100644 --- a/lib/src/types/fetch_request_action.dart +++ b/lib/src/types/fetch_request_action.dart @@ -1,22 +1,19 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'fetch_request.dart'; +part 'fetch_request_action.g.dart'; + ///Class used by [FetchRequest] class. -class FetchRequestAction { +@ExchangeableEnum() +class FetchRequestAction_ { + // ignore: unused_field final int _value; - - const FetchRequestAction._internal(this._value); - - ///Gets [int] value. - int toValue() => _value; + const FetchRequestAction_._internal(this._value); ///Aborts the fetch request. - static const ABORT = const FetchRequestAction._internal(0); + static const ABORT = const FetchRequestAction_._internal(0); ///Proceeds with the fetch request. - static const PROCEED = const FetchRequestAction._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const PROCEED = const FetchRequestAction_._internal(1); } \ No newline at end of file diff --git a/lib/src/types/fetch_request_action.g.dart b/lib/src/types/fetch_request_action.g.dart new file mode 100644 index 00000000..446657bd --- /dev/null +++ b/lib/src/types/fetch_request_action.g.dart @@ -0,0 +1,79 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'fetch_request_action.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used by [FetchRequest] class. +class FetchRequestAction { + final int _value; + final int _nativeValue; + const FetchRequestAction._internal(this._value, this._nativeValue); +// ignore: unused_element + factory FetchRequestAction._internalMultiPlatform( + int value, Function nativeValue) => + FetchRequestAction._internal(value, nativeValue()); + + ///Aborts the fetch request. + static const ABORT = FetchRequestAction._internal(0, 0); + + ///Proceeds with the fetch request. + static const PROCEED = FetchRequestAction._internal(1, 1); + + ///Set of all values of [FetchRequestAction]. + static final Set values = [ + FetchRequestAction.ABORT, + FetchRequestAction.PROCEED, + ].toSet(); + + ///Gets a possible [FetchRequestAction] instance from [int] value. + static FetchRequestAction? fromValue(int? value) { + if (value != null) { + try { + return FetchRequestAction.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [FetchRequestAction] instance from a native value. + static FetchRequestAction? fromNativeValue(int? value) { + if (value != null) { + try { + return FetchRequestAction.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'ABORT'; + case 1: + return 'PROCEED'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/fetch_request_credential.dart b/lib/src/types/fetch_request_credential.dart index 7e3e2bd6..9f356d7d 100644 --- a/lib/src/types/fetch_request_credential.dart +++ b/lib/src/types/fetch_request_credential.dart @@ -1,34 +1,16 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'fetch_request_credential_default.dart'; import 'fetch_request_federated_credential.dart'; import 'fetch_request_password_credential.dart'; +part 'fetch_request_credential.g.dart'; + ///Class that is an interface for [FetchRequestCredentialDefault], [FetchRequestFederatedCredential] and [FetchRequestPasswordCredential] classes. -class FetchRequestCredential { +@ExchangeableObject() +class FetchRequestCredential_ { ///Type of credentials. String? type; - FetchRequestCredential({this.type}); - - ///Gets a possible [FetchRequestCredential] instance from a [Map] value. - static FetchRequestCredential? fromMap(Map? map) { - if (map == null) { - return null; - } - return FetchRequestCredential(type: map["type"]); - } - - ///Converts instance to a map. - Map toMap() { - return {"type": type}; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + FetchRequestCredential_({this.type}); } \ No newline at end of file diff --git a/lib/src/types/fetch_request_credential.g.dart b/lib/src/types/fetch_request_credential.g.dart new file mode 100644 index 00000000..18909583 --- /dev/null +++ b/lib/src/types/fetch_request_credential.g.dart @@ -0,0 +1,42 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'fetch_request_credential.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that is an interface for [FetchRequestCredentialDefault], [FetchRequestFederatedCredential] and [FetchRequestPasswordCredential] classes. +class FetchRequestCredential { + ///Type of credentials. + String? type; + FetchRequestCredential({this.type}); + + ///Gets a possible [FetchRequestCredential] instance from a [Map] value. + static FetchRequestCredential? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = FetchRequestCredential( + type: map['type'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "type": type, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'FetchRequestCredential{type: $type}'; + } +} diff --git a/lib/src/types/fetch_request_credential_default.dart b/lib/src/types/fetch_request_credential_default.dart index c9219779..05771de6 100644 --- a/lib/src/types/fetch_request_credential_default.dart +++ b/lib/src/types/fetch_request_credential_default.dart @@ -1,38 +1,15 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'fetch_request.dart'; import 'fetch_request_credential.dart'; +part 'fetch_request_credential_default.g.dart'; + ///Class that represents the default credentials used by an [FetchRequest]. -class FetchRequestCredentialDefault extends FetchRequestCredential { +@ExchangeableObject() +class FetchRequestCredentialDefault_ extends FetchRequestCredential_ { ///The value of the credentials. String? value; - FetchRequestCredentialDefault({type, this.value}) : super(type: type); - - ///Gets a possible [FetchRequestCredentialDefault] instance from a [Map] value. - static FetchRequestCredentialDefault? fromMap( - Map? credentialsMap) { - if (credentialsMap == null) { - return null; - } - return FetchRequestCredentialDefault( - type: credentialsMap["type"], value: credentialsMap["value"]); - } - - ///Converts instance to a map. - Map toMap() { - return { - "type": type, - "value": value, - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + FetchRequestCredentialDefault_({type, this.value}) : super(type: type); } \ No newline at end of file diff --git a/lib/src/types/fetch_request_credential_default.g.dart b/lib/src/types/fetch_request_credential_default.g.dart new file mode 100644 index 00000000..30157ab2 --- /dev/null +++ b/lib/src/types/fetch_request_credential_default.g.dart @@ -0,0 +1,44 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'fetch_request_credential_default.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the default credentials used by an [FetchRequest]. +class FetchRequestCredentialDefault extends FetchRequestCredential { + ///The value of the credentials. + String? value; + FetchRequestCredentialDefault({this.value, String? type}) : super(type: type); + + ///Gets a possible [FetchRequestCredentialDefault] instance from a [Map] value. + static FetchRequestCredentialDefault? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = FetchRequestCredentialDefault( + value: map['value'], + ); + instance.type = map['type']; + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "type": type, + "value": value, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'FetchRequestCredentialDefault{type: $type, value: $value}'; + } +} diff --git a/lib/src/types/fetch_request_federated_credential.dart b/lib/src/types/fetch_request_federated_credential.dart index 1e9192c0..f0408508 100644 --- a/lib/src/types/fetch_request_federated_credential.dart +++ b/lib/src/types/fetch_request_federated_credential.dart @@ -1,7 +1,12 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'fetch_request_credential.dart'; +part 'fetch_request_federated_credential.g.dart'; + ///Class that represents a [FederatedCredential](https://developer.mozilla.org/en-US/docs/Web/API/FederatedCredential) type of credentials. -class FetchRequestFederatedCredential extends FetchRequestCredential { +@ExchangeableObject() +class FetchRequestFederatedCredential_ extends FetchRequestCredential_ { ///Credential's identifier. dynamic id; @@ -17,46 +22,7 @@ class FetchRequestFederatedCredential extends FetchRequestCredential { ///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication. Uri? iconURL; - FetchRequestFederatedCredential( + FetchRequestFederatedCredential_( {type, this.id, this.name, this.protocol, this.provider, this.iconURL}) : super(type: type); - - ///Gets a possible [FetchRequestFederatedCredential] instance from a [Map] value. - static FetchRequestFederatedCredential? fromMap( - Map? credentialsMap) { - if (credentialsMap == null) { - return null; - } - return FetchRequestFederatedCredential( - type: credentialsMap["type"], - id: credentialsMap["id"], - name: credentialsMap["name"], - protocol: credentialsMap["protocol"], - provider: credentialsMap["provider"], - iconURL: credentialsMap["iconURL"] != null - ? Uri.parse(credentialsMap["iconURL"]) - : null); - } - - ///Converts instance to a map. - Map toMap() { - return { - "type": type, - "id": id, - "name": name, - "protocol": protocol, - "provider": provider, - "iconURL": iconURL?.toString() - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } \ No newline at end of file diff --git a/lib/src/types/fetch_request_federated_credential.g.dart b/lib/src/types/fetch_request_federated_credential.g.dart new file mode 100644 index 00000000..7638e513 --- /dev/null +++ b/lib/src/types/fetch_request_federated_credential.g.dart @@ -0,0 +1,71 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'fetch_request_federated_credential.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents a [FederatedCredential](https://developer.mozilla.org/en-US/docs/Web/API/FederatedCredential) type of credentials. +class FetchRequestFederatedCredential extends FetchRequestCredential { + ///Credential's identifier. + dynamic id; + + ///The name associated with a credential. It should be a human-readable, public name. + String? name; + + ///Credential's federated identity protocol. + String? protocol; + + ///Credential's federated identity provider. + String? provider; + + ///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication. + Uri? iconURL; + FetchRequestFederatedCredential( + {this.id, + this.name, + this.protocol, + this.provider, + this.iconURL, + String? type}) + : super(type: type); + + ///Gets a possible [FetchRequestFederatedCredential] instance from a [Map] value. + static FetchRequestFederatedCredential? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = FetchRequestFederatedCredential( + id: map['id'], + name: map['name'], + protocol: map['protocol'], + provider: map['provider'], + iconURL: map['iconURL'] != null ? Uri.parse(map['iconURL']) : null, + ); + instance.type = map['type']; + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "type": type, + "id": id, + "name": name, + "protocol": protocol, + "provider": provider, + "iconURL": iconURL?.toString(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'FetchRequestFederatedCredential{type: $type, id: $id, name: $name, protocol: $protocol, provider: $provider, iconURL: $iconURL}'; + } +} diff --git a/lib/src/types/fetch_request_password_credential.dart b/lib/src/types/fetch_request_password_credential.dart index 95a4e34d..ea3aa1ac 100644 --- a/lib/src/types/fetch_request_password_credential.dart +++ b/lib/src/types/fetch_request_password_credential.dart @@ -1,7 +1,12 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'fetch_request_credential.dart'; +part 'fetch_request_password_credential.g.dart'; + ///Class that represents a [PasswordCredential](https://developer.mozilla.org/en-US/docs/Web/API/PasswordCredential) type of credentials. -class FetchRequestPasswordCredential extends FetchRequestCredential { +@ExchangeableObject() +class FetchRequestPasswordCredential_ extends FetchRequestCredential_ { ///Credential's identifier. dynamic id; @@ -14,44 +19,7 @@ class FetchRequestPasswordCredential extends FetchRequestCredential { ///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication. Uri? iconURL; - FetchRequestPasswordCredential( + FetchRequestPasswordCredential_( {type, this.id, this.name, this.password, this.iconURL}) : super(type: type); - - ///Gets a possible [FetchRequestPasswordCredential] instance from a [Map] value. - static FetchRequestPasswordCredential? fromMap( - Map? credentialsMap) { - if (credentialsMap == null) { - return null; - } - return FetchRequestPasswordCredential( - type: credentialsMap["type"], - id: credentialsMap["id"], - name: credentialsMap["name"], - password: credentialsMap["password"], - iconURL: credentialsMap["iconURL"] != null - ? Uri.parse(credentialsMap["iconURL"]) - : null); - } - - ///Converts instance to a map. - Map toMap() { - return { - "type": type, - "id": id, - "name": name, - "password": password, - "iconURL": iconURL?.toString() - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } \ No newline at end of file diff --git a/lib/src/types/fetch_request_password_credential.g.dart b/lib/src/types/fetch_request_password_credential.g.dart new file mode 100644 index 00000000..612d81e6 --- /dev/null +++ b/lib/src/types/fetch_request_password_credential.g.dart @@ -0,0 +1,61 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'fetch_request_password_credential.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents a [PasswordCredential](https://developer.mozilla.org/en-US/docs/Web/API/PasswordCredential) type of credentials. +class FetchRequestPasswordCredential extends FetchRequestCredential { + ///Credential's identifier. + dynamic id; + + ///The name associated with a credential. It should be a human-readable, public name. + String? name; + + ///The password of the credential. + String? password; + + ///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication. + Uri? iconURL; + FetchRequestPasswordCredential( + {this.id, this.name, this.password, this.iconURL, String? type}) + : super(type: type); + + ///Gets a possible [FetchRequestPasswordCredential] instance from a [Map] value. + static FetchRequestPasswordCredential? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = FetchRequestPasswordCredential( + id: map['id'], + name: map['name'], + password: map['password'], + iconURL: map['iconURL'] != null ? Uri.parse(map['iconURL']) : null, + ); + instance.type = map['type']; + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "type": type, + "id": id, + "name": name, + "password": password, + "iconURL": iconURL?.toString(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'FetchRequestPasswordCredential{type: $type, id: $id, name: $name, password: $password, iconURL: $iconURL}'; + } +} diff --git a/lib/src/types/force_dark.dart b/lib/src/types/force_dark.dart index 6236dfcb..d6d13451 100644 --- a/lib/src/types/force_dark.dart +++ b/lib/src/types/force_dark.dart @@ -1,59 +1,23 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'force_dark.g.dart'; + ///Class used to indicate the force dark mode. -class ForceDark { +@ExchangeableEnum() +class ForceDark_ { + // ignore: unused_field final int _value; - - const ForceDark._internal(this._value); - - ///Set of all values of [ForceDark]. - static final Set values = [ - ForceDark.OFF, - ForceDark.AUTO, - ForceDark.ON, - ].toSet(); - - ///Gets a possible [ForceDark] instance from an [int] value. - static ForceDark? fromValue(int? value) { - if (value != null) { - try { - return ForceDark.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "AUTO"; - case 2: - return "ON"; - case 0: - default: - return "OFF"; - } - } + const ForceDark_._internal(this._value); ///Disable force dark, irrespective of the force dark mode of the WebView parent. ///In this mode, WebView content will always be rendered as-is, regardless of whether native views are being automatically darkened. - static const OFF = const ForceDark._internal(0); + static const OFF = const ForceDark_._internal(0); ///Enable force dark dependent on the state of the WebView parent view. - static const AUTO = const ForceDark._internal(1); + static const AUTO = const ForceDark_._internal(1); ///Unconditionally enable force dark. In this mode WebView content will always be rendered so as to emulate a dark theme. - static const ON = const ForceDark._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const ON = const ForceDark_._internal(2); } ///An Android-specific class used to indicate the force dark mode. @@ -62,59 +26,19 @@ class ForceDark { /// ///Use [ForceDark] instead. @Deprecated("Use ForceDark instead") -class AndroidForceDark { +@ExchangeableEnum() +class AndroidForceDark_ { + // ignore: unused_field final int _value; - - const AndroidForceDark._internal(this._value); - - ///Set of all values of [AndroidForceDark]. - static final Set values = [ - AndroidForceDark.FORCE_DARK_OFF, - AndroidForceDark.FORCE_DARK_AUTO, - AndroidForceDark.FORCE_DARK_ON, - ].toSet(); - - ///Gets a possible [AndroidForceDark] instance from an [int] value. - static AndroidForceDark? fromValue(int? value) { - if (value != null) { - try { - return AndroidForceDark.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "FORCE_DARK_AUTO"; - case 2: - return "FORCE_DARK_ON"; - case 0: - default: - return "FORCE_DARK_OFF"; - } - } + const AndroidForceDark_._internal(this._value); ///Disable force dark, irrespective of the force dark mode of the WebView parent. ///In this mode, WebView content will always be rendered as-is, regardless of whether native views are being automatically darkened. - static const FORCE_DARK_OFF = const AndroidForceDark._internal(0); + static const FORCE_DARK_OFF = const AndroidForceDark_._internal(0); ///Enable force dark dependent on the state of the WebView parent view. - static const FORCE_DARK_AUTO = const AndroidForceDark._internal(1); + static const FORCE_DARK_AUTO = const AndroidForceDark_._internal(1); ///Unconditionally enable force dark. In this mode WebView content will always be rendered so as to emulate a dark theme. - static const FORCE_DARK_ON = const AndroidForceDark._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const FORCE_DARK_ON = const AndroidForceDark_._internal(2); } \ No newline at end of file diff --git a/lib/src/types/force_dark.g.dart b/lib/src/types/force_dark.g.dart new file mode 100644 index 00000000..730f4a75 --- /dev/null +++ b/lib/src/types/force_dark.g.dart @@ -0,0 +1,169 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'force_dark.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used to indicate the force dark mode. +class ForceDark { + final int _value; + final int _nativeValue; + const ForceDark._internal(this._value, this._nativeValue); +// ignore: unused_element + factory ForceDark._internalMultiPlatform(int value, Function nativeValue) => + ForceDark._internal(value, nativeValue()); + + ///Disable force dark, irrespective of the force dark mode of the WebView parent. + ///In this mode, WebView content will always be rendered as-is, regardless of whether native views are being automatically darkened. + static const OFF = ForceDark._internal(0, 0); + + ///Enable force dark dependent on the state of the WebView parent view. + static const AUTO = ForceDark._internal(1, 1); + + ///Unconditionally enable force dark. In this mode WebView content will always be rendered so as to emulate a dark theme. + static const ON = ForceDark._internal(2, 2); + + ///Set of all values of [ForceDark]. + static final Set values = [ + ForceDark.OFF, + ForceDark.AUTO, + ForceDark.ON, + ].toSet(); + + ///Gets a possible [ForceDark] instance from [int] value. + static ForceDark? fromValue(int? value) { + if (value != null) { + try { + return ForceDark.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [ForceDark] instance from a native value. + static ForceDark? fromNativeValue(int? value) { + if (value != null) { + try { + return ForceDark.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'OFF'; + case 1: + return 'AUTO'; + case 2: + return 'ON'; + } + return _value.toString(); + } +} + +///An Android-specific class used to indicate the force dark mode. +/// +///**NOTE**: available on Android 29+. +/// +///Use [ForceDark] instead. +@Deprecated('Use ForceDark instead') +class AndroidForceDark { + final int _value; + final int _nativeValue; + const AndroidForceDark._internal(this._value, this._nativeValue); +// ignore: unused_element + factory AndroidForceDark._internalMultiPlatform( + int value, Function nativeValue) => + AndroidForceDark._internal(value, nativeValue()); + + ///Disable force dark, irrespective of the force dark mode of the WebView parent. + ///In this mode, WebView content will always be rendered as-is, regardless of whether native views are being automatically darkened. + static const FORCE_DARK_OFF = AndroidForceDark._internal(0, 0); + + ///Enable force dark dependent on the state of the WebView parent view. + static const FORCE_DARK_AUTO = AndroidForceDark._internal(1, 1); + + ///Unconditionally enable force dark. In this mode WebView content will always be rendered so as to emulate a dark theme. + static const FORCE_DARK_ON = AndroidForceDark._internal(2, 2); + + ///Set of all values of [AndroidForceDark]. + static final Set values = [ + AndroidForceDark.FORCE_DARK_OFF, + AndroidForceDark.FORCE_DARK_AUTO, + AndroidForceDark.FORCE_DARK_ON, + ].toSet(); + + ///Gets a possible [AndroidForceDark] instance from [int] value. + static AndroidForceDark? fromValue(int? value) { + if (value != null) { + try { + return AndroidForceDark.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [AndroidForceDark] instance from a native value. + static AndroidForceDark? fromNativeValue(int? value) { + if (value != null) { + try { + return AndroidForceDark.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'FORCE_DARK_OFF'; + case 1: + return 'FORCE_DARK_AUTO'; + case 2: + return 'FORCE_DARK_ON'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/force_dark_strategy.dart b/lib/src/types/force_dark_strategy.dart index 700caf1b..154966e0 100644 --- a/lib/src/types/force_dark_strategy.dart +++ b/lib/src/types/force_dark_strategy.dart @@ -1,58 +1,27 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; +part 'force_dark_strategy.g.dart'; + ///Class used to indicate how [WebView] content should be darkened. -class ForceDarkStrategy { +@ExchangeableEnum() +class ForceDarkStrategy_ { + // ignore: unused_field final int _value; - - const ForceDarkStrategy._internal(this._value); - - ///Set of all values of [ForceDarkStrategy]. - static final Set values = [ - ForceDarkStrategy.USER_AGENT_DARKENING_ONLY, - ForceDarkStrategy.WEB_THEME_DARKENING_ONLY, - ForceDarkStrategy.PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING, - ].toSet(); - - ///Gets a possible [ForceDarkStrategy] instance from an [int] value. - static ForceDarkStrategy? fromValue(int? value) { - if (value != null) { - try { - return ForceDarkStrategy.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "WEB_THEME_DARKENING_ONLY"; - case 2: - return "PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING"; - case 0: - default: - return "USER_AGENT_DARKENING_ONLY"; - } - } + const ForceDarkStrategy_._internal(this._value); ///In this mode [WebView] content will be darkened by a user agent and it will ignore the web page's dark theme if it exists. ///To avoid mixing two different darkening strategies, the `prefers-color-scheme` media query will evaluate to light. /// ///See [specification](https://drafts.csswg.org/css-color-adjust-1/) for more information. - static const USER_AGENT_DARKENING_ONLY = const ForceDarkStrategy._internal(0); + static const USER_AGENT_DARKENING_ONLY = const ForceDarkStrategy_._internal(0); ///In this mode [WebView] content will always be darkened using dark theme provided by web page. ///If web page does not provide dark theme support [WebView] content will be rendered with a default theme. /// ///See [specification](https://drafts.csswg.org/css-color-adjust-1/) for more information. - static const WEB_THEME_DARKENING_ONLY = const ForceDarkStrategy._internal(1); + static const WEB_THEME_DARKENING_ONLY = const ForceDarkStrategy_._internal(1); ///In this mode [WebView] content will be darkened by a user agent unless web page supports dark theme. ///[WebView] determines whether web pages supports dark theme by the presence of `color-scheme` metadata containing `"dark"` value. @@ -60,10 +29,5 @@ class ForceDarkStrategy { ///If the metadata is not presented [WebView] content will be darkened by a user agent and `prefers-color-scheme` media query will evaluate to light. /// ///See [specification](https://drafts.csswg.org/css-color-adjust-1/) for more information. - static const PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING = const ForceDarkStrategy._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING = const ForceDarkStrategy_._internal(2); } diff --git a/lib/src/types/force_dark_strategy.g.dart b/lib/src/types/force_dark_strategy.g.dart new file mode 100644 index 00000000..9a23833b --- /dev/null +++ b/lib/src/types/force_dark_strategy.g.dart @@ -0,0 +1,97 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'force_dark_strategy.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used to indicate how [WebView] content should be darkened. +class ForceDarkStrategy { + final int _value; + final int _nativeValue; + const ForceDarkStrategy._internal(this._value, this._nativeValue); +// ignore: unused_element + factory ForceDarkStrategy._internalMultiPlatform( + int value, Function nativeValue) => + ForceDarkStrategy._internal(value, nativeValue()); + + ///In this mode [WebView] content will be darkened by a user agent and it will ignore the web page's dark theme if it exists. + ///To avoid mixing two different darkening strategies, the `prefers-color-scheme` media query will evaluate to light. + /// + ///See [specification](https://drafts.csswg.org/css-color-adjust-1/) for more information. + static const USER_AGENT_DARKENING_ONLY = ForceDarkStrategy._internal(0, 0); + + ///In this mode [WebView] content will always be darkened using dark theme provided by web page. + ///If web page does not provide dark theme support [WebView] content will be rendered with a default theme. + /// + ///See [specification](https://drafts.csswg.org/css-color-adjust-1/) for more information. + static const WEB_THEME_DARKENING_ONLY = ForceDarkStrategy._internal(1, 1); + + ///In this mode [WebView] content will be darkened by a user agent unless web page supports dark theme. + ///[WebView] determines whether web pages supports dark theme by the presence of `color-scheme` metadata containing `"dark"` value. + ///For example, ``. + ///If the metadata is not presented [WebView] content will be darkened by a user agent and `prefers-color-scheme` media query will evaluate to light. + /// + ///See [specification](https://drafts.csswg.org/css-color-adjust-1/) for more information. + static const PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING = + ForceDarkStrategy._internal(2, 2); + + ///Set of all values of [ForceDarkStrategy]. + static final Set values = [ + ForceDarkStrategy.USER_AGENT_DARKENING_ONLY, + ForceDarkStrategy.WEB_THEME_DARKENING_ONLY, + ForceDarkStrategy.PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING, + ].toSet(); + + ///Gets a possible [ForceDarkStrategy] instance from [int] value. + static ForceDarkStrategy? fromValue(int? value) { + if (value != null) { + try { + return ForceDarkStrategy.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [ForceDarkStrategy] instance from a native value. + static ForceDarkStrategy? fromNativeValue(int? value) { + if (value != null) { + try { + return ForceDarkStrategy.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'USER_AGENT_DARKENING_ONLY'; + case 1: + return 'WEB_THEME_DARKENING_ONLY'; + case 2: + return 'PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/form_resubmission_action.dart b/lib/src/types/form_resubmission_action.dart index 2cff9af5..052f202a 100644 --- a/lib/src/types/form_resubmission_action.dart +++ b/lib/src/types/form_resubmission_action.dart @@ -1,37 +1,19 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; +part 'form_resubmission_action.g.dart'; + ///Class that represents the action to take used by the [WebView.onFormResubmission] event. -class FormResubmissionAction { +@ExchangeableEnum() +class FormResubmissionAction_ { + // ignore: unused_field final int _value; - - const FormResubmissionAction._internal(this._value); - - ///Gets [int] value. - int toValue() => _value; + const FormResubmissionAction_._internal(this._value); ///Resend data - static const RESEND = const FormResubmissionAction._internal(0); + static const RESEND = const FormResubmissionAction_._internal(0); ///Don't resend data - static const DONT_RESEND = const FormResubmissionAction._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; - - ///Converts instance to a map. - Map toMap() { - return {"action": _value}; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + static const DONT_RESEND = const FormResubmissionAction_._internal(1); } \ No newline at end of file diff --git a/lib/src/types/form_resubmission_action.g.dart b/lib/src/types/form_resubmission_action.g.dart new file mode 100644 index 00000000..9fad9432 --- /dev/null +++ b/lib/src/types/form_resubmission_action.g.dart @@ -0,0 +1,79 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'form_resubmission_action.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class that represents the action to take used by the [WebView.onFormResubmission] event. +class FormResubmissionAction { + final int _value; + final int _nativeValue; + const FormResubmissionAction._internal(this._value, this._nativeValue); +// ignore: unused_element + factory FormResubmissionAction._internalMultiPlatform( + int value, Function nativeValue) => + FormResubmissionAction._internal(value, nativeValue()); + + ///Resend data + static const RESEND = FormResubmissionAction._internal(0, 0); + + ///Don't resend data + static const DONT_RESEND = FormResubmissionAction._internal(1, 1); + + ///Set of all values of [FormResubmissionAction]. + static final Set values = [ + FormResubmissionAction.RESEND, + FormResubmissionAction.DONT_RESEND, + ].toSet(); + + ///Gets a possible [FormResubmissionAction] instance from [int] value. + static FormResubmissionAction? fromValue(int? value) { + if (value != null) { + try { + return FormResubmissionAction.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [FormResubmissionAction] instance from a native value. + static FormResubmissionAction? fromNativeValue(int? value) { + if (value != null) { + try { + return FormResubmissionAction.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'RESEND'; + case 1: + return 'DONT_RESEND'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/frame_info.g.dart b/lib/src/types/frame_info.g.dart index 3b270ccb..71f0402a 100644 --- a/lib/src/types/frame_info.g.dart +++ b/lib/src/types/frame_info.g.dart @@ -15,7 +15,7 @@ class FrameInfo { URLRequest? request; ///The frame’s security origin. - dynamic securityOrigin; + SecurityOrigin? securityOrigin; FrameInfo({required this.isMainFrame, this.request, this.securityOrigin}); ///Gets a possible [FrameInfo] instance from a [Map] value. @@ -26,8 +26,9 @@ class FrameInfo { final instance = FrameInfo( isMainFrame: map['isMainFrame'], request: URLRequest.fromMap(map['request']?.cast()), + securityOrigin: SecurityOrigin.fromMap( + map['securityOrigin']?.cast()), ); - instance.securityOrigin = map['securityOrigin']; return instance; } @@ -36,7 +37,7 @@ class FrameInfo { return { "isMainFrame": isMainFrame, "request": request?.toMap(), - "securityOrigin": securityOrigin, + "securityOrigin": securityOrigin?.toMap(), }; } @@ -65,7 +66,7 @@ class IOSWKFrameInfo { URLRequest? request; ///The frame’s security origin. - dynamic securityOrigin; + IOSWKSecurityOrigin? securityOrigin; IOSWKFrameInfo( {required this.isMainFrame, this.request, this.securityOrigin}); @@ -77,8 +78,9 @@ class IOSWKFrameInfo { final instance = IOSWKFrameInfo( isMainFrame: map['isMainFrame'], request: URLRequest.fromMap(map['request']?.cast()), + securityOrigin: IOSWKSecurityOrigin.fromMap( + map['securityOrigin']?.cast()), ); - instance.securityOrigin = map['securityOrigin']; return instance; } @@ -87,7 +89,7 @@ class IOSWKFrameInfo { return { "isMainFrame": isMainFrame, "request": request?.toMap(), - "securityOrigin": securityOrigin, + "securityOrigin": securityOrigin?.toMap(), }; } diff --git a/lib/src/types/geolocation_permission_show_prompt_response.dart b/lib/src/types/geolocation_permission_show_prompt_response.dart index 59fe0da6..623f5f1d 100644 --- a/lib/src/types/geolocation_permission_show_prompt_response.dart +++ b/lib/src/types/geolocation_permission_show_prompt_response.dart @@ -1,7 +1,12 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; +part 'geolocation_permission_show_prompt_response.g.dart'; + ///Class used by the host application to set the Geolocation permission state for an origin during the [WebView.onGeolocationPermissionsShowPrompt] event. -class GeolocationPermissionShowPromptResponse { +@ExchangeableObject() +class GeolocationPermissionShowPromptResponse_ { ///The origin for which permissions are set. String origin; @@ -12,21 +17,6 @@ class GeolocationPermissionShowPromptResponse { ///The default value is `false`. bool retain; - GeolocationPermissionShowPromptResponse( + GeolocationPermissionShowPromptResponse_( {required this.origin, required this.allow, this.retain = false}); - - ///Converts instance to a map. - Map toMap() { - return {"origin": origin, "allow": allow, "retain": retain}; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } \ No newline at end of file diff --git a/lib/src/types/geolocation_permission_show_prompt_response.g.dart b/lib/src/types/geolocation_permission_show_prompt_response.g.dart new file mode 100644 index 00000000..082749eb --- /dev/null +++ b/lib/src/types/geolocation_permission_show_prompt_response.g.dart @@ -0,0 +1,55 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'geolocation_permission_show_prompt_response.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class used by the host application to set the Geolocation permission state for an origin during the [WebView.onGeolocationPermissionsShowPrompt] event. +class GeolocationPermissionShowPromptResponse { + ///The origin for which permissions are set. + String origin; + + ///Whether or not the origin should be allowed to use the Geolocation API. + bool allow; + + ///Whether the permission should be retained beyond the lifetime of a page currently being displayed by a WebView + ///The default value is `false`. + bool retain; + GeolocationPermissionShowPromptResponse( + {required this.origin, required this.allow, this.retain = false}); + + ///Gets a possible [GeolocationPermissionShowPromptResponse] instance from a [Map] value. + static GeolocationPermissionShowPromptResponse? fromMap( + Map? map) { + if (map == null) { + return null; + } + final instance = GeolocationPermissionShowPromptResponse( + origin: map['origin'], + allow: map['allow'], + ); + instance.retain = map['retain']; + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "origin": origin, + "allow": allow, + "retain": retain, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'GeolocationPermissionShowPromptResponse{origin: $origin, allow: $allow, retain: $retain}'; + } +} diff --git a/lib/src/types/http_auth_response.dart b/lib/src/types/http_auth_response.dart index 9cc7e199..bf05075f 100644 --- a/lib/src/types/http_auth_response.dart +++ b/lib/src/types/http_auth_response.dart @@ -1,9 +1,13 @@ -import '../in_app_webview/webview.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; +import '../in_app_webview/webview.dart'; import 'http_auth_response_action.dart'; +part 'http_auth_response.g.dart'; + ///Class that represents the response used by the [WebView.onReceivedHttpAuthRequest] event. -class HttpAuthResponse { +@ExchangeableObject() +class HttpAuthResponse_ { ///Represents the username used for the authentication if the [action] corresponds to [HttpAuthResponseAction.PROCEED] String username; @@ -14,31 +18,11 @@ class HttpAuthResponse { bool permanentPersistence; ///Indicate the [HttpAuthResponseAction] to take in response of the authentication challenge. - HttpAuthResponseAction? action; + HttpAuthResponseAction_? action; - HttpAuthResponse( + HttpAuthResponse_( {this.username = "", this.password = "", this.permanentPersistence = false, - this.action = HttpAuthResponseAction.CANCEL}); - - ///Converts instance to a map. - Map toMap() { - return { - "username": username, - "password": password, - "permanentPersistence": permanentPersistence, - "action": action?.toValue() - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + this.action = HttpAuthResponseAction_.CANCEL}); } \ No newline at end of file diff --git a/lib/src/types/http_auth_response.g.dart b/lib/src/types/http_auth_response.g.dart new file mode 100644 index 00000000..62ce547b --- /dev/null +++ b/lib/src/types/http_auth_response.g.dart @@ -0,0 +1,60 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'http_auth_response.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the response used by the [WebView.onReceivedHttpAuthRequest] event. +class HttpAuthResponse { + ///Represents the username used for the authentication if the [action] corresponds to [HttpAuthResponseAction.PROCEED] + String username; + + ///Represents the password used for the authentication if the [action] corresponds to [HttpAuthResponseAction.PROCEED] + String password; + + ///Indicate if the given credentials need to be saved permanently. + bool permanentPersistence; + + ///Indicate the [HttpAuthResponseAction] to take in response of the authentication challenge. + HttpAuthResponseAction? action; + HttpAuthResponse( + {this.username = "", + this.password = "", + this.permanentPersistence = false, + this.action = HttpAuthResponseAction.CANCEL}); + + ///Gets a possible [HttpAuthResponse] instance from a [Map] value. + static HttpAuthResponse? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = HttpAuthResponse(); + instance.username = map['username']; + instance.password = map['password']; + instance.permanentPersistence = map['permanentPersistence']; + instance.action = HttpAuthResponseAction.fromNativeValue(map['action']); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "username": username, + "password": password, + "permanentPersistence": permanentPersistence, + "action": action?.toNativeValue(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'HttpAuthResponse{username: $username, password: $password, permanentPersistence: $permanentPersistence, action: $action}'; + } +} diff --git a/lib/src/types/http_auth_response_action.dart b/lib/src/types/http_auth_response_action.dart index 46c538d9..1e5a8aae 100644 --- a/lib/src/types/http_auth_response_action.dart +++ b/lib/src/types/http_auth_response_action.dart @@ -1,26 +1,22 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'http_auth_response.dart'; +part 'http_auth_response_action.g.dart'; + ///Class used by [HttpAuthResponse] class. -class HttpAuthResponseAction { +@ExchangeableEnum() +class HttpAuthResponseAction_ { + // ignore: unused_field final int _value; - - const HttpAuthResponseAction._internal(this._value); - - ///Gets [int] value. - int toValue() => _value; - + const HttpAuthResponseAction_._internal(this._value); ///Instructs the WebView to cancel the authentication request. - static const CANCEL = const HttpAuthResponseAction._internal(0); + static const CANCEL = const HttpAuthResponseAction_._internal(0); ///Instructs the WebView to proceed with the authentication with the given credentials. - static const PROCEED = const HttpAuthResponseAction._internal(1); + static const PROCEED = const HttpAuthResponseAction_._internal(1); ///Uses the credentials stored for the current host. static const USE_SAVED_HTTP_AUTH_CREDENTIALS = - const HttpAuthResponseAction._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + const HttpAuthResponseAction_._internal(2); } \ No newline at end of file diff --git a/lib/src/types/http_auth_response_action.g.dart b/lib/src/types/http_auth_response_action.g.dart new file mode 100644 index 00000000..32012431 --- /dev/null +++ b/lib/src/types/http_auth_response_action.g.dart @@ -0,0 +1,86 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'http_auth_response_action.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used by [HttpAuthResponse] class. +class HttpAuthResponseAction { + final int _value; + final int _nativeValue; + const HttpAuthResponseAction._internal(this._value, this._nativeValue); +// ignore: unused_element + factory HttpAuthResponseAction._internalMultiPlatform( + int value, Function nativeValue) => + HttpAuthResponseAction._internal(value, nativeValue()); + + ///Instructs the WebView to cancel the authentication request. + static const CANCEL = HttpAuthResponseAction._internal(0, 0); + + ///Instructs the WebView to proceed with the authentication with the given credentials. + static const PROCEED = HttpAuthResponseAction._internal(1, 1); + + ///Uses the credentials stored for the current host. + static const USE_SAVED_HTTP_AUTH_CREDENTIALS = + HttpAuthResponseAction._internal(2, 2); + + ///Set of all values of [HttpAuthResponseAction]. + static final Set values = [ + HttpAuthResponseAction.CANCEL, + HttpAuthResponseAction.PROCEED, + HttpAuthResponseAction.USE_SAVED_HTTP_AUTH_CREDENTIALS, + ].toSet(); + + ///Gets a possible [HttpAuthResponseAction] instance from [int] value. + static HttpAuthResponseAction? fromValue(int? value) { + if (value != null) { + try { + return HttpAuthResponseAction.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [HttpAuthResponseAction] instance from a native value. + static HttpAuthResponseAction? fromNativeValue(int? value) { + if (value != null) { + try { + return HttpAuthResponseAction.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'CANCEL'; + case 1: + return 'PROCEED'; + case 2: + return 'USE_SAVED_HTTP_AUTH_CREDENTIALS'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/http_authentication_challenge.dart b/lib/src/types/http_authentication_challenge.dart index 6dd7300f..a149191f 100644 --- a/lib/src/types/http_authentication_challenge.dart +++ b/lib/src/types/http_authentication_challenge.dart @@ -1,12 +1,17 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; import 'url_credential.dart'; import 'url_response.dart'; import 'url_authentication_challenge.dart'; import 'url_protection_space.dart'; +part 'http_authentication_challenge.g.dart'; + ///Class that represents the challenge of the [WebView.onReceivedHttpAuthRequest] event. ///It provides all the information about the challenge. -class HttpAuthenticationChallenge extends URLAuthenticationChallenge { +@ExchangeableObject() +class HttpAuthenticationChallenge_ extends URLAuthenticationChallenge_ { ///A count of previous failed authentication attempts. int previousFailureCount; @@ -16,17 +21,17 @@ class HttpAuthenticationChallenge extends URLAuthenticationChallenge { ///If the proposed credential is not nil and returns true when you call its hasPassword method, then the credential is ready to use as-is. ///If the proposed credential’s hasPassword method returns false, then the credential provides a default user name, ///and the client must prompt the user for a corresponding password. - URLCredential? proposedCredential; + URLCredential_? proposedCredential; ///Use [failureResponse] instead. @Deprecated("Use failureResponse instead") - IOSURLResponse? iosFailureResponse; + IOSURLResponse_? iosFailureResponse; ///The URL response object representing the last authentication failure. ///This value is `null` if the protocol doesn’t use responses to indicate an authentication failure. /// ///**NOTE**: available only on iOS. - URLResponse? failureResponse; + URLResponse_? failureResponse; ///Use [error] instead. @Deprecated("Use error instead") @@ -38,62 +43,13 @@ class HttpAuthenticationChallenge extends URLAuthenticationChallenge { ///**NOTE**: available only on iOS. String? error; - HttpAuthenticationChallenge( + HttpAuthenticationChallenge_( {required this.previousFailureCount, - required URLProtectionSpace protectionSpace, + required URLProtectionSpace_ protectionSpace, @Deprecated("Use failureResponse instead") this.iosFailureResponse, this.failureResponse, this.proposedCredential, @Deprecated("Use error instead") this.iosError, this.error}) - : super(protectionSpace: protectionSpace) { - this.failureResponse = this.failureResponse ?? - // ignore: deprecated_member_use_from_same_package - URLResponse.fromMap(this.iosFailureResponse?.toMap()); - // ignore: deprecated_member_use_from_same_package - this.error = this.error ?? this.iosError; - } - - ///Gets a possible [HttpAuthenticationChallenge] instance from a [Map] value. - static HttpAuthenticationChallenge? fromMap(Map? map) { - if (map == null) { - return null; - } - return HttpAuthenticationChallenge( - previousFailureCount: map["previousFailureCount"], - protectionSpace: URLProtectionSpace.fromMap( - map["protectionSpace"].cast())!, - proposedCredential: URLCredential.fromMap( - map["proposedCredential"]?.cast()), - // ignore: deprecated_member_use_from_same_package - iosFailureResponse: IOSURLResponse.fromMap( - map["failureResponse"]?.cast()), - failureResponse: - URLResponse.fromMap(map["failureResponse"]?.cast()), - // ignore: deprecated_member_use_from_same_package - iosError: map["error"], - error: map["error"], - ); - } - - ///Converts instance to a map. - Map toMap() { - var map = super.toMap(); - map.addAll({ - "previousFailureCount": previousFailureCount, - "protectionSpace": protectionSpace.toMap(), - "proposedCredential": proposedCredential?.toMap(), - "iosFailureResponse": - // ignore: deprecated_member_use_from_same_package - failureResponse?.toMap() ?? iosFailureResponse?.toMap(), - "failureResponse": - // ignore: deprecated_member_use_from_same_package - failureResponse?.toMap() ?? iosFailureResponse?.toMap(), - // ignore: deprecated_member_use_from_same_package - "iosError": error ?? iosError, - // ignore: deprecated_member_use_from_same_package - "error": error ?? iosError, - }); - return map; - } + : super(protectionSpace: protectionSpace); } \ No newline at end of file diff --git a/lib/src/types/http_authentication_challenge.g.dart b/lib/src/types/http_authentication_challenge.g.dart new file mode 100644 index 00000000..5baa3860 --- /dev/null +++ b/lib/src/types/http_authentication_challenge.g.dart @@ -0,0 +1,97 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'http_authentication_challenge.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the challenge of the [WebView.onReceivedHttpAuthRequest] event. +///It provides all the information about the challenge. +class HttpAuthenticationChallenge extends URLAuthenticationChallenge { + ///A count of previous failed authentication attempts. + int previousFailureCount; + + ///The proposed credential for this challenge. + ///This method returns `null` if there is no default credential for this challenge. + ///If you have previously attempted to authenticate and failed, this method returns the most recent failed credential. + ///If the proposed credential is not nil and returns true when you call its hasPassword method, then the credential is ready to use as-is. + ///If the proposed credential’s hasPassword method returns false, then the credential provides a default user name, + ///and the client must prompt the user for a corresponding password. + URLCredential? proposedCredential; + + ///Use [failureResponse] instead. + @Deprecated('Use failureResponse instead') + IOSURLResponse? iosFailureResponse; + + ///The URL response object representing the last authentication failure. + ///This value is `null` if the protocol doesn’t use responses to indicate an authentication failure. + /// + ///**NOTE**: available only on iOS. + URLResponse? failureResponse; + + ///Use [error] instead. + @Deprecated('Use error instead') + String? iosError; + + ///The error object representing the last authentication failure. + ///This value is `null` if the protocol doesn’t use errors to indicate an authentication failure. + /// + ///**NOTE**: available only on iOS. + String? error; + HttpAuthenticationChallenge( + {required this.previousFailureCount, + this.proposedCredential, + @Deprecated('Use failureResponse instead') this.iosFailureResponse, + this.failureResponse, + @Deprecated('Use error instead') this.iosError, + this.error, + required URLProtectionSpace protectionSpace}) + : super(protectionSpace: protectionSpace) { + failureResponse = + failureResponse ?? URLResponse.fromMap(iosFailureResponse?.toMap()); + error = error ?? iosError; + } + + ///Gets a possible [HttpAuthenticationChallenge] instance from a [Map] value. + static HttpAuthenticationChallenge? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = HttpAuthenticationChallenge( + protectionSpace: URLProtectionSpace.fromMap( + map['protectionSpace']?.cast())!, + previousFailureCount: map['previousFailureCount'], + proposedCredential: URLCredential.fromMap( + map['proposedCredential']?.cast()), + iosFailureResponse: IOSURLResponse.fromMap( + map['failureResponse']?.cast()), + failureResponse: + URLResponse.fromMap(map['failureResponse']?.cast()), + iosError: map['error'], + error: map['error'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "protectionSpace": protectionSpace.toMap(), + "previousFailureCount": previousFailureCount, + "proposedCredential": proposedCredential?.toMap(), + "failureResponse": failureResponse?.toMap(), + "error": error, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'HttpAuthenticationChallenge{protectionSpace: $protectionSpace, previousFailureCount: $previousFailureCount, proposedCredential: $proposedCredential, failureResponse: $failureResponse, error: $error}'; + } +} diff --git a/lib/src/types/in_app_webview_hit_test_result.dart b/lib/src/types/in_app_webview_hit_test_result.dart index c1b5a4d2..bc5807fb 100644 --- a/lib/src/types/in_app_webview_hit_test_result.dart +++ b/lib/src/types/in_app_webview_hit_test_result.dart @@ -1,38 +1,17 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'in_app_webview_hit_test_result_type.dart'; +part 'in_app_webview_hit_test_result.g.dart'; + ///Class that represents the hit result for hitting an HTML elements. -class InAppWebViewHitTestResult { +@ExchangeableObject() +class InAppWebViewHitTestResult_ { ///The type of the hit test result. - InAppWebViewHitTestResultType? type; + InAppWebViewHitTestResultType_? type; ///Additional type-dependant information about the result. String? extra; - InAppWebViewHitTestResult({this.type, this.extra}); - - ///Gets a possible [InAppWebViewHitTestResult] instance from a [Map] value. - static InAppWebViewHitTestResult? fromMap(Map? map) { - if (map == null) { - return null; - } - - return InAppWebViewHitTestResult( - type: InAppWebViewHitTestResultType.fromValue(map["type"]), - extra: map["extra"]); - } - - ///Converts instance to a map. - Map toMap() { - return {"type": type?.toValue(), "extra": extra}; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + InAppWebViewHitTestResult_({this.type, this.extra}); } \ No newline at end of file diff --git a/lib/src/types/in_app_webview_hit_test_result.g.dart b/lib/src/types/in_app_webview_hit_test_result.g.dart new file mode 100644 index 00000000..131e2d2b --- /dev/null +++ b/lib/src/types/in_app_webview_hit_test_result.g.dart @@ -0,0 +1,47 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'in_app_webview_hit_test_result.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the hit result for hitting an HTML elements. +class InAppWebViewHitTestResult { + ///The type of the hit test result. + InAppWebViewHitTestResultType? type; + + ///Additional type-dependant information about the result. + String? extra; + InAppWebViewHitTestResult({this.type, this.extra}); + + ///Gets a possible [InAppWebViewHitTestResult] instance from a [Map] value. + static InAppWebViewHitTestResult? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = InAppWebViewHitTestResult( + type: InAppWebViewHitTestResultType.fromNativeValue(map['type']), + extra: map['extra'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "type": type?.toNativeValue(), + "extra": extra, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'InAppWebViewHitTestResult{type: $type, extra: $extra}'; + } +} diff --git a/lib/src/types/in_app_webview_hit_test_result_type.dart b/lib/src/types/in_app_webview_hit_test_result_type.dart index 5679b4cd..1a4d8962 100644 --- a/lib/src/types/in_app_webview_hit_test_result_type.dart +++ b/lib/src/types/in_app_webview_hit_test_result_type.dart @@ -1,89 +1,38 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'in_app_webview_hit_test_result_type.g.dart'; + ///Class representing the [InAppWebViewHitTestResult] type. -class InAppWebViewHitTestResultType { +@ExchangeableEnum() +class InAppWebViewHitTestResultType_ { + // ignore: unused_field final int _value; - - const InAppWebViewHitTestResultType._internal(this._value); - - ///Set of all values of [InAppWebViewHitTestResultType]. - static final Set values = [ - InAppWebViewHitTestResultType.UNKNOWN_TYPE, - InAppWebViewHitTestResultType.PHONE_TYPE, - InAppWebViewHitTestResultType.GEO_TYPE, - InAppWebViewHitTestResultType.EMAIL_TYPE, - InAppWebViewHitTestResultType.IMAGE_TYPE, - InAppWebViewHitTestResultType.SRC_ANCHOR_TYPE, - InAppWebViewHitTestResultType.SRC_IMAGE_ANCHOR_TYPE, - InAppWebViewHitTestResultType.EDIT_TEXT_TYPE, - ].toSet(); - - ///Gets a possible [InAppWebViewHitTestResultType] instance from an [int] value. - static InAppWebViewHitTestResultType? fromValue(int? value) { - if (value != null) { - try { - return InAppWebViewHitTestResultType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 2: - return "PHONE_TYPE"; - case 3: - return "GEO_TYPE"; - case 4: - return "EMAIL_TYPE"; - case 5: - return "IMAGE_TYPE"; - case 7: - return "SRC_ANCHOR_TYPE"; - case 8: - return "SRC_IMAGE_ANCHOR_TYPE"; - case 9: - return "EDIT_TEXT_TYPE"; - case 0: - default: - return "UNKNOWN_TYPE"; - } - } + const InAppWebViewHitTestResultType_._internal(this._value); ///Default [InAppWebViewHitTestResult], where the target is unknown. - static const UNKNOWN_TYPE = const InAppWebViewHitTestResultType._internal(0); + static const UNKNOWN_TYPE = const InAppWebViewHitTestResultType_._internal(0); ///[InAppWebViewHitTestResult] for hitting a phone number. - static const PHONE_TYPE = const InAppWebViewHitTestResultType._internal(2); + static const PHONE_TYPE = const InAppWebViewHitTestResultType_._internal(2); ///[InAppWebViewHitTestResult] for hitting a map address. - static const GEO_TYPE = const InAppWebViewHitTestResultType._internal(3); + static const GEO_TYPE = const InAppWebViewHitTestResultType_._internal(3); ///[InAppWebViewHitTestResult] for hitting an email address. - static const EMAIL_TYPE = const InAppWebViewHitTestResultType._internal(4); + static const EMAIL_TYPE = const InAppWebViewHitTestResultType_._internal(4); ///[InAppWebViewHitTestResult] for hitting an HTML::img tag. - static const IMAGE_TYPE = const InAppWebViewHitTestResultType._internal(5); + static const IMAGE_TYPE = const InAppWebViewHitTestResultType_._internal(5); ///[InAppWebViewHitTestResult] for hitting a HTML::a tag with src=http. static const SRC_ANCHOR_TYPE = - const InAppWebViewHitTestResultType._internal(7); + const InAppWebViewHitTestResultType_._internal(7); ///[InAppWebViewHitTestResult] for hitting a HTML::a tag with src=http + HTML::img. static const SRC_IMAGE_ANCHOR_TYPE = - const InAppWebViewHitTestResultType._internal(8); + const InAppWebViewHitTestResultType_._internal(8); ///[InAppWebViewHitTestResult] for hitting an edit text area. static const EDIT_TEXT_TYPE = - const InAppWebViewHitTestResultType._internal(9); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + const InAppWebViewHitTestResultType_._internal(9); } \ No newline at end of file diff --git a/lib/src/types/in_app_webview_hit_test_result_type.g.dart b/lib/src/types/in_app_webview_hit_test_result_type.g.dart new file mode 100644 index 00000000..ca208812 --- /dev/null +++ b/lib/src/types/in_app_webview_hit_test_result_type.g.dart @@ -0,0 +1,116 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'in_app_webview_hit_test_result_type.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class representing the [InAppWebViewHitTestResult] type. +class InAppWebViewHitTestResultType { + final int _value; + final int _nativeValue; + const InAppWebViewHitTestResultType._internal(this._value, this._nativeValue); +// ignore: unused_element + factory InAppWebViewHitTestResultType._internalMultiPlatform( + int value, Function nativeValue) => + InAppWebViewHitTestResultType._internal(value, nativeValue()); + + ///Default [InAppWebViewHitTestResult], where the target is unknown. + static const UNKNOWN_TYPE = InAppWebViewHitTestResultType._internal(0, 0); + + ///[InAppWebViewHitTestResult] for hitting a phone number. + static const PHONE_TYPE = InAppWebViewHitTestResultType._internal(2, 2); + + ///[InAppWebViewHitTestResult] for hitting a map address. + static const GEO_TYPE = InAppWebViewHitTestResultType._internal(3, 3); + + ///[InAppWebViewHitTestResult] for hitting an email address. + static const EMAIL_TYPE = InAppWebViewHitTestResultType._internal(4, 4); + + ///[InAppWebViewHitTestResult] for hitting an HTML::img tag. + static const IMAGE_TYPE = InAppWebViewHitTestResultType._internal(5, 5); + + ///[InAppWebViewHitTestResult] for hitting a HTML::a tag with src=http. + static const SRC_ANCHOR_TYPE = InAppWebViewHitTestResultType._internal(7, 7); + + ///[InAppWebViewHitTestResult] for hitting a HTML::a tag with src=http + HTML::img. + static const SRC_IMAGE_ANCHOR_TYPE = + InAppWebViewHitTestResultType._internal(8, 8); + + ///[InAppWebViewHitTestResult] for hitting an edit text area. + static const EDIT_TEXT_TYPE = InAppWebViewHitTestResultType._internal(9, 9); + + ///Set of all values of [InAppWebViewHitTestResultType]. + static final Set values = [ + InAppWebViewHitTestResultType.UNKNOWN_TYPE, + InAppWebViewHitTestResultType.PHONE_TYPE, + InAppWebViewHitTestResultType.GEO_TYPE, + InAppWebViewHitTestResultType.EMAIL_TYPE, + InAppWebViewHitTestResultType.IMAGE_TYPE, + InAppWebViewHitTestResultType.SRC_ANCHOR_TYPE, + InAppWebViewHitTestResultType.SRC_IMAGE_ANCHOR_TYPE, + InAppWebViewHitTestResultType.EDIT_TEXT_TYPE, + ].toSet(); + + ///Gets a possible [InAppWebViewHitTestResultType] instance from [int] value. + static InAppWebViewHitTestResultType? fromValue(int? value) { + if (value != null) { + try { + return InAppWebViewHitTestResultType.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [InAppWebViewHitTestResultType] instance from a native value. + static InAppWebViewHitTestResultType? fromNativeValue(int? value) { + if (value != null) { + try { + return InAppWebViewHitTestResultType.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'UNKNOWN_TYPE'; + case 2: + return 'PHONE_TYPE'; + case 3: + return 'GEO_TYPE'; + case 4: + return 'EMAIL_TYPE'; + case 5: + return 'IMAGE_TYPE'; + case 7: + return 'SRC_ANCHOR_TYPE'; + case 8: + return 'SRC_IMAGE_ANCHOR_TYPE'; + case 9: + return 'EDIT_TEXT_TYPE'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/in_app_webview_initial_data.dart b/lib/src/types/in_app_webview_initial_data.dart index 935da096..e5ad2c8d 100644 --- a/lib/src/types/in_app_webview_initial_data.dart +++ b/lib/src/types/in_app_webview_initial_data.dart @@ -1,7 +1,12 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; +part 'in_app_webview_initial_data.g.dart'; + ///Initial [data] as a content for an [WebView] instance, using [baseUrl] as the base URL for it. -class InAppWebViewInitialData { +@ExchangeableObject() +class InAppWebViewInitialData_ { ///A String of data in the given encoding. String data; @@ -11,68 +16,24 @@ class InAppWebViewInitialData { ///The encoding of the data. The default value is `"utf8"`. String encoding; - ///The URL to use as the page's base URL. The default value is `about:blank`. - late Uri baseUrl; + ///The URL to use as the page's base URL. If `null` defaults to `about:blank`. + Uri? baseUrl; ///Use [historyUrl] instead. @Deprecated('Use historyUrl instead') - late Uri androidHistoryUrl; + Uri? androidHistoryUrl; - ///The URL to use as the history entry. The default value is `about:blank`. If non-null, this must be a valid URL. - /// - ///This parameter is used only on Android. - late Uri historyUrl; + ///The URL to use as the history entry. If `null` defaults to `about:blank`. If non-null, this must be a valid URL. + @SupportedPlatforms(platforms: [ + AndroidPlatform() + ]) + Uri? historyUrl; - InAppWebViewInitialData( + InAppWebViewInitialData_( {required this.data, this.mimeType = "text/html", this.encoding = "utf8", - Uri? baseUrl, - @Deprecated('Use historyUrl instead') Uri? androidHistoryUrl, - Uri? historyUrl}) { - this.baseUrl = baseUrl == null ? Uri.parse("about:blank") : baseUrl; - this.historyUrl = historyUrl == null - ? (androidHistoryUrl == null - ? Uri.parse("about:blank") - : androidHistoryUrl) - : historyUrl; - // ignore: deprecated_member_use_from_same_package - this.androidHistoryUrl = this.historyUrl; - } - - ///Gets a possible [InAppWebViewInitialData] instance from a [Map] value. - static InAppWebViewInitialData? fromMap(Map? map) { - if (map == null) { - return null; - } - return InAppWebViewInitialData( - data: map["data"], - mimeType: map["mimeType"], - encoding: map["encoding"], - baseUrl: map["baseUrl"], - // ignore: deprecated_member_use_from_same_package - androidHistoryUrl: map["androidHistoryUrl"], - historyUrl: map["historyUrl"]); - } - - ///Converts instance to a map. - Map toMap() { - return { - "data": data, - "mimeType": mimeType, - "encoding": encoding, - "baseUrl": baseUrl.toString(), - "historyUrl": historyUrl.toString() - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + this.baseUrl, + @Deprecated('Use historyUrl instead') this.androidHistoryUrl, + this.historyUrl}); } \ No newline at end of file diff --git a/lib/src/types/in_app_webview_initial_data.g.dart b/lib/src/types/in_app_webview_initial_data.g.dart new file mode 100644 index 00000000..d72c8037 --- /dev/null +++ b/lib/src/types/in_app_webview_initial_data.g.dart @@ -0,0 +1,80 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'in_app_webview_initial_data.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Initial [data] as a content for an [WebView] instance, using [baseUrl] as the base URL for it. +class InAppWebViewInitialData { + ///A String of data in the given encoding. + String data; + + ///The MIME type of the data, e.g. "text/html". The default value is `"text/html"`. + String mimeType; + + ///The encoding of the data. The default value is `"utf8"`. + String encoding; + + ///The URL to use as the page's base URL. If `null` defaults to `about:blank`. + Uri? baseUrl; + + ///Use [historyUrl] instead. + @Deprecated('Use historyUrl instead') + Uri? androidHistoryUrl; + + ///The URL to use as the history entry. If `null` defaults to `about:blank`. If non-null, this must be a valid URL. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + Uri? historyUrl; + InAppWebViewInitialData( + {required this.data, + this.mimeType = "text/html", + this.encoding = "utf8", + this.baseUrl, + @Deprecated('Use historyUrl instead') this.androidHistoryUrl, + this.historyUrl}) { + historyUrl = historyUrl ?? androidHistoryUrl; + } + + ///Gets a possible [InAppWebViewInitialData] instance from a [Map] value. + static InAppWebViewInitialData? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = InAppWebViewInitialData( + data: map['data'], + baseUrl: map['baseUrl'] != null ? Uri.parse(map['baseUrl']) : null, + androidHistoryUrl: + map['historyUrl'] != null ? Uri.parse(map['historyUrl']) : null, + historyUrl: + map['historyUrl'] != null ? Uri.parse(map['historyUrl']) : null, + ); + instance.mimeType = map['mimeType']; + instance.encoding = map['encoding']; + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "data": data, + "mimeType": mimeType, + "encoding": encoding, + "baseUrl": baseUrl?.toString(), + "historyUrl": historyUrl?.toString(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'InAppWebViewInitialData{data: $data, mimeType: $mimeType, encoding: $encoding, baseUrl: $baseUrl, historyUrl: $historyUrl}'; + } +} diff --git a/lib/src/types/in_app_webview_rect.dart b/lib/src/types/in_app_webview_rect.dart index 022beed2..a09dd7aa 100644 --- a/lib/src/types/in_app_webview_rect.dart +++ b/lib/src/types/in_app_webview_rect.dart @@ -1,5 +1,10 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'in_app_webview_rect.g.dart'; + ///A class that represents a structure that contains the location and dimensions of a rectangle. -class InAppWebViewRect { +@ExchangeableObject() +class InAppWebViewRect_ { ///x position double x; @@ -12,40 +17,12 @@ class InAppWebViewRect { ///rect height double height; - InAppWebViewRect( + @ExchangeableObjectConstructor() + InAppWebViewRect_( {required this.x, required this.y, required this.width, required this.height}) { assert(this.x >= 0 && this.y >= 0 && this.width >= 0 && this.height >= 0); } - - ///Gets a possible [InAppWebViewRect] instance from a [Map] value. - static InAppWebViewRect? fromMap(Map? map) { - if (map == null) { - return null; - } - - return InAppWebViewRect( - x: map["x"], - y: map["y"], - width: map["width"], - height: map["height"], - ); - } - - ///Converts instance to a map. - Map toMap() { - return {"x": x, "y": y, "width": width, "height": height}; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } \ No newline at end of file diff --git a/lib/src/types/in_app_webview_rect.g.dart b/lib/src/types/in_app_webview_rect.g.dart new file mode 100644 index 00000000..aaf4615c --- /dev/null +++ b/lib/src/types/in_app_webview_rect.g.dart @@ -0,0 +1,63 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'in_app_webview_rect.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///A class that represents a structure that contains the location and dimensions of a rectangle. +class InAppWebViewRect { + ///x position + double x; + + ///y position + double y; + + ///rect width + double width; + + ///rect height + double height; + InAppWebViewRect( + {required this.x, + required this.y, + required this.width, + required this.height}) { + assert(this.x >= 0 && this.y >= 0 && this.width >= 0 && this.height >= 0); + } + + ///Gets a possible [InAppWebViewRect] instance from a [Map] value. + static InAppWebViewRect? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = InAppWebViewRect( + x: map['x'], + y: map['y'], + width: map['width'], + height: map['height'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "x": x, + "y": y, + "width": width, + "height": height, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'InAppWebViewRect{x: $x, y: $y, width: $width, height: $height}'; + } +} diff --git a/lib/src/types/js_alert_request.dart b/lib/src/types/js_alert_request.dart index bf7dda8c..addc8a77 100644 --- a/lib/src/types/js_alert_request.dart +++ b/lib/src/types/js_alert_request.dart @@ -1,7 +1,12 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; +part 'js_alert_request.g.dart'; + ///Class that represents the request of the [WebView.onJsAlert] event. -class JsAlertRequest { +@ExchangeableObject() +class JsAlertRequest_ { ///The url of the page requesting the dialog. Uri? url; @@ -13,52 +18,12 @@ class JsAlertRequest { bool? iosIsMainFrame; ///Indicates whether the request was made for the main frame. - /// - ///**NOTE**: available only on iOS. + @SupportedPlatforms(platforms: [IOSPlatform()]) bool? isMainFrame; - JsAlertRequest( + JsAlertRequest_( {this.url, this.message, @Deprecated("Use isMainFrame instead") this.iosIsMainFrame, - this.isMainFrame}) { - // ignore: deprecated_member_use_from_same_package - this.isMainFrame = this.isMainFrame ?? this.iosIsMainFrame; - } - - ///Gets a possible [JsAlertRequest] instance from a [Map] value. - static JsAlertRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - return JsAlertRequest( - url: map["url"] != null ? Uri.parse(map["url"]) : null, - message: map["message"], - // ignore: deprecated_member_use_from_same_package - iosIsMainFrame: map["isMainFrame"], - isMainFrame: map["isMainFrame"], - ); - } - - ///Converts instance to a map. - Map toMap() { - return { - "url": url?.toString(), - "message": message, - // ignore: deprecated_member_use_from_same_package - "iosIsMainFrame": isMainFrame ?? iosIsMainFrame, - // ignore: deprecated_member_use_from_same_package - "isMainFrame": isMainFrame ?? iosIsMainFrame - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + this.isMainFrame}); } \ No newline at end of file diff --git a/lib/src/types/js_alert_request.g.dart b/lib/src/types/js_alert_request.g.dart new file mode 100644 index 00000000..4fb17353 --- /dev/null +++ b/lib/src/types/js_alert_request.g.dart @@ -0,0 +1,66 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'js_alert_request.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the request of the [WebView.onJsAlert] event. +class JsAlertRequest { + ///The url of the page requesting the dialog. + Uri? url; + + ///Message to be displayed in the window. + String? message; + + ///Use [isMainFrame] instead. + @Deprecated('Use isMainFrame instead') + bool? iosIsMainFrame; + + ///Indicates whether the request was made for the main frame. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + bool? isMainFrame; + JsAlertRequest( + {this.url, + this.message, + @Deprecated('Use isMainFrame instead') this.iosIsMainFrame, + this.isMainFrame}) { + isMainFrame = isMainFrame ?? iosIsMainFrame; + } + + ///Gets a possible [JsAlertRequest] instance from a [Map] value. + static JsAlertRequest? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = JsAlertRequest( + url: map['url'] != null ? Uri.parse(map['url']) : null, + message: map['message'], + iosIsMainFrame: map['isMainFrame'], + isMainFrame: map['isMainFrame'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "url": url?.toString(), + "message": message, + "isMainFrame": isMainFrame, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'JsAlertRequest{url: $url, message: $message, isMainFrame: $isMainFrame}'; + } +} diff --git a/lib/src/types/js_alert_response.dart b/lib/src/types/js_alert_response.dart index eed81335..ca6546f4 100644 --- a/lib/src/types/js_alert_response.dart +++ b/lib/src/types/js_alert_response.dart @@ -1,9 +1,14 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; import 'js_alert_response_action.dart'; +part 'js_alert_response.g.dart'; + ///Class that represents the response used by the [WebView.onJsAlert] event to control a JavaScript alert dialog. -class JsAlertResponse { +@ExchangeableObject() +class JsAlertResponse_ { ///Message to be displayed in the window. String message; @@ -14,31 +19,11 @@ class JsAlertResponse { bool handledByClient; ///Action used to confirm that the user hit confirm button. - JsAlertResponseAction? action; + JsAlertResponseAction_? action; - JsAlertResponse( + JsAlertResponse_( {this.message = "", this.handledByClient = false, this.confirmButtonTitle = "", - this.action = JsAlertResponseAction.CONFIRM}); - - ///Converts instance to a map. - Map toMap() { - return { - "message": message, - "confirmButtonTitle": confirmButtonTitle, - "handledByClient": handledByClient, - "action": action?.toValue() - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + this.action = JsAlertResponseAction_.CONFIRM}); } \ No newline at end of file diff --git a/lib/src/types/js_alert_response.g.dart b/lib/src/types/js_alert_response.g.dart new file mode 100644 index 00000000..3ee7ae95 --- /dev/null +++ b/lib/src/types/js_alert_response.g.dart @@ -0,0 +1,60 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'js_alert_response.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the response used by the [WebView.onJsAlert] event to control a JavaScript alert dialog. +class JsAlertResponse { + ///Message to be displayed in the window. + String message; + + ///Title of the confirm button. + String confirmButtonTitle; + + ///Whether the client will handle the alert dialog. + bool handledByClient; + + ///Action used to confirm that the user hit confirm button. + JsAlertResponseAction? action; + JsAlertResponse( + {this.message = "", + this.confirmButtonTitle = "", + this.handledByClient = false, + this.action = JsAlertResponseAction.CONFIRM}); + + ///Gets a possible [JsAlertResponse] instance from a [Map] value. + static JsAlertResponse? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = JsAlertResponse(); + instance.message = map['message']; + instance.confirmButtonTitle = map['confirmButtonTitle']; + instance.handledByClient = map['handledByClient']; + instance.action = JsAlertResponseAction.fromNativeValue(map['action']); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "message": message, + "confirmButtonTitle": confirmButtonTitle, + "handledByClient": handledByClient, + "action": action?.toNativeValue(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'JsAlertResponse{message: $message, confirmButtonTitle: $confirmButtonTitle, handledByClient: $handledByClient, action: $action}'; + } +} diff --git a/lib/src/types/js_alert_response_action.dart b/lib/src/types/js_alert_response_action.dart index 69ff554e..e98cbb06 100644 --- a/lib/src/types/js_alert_response_action.dart +++ b/lib/src/types/js_alert_response_action.dart @@ -1,19 +1,16 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'js_alert_response.dart'; +part 'js_alert_response_action.g.dart'; + ///Class used by [JsAlertResponse] class. -class JsAlertResponseAction { +@ExchangeableEnum() +class JsAlertResponseAction_ { + // ignore: unused_field final int _value; - - const JsAlertResponseAction._internal(this._value); - - ///Gets [int] value. - int toValue() => _value; + const JsAlertResponseAction_._internal(this._value); ///Confirm that the user hit confirm button. - static const CONFIRM = const JsAlertResponseAction._internal(0); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const CONFIRM = const JsAlertResponseAction_._internal(0); } \ No newline at end of file diff --git a/lib/src/types/js_alert_response_action.g.dart b/lib/src/types/js_alert_response_action.g.dart new file mode 100644 index 00000000..49654132 --- /dev/null +++ b/lib/src/types/js_alert_response_action.g.dart @@ -0,0 +1,73 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'js_alert_response_action.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used by [JsAlertResponse] class. +class JsAlertResponseAction { + final int _value; + final int _nativeValue; + const JsAlertResponseAction._internal(this._value, this._nativeValue); +// ignore: unused_element + factory JsAlertResponseAction._internalMultiPlatform( + int value, Function nativeValue) => + JsAlertResponseAction._internal(value, nativeValue()); + + ///Confirm that the user hit confirm button. + static const CONFIRM = JsAlertResponseAction._internal(0, 0); + + ///Set of all values of [JsAlertResponseAction]. + static final Set values = [ + JsAlertResponseAction.CONFIRM, + ].toSet(); + + ///Gets a possible [JsAlertResponseAction] instance from [int] value. + static JsAlertResponseAction? fromValue(int? value) { + if (value != null) { + try { + return JsAlertResponseAction.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [JsAlertResponseAction] instance from a native value. + static JsAlertResponseAction? fromNativeValue(int? value) { + if (value != null) { + try { + return JsAlertResponseAction.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'CONFIRM'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/js_before_unload_request.dart b/lib/src/types/js_before_unload_request.dart index 2bd22990..9c40834b 100644 --- a/lib/src/types/js_before_unload_request.dart +++ b/lib/src/types/js_before_unload_request.dart @@ -1,38 +1,17 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; +part 'js_before_unload_request.g.dart'; + ///Class that represents the request of the [WebView.onJsBeforeUnload] event. -class JsBeforeUnloadRequest { +@ExchangeableObject() +class JsBeforeUnloadRequest_ { ///The url of the page requesting the dialog. Uri? url; ///Message to be displayed in the window. String? message; - JsBeforeUnloadRequest({this.url, this.message}); - - ///Gets a possible [JsBeforeUnloadRequest] instance from a [Map] value. - static JsBeforeUnloadRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - return JsBeforeUnloadRequest( - url: map["url"] != null ? Uri.parse(map["url"]) : null, - message: map["message"], - ); - } - - ///Converts instance to a map. - Map toMap() { - return {"url": url?.toString(), "message": message}; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + JsBeforeUnloadRequest_({this.url, this.message}); } \ No newline at end of file diff --git a/lib/src/types/js_before_unload_request.g.dart b/lib/src/types/js_before_unload_request.g.dart new file mode 100644 index 00000000..5553aece --- /dev/null +++ b/lib/src/types/js_before_unload_request.g.dart @@ -0,0 +1,47 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'js_before_unload_request.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the request of the [WebView.onJsBeforeUnload] event. +class JsBeforeUnloadRequest { + ///The url of the page requesting the dialog. + Uri? url; + + ///Message to be displayed in the window. + String? message; + JsBeforeUnloadRequest({this.url, this.message}); + + ///Gets a possible [JsBeforeUnloadRequest] instance from a [Map] value. + static JsBeforeUnloadRequest? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = JsBeforeUnloadRequest( + url: map['url'] != null ? Uri.parse(map['url']) : null, + message: map['message'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "url": url?.toString(), + "message": message, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'JsBeforeUnloadRequest{url: $url, message: $message}'; + } +} diff --git a/lib/src/types/js_before_unload_response.dart b/lib/src/types/js_before_unload_response.dart index 390c5172..1b0bb156 100644 --- a/lib/src/types/js_before_unload_response.dart +++ b/lib/src/types/js_before_unload_response.dart @@ -1,9 +1,14 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; import 'js_before_unload_response_action.dart'; +part 'js_before_unload_response.g.dart'; + ///Class that represents the response used by the [WebView.onJsBeforeUnload] event to control a JavaScript alert dialog. -class JsBeforeUnloadResponse { +@ExchangeableObject() +class JsBeforeUnloadResponse_ { ///Message to be displayed in the window. String message; @@ -17,33 +22,12 @@ class JsBeforeUnloadResponse { bool handledByClient; ///Action used to confirm that the user hit confirm or cancel button. - JsBeforeUnloadResponseAction? action; + JsBeforeUnloadResponseAction_? action; - JsBeforeUnloadResponse( + JsBeforeUnloadResponse_( {this.message = "", this.handledByClient = false, this.confirmButtonTitle = "", this.cancelButtonTitle = "", - this.action = JsBeforeUnloadResponseAction.CONFIRM}); - - ///Converts instance to a map. - Map toMap() { - return { - "message": message, - "confirmButtonTitle": confirmButtonTitle, - "cancelButtonTitle": cancelButtonTitle, - "handledByClient": handledByClient, - "action": action?.toValue() - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + this.action = JsBeforeUnloadResponseAction_.CONFIRM}); } \ No newline at end of file diff --git a/lib/src/types/js_before_unload_response.g.dart b/lib/src/types/js_before_unload_response.g.dart new file mode 100644 index 00000000..a5a034ae --- /dev/null +++ b/lib/src/types/js_before_unload_response.g.dart @@ -0,0 +1,67 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'js_before_unload_response.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the response used by the [WebView.onJsBeforeUnload] event to control a JavaScript alert dialog. +class JsBeforeUnloadResponse { + ///Message to be displayed in the window. + String message; + + ///Title of the confirm button. + String confirmButtonTitle; + + ///Title of the cancel button. + String cancelButtonTitle; + + ///Whether the client will handle the alert dialog. + bool handledByClient; + + ///Action used to confirm that the user hit confirm or cancel button. + JsBeforeUnloadResponseAction? action; + JsBeforeUnloadResponse( + {this.message = "", + this.confirmButtonTitle = "", + this.cancelButtonTitle = "", + this.handledByClient = false, + this.action = JsBeforeUnloadResponseAction.CONFIRM}); + + ///Gets a possible [JsBeforeUnloadResponse] instance from a [Map] value. + static JsBeforeUnloadResponse? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = JsBeforeUnloadResponse(); + instance.message = map['message']; + instance.confirmButtonTitle = map['confirmButtonTitle']; + instance.cancelButtonTitle = map['cancelButtonTitle']; + instance.handledByClient = map['handledByClient']; + instance.action = + JsBeforeUnloadResponseAction.fromNativeValue(map['action']); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "message": message, + "confirmButtonTitle": confirmButtonTitle, + "cancelButtonTitle": cancelButtonTitle, + "handledByClient": handledByClient, + "action": action?.toNativeValue(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'JsBeforeUnloadResponse{message: $message, confirmButtonTitle: $confirmButtonTitle, cancelButtonTitle: $cancelButtonTitle, handledByClient: $handledByClient, action: $action}'; + } +} diff --git a/lib/src/types/js_before_unload_response_action.dart b/lib/src/types/js_before_unload_response_action.dart index 6236c54e..99eaa818 100644 --- a/lib/src/types/js_before_unload_response_action.dart +++ b/lib/src/types/js_before_unload_response_action.dart @@ -1,22 +1,19 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'js_before_unload_response.dart'; +part 'js_before_unload_response_action.g.dart'; + ///Class used by [JsBeforeUnloadResponse] class. -class JsBeforeUnloadResponseAction { +@ExchangeableEnum() +class JsBeforeUnloadResponseAction_ { + // ignore: unused_field final int _value; - - const JsBeforeUnloadResponseAction._internal(this._value); - - ///Gets [int] value. - int toValue() => _value; + const JsBeforeUnloadResponseAction_._internal(this._value); ///Confirm that the user hit confirm button. - static const CONFIRM = const JsBeforeUnloadResponseAction._internal(0); + static const CONFIRM = const JsBeforeUnloadResponseAction_._internal(0); ///Confirm that the user hit cancel button. - static const CANCEL = const JsBeforeUnloadResponseAction._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const CANCEL = const JsBeforeUnloadResponseAction_._internal(1); } \ No newline at end of file diff --git a/lib/src/types/js_before_unload_response_action.g.dart b/lib/src/types/js_before_unload_response_action.g.dart new file mode 100644 index 00000000..b88de3a0 --- /dev/null +++ b/lib/src/types/js_before_unload_response_action.g.dart @@ -0,0 +1,79 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'js_before_unload_response_action.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used by [JsBeforeUnloadResponse] class. +class JsBeforeUnloadResponseAction { + final int _value; + final int _nativeValue; + const JsBeforeUnloadResponseAction._internal(this._value, this._nativeValue); +// ignore: unused_element + factory JsBeforeUnloadResponseAction._internalMultiPlatform( + int value, Function nativeValue) => + JsBeforeUnloadResponseAction._internal(value, nativeValue()); + + ///Confirm that the user hit confirm button. + static const CONFIRM = JsBeforeUnloadResponseAction._internal(0, 0); + + ///Confirm that the user hit cancel button. + static const CANCEL = JsBeforeUnloadResponseAction._internal(1, 1); + + ///Set of all values of [JsBeforeUnloadResponseAction]. + static final Set values = [ + JsBeforeUnloadResponseAction.CONFIRM, + JsBeforeUnloadResponseAction.CANCEL, + ].toSet(); + + ///Gets a possible [JsBeforeUnloadResponseAction] instance from [int] value. + static JsBeforeUnloadResponseAction? fromValue(int? value) { + if (value != null) { + try { + return JsBeforeUnloadResponseAction.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [JsBeforeUnloadResponseAction] instance from a native value. + static JsBeforeUnloadResponseAction? fromNativeValue(int? value) { + if (value != null) { + try { + return JsBeforeUnloadResponseAction.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'CONFIRM'; + case 1: + return 'CANCEL'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/js_confirm_request.dart b/lib/src/types/js_confirm_request.dart index 210bac08..79f87ce6 100644 --- a/lib/src/types/js_confirm_request.dart +++ b/lib/src/types/js_confirm_request.dart @@ -1,7 +1,12 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; +part 'js_confirm_request.g.dart'; + ///Class that represents the request of the [WebView.onJsConfirm] event. -class JsConfirmRequest { +@ExchangeableObject() +class JsConfirmRequest_ { ///The url of the page requesting the dialog. Uri? url; @@ -13,51 +18,12 @@ class JsConfirmRequest { bool? iosIsMainFrame; ///Indicates whether the request was made for the main frame. - /// - ///**NOTE**: available only on iOS. + @SupportedPlatforms(platforms: [IOSPlatform()]) bool? isMainFrame; - JsConfirmRequest( + JsConfirmRequest_( {this.url, this.message, @Deprecated("Use isMainFrame instead") this.iosIsMainFrame, - this.isMainFrame}) { - // ignore: deprecated_member_use_from_same_package - this.isMainFrame = this.isMainFrame ?? this.iosIsMainFrame; - } - - ///Gets a possible [JsConfirmRequest] instance from a [Map] value. - static JsConfirmRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - return JsConfirmRequest( - url: map["url"] != null ? Uri.parse(map["url"]) : null, - message: map["message"], - // ignore: deprecated_member_use_from_same_package - iosIsMainFrame: map["isMainFrame"], - isMainFrame: map["isMainFrame"]); - } - - ///Converts instance to a map. - Map toMap() { - return { - "url": url?.toString(), - "message": message, - // ignore: deprecated_member_use_from_same_package - "iosIsMainFrame": isMainFrame ?? iosIsMainFrame, - // ignore: deprecated_member_use_from_same_package - "isMainFrame": isMainFrame ?? iosIsMainFrame - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + this.isMainFrame}); } \ No newline at end of file diff --git a/lib/src/types/js_confirm_request.g.dart b/lib/src/types/js_confirm_request.g.dart new file mode 100644 index 00000000..869a81d5 --- /dev/null +++ b/lib/src/types/js_confirm_request.g.dart @@ -0,0 +1,66 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'js_confirm_request.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the request of the [WebView.onJsConfirm] event. +class JsConfirmRequest { + ///The url of the page requesting the dialog. + Uri? url; + + ///Message to be displayed in the window. + String? message; + + ///Use [isMainFrame] instead. + @Deprecated('Use isMainFrame instead') + bool? iosIsMainFrame; + + ///Indicates whether the request was made for the main frame. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + bool? isMainFrame; + JsConfirmRequest( + {this.url, + this.message, + @Deprecated('Use isMainFrame instead') this.iosIsMainFrame, + this.isMainFrame}) { + isMainFrame = isMainFrame ?? iosIsMainFrame; + } + + ///Gets a possible [JsConfirmRequest] instance from a [Map] value. + static JsConfirmRequest? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = JsConfirmRequest( + url: map['url'] != null ? Uri.parse(map['url']) : null, + message: map['message'], + iosIsMainFrame: map['isMainFrame'], + isMainFrame: map['isMainFrame'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "url": url?.toString(), + "message": message, + "isMainFrame": isMainFrame, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'JsConfirmRequest{url: $url, message: $message, isMainFrame: $isMainFrame}'; + } +} diff --git a/lib/src/types/js_confirm_response.dart b/lib/src/types/js_confirm_response.dart index 3a99688c..5e35640c 100644 --- a/lib/src/types/js_confirm_response.dart +++ b/lib/src/types/js_confirm_response.dart @@ -1,9 +1,14 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; import 'js_confirm_response_action.dart'; +part 'js_confirm_response.g.dart'; + ///Class that represents the response used by the [WebView.onJsConfirm] event to control a JavaScript confirm dialog. -class JsConfirmResponse { +@ExchangeableObject() +class JsConfirmResponse_ { ///Message to be displayed in the window. String message; @@ -17,31 +22,12 @@ class JsConfirmResponse { bool handledByClient; ///Action used to confirm that the user hit confirm or cancel button. - JsConfirmResponseAction? action; + JsConfirmResponseAction_? action; - JsConfirmResponse( + JsConfirmResponse_( {this.message = "", this.handledByClient = false, this.confirmButtonTitle = "", this.cancelButtonTitle = "", - this.action = JsConfirmResponseAction.CANCEL}); - - Map toMap() { - return { - "message": message, - "confirmButtonTitle": confirmButtonTitle, - "cancelButtonTitle": cancelButtonTitle, - "handledByClient": handledByClient, - "action": action?.toValue() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + this.action = JsConfirmResponseAction_.CANCEL}); } \ No newline at end of file diff --git a/lib/src/types/js_confirm_response.g.dart b/lib/src/types/js_confirm_response.g.dart new file mode 100644 index 00000000..ebc51bd7 --- /dev/null +++ b/lib/src/types/js_confirm_response.g.dart @@ -0,0 +1,66 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'js_confirm_response.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the response used by the [WebView.onJsConfirm] event to control a JavaScript confirm dialog. +class JsConfirmResponse { + ///Message to be displayed in the window. + String message; + + ///Title of the confirm button. + String confirmButtonTitle; + + ///Title of the cancel button. + String cancelButtonTitle; + + ///Whether the client will handle the confirm dialog. + bool handledByClient; + + ///Action used to confirm that the user hit confirm or cancel button. + JsConfirmResponseAction? action; + JsConfirmResponse( + {this.message = "", + this.confirmButtonTitle = "", + this.cancelButtonTitle = "", + this.handledByClient = false, + this.action = JsConfirmResponseAction.CANCEL}); + + ///Gets a possible [JsConfirmResponse] instance from a [Map] value. + static JsConfirmResponse? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = JsConfirmResponse(); + instance.message = map['message']; + instance.confirmButtonTitle = map['confirmButtonTitle']; + instance.cancelButtonTitle = map['cancelButtonTitle']; + instance.handledByClient = map['handledByClient']; + instance.action = JsConfirmResponseAction.fromNativeValue(map['action']); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "message": message, + "confirmButtonTitle": confirmButtonTitle, + "cancelButtonTitle": cancelButtonTitle, + "handledByClient": handledByClient, + "action": action?.toNativeValue(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'JsConfirmResponse{message: $message, confirmButtonTitle: $confirmButtonTitle, cancelButtonTitle: $cancelButtonTitle, handledByClient: $handledByClient, action: $action}'; + } +} diff --git a/lib/src/types/js_confirm_response_action.dart b/lib/src/types/js_confirm_response_action.dart index 4cdc9ab9..0b373273 100644 --- a/lib/src/types/js_confirm_response_action.dart +++ b/lib/src/types/js_confirm_response_action.dart @@ -1,22 +1,19 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'js_confirm_response.dart'; +part 'js_confirm_response_action.g.dart'; + ///Class used by [JsConfirmResponse] class. -class JsConfirmResponseAction { +@ExchangeableEnum() +class JsConfirmResponseAction_ { + // ignore: unused_field final int _value; - - const JsConfirmResponseAction._internal(this._value); - - ///Gets [int] value. - int toValue() => _value; + const JsConfirmResponseAction_._internal(this._value); ///Confirm that the user hit confirm button. - static const CONFIRM = const JsConfirmResponseAction._internal(0); + static const CONFIRM = const JsConfirmResponseAction_._internal(0); ///Confirm that the user hit cancel button. - static const CANCEL = const JsConfirmResponseAction._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const CANCEL = const JsConfirmResponseAction_._internal(1); } \ No newline at end of file diff --git a/lib/src/types/js_confirm_response_action.g.dart b/lib/src/types/js_confirm_response_action.g.dart new file mode 100644 index 00000000..69e17045 --- /dev/null +++ b/lib/src/types/js_confirm_response_action.g.dart @@ -0,0 +1,79 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'js_confirm_response_action.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used by [JsConfirmResponse] class. +class JsConfirmResponseAction { + final int _value; + final int _nativeValue; + const JsConfirmResponseAction._internal(this._value, this._nativeValue); +// ignore: unused_element + factory JsConfirmResponseAction._internalMultiPlatform( + int value, Function nativeValue) => + JsConfirmResponseAction._internal(value, nativeValue()); + + ///Confirm that the user hit confirm button. + static const CONFIRM = JsConfirmResponseAction._internal(0, 0); + + ///Confirm that the user hit cancel button. + static const CANCEL = JsConfirmResponseAction._internal(1, 1); + + ///Set of all values of [JsConfirmResponseAction]. + static final Set values = [ + JsConfirmResponseAction.CONFIRM, + JsConfirmResponseAction.CANCEL, + ].toSet(); + + ///Gets a possible [JsConfirmResponseAction] instance from [int] value. + static JsConfirmResponseAction? fromValue(int? value) { + if (value != null) { + try { + return JsConfirmResponseAction.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [JsConfirmResponseAction] instance from a native value. + static JsConfirmResponseAction? fromNativeValue(int? value) { + if (value != null) { + try { + return JsConfirmResponseAction.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'CONFIRM'; + case 1: + return 'CANCEL'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/js_prompt_request.dart b/lib/src/types/js_prompt_request.dart index 81b4a9db..d7bff07b 100644 --- a/lib/src/types/js_prompt_request.dart +++ b/lib/src/types/js_prompt_request.dart @@ -1,7 +1,12 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; +part 'js_prompt_request.g.dart'; + ///Class that represents the request of the [WebView.onJsPrompt] event. -class JsPromptRequest { +@ExchangeableObject() +class JsPromptRequest_ { ///The url of the page requesting the dialog. Uri? url; @@ -16,54 +21,13 @@ class JsPromptRequest { bool? iosIsMainFrame; ///Indicates whether the request was made for the main frame. - /// - ///**NOTE**: available only on iOS. + @SupportedPlatforms(platforms: [IOSPlatform()]) bool? isMainFrame; - JsPromptRequest( + JsPromptRequest_( {this.url, this.message, this.defaultValue, @Deprecated("Use isMainFrame instead") this.iosIsMainFrame, - this.isMainFrame}) { - // ignore: deprecated_member_use_from_same_package - this.isMainFrame = this.isMainFrame ?? this.iosIsMainFrame; - } - - ///Gets a possible [JsPromptRequest] instance from a [Map] value. - static JsPromptRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - return JsPromptRequest( - url: map["url"] != null ? Uri.parse(map["url"]) : null, - message: map["message"], - defaultValue: map["defaultValue"], - // ignore: deprecated_member_use_from_same_package - iosIsMainFrame: map["isMainFrame"], - isMainFrame: map["isMainFrame"]); - } - - ///Converts instance to a map. - Map toMap() { - return { - "url": url?.toString(), - "message": message, - "defaultValue": defaultValue, - // ignore: deprecated_member_use_from_same_package - "iosIsMainFrame": isMainFrame ?? iosIsMainFrame, - // ignore: deprecated_member_use_from_same_package - "isMainFrame": isMainFrame ?? iosIsMainFrame - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + this.isMainFrame}); } \ No newline at end of file diff --git a/lib/src/types/js_prompt_request.g.dart b/lib/src/types/js_prompt_request.g.dart new file mode 100644 index 00000000..29339e92 --- /dev/null +++ b/lib/src/types/js_prompt_request.g.dart @@ -0,0 +1,72 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'js_prompt_request.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the request of the [WebView.onJsPrompt] event. +class JsPromptRequest { + ///The url of the page requesting the dialog. + Uri? url; + + ///Message to be displayed in the window. + String? message; + + ///The default value displayed in the prompt dialog. + String? defaultValue; + + ///Use [isMainFrame] instead. + @Deprecated('Use isMainFrame instead') + bool? iosIsMainFrame; + + ///Indicates whether the request was made for the main frame. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + bool? isMainFrame; + JsPromptRequest( + {this.url, + this.message, + this.defaultValue, + @Deprecated('Use isMainFrame instead') this.iosIsMainFrame, + this.isMainFrame}) { + isMainFrame = isMainFrame ?? iosIsMainFrame; + } + + ///Gets a possible [JsPromptRequest] instance from a [Map] value. + static JsPromptRequest? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = JsPromptRequest( + url: map['url'] != null ? Uri.parse(map['url']) : null, + message: map['message'], + defaultValue: map['defaultValue'], + iosIsMainFrame: map['isMainFrame'], + isMainFrame: map['isMainFrame'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "url": url?.toString(), + "message": message, + "defaultValue": defaultValue, + "isMainFrame": isMainFrame, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'JsPromptRequest{url: $url, message: $message, defaultValue: $defaultValue, isMainFrame: $isMainFrame}'; + } +} diff --git a/lib/src/types/js_prompt_response.dart b/lib/src/types/js_prompt_response.dart index 5ba3f368..9f778395 100644 --- a/lib/src/types/js_prompt_response.dart +++ b/lib/src/types/js_prompt_response.dart @@ -1,9 +1,14 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; import 'js_prompt_response_action.dart'; +part 'js_prompt_response.g.dart'; + ///Class that represents the response used by the [WebView.onJsPrompt] event to control a JavaScript prompt dialog. -class JsPromptResponse { +@ExchangeableObject() +class JsPromptResponse_ { ///Message to be displayed in the window. String message; @@ -23,37 +28,14 @@ class JsPromptResponse { String? value; ///Action used to confirm that the user hit confirm or cancel button. - JsPromptResponseAction? action; + JsPromptResponseAction_? action; - JsPromptResponse( + JsPromptResponse_( {this.message = "", this.defaultValue = "", this.handledByClient = false, this.confirmButtonTitle = "", this.cancelButtonTitle = "", this.value, - this.action = JsPromptResponseAction.CANCEL}); - - ///Converts instance to a map. - Map toMap() { - return { - "message": message, - "defaultValue": defaultValue, - "confirmButtonTitle": confirmButtonTitle, - "cancelButtonTitle": cancelButtonTitle, - "handledByClient": handledByClient, - "value": value, - "action": action?.toValue() - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + this.action = JsPromptResponseAction_.CANCEL}); } \ No newline at end of file diff --git a/lib/src/types/js_prompt_response.g.dart b/lib/src/types/js_prompt_response.g.dart new file mode 100644 index 00000000..a2b7f73f --- /dev/null +++ b/lib/src/types/js_prompt_response.g.dart @@ -0,0 +1,79 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'js_prompt_response.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the response used by the [WebView.onJsPrompt] event to control a JavaScript prompt dialog. +class JsPromptResponse { + ///Message to be displayed in the window. + String message; + + ///The default value displayed in the prompt dialog. + String defaultValue; + + ///Title of the confirm button. + String confirmButtonTitle; + + ///Title of the cancel button. + String cancelButtonTitle; + + ///Whether the client will handle the prompt dialog. + bool handledByClient; + + ///Value of the prompt dialog. + String? value; + + ///Action used to confirm that the user hit confirm or cancel button. + JsPromptResponseAction? action; + JsPromptResponse( + {this.message = "", + this.defaultValue = "", + this.confirmButtonTitle = "", + this.cancelButtonTitle = "", + this.handledByClient = false, + this.value, + this.action = JsPromptResponseAction.CANCEL}); + + ///Gets a possible [JsPromptResponse] instance from a [Map] value. + static JsPromptResponse? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = JsPromptResponse( + value: map['value'], + ); + instance.message = map['message']; + instance.defaultValue = map['defaultValue']; + instance.confirmButtonTitle = map['confirmButtonTitle']; + instance.cancelButtonTitle = map['cancelButtonTitle']; + instance.handledByClient = map['handledByClient']; + instance.action = JsPromptResponseAction.fromNativeValue(map['action']); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "message": message, + "defaultValue": defaultValue, + "confirmButtonTitle": confirmButtonTitle, + "cancelButtonTitle": cancelButtonTitle, + "handledByClient": handledByClient, + "value": value, + "action": action?.toNativeValue(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'JsPromptResponse{message: $message, defaultValue: $defaultValue, confirmButtonTitle: $confirmButtonTitle, cancelButtonTitle: $cancelButtonTitle, handledByClient: $handledByClient, value: $value, action: $action}'; + } +} diff --git a/lib/src/types/js_prompt_response_action.dart b/lib/src/types/js_prompt_response_action.dart index 76faa8ce..14ffa40a 100644 --- a/lib/src/types/js_prompt_response_action.dart +++ b/lib/src/types/js_prompt_response_action.dart @@ -1,22 +1,19 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'js_prompt_response.dart'; +part 'js_prompt_response_action.g.dart'; + ///Class used by [JsPromptResponse] class. -class JsPromptResponseAction { +@ExchangeableEnum() +class JsPromptResponseAction_ { + // ignore: unused_field final int _value; - - const JsPromptResponseAction._internal(this._value); - - ///Gets [int] value. - int toValue() => _value; + const JsPromptResponseAction_._internal(this._value); ///Confirm that the user hit confirm button. - static const CONFIRM = const JsPromptResponseAction._internal(0); + static const CONFIRM = const JsPromptResponseAction_._internal(0); ///Confirm that the user hit cancel button. - static const CANCEL = const JsPromptResponseAction._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const CANCEL = const JsPromptResponseAction_._internal(1); } \ No newline at end of file diff --git a/lib/src/types/js_prompt_response_action.g.dart b/lib/src/types/js_prompt_response_action.g.dart new file mode 100644 index 00000000..fb492fa9 --- /dev/null +++ b/lib/src/types/js_prompt_response_action.g.dart @@ -0,0 +1,79 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'js_prompt_response_action.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used by [JsPromptResponse] class. +class JsPromptResponseAction { + final int _value; + final int _nativeValue; + const JsPromptResponseAction._internal(this._value, this._nativeValue); +// ignore: unused_element + factory JsPromptResponseAction._internalMultiPlatform( + int value, Function nativeValue) => + JsPromptResponseAction._internal(value, nativeValue()); + + ///Confirm that the user hit confirm button. + static const CONFIRM = JsPromptResponseAction._internal(0, 0); + + ///Confirm that the user hit cancel button. + static const CANCEL = JsPromptResponseAction._internal(1, 1); + + ///Set of all values of [JsPromptResponseAction]. + static final Set values = [ + JsPromptResponseAction.CONFIRM, + JsPromptResponseAction.CANCEL, + ].toSet(); + + ///Gets a possible [JsPromptResponseAction] instance from [int] value. + static JsPromptResponseAction? fromValue(int? value) { + if (value != null) { + try { + return JsPromptResponseAction.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [JsPromptResponseAction] instance from a native value. + static JsPromptResponseAction? fromNativeValue(int? value) { + if (value != null) { + try { + return JsPromptResponseAction.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'CONFIRM'; + case 1: + return 'CANCEL'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/layout_algorithm.dart b/lib/src/types/layout_algorithm.dart index 6a08bd0f..5f811029 100644 --- a/lib/src/types/layout_algorithm.dart +++ b/lib/src/types/layout_algorithm.dart @@ -1,105 +1,52 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +import '../in_app_webview/in_app_webview_settings.dart'; +import '../in_app_webview/android/in_app_webview_options.dart'; + +part 'layout_algorithm.g.dart'; + ///Class used to set the underlying layout algorithm. -class LayoutAlgorithm { +@ExchangeableEnum() +class LayoutAlgorithm_ { + // ignore: unused_field final String _value; - - const LayoutAlgorithm._internal(this._value); - - ///Set of all values of [LayoutAlgorithm]. - static final Set values = [ - LayoutAlgorithm.NORMAL, - LayoutAlgorithm.TEXT_AUTOSIZING, - LayoutAlgorithm.NARROW_COLUMNS, - ].toSet(); - - ///Gets a possible [LayoutAlgorithm] instance from a [String] value. - static LayoutAlgorithm? fromValue(String? value) { - if (value != null) { - try { - return LayoutAlgorithm.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [String] value. - String toValue() => _value; - - @override - String toString() => _value; + const LayoutAlgorithm_._internal(this._value); ///NORMAL means no rendering changes. This is the recommended choice for maximum compatibility across different platforms and Android versions. - static const NORMAL = const LayoutAlgorithm._internal("NORMAL"); + static const NORMAL = const LayoutAlgorithm_._internal("NORMAL"); ///TEXT_AUTOSIZING boosts font size of paragraphs based on heuristics to make the text readable when viewing a wide-viewport layout in the overview mode. - ///It is recommended to enable zoom support [AndroidInAppWebViewOptions.supportZoom] when using this mode. + ///It is recommended to enable zoom support [InAppWebViewSettings.supportZoom] when using this mode. /// ///**NOTE**: available on Android 19+. static const TEXT_AUTOSIZING = - const LayoutAlgorithm._internal("TEXT_AUTOSIZING"); + const LayoutAlgorithm_._internal("TEXT_AUTOSIZING"); ///NARROW_COLUMNS makes all columns no wider than the screen if possible. Only use this for API levels prior to `Build.VERSION_CODES.KITKAT`. static const NARROW_COLUMNS = - const LayoutAlgorithm._internal("NARROW_COLUMNS"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + const LayoutAlgorithm_._internal("NARROW_COLUMNS"); } ///An Android-specific class used to set the underlying layout algorithm. ///Use [LayoutAlgorithm] instead. @Deprecated("Use LayoutAlgorithm instead") -class AndroidLayoutAlgorithm { +@ExchangeableEnum() +class AndroidLayoutAlgorithm_ { + // ignore: unused_field final String _value; - - const AndroidLayoutAlgorithm._internal(this._value); - - ///Set of all values of [AndroidLayoutAlgorithm]. - static final Set values = [ - AndroidLayoutAlgorithm.NORMAL, - AndroidLayoutAlgorithm.TEXT_AUTOSIZING, - AndroidLayoutAlgorithm.NARROW_COLUMNS, - ].toSet(); - - ///Gets a possible [AndroidLayoutAlgorithm] instance from a [String] value. - static AndroidLayoutAlgorithm? fromValue(String? value) { - if (value != null) { - try { - return AndroidLayoutAlgorithm.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [String] value. - String toValue() => _value; - - @override - String toString() => _value; + const AndroidLayoutAlgorithm_._internal(this._value); ///NORMAL means no rendering changes. This is the recommended choice for maximum compatibility across different platforms and Android versions. - static const NORMAL = const AndroidLayoutAlgorithm._internal("NORMAL"); + static const NORMAL = const AndroidLayoutAlgorithm_._internal("NORMAL"); ///TEXT_AUTOSIZING boosts font size of paragraphs based on heuristics to make the text readable when viewing a wide-viewport layout in the overview mode. ///It is recommended to enable zoom support [AndroidInAppWebViewOptions.supportZoom] when using this mode. /// ///**NOTE**: available on Android 19+. static const TEXT_AUTOSIZING = - const AndroidLayoutAlgorithm._internal("TEXT_AUTOSIZING"); + const AndroidLayoutAlgorithm_._internal("TEXT_AUTOSIZING"); ///NARROW_COLUMNS makes all columns no wider than the screen if possible. Only use this for API levels prior to `Build.VERSION_CODES.KITKAT`. static const NARROW_COLUMNS = - const AndroidLayoutAlgorithm._internal("NARROW_COLUMNS"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + const AndroidLayoutAlgorithm_._internal("NARROW_COLUMNS"); } \ No newline at end of file diff --git a/lib/src/types/layout_algorithm.g.dart b/lib/src/types/layout_algorithm.g.dart new file mode 100644 index 00000000..a6109b96 --- /dev/null +++ b/lib/src/types/layout_algorithm.g.dart @@ -0,0 +1,159 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'layout_algorithm.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used to set the underlying layout algorithm. +class LayoutAlgorithm { + final String _value; + final String _nativeValue; + const LayoutAlgorithm._internal(this._value, this._nativeValue); +// ignore: unused_element + factory LayoutAlgorithm._internalMultiPlatform( + String value, Function nativeValue) => + LayoutAlgorithm._internal(value, nativeValue()); + + ///NORMAL means no rendering changes. This is the recommended choice for maximum compatibility across different platforms and Android versions. + static const NORMAL = LayoutAlgorithm._internal('NORMAL', 'NORMAL'); + + ///TEXT_AUTOSIZING boosts font size of paragraphs based on heuristics to make the text readable when viewing a wide-viewport layout in the overview mode. + ///It is recommended to enable zoom support [InAppWebViewSettings.supportZoom] when using this mode. + /// + ///**NOTE**: available on Android 19+. + static const TEXT_AUTOSIZING = + LayoutAlgorithm._internal('TEXT_AUTOSIZING', 'TEXT_AUTOSIZING'); + + ///NARROW_COLUMNS makes all columns no wider than the screen if possible. Only use this for API levels prior to `Build.VERSION_CODES.KITKAT`. + static const NARROW_COLUMNS = + LayoutAlgorithm._internal('NARROW_COLUMNS', 'NARROW_COLUMNS'); + + ///Set of all values of [LayoutAlgorithm]. + static final Set values = [ + LayoutAlgorithm.NORMAL, + LayoutAlgorithm.TEXT_AUTOSIZING, + LayoutAlgorithm.NARROW_COLUMNS, + ].toSet(); + + ///Gets a possible [LayoutAlgorithm] instance from [String] value. + static LayoutAlgorithm? fromValue(String? value) { + if (value != null) { + try { + return LayoutAlgorithm.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [LayoutAlgorithm] instance from a native value. + static LayoutAlgorithm? fromNativeValue(String? value) { + if (value != null) { + try { + return LayoutAlgorithm.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [String] native value. + String toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} + +///An Android-specific class used to set the underlying layout algorithm. +///Use [LayoutAlgorithm] instead. +@Deprecated('Use LayoutAlgorithm instead') +class AndroidLayoutAlgorithm { + final String _value; + final String _nativeValue; + const AndroidLayoutAlgorithm._internal(this._value, this._nativeValue); +// ignore: unused_element + factory AndroidLayoutAlgorithm._internalMultiPlatform( + String value, Function nativeValue) => + AndroidLayoutAlgorithm._internal(value, nativeValue()); + + ///NORMAL means no rendering changes. This is the recommended choice for maximum compatibility across different platforms and Android versions. + static const NORMAL = AndroidLayoutAlgorithm._internal('NORMAL', 'NORMAL'); + + ///TEXT_AUTOSIZING boosts font size of paragraphs based on heuristics to make the text readable when viewing a wide-viewport layout in the overview mode. + ///It is recommended to enable zoom support [AndroidInAppWebViewOptions.supportZoom] when using this mode. + /// + ///**NOTE**: available on Android 19+. + static const TEXT_AUTOSIZING = + AndroidLayoutAlgorithm._internal('TEXT_AUTOSIZING', 'TEXT_AUTOSIZING'); + + ///NARROW_COLUMNS makes all columns no wider than the screen if possible. Only use this for API levels prior to `Build.VERSION_CODES.KITKAT`. + static const NARROW_COLUMNS = + AndroidLayoutAlgorithm._internal('NARROW_COLUMNS', 'NARROW_COLUMNS'); + + ///Set of all values of [AndroidLayoutAlgorithm]. + static final Set values = [ + AndroidLayoutAlgorithm.NORMAL, + AndroidLayoutAlgorithm.TEXT_AUTOSIZING, + AndroidLayoutAlgorithm.NARROW_COLUMNS, + ].toSet(); + + ///Gets a possible [AndroidLayoutAlgorithm] instance from [String] value. + static AndroidLayoutAlgorithm? fromValue(String? value) { + if (value != null) { + try { + return AndroidLayoutAlgorithm.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [AndroidLayoutAlgorithm] instance from a native value. + static AndroidLayoutAlgorithm? fromNativeValue(String? value) { + if (value != null) { + try { + return AndroidLayoutAlgorithm.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [String] native value. + String toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} diff --git a/lib/src/types/layout_in_display_cutout_mode.dart b/lib/src/types/layout_in_display_cutout_mode.dart index 260d21e7..c36e93ff 100644 --- a/lib/src/types/layout_in_display_cutout_mode.dart +++ b/lib/src/types/layout_in_display_cutout_mode.dart @@ -1,74 +1,33 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'layout_in_display_cutout_mode.g.dart'; + ///Class representing the share state that should be applied to the custom tab. -/// -///**NOTE**: available on Android 28+. -class LayoutInDisplayCutoutMode { +@ExchangeableEnum() +class LayoutInDisplayCutoutMode_ { + // ignore: unused_field final int _value; - - const LayoutInDisplayCutoutMode._internal(this._value); - - ///Set of all values of [LayoutInDisplayCutoutMode]. - static final Set values = [ - LayoutInDisplayCutoutMode.DEFAULT, - LayoutInDisplayCutoutMode.SHORT_EDGES, - LayoutInDisplayCutoutMode.NEVER, - LayoutInDisplayCutoutMode.ALWAYS - ].toSet(); - - ///Gets a possible [LayoutInDisplayCutoutMode] instance from an [int] value. - static LayoutInDisplayCutoutMode? fromValue(int? value) { - if (value != null) { - try { - return LayoutInDisplayCutoutMode.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "SHORT_EDGES"; - case 2: - return "NEVER"; - case 3: - return "ALWAYS"; - case 0: - default: - return "DEFAULT"; - } - } + const LayoutInDisplayCutoutMode_._internal(this._value); ///With this default setting, content renders into the cutout area when displayed in portrait mode, but content is letterboxed when displayed in landscape mode. /// ///**NOTE**: available on Android 28+. - static const DEFAULT = const LayoutInDisplayCutoutMode._internal(0); + static const DEFAULT = const LayoutInDisplayCutoutMode_._internal(0); ///Content renders into the cutout area in both portrait and landscape modes. /// ///**NOTE**: available on Android 28+. - static const SHORT_EDGES = const LayoutInDisplayCutoutMode._internal(1); + static const SHORT_EDGES = const LayoutInDisplayCutoutMode_._internal(1); ///Content never renders into the cutout area. /// ///**NOTE**: available on Android 28+. - static const NEVER = const LayoutInDisplayCutoutMode._internal(2); + static const NEVER = const LayoutInDisplayCutoutMode_._internal(2); ///The window is always allowed to extend into the DisplayCutout areas on the all edges of the screen. /// ///**NOTE**: available on Android 30+. - static const ALWAYS = const LayoutInDisplayCutoutMode._internal(3); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const ALWAYS = const LayoutInDisplayCutoutMode_._internal(3); } ///Android-specific class representing the share state that should be applied to the custom tab. @@ -77,73 +36,30 @@ class LayoutInDisplayCutoutMode { /// ///Use [LayoutInDisplayCutoutMode] instead. @Deprecated("Use LayoutInDisplayCutoutMode instead") -class AndroidLayoutInDisplayCutoutMode { +@ExchangeableEnum() +class AndroidLayoutInDisplayCutoutMode_ { + // ignore: unused_field final int _value; - - const AndroidLayoutInDisplayCutoutMode._internal(this._value); - - ///Set of all values of [AndroidLayoutInDisplayCutoutMode]. - static final Set values = [ - AndroidLayoutInDisplayCutoutMode.DEFAULT, - AndroidLayoutInDisplayCutoutMode.SHORT_EDGES, - AndroidLayoutInDisplayCutoutMode.NEVER, - AndroidLayoutInDisplayCutoutMode.ALWAYS - ].toSet(); - - ///Gets a possible [AndroidLayoutInDisplayCutoutMode] instance from an [int] value. - static AndroidLayoutInDisplayCutoutMode? fromValue(int? value) { - if (value != null) { - try { - return AndroidLayoutInDisplayCutoutMode.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "SHORT_EDGES"; - case 2: - return "NEVER"; - case 3: - return "ALWAYS"; - case 0: - default: - return "DEFAULT"; - } - } + const AndroidLayoutInDisplayCutoutMode_._internal(this._value); ///With this default setting, content renders into the cutout area when displayed in portrait mode, but content is letterboxed when displayed in landscape mode. /// ///**NOTE**: available on Android 28+. - static const DEFAULT = const AndroidLayoutInDisplayCutoutMode._internal(0); + static const DEFAULT = const AndroidLayoutInDisplayCutoutMode_._internal(0); ///Content renders into the cutout area in both portrait and landscape modes. /// ///**NOTE**: available on Android 28+. static const SHORT_EDGES = - const AndroidLayoutInDisplayCutoutMode._internal(1); + const AndroidLayoutInDisplayCutoutMode_._internal(1); ///Content never renders into the cutout area. /// ///**NOTE**: available on Android 28+. - static const NEVER = const AndroidLayoutInDisplayCutoutMode._internal(2); + static const NEVER = const AndroidLayoutInDisplayCutoutMode_._internal(2); ///The window is always allowed to extend into the DisplayCutout areas on the all edges of the screen. /// ///**NOTE**: available on Android 30+. - static const ALWAYS = const AndroidLayoutInDisplayCutoutMode._internal(3); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const ALWAYS = const AndroidLayoutInDisplayCutoutMode_._internal(3); } \ No newline at end of file diff --git a/lib/src/types/layout_in_display_cutout_mode.g.dart b/lib/src/types/layout_in_display_cutout_mode.g.dart new file mode 100644 index 00000000..f5bf22ca --- /dev/null +++ b/lib/src/types/layout_in_display_cutout_mode.g.dart @@ -0,0 +1,197 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'layout_in_display_cutout_mode.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class representing the share state that should be applied to the custom tab. +class LayoutInDisplayCutoutMode { + final int _value; + final int _nativeValue; + const LayoutInDisplayCutoutMode._internal(this._value, this._nativeValue); +// ignore: unused_element + factory LayoutInDisplayCutoutMode._internalMultiPlatform( + int value, Function nativeValue) => + LayoutInDisplayCutoutMode._internal(value, nativeValue()); + + ///With this default setting, content renders into the cutout area when displayed in portrait mode, but content is letterboxed when displayed in landscape mode. + /// + ///**NOTE**: available on Android 28+. + static const DEFAULT = LayoutInDisplayCutoutMode._internal(0, 0); + + ///Content renders into the cutout area in both portrait and landscape modes. + /// + ///**NOTE**: available on Android 28+. + static const SHORT_EDGES = LayoutInDisplayCutoutMode._internal(1, 1); + + ///Content never renders into the cutout area. + /// + ///**NOTE**: available on Android 28+. + static const NEVER = LayoutInDisplayCutoutMode._internal(2, 2); + + ///The window is always allowed to extend into the DisplayCutout areas on the all edges of the screen. + /// + ///**NOTE**: available on Android 30+. + static const ALWAYS = LayoutInDisplayCutoutMode._internal(3, 3); + + ///Set of all values of [LayoutInDisplayCutoutMode]. + static final Set values = [ + LayoutInDisplayCutoutMode.DEFAULT, + LayoutInDisplayCutoutMode.SHORT_EDGES, + LayoutInDisplayCutoutMode.NEVER, + LayoutInDisplayCutoutMode.ALWAYS, + ].toSet(); + + ///Gets a possible [LayoutInDisplayCutoutMode] instance from [int] value. + static LayoutInDisplayCutoutMode? fromValue(int? value) { + if (value != null) { + try { + return LayoutInDisplayCutoutMode.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [LayoutInDisplayCutoutMode] instance from a native value. + static LayoutInDisplayCutoutMode? fromNativeValue(int? value) { + if (value != null) { + try { + return LayoutInDisplayCutoutMode.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'DEFAULT'; + case 1: + return 'SHORT_EDGES'; + case 2: + return 'NEVER'; + case 3: + return 'ALWAYS'; + } + return _value.toString(); + } +} + +///Android-specific class representing the share state that should be applied to the custom tab. +/// +///**NOTE**: available on Android 28+. +/// +///Use [LayoutInDisplayCutoutMode] instead. +@Deprecated('Use LayoutInDisplayCutoutMode instead') +class AndroidLayoutInDisplayCutoutMode { + final int _value; + final int _nativeValue; + const AndroidLayoutInDisplayCutoutMode._internal( + this._value, this._nativeValue); +// ignore: unused_element + factory AndroidLayoutInDisplayCutoutMode._internalMultiPlatform( + int value, Function nativeValue) => + AndroidLayoutInDisplayCutoutMode._internal(value, nativeValue()); + + ///With this default setting, content renders into the cutout area when displayed in portrait mode, but content is letterboxed when displayed in landscape mode. + /// + ///**NOTE**: available on Android 28+. + static const DEFAULT = AndroidLayoutInDisplayCutoutMode._internal(0, 0); + + ///Content renders into the cutout area in both portrait and landscape modes. + /// + ///**NOTE**: available on Android 28+. + static const SHORT_EDGES = AndroidLayoutInDisplayCutoutMode._internal(1, 1); + + ///Content never renders into the cutout area. + /// + ///**NOTE**: available on Android 28+. + static const NEVER = AndroidLayoutInDisplayCutoutMode._internal(2, 2); + + ///The window is always allowed to extend into the DisplayCutout areas on the all edges of the screen. + /// + ///**NOTE**: available on Android 30+. + static const ALWAYS = AndroidLayoutInDisplayCutoutMode._internal(3, 3); + + ///Set of all values of [AndroidLayoutInDisplayCutoutMode]. + static final Set values = [ + AndroidLayoutInDisplayCutoutMode.DEFAULT, + AndroidLayoutInDisplayCutoutMode.SHORT_EDGES, + AndroidLayoutInDisplayCutoutMode.NEVER, + AndroidLayoutInDisplayCutoutMode.ALWAYS, + ].toSet(); + + ///Gets a possible [AndroidLayoutInDisplayCutoutMode] instance from [int] value. + static AndroidLayoutInDisplayCutoutMode? fromValue(int? value) { + if (value != null) { + try { + return AndroidLayoutInDisplayCutoutMode.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [AndroidLayoutInDisplayCutoutMode] instance from a native value. + static AndroidLayoutInDisplayCutoutMode? fromNativeValue(int? value) { + if (value != null) { + try { + return AndroidLayoutInDisplayCutoutMode.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'DEFAULT'; + case 1: + return 'SHORT_EDGES'; + case 2: + return 'NEVER'; + case 3: + return 'ALWAYS'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/loaded_resource.dart b/lib/src/types/loaded_resource.dart index 8fd7bd11..930e29af 100644 --- a/lib/src/types/loaded_resource.dart +++ b/lib/src/types/loaded_resource.dart @@ -1,8 +1,13 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; +part 'loaded_resource.g.dart'; + ///Class representing a resource response of the [WebView]. ///It is used by the method [WebView.onLoadResource]. -class LoadedResource { +@ExchangeableObject() +class LoadedResource_ { ///A string representing the type of resource. String? initiatorType; @@ -15,37 +20,5 @@ class LoadedResource { ///Returns the [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) duration to fetch a resource. double? duration; - LoadedResource({this.initiatorType, this.url, this.startTime, this.duration}); - - ///Gets a possible [LoadedResource] instance from a [Map] value. - static LoadedResource? fromMap(Map? map) { - if (map == null) { - return null; - } - return LoadedResource( - initiatorType: map["initiatorType"], - url: map["url"] != null ? Uri.parse(map["url"]) : null, - startTime: map["startTime"], - duration: map["duration"]); - } - - ///Converts instance to a map. - Map toMap() { - return { - "initiatorType": initiatorType, - "url": url?.toString(), - "startTime": startTime, - "duration": duration - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + LoadedResource_({this.initiatorType, this.url, this.startTime, this.duration}); } \ No newline at end of file diff --git a/lib/src/types/loaded_resource.g.dart b/lib/src/types/loaded_resource.g.dart new file mode 100644 index 00000000..f955d569 --- /dev/null +++ b/lib/src/types/loaded_resource.g.dart @@ -0,0 +1,58 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'loaded_resource.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class representing a resource response of the [WebView]. +///It is used by the method [WebView.onLoadResource]. +class LoadedResource { + ///A string representing the type of resource. + String? initiatorType; + + ///Resource URL. + Uri? url; + + ///Returns the [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) for the time a resource fetch started. + double? startTime; + + ///Returns the [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) duration to fetch a resource. + double? duration; + LoadedResource({this.initiatorType, this.url, this.startTime, this.duration}); + + ///Gets a possible [LoadedResource] instance from a [Map] value. + static LoadedResource? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = LoadedResource( + initiatorType: map['initiatorType'], + url: map['url'] != null ? Uri.parse(map['url']) : null, + startTime: map['startTime'], + duration: map['duration'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "initiatorType": initiatorType, + "url": url?.toString(), + "startTime": startTime, + "duration": duration, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'LoadedResource{initiatorType: $initiatorType, url: $url, startTime: $startTime, duration: $duration}'; + } +} diff --git a/lib/src/types/login_request.dart b/lib/src/types/login_request.dart index f9f2c5d9..19a036b6 100644 --- a/lib/src/types/login_request.dart +++ b/lib/src/types/login_request.dart @@ -1,7 +1,12 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; +part 'login_request.g.dart'; + ///Class used by [WebView.onReceivedLoginRequest] event. -class LoginRequest { +@ExchangeableObject() +class LoginRequest_ { ///The account realm used to look up accounts. String realm; @@ -12,32 +17,5 @@ class LoginRequest { ///Authenticator specific arguments used to log in the user. String args; - LoginRequest({required this.realm, this.account, required this.args}); - - ///Gets a possible [LoginRequest] instance from a [Map] value. - static LoginRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - return LoginRequest( - realm: map["realm"], - account: map["account"], - args: map["args"], - ); - } - - ///Converts instance to a map. - Map toMap() { - return {"realm": realm, "account": account, "args": args}; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + LoginRequest_({required this.realm, this.account, required this.args}); } \ No newline at end of file diff --git a/lib/src/types/login_request.g.dart b/lib/src/types/login_request.g.dart new file mode 100644 index 00000000..8f76cf17 --- /dev/null +++ b/lib/src/types/login_request.g.dart @@ -0,0 +1,53 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'login_request.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class used by [WebView.onReceivedLoginRequest] event. +class LoginRequest { + ///The account realm used to look up accounts. + String realm; + + ///An optional account. If not `null`, the account should be checked against accounts on the device. + ///If it is a valid account, it should be used to log in the user. This value may be `null`. + String? account; + + ///Authenticator specific arguments used to log in the user. + String args; + LoginRequest({required this.realm, this.account, required this.args}); + + ///Gets a possible [LoginRequest] instance from a [Map] value. + static LoginRequest? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = LoginRequest( + realm: map['realm'], + account: map['account'], + args: map['args'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "realm": realm, + "account": account, + "args": args, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'LoginRequest{realm: $realm, account: $account, args: $args}'; + } +} diff --git a/lib/src/types/media_capture_state.dart b/lib/src/types/media_capture_state.dart index 4d331b04..5ad4a107 100644 --- a/lib/src/types/media_capture_state.dart +++ b/lib/src/types/media_capture_state.dart @@ -1,56 +1,20 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'media_capture_state.g.dart'; + ///Class that describes whether a media device, like a camera or microphone, is currently capturing audio or video. -class MediaCaptureState { +@ExchangeableEnum() +class MediaCaptureState_ { + // ignore: unused_field final int _value; - - const MediaCaptureState._internal(this._value); - - ///Set of all values of [MediaCaptureState]. - static final Set values = [ - MediaCaptureState.NONE, - MediaCaptureState.ACTIVE, - MediaCaptureState.MUTED, - ].toSet(); - - ///Gets a possible [MediaCaptureState] instance from an [int] value. - static MediaCaptureState? fromValue(int? value) { - if (value != null) { - try { - return MediaCaptureState.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "ACTIVE"; - case 2: - return "MUTED"; - case 0: - default: - return "NONE"; - } - } + const MediaCaptureState_._internal(this._value); ///The media device is off. - static const NONE = const MediaCaptureState._internal(0); + static const NONE = const MediaCaptureState_._internal(0); ///The media device is actively capturing audio or video. - static const ACTIVE = const MediaCaptureState._internal(1); + static const ACTIVE = const MediaCaptureState_._internal(1); ///The media device is muted, and not actively capturing audio or video. - static const MUTED = const MediaCaptureState._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const MUTED = const MediaCaptureState_._internal(2); } \ No newline at end of file diff --git a/lib/src/types/media_capture_state.g.dart b/lib/src/types/media_capture_state.g.dart new file mode 100644 index 00000000..2d82e5b0 --- /dev/null +++ b/lib/src/types/media_capture_state.g.dart @@ -0,0 +1,85 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'media_capture_state.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class that describes whether a media device, like a camera or microphone, is currently capturing audio or video. +class MediaCaptureState { + final int _value; + final int _nativeValue; + const MediaCaptureState._internal(this._value, this._nativeValue); +// ignore: unused_element + factory MediaCaptureState._internalMultiPlatform( + int value, Function nativeValue) => + MediaCaptureState._internal(value, nativeValue()); + + ///The media device is off. + static const NONE = MediaCaptureState._internal(0, 0); + + ///The media device is actively capturing audio or video. + static const ACTIVE = MediaCaptureState._internal(1, 1); + + ///The media device is muted, and not actively capturing audio or video. + static const MUTED = MediaCaptureState._internal(2, 2); + + ///Set of all values of [MediaCaptureState]. + static final Set values = [ + MediaCaptureState.NONE, + MediaCaptureState.ACTIVE, + MediaCaptureState.MUTED, + ].toSet(); + + ///Gets a possible [MediaCaptureState] instance from [int] value. + static MediaCaptureState? fromValue(int? value) { + if (value != null) { + try { + return MediaCaptureState.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [MediaCaptureState] instance from a native value. + static MediaCaptureState? fromNativeValue(int? value) { + if (value != null) { + try { + return MediaCaptureState.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'NONE'; + case 1: + return 'ACTIVE'; + case 2: + return 'MUTED'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/media_playback_state.dart b/lib/src/types/media_playback_state.dart index 03821f0d..1a00fac0 100644 --- a/lib/src/types/media_playback_state.dart +++ b/lib/src/types/media_playback_state.dart @@ -1,62 +1,23 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'media_playback_state.g.dart'; + ///Class that describes whether an audio or video presentation is playing, paused, or suspended. -class MediaPlaybackState { +@ExchangeableEnum() +class MediaPlaybackState_ { + // ignore: unused_field final int _value; - - const MediaPlaybackState._internal(this._value); - - ///Set of all values of [MediaPlaybackState]. - static final Set values = [ - MediaPlaybackState.NONE, - MediaPlaybackState.PLAYING, - MediaPlaybackState.PAUSED, - MediaPlaybackState.SUSPENDED, - ].toSet(); - - ///Gets a possible [MediaPlaybackState] instance from an [int] value. - static MediaPlaybackState? fromValue(int? value) { - if (value != null) { - try { - return MediaPlaybackState.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "PLAYING"; - case 2: - return "PAUSED"; - case 3: - return "SUSPENDED"; - case 0: - default: - return "NONE"; - } - } + const MediaPlaybackState_._internal(this._value); ///There is no media to play back. - static const NONE = const MediaPlaybackState._internal(0); + static const NONE = const MediaPlaybackState_._internal(0); ///The media is playing. - static const PLAYING = const MediaPlaybackState._internal(1); + static const PLAYING = const MediaPlaybackState_._internal(1); ///The media playback is paused. - static const PAUSED = const MediaPlaybackState._internal(2); + static const PAUSED = const MediaPlaybackState_._internal(2); ///The media is not playing, and cannot be resumed until the user revokes the suspension. - static const SUSPENDED = const MediaPlaybackState._internal(3); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const SUSPENDED = const MediaPlaybackState_._internal(3); } \ No newline at end of file diff --git a/lib/src/types/media_playback_state.g.dart b/lib/src/types/media_playback_state.g.dart new file mode 100644 index 00000000..038f1ff1 --- /dev/null +++ b/lib/src/types/media_playback_state.g.dart @@ -0,0 +1,91 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'media_playback_state.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class that describes whether an audio or video presentation is playing, paused, or suspended. +class MediaPlaybackState { + final int _value; + final int _nativeValue; + const MediaPlaybackState._internal(this._value, this._nativeValue); +// ignore: unused_element + factory MediaPlaybackState._internalMultiPlatform( + int value, Function nativeValue) => + MediaPlaybackState._internal(value, nativeValue()); + + ///There is no media to play back. + static const NONE = MediaPlaybackState._internal(0, 0); + + ///The media is playing. + static const PLAYING = MediaPlaybackState._internal(1, 1); + + ///The media playback is paused. + static const PAUSED = MediaPlaybackState._internal(2, 2); + + ///The media is not playing, and cannot be resumed until the user revokes the suspension. + static const SUSPENDED = MediaPlaybackState._internal(3, 3); + + ///Set of all values of [MediaPlaybackState]. + static final Set values = [ + MediaPlaybackState.NONE, + MediaPlaybackState.PLAYING, + MediaPlaybackState.PAUSED, + MediaPlaybackState.SUSPENDED, + ].toSet(); + + ///Gets a possible [MediaPlaybackState] instance from [int] value. + static MediaPlaybackState? fromValue(int? value) { + if (value != null) { + try { + return MediaPlaybackState.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [MediaPlaybackState] instance from a native value. + static MediaPlaybackState? fromNativeValue(int? value) { + if (value != null) { + try { + return MediaPlaybackState.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'NONE'; + case 1: + return 'PLAYING'; + case 2: + return 'PAUSED'; + case 3: + return 'SUSPENDED'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/meta_tag.dart b/lib/src/types/meta_tag.dart index 3480ef61..1e6100e4 100644 --- a/lib/src/types/meta_tag.dart +++ b/lib/src/types/meta_tag.dart @@ -1,8 +1,13 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/in_app_webview_controller.dart'; import 'meta_tag_attribute.dart'; +part 'meta_tag.g.dart'; + ///Class that represents a `` HTML tag. It is used by the [InAppWebViewController.getMetaTags] method. -class MetaTag { +@ExchangeableObject() +class MetaTag_ { ///The meta tag name value. String? name; @@ -10,22 +15,7 @@ class MetaTag { String? content; ///The meta tag attributes list. - List? attrs; + List? attrs; - MetaTag({this.name, this.content, this.attrs}); - - ///Converts instance to a map. - Map toMap() { - return {"name": name, "content": content, "attrs": attrs}; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + MetaTag_({this.name, this.content, this.attrs}); } \ No newline at end of file diff --git a/lib/src/types/meta_tag.g.dart b/lib/src/types/meta_tag.g.dart new file mode 100644 index 00000000..a2a1a529 --- /dev/null +++ b/lib/src/types/meta_tag.g.dart @@ -0,0 +1,53 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'meta_tag.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents a `` HTML tag. It is used by the [InAppWebViewController.getMetaTags] method. +class MetaTag { + ///The meta tag name value. + String? name; + + ///The meta tag content value. + String? content; + + ///The meta tag attributes list. + List? attrs; + MetaTag({this.name, this.content, this.attrs}); + + ///Gets a possible [MetaTag] instance from a [Map] value. + static MetaTag? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = MetaTag( + name: map['name'], + content: map['content'], + attrs: map['attrs']?.forEach( + (e) => MetaTagAttribute.fromMap(e?.cast())!), + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "name": name, + "content": content, + "attrs": attrs?.map((e) => e.toMap()).toList(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'MetaTag{name: $name, content: $content, attrs: $attrs}'; + } +} diff --git a/lib/src/types/meta_tag_attribute.dart b/lib/src/types/meta_tag_attribute.dart index 90cf2d39..d5a0144d 100644 --- a/lib/src/types/meta_tag_attribute.dart +++ b/lib/src/types/meta_tag_attribute.dart @@ -1,30 +1,17 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'meta_tag.dart'; +part 'meta_tag_attribute.g.dart'; + ///Class that represents an attribute of a `` HTML tag. It is used by the [MetaTag] class. -class MetaTagAttribute { +@ExchangeableObject() +class MetaTagAttribute_ { ///The attribute name. String? name; ///The attribute value. String? value; - MetaTagAttribute({this.name, this.value}); - - ///Converts instance to a map. - Map toMap() { - return { - "name": name, - "value": value, - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + MetaTagAttribute_({this.name, this.value}); } \ No newline at end of file diff --git a/lib/src/types/meta_tag_attribute.g.dart b/lib/src/types/meta_tag_attribute.g.dart new file mode 100644 index 00000000..8e546a06 --- /dev/null +++ b/lib/src/types/meta_tag_attribute.g.dart @@ -0,0 +1,47 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'meta_tag_attribute.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents an attribute of a `` HTML tag. It is used by the [MetaTag] class. +class MetaTagAttribute { + ///The attribute name. + String? name; + + ///The attribute value. + String? value; + MetaTagAttribute({this.name, this.value}); + + ///Gets a possible [MetaTagAttribute] instance from a [Map] value. + static MetaTagAttribute? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = MetaTagAttribute( + name: map['name'], + value: map['value'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "name": name, + "value": value, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'MetaTagAttribute{name: $name, value: $value}'; + } +} diff --git a/lib/src/types/mixed_content_mode.dart b/lib/src/types/mixed_content_mode.dart index e1034a61..1d138aad 100644 --- a/lib/src/types/mixed_content_mode.dart +++ b/lib/src/types/mixed_content_mode.dart @@ -1,52 +1,21 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'mixed_content_mode.g.dart'; + ///Class used to configure the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. -class MixedContentMode { +@ExchangeableEnum() +class MixedContentMode_ { + // ignore: unused_field final int _value; - - const MixedContentMode._internal(this._value); - - ///Set of all values of [MixedContentMode]. - static final Set values = [ - MixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW, - MixedContentMode.MIXED_CONTENT_NEVER_ALLOW, - MixedContentMode.MIXED_CONTENT_COMPATIBILITY_MODE, - ].toSet(); - - ///Gets a possible [MixedContentMode] instance from an [int] value. - static MixedContentMode? fromValue(int? value) { - if (value != null) { - try { - return MixedContentMode.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "MIXED_CONTENT_NEVER_ALLOW"; - case 2: - return "MIXED_CONTENT_COMPATIBILITY_MODE"; - case 0: - default: - return "MIXED_CONTENT_ALWAYS_ALLOW"; - } - } + const MixedContentMode_._internal(this._value); ///In this mode, the WebView will allow a secure origin to load content from any other origin, even if that origin is insecure. ///This is the least secure mode of operation for the WebView, and where possible apps should not set this mode. - static const MIXED_CONTENT_ALWAYS_ALLOW = const MixedContentMode._internal(0); + static const MIXED_CONTENT_ALWAYS_ALLOW = const MixedContentMode_._internal(0); ///In this mode, the WebView will not allow a secure origin to load content from an insecure origin. ///This is the preferred and most secure mode of operation for the WebView and apps are strongly advised to use this mode. - static const MIXED_CONTENT_NEVER_ALLOW = const MixedContentMode._internal(1); + static const MIXED_CONTENT_NEVER_ALLOW = const MixedContentMode_._internal(1); ///In this mode, the WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content. ///Some insecure content may be allowed to be loaded by a secure origin and other types of content will be blocked. @@ -54,12 +23,7 @@ class MixedContentMode { ///This mode is intended to be used by apps that are not in control of the content that they render but desire to operate in a reasonably secure environment. ///For highest security, apps are recommended to use [MixedContentMode.MIXED_CONTENT_NEVER_ALLOW]. static const MIXED_CONTENT_COMPATIBILITY_MODE = - const MixedContentMode._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + const MixedContentMode_._internal(2); } ///An Android-specific class used to configure the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. @@ -68,56 +32,21 @@ class MixedContentMode { /// ///Use [MixedContentMode] instead. @Deprecated("Use MixedContentMode instead") -class AndroidMixedContentMode { +@ExchangeableEnum() +class AndroidMixedContentMode_ { + // ignore: unused_field final int _value; - - const AndroidMixedContentMode._internal(this._value); - - ///Set of all values of [AndroidMixedContentMode]. - static final Set values = [ - AndroidMixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW, - AndroidMixedContentMode.MIXED_CONTENT_NEVER_ALLOW, - AndroidMixedContentMode.MIXED_CONTENT_COMPATIBILITY_MODE, - ].toSet(); - - ///Gets a possible [AndroidMixedContentMode] instance from an [int] value. - static AndroidMixedContentMode? fromValue(int? value) { - if (value != null) { - try { - return AndroidMixedContentMode.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "MIXED_CONTENT_NEVER_ALLOW"; - case 2: - return "MIXED_CONTENT_COMPATIBILITY_MODE"; - case 0: - default: - return "MIXED_CONTENT_ALWAYS_ALLOW"; - } - } + const AndroidMixedContentMode_._internal(this._value); ///In this mode, the WebView will allow a secure origin to load content from any other origin, even if that origin is insecure. ///This is the least secure mode of operation for the WebView, and where possible apps should not set this mode. static const MIXED_CONTENT_ALWAYS_ALLOW = - const AndroidMixedContentMode._internal(0); + const AndroidMixedContentMode_._internal(0); ///In this mode, the WebView will not allow a secure origin to load content from an insecure origin. ///This is the preferred and most secure mode of operation for the WebView and apps are strongly advised to use this mode. static const MIXED_CONTENT_NEVER_ALLOW = - const AndroidMixedContentMode._internal(1); + const AndroidMixedContentMode_._internal(1); ///In this mode, the WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content. ///Some insecure content may be allowed to be loaded by a secure origin and other types of content will be blocked. @@ -125,10 +54,5 @@ class AndroidMixedContentMode { ///This mode is intended to be used by apps that are not in control of the content that they render but desire to operate in a reasonably secure environment. ///For highest security, apps are recommended to use [AndroidMixedContentMode.MIXED_CONTENT_NEVER_ALLOW]. static const MIXED_CONTENT_COMPATIBILITY_MODE = - const AndroidMixedContentMode._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + const AndroidMixedContentMode_._internal(2); } \ No newline at end of file diff --git a/lib/src/types/mixed_content_mode.g.dart b/lib/src/types/mixed_content_mode.g.dart new file mode 100644 index 00000000..013e5c2c --- /dev/null +++ b/lib/src/types/mixed_content_mode.g.dart @@ -0,0 +1,184 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'mixed_content_mode.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used to configure the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. +class MixedContentMode { + final int _value; + final int _nativeValue; + const MixedContentMode._internal(this._value, this._nativeValue); +// ignore: unused_element + factory MixedContentMode._internalMultiPlatform( + int value, Function nativeValue) => + MixedContentMode._internal(value, nativeValue()); + + ///In this mode, the WebView will allow a secure origin to load content from any other origin, even if that origin is insecure. + ///This is the least secure mode of operation for the WebView, and where possible apps should not set this mode. + static const MIXED_CONTENT_ALWAYS_ALLOW = MixedContentMode._internal(0, 0); + + ///In this mode, the WebView will not allow a secure origin to load content from an insecure origin. + ///This is the preferred and most secure mode of operation for the WebView and apps are strongly advised to use this mode. + static const MIXED_CONTENT_NEVER_ALLOW = MixedContentMode._internal(1, 1); + + ///In this mode, the WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content. + ///Some insecure content may be allowed to be loaded by a secure origin and other types of content will be blocked. + ///The types of content are allowed or blocked may change release to release and are not explicitly defined. + ///This mode is intended to be used by apps that are not in control of the content that they render but desire to operate in a reasonably secure environment. + ///For highest security, apps are recommended to use [MixedContentMode.MIXED_CONTENT_NEVER_ALLOW]. + static const MIXED_CONTENT_COMPATIBILITY_MODE = + MixedContentMode._internal(2, 2); + + ///Set of all values of [MixedContentMode]. + static final Set values = [ + MixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW, + MixedContentMode.MIXED_CONTENT_NEVER_ALLOW, + MixedContentMode.MIXED_CONTENT_COMPATIBILITY_MODE, + ].toSet(); + + ///Gets a possible [MixedContentMode] instance from [int] value. + static MixedContentMode? fromValue(int? value) { + if (value != null) { + try { + return MixedContentMode.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [MixedContentMode] instance from a native value. + static MixedContentMode? fromNativeValue(int? value) { + if (value != null) { + try { + return MixedContentMode.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'MIXED_CONTENT_ALWAYS_ALLOW'; + case 1: + return 'MIXED_CONTENT_NEVER_ALLOW'; + case 2: + return 'MIXED_CONTENT_COMPATIBILITY_MODE'; + } + return _value.toString(); + } +} + +///An Android-specific class used to configure the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. +/// +///**NOTE**: available on Android 21+. +/// +///Use [MixedContentMode] instead. +@Deprecated('Use MixedContentMode instead') +class AndroidMixedContentMode { + final int _value; + final int _nativeValue; + const AndroidMixedContentMode._internal(this._value, this._nativeValue); +// ignore: unused_element + factory AndroidMixedContentMode._internalMultiPlatform( + int value, Function nativeValue) => + AndroidMixedContentMode._internal(value, nativeValue()); + + ///In this mode, the WebView will allow a secure origin to load content from any other origin, even if that origin is insecure. + ///This is the least secure mode of operation for the WebView, and where possible apps should not set this mode. + static const MIXED_CONTENT_ALWAYS_ALLOW = + AndroidMixedContentMode._internal(0, 0); + + ///In this mode, the WebView will not allow a secure origin to load content from an insecure origin. + ///This is the preferred and most secure mode of operation for the WebView and apps are strongly advised to use this mode. + static const MIXED_CONTENT_NEVER_ALLOW = + AndroidMixedContentMode._internal(1, 1); + + ///In this mode, the WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content. + ///Some insecure content may be allowed to be loaded by a secure origin and other types of content will be blocked. + ///The types of content are allowed or blocked may change release to release and are not explicitly defined. + ///This mode is intended to be used by apps that are not in control of the content that they render but desire to operate in a reasonably secure environment. + ///For highest security, apps are recommended to use [AndroidMixedContentMode.MIXED_CONTENT_NEVER_ALLOW]. + static const MIXED_CONTENT_COMPATIBILITY_MODE = + AndroidMixedContentMode._internal(2, 2); + + ///Set of all values of [AndroidMixedContentMode]. + static final Set values = [ + AndroidMixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW, + AndroidMixedContentMode.MIXED_CONTENT_NEVER_ALLOW, + AndroidMixedContentMode.MIXED_CONTENT_COMPATIBILITY_MODE, + ].toSet(); + + ///Gets a possible [AndroidMixedContentMode] instance from [int] value. + static AndroidMixedContentMode? fromValue(int? value) { + if (value != null) { + try { + return AndroidMixedContentMode.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [AndroidMixedContentMode] instance from a native value. + static AndroidMixedContentMode? fromNativeValue(int? value) { + if (value != null) { + try { + return AndroidMixedContentMode.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'MIXED_CONTENT_ALWAYS_ALLOW'; + case 1: + return 'MIXED_CONTENT_NEVER_ALLOW'; + case 2: + return 'MIXED_CONTENT_COMPATIBILITY_MODE'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/modal_presentation_style.dart b/lib/src/types/modal_presentation_style.dart index d748d9f6..76bce2fc 100644 --- a/lib/src/types/modal_presentation_style.dart +++ b/lib/src/types/modal_presentation_style.dart @@ -1,205 +1,87 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'modal_presentation_style.g.dart'; + ///Class used to specify the modal presentation style when presenting a view controller. -class ModalPresentationStyle { +@ExchangeableEnum() +class ModalPresentationStyle_ { + // ignore: unused_field final int _value; - - const ModalPresentationStyle._internal(this._value); - - ///Set of all values of [ModalPresentationStyle]. - static final Set values = [ - ModalPresentationStyle.FULL_SCREEN, - ModalPresentationStyle.PAGE_SHEET, - ModalPresentationStyle.FORM_SHEET, - ModalPresentationStyle.CURRENT_CONTEXT, - ModalPresentationStyle.CUSTOM, - ModalPresentationStyle.OVER_FULL_SCREEN, - ModalPresentationStyle.OVER_CURRENT_CONTEXT, - ModalPresentationStyle.POPOVER, - ModalPresentationStyle.NONE, - ModalPresentationStyle.AUTOMATIC, - ].toSet(); - - ///Gets a possible [ModalPresentationStyle] instance from an [int] value. - static ModalPresentationStyle? fromValue(int? value) { - if (value != null) { - try { - return ModalPresentationStyle.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "PAGE_SHEET"; - case 2: - return "FORM_SHEET"; - case 3: - return "CURRENT_CONTEXT"; - case 4: - return "CUSTOM"; - case 5: - return "OVER_FULL_SCREEN"; - case 6: - return "OVER_CURRENT_CONTEXT"; - case 7: - return "POPOVER"; - case 8: - return "NONE"; - case 9: - return "AUTOMATIC"; - case 0: - default: - return "FULL_SCREEN"; - } - } + const ModalPresentationStyle_._internal(this._value); ///A presentation style in which the presented view covers the screen. - static const FULL_SCREEN = const ModalPresentationStyle._internal(0); + static const FULL_SCREEN = const ModalPresentationStyle_._internal(0); ///A presentation style that partially covers the underlying content. - static const PAGE_SHEET = const ModalPresentationStyle._internal(1); + static const PAGE_SHEET = const ModalPresentationStyle_._internal(1); ///A presentation style that displays the content centered in the screen. - static const FORM_SHEET = const ModalPresentationStyle._internal(2); + static const FORM_SHEET = const ModalPresentationStyle_._internal(2); ///A presentation style where the content is displayed over another view controller’s content. - static const CURRENT_CONTEXT = const ModalPresentationStyle._internal(3); + static const CURRENT_CONTEXT = const ModalPresentationStyle_._internal(3); ///A custom view presentation style that is managed by a custom presentation controller and one or more custom animator objects. - static const CUSTOM = const ModalPresentationStyle._internal(4); + static const CUSTOM = const ModalPresentationStyle_._internal(4); ///A view presentation style in which the presented view covers the screen. - static const OVER_FULL_SCREEN = const ModalPresentationStyle._internal(5); + static const OVER_FULL_SCREEN = const ModalPresentationStyle_._internal(5); ///A presentation style where the content is displayed over another view controller’s content. - static const OVER_CURRENT_CONTEXT = const ModalPresentationStyle._internal(6); + static const OVER_CURRENT_CONTEXT = const ModalPresentationStyle_._internal(6); ///A presentation style where the content is displayed in a popover view. - static const POPOVER = const ModalPresentationStyle._internal(7); + static const POPOVER = const ModalPresentationStyle_._internal(7); ///A presentation style that indicates no adaptations should be made. - static const NONE = const ModalPresentationStyle._internal(8); + static const NONE = const ModalPresentationStyle_._internal(8); ///The default presentation style chosen by the system. /// ///**NOTE**: available on iOS 13.0+. - static const AUTOMATIC = const ModalPresentationStyle._internal(9); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const AUTOMATIC = const ModalPresentationStyle_._internal(9); } ///An iOS-specific class used to specify the modal presentation style when presenting a view controller. ///Use [ModalPresentationStyle] instead. @Deprecated("Use ModalPresentationStyle instead") -class IOSUIModalPresentationStyle { +@ExchangeableEnum() +class IOSUIModalPresentationStyle_ { + // ignore: unused_field final int _value; - - const IOSUIModalPresentationStyle._internal(this._value); - - ///Set of all values of [IOSUIModalPresentationStyle]. - static final Set values = [ - IOSUIModalPresentationStyle.FULL_SCREEN, - IOSUIModalPresentationStyle.PAGE_SHEET, - IOSUIModalPresentationStyle.FORM_SHEET, - IOSUIModalPresentationStyle.CURRENT_CONTEXT, - IOSUIModalPresentationStyle.CUSTOM, - IOSUIModalPresentationStyle.OVER_FULL_SCREEN, - IOSUIModalPresentationStyle.OVER_CURRENT_CONTEXT, - IOSUIModalPresentationStyle.POPOVER, - IOSUIModalPresentationStyle.NONE, - IOSUIModalPresentationStyle.AUTOMATIC, - ].toSet(); - - ///Gets a possible [IOSUIModalPresentationStyle] instance from an [int] value. - static IOSUIModalPresentationStyle? fromValue(int? value) { - if (value != null) { - try { - return IOSUIModalPresentationStyle.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "PAGE_SHEET"; - case 2: - return "FORM_SHEET"; - case 3: - return "CURRENT_CONTEXT"; - case 4: - return "CUSTOM"; - case 5: - return "OVER_FULL_SCREEN"; - case 6: - return "OVER_CURRENT_CONTEXT"; - case 7: - return "POPOVER"; - case 8: - return "NONE"; - case 9: - return "AUTOMATIC"; - case 0: - default: - return "FULL_SCREEN"; - } - } + const IOSUIModalPresentationStyle_._internal(this._value); ///A presentation style in which the presented view covers the screen. - static const FULL_SCREEN = const IOSUIModalPresentationStyle._internal(0); + static const FULL_SCREEN = const IOSUIModalPresentationStyle_._internal(0); ///A presentation style that partially covers the underlying content. - static const PAGE_SHEET = const IOSUIModalPresentationStyle._internal(1); + static const PAGE_SHEET = const IOSUIModalPresentationStyle_._internal(1); ///A presentation style that displays the content centered in the screen. - static const FORM_SHEET = const IOSUIModalPresentationStyle._internal(2); + static const FORM_SHEET = const IOSUIModalPresentationStyle_._internal(2); ///A presentation style where the content is displayed over another view controller’s content. - static const CURRENT_CONTEXT = const IOSUIModalPresentationStyle._internal(3); + static const CURRENT_CONTEXT = const IOSUIModalPresentationStyle_._internal(3); ///A custom view presentation style that is managed by a custom presentation controller and one or more custom animator objects. - static const CUSTOM = const IOSUIModalPresentationStyle._internal(4); + static const CUSTOM = const IOSUIModalPresentationStyle_._internal(4); ///A view presentation style in which the presented view covers the screen. static const OVER_FULL_SCREEN = - const IOSUIModalPresentationStyle._internal(5); + const IOSUIModalPresentationStyle_._internal(5); ///A presentation style where the content is displayed over another view controller’s content. static const OVER_CURRENT_CONTEXT = - const IOSUIModalPresentationStyle._internal(6); + const IOSUIModalPresentationStyle_._internal(6); ///A presentation style where the content is displayed in a popover view. - static const POPOVER = const IOSUIModalPresentationStyle._internal(7); + static const POPOVER = const IOSUIModalPresentationStyle_._internal(7); ///A presentation style that indicates no adaptations should be made. - static const NONE = const IOSUIModalPresentationStyle._internal(8); + static const NONE = const IOSUIModalPresentationStyle_._internal(8); ///The default presentation style chosen by the system. /// ///**NOTE**: available on iOS 13.0+. - static const AUTOMATIC = const IOSUIModalPresentationStyle._internal(9); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const AUTOMATIC = const IOSUIModalPresentationStyle_._internal(9); } \ No newline at end of file diff --git a/lib/src/types/modal_presentation_style.g.dart b/lib/src/types/modal_presentation_style.g.dart new file mode 100644 index 00000000..b79f83cb --- /dev/null +++ b/lib/src/types/modal_presentation_style.g.dart @@ -0,0 +1,254 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'modal_presentation_style.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used to specify the modal presentation style when presenting a view controller. +class ModalPresentationStyle { + final int _value; + final int _nativeValue; + const ModalPresentationStyle._internal(this._value, this._nativeValue); +// ignore: unused_element + factory ModalPresentationStyle._internalMultiPlatform( + int value, Function nativeValue) => + ModalPresentationStyle._internal(value, nativeValue()); + + ///A presentation style in which the presented view covers the screen. + static const FULL_SCREEN = ModalPresentationStyle._internal(0, 0); + + ///A presentation style that partially covers the underlying content. + static const PAGE_SHEET = ModalPresentationStyle._internal(1, 1); + + ///A presentation style that displays the content centered in the screen. + static const FORM_SHEET = ModalPresentationStyle._internal(2, 2); + + ///A presentation style where the content is displayed over another view controller’s content. + static const CURRENT_CONTEXT = ModalPresentationStyle._internal(3, 3); + + ///A custom view presentation style that is managed by a custom presentation controller and one or more custom animator objects. + static const CUSTOM = ModalPresentationStyle._internal(4, 4); + + ///A view presentation style in which the presented view covers the screen. + static const OVER_FULL_SCREEN = ModalPresentationStyle._internal(5, 5); + + ///A presentation style where the content is displayed over another view controller’s content. + static const OVER_CURRENT_CONTEXT = ModalPresentationStyle._internal(6, 6); + + ///A presentation style where the content is displayed in a popover view. + static const POPOVER = ModalPresentationStyle._internal(7, 7); + + ///A presentation style that indicates no adaptations should be made. + static const NONE = ModalPresentationStyle._internal(8, 8); + + ///The default presentation style chosen by the system. + /// + ///**NOTE**: available on iOS 13.0+. + static const AUTOMATIC = ModalPresentationStyle._internal(9, 9); + + ///Set of all values of [ModalPresentationStyle]. + static final Set values = [ + ModalPresentationStyle.FULL_SCREEN, + ModalPresentationStyle.PAGE_SHEET, + ModalPresentationStyle.FORM_SHEET, + ModalPresentationStyle.CURRENT_CONTEXT, + ModalPresentationStyle.CUSTOM, + ModalPresentationStyle.OVER_FULL_SCREEN, + ModalPresentationStyle.OVER_CURRENT_CONTEXT, + ModalPresentationStyle.POPOVER, + ModalPresentationStyle.NONE, + ModalPresentationStyle.AUTOMATIC, + ].toSet(); + + ///Gets a possible [ModalPresentationStyle] instance from [int] value. + static ModalPresentationStyle? fromValue(int? value) { + if (value != null) { + try { + return ModalPresentationStyle.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [ModalPresentationStyle] instance from a native value. + static ModalPresentationStyle? fromNativeValue(int? value) { + if (value != null) { + try { + return ModalPresentationStyle.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'FULL_SCREEN'; + case 1: + return 'PAGE_SHEET'; + case 2: + return 'FORM_SHEET'; + case 3: + return 'CURRENT_CONTEXT'; + case 4: + return 'CUSTOM'; + case 5: + return 'OVER_FULL_SCREEN'; + case 6: + return 'OVER_CURRENT_CONTEXT'; + case 7: + return 'POPOVER'; + case 8: + return 'NONE'; + case 9: + return 'AUTOMATIC'; + } + return _value.toString(); + } +} + +///An iOS-specific class used to specify the modal presentation style when presenting a view controller. +///Use [ModalPresentationStyle] instead. +@Deprecated('Use ModalPresentationStyle instead') +class IOSUIModalPresentationStyle { + final int _value; + final int _nativeValue; + const IOSUIModalPresentationStyle._internal(this._value, this._nativeValue); +// ignore: unused_element + factory IOSUIModalPresentationStyle._internalMultiPlatform( + int value, Function nativeValue) => + IOSUIModalPresentationStyle._internal(value, nativeValue()); + + ///A presentation style in which the presented view covers the screen. + static const FULL_SCREEN = IOSUIModalPresentationStyle._internal(0, 0); + + ///A presentation style that partially covers the underlying content. + static const PAGE_SHEET = IOSUIModalPresentationStyle._internal(1, 1); + + ///A presentation style that displays the content centered in the screen. + static const FORM_SHEET = IOSUIModalPresentationStyle._internal(2, 2); + + ///A presentation style where the content is displayed over another view controller’s content. + static const CURRENT_CONTEXT = IOSUIModalPresentationStyle._internal(3, 3); + + ///A custom view presentation style that is managed by a custom presentation controller and one or more custom animator objects. + static const CUSTOM = IOSUIModalPresentationStyle._internal(4, 4); + + ///A view presentation style in which the presented view covers the screen. + static const OVER_FULL_SCREEN = IOSUIModalPresentationStyle._internal(5, 5); + + ///A presentation style where the content is displayed over another view controller’s content. + static const OVER_CURRENT_CONTEXT = + IOSUIModalPresentationStyle._internal(6, 6); + + ///A presentation style where the content is displayed in a popover view. + static const POPOVER = IOSUIModalPresentationStyle._internal(7, 7); + + ///A presentation style that indicates no adaptations should be made. + static const NONE = IOSUIModalPresentationStyle._internal(8, 8); + + ///The default presentation style chosen by the system. + /// + ///**NOTE**: available on iOS 13.0+. + static const AUTOMATIC = IOSUIModalPresentationStyle._internal(9, 9); + + ///Set of all values of [IOSUIModalPresentationStyle]. + static final Set values = [ + IOSUIModalPresentationStyle.FULL_SCREEN, + IOSUIModalPresentationStyle.PAGE_SHEET, + IOSUIModalPresentationStyle.FORM_SHEET, + IOSUIModalPresentationStyle.CURRENT_CONTEXT, + IOSUIModalPresentationStyle.CUSTOM, + IOSUIModalPresentationStyle.OVER_FULL_SCREEN, + IOSUIModalPresentationStyle.OVER_CURRENT_CONTEXT, + IOSUIModalPresentationStyle.POPOVER, + IOSUIModalPresentationStyle.NONE, + IOSUIModalPresentationStyle.AUTOMATIC, + ].toSet(); + + ///Gets a possible [IOSUIModalPresentationStyle] instance from [int] value. + static IOSUIModalPresentationStyle? fromValue(int? value) { + if (value != null) { + try { + return IOSUIModalPresentationStyle.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [IOSUIModalPresentationStyle] instance from a native value. + static IOSUIModalPresentationStyle? fromNativeValue(int? value) { + if (value != null) { + try { + return IOSUIModalPresentationStyle.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'FULL_SCREEN'; + case 1: + return 'PAGE_SHEET'; + case 2: + return 'FORM_SHEET'; + case 3: + return 'CURRENT_CONTEXT'; + case 4: + return 'CUSTOM'; + case 5: + return 'OVER_FULL_SCREEN'; + case 6: + return 'OVER_CURRENT_CONTEXT'; + case 7: + return 'POPOVER'; + case 8: + return 'NONE'; + case 9: + return 'AUTOMATIC'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/modal_transition_style.dart b/lib/src/types/modal_transition_style.dart index fbe172b8..c47736c0 100644 --- a/lib/src/types/modal_transition_style.dart +++ b/lib/src/types/modal_transition_style.dart @@ -1,139 +1,56 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'modal_transition_style.g.dart'; + ///Class used to specify the transition style when presenting a view controller. -class ModalTransitionStyle { +@ExchangeableEnum() +class ModalTransitionStyle_ { + // ignore: unused_field final int _value; - - const ModalTransitionStyle._internal(this._value); - - ///Set of all values of [ModalTransitionStyle]. - static final Set values = [ - ModalTransitionStyle.COVER_VERTICAL, - ModalTransitionStyle.FLIP_HORIZONTAL, - ModalTransitionStyle.CROSS_DISSOLVE, - ModalTransitionStyle.PARTIAL_CURL, - ].toSet(); - - ///Gets a possible [ModalTransitionStyle] instance from an [int] value. - static ModalTransitionStyle? fromValue(int? value) { - if (value != null) { - try { - return ModalTransitionStyle.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "FLIP_HORIZONTAL"; - case 2: - return "CROSS_DISSOLVE"; - case 3: - return "PARTIAL_CURL"; - case 0: - default: - return "COVER_VERTICAL"; - } - } + const ModalTransitionStyle_._internal(this._value); ///When the view controller is presented, its view slides up from the bottom of the screen. ///On dismissal, the view slides back down. This is the default transition style. - static const COVER_VERTICAL = const ModalTransitionStyle._internal(0); + static const COVER_VERTICAL = const ModalTransitionStyle_._internal(0); ///When the view controller is presented, the current view initiates a horizontal 3D flip from right-to-left, ///resulting in the revealing of the new view as if it were on the back of the previous view. ///On dismissal, the flip occurs from left-to-right, returning to the original view. - static const FLIP_HORIZONTAL = const ModalTransitionStyle._internal(1); + static const FLIP_HORIZONTAL = const ModalTransitionStyle_._internal(1); ///When the view controller is presented, the current view fades out while the new view fades in at the same time. ///On dismissal, a similar type of cross-fade is used to return to the original view. - static const CROSS_DISSOLVE = const ModalTransitionStyle._internal(2); + static const CROSS_DISSOLVE = const ModalTransitionStyle_._internal(2); ///When the view controller is presented, one corner of the current view curls up to reveal the presented view underneath. ///On dismissal, the curled up page unfurls itself back on top of the presented view. ///A view controller presented using this transition is itself prevented from presenting any additional view controllers. - static const PARTIAL_CURL = const ModalTransitionStyle._internal(3); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const PARTIAL_CURL = const ModalTransitionStyle_._internal(3); } ///An iOS-specific class used to specify the transition style when presenting a view controller. ///Use [ModalTransitionStyle] instead. @Deprecated("Use ModalTransitionStyle instead") -class IOSUIModalTransitionStyle { +@ExchangeableEnum() +class IOSUIModalTransitionStyle_ { final int _value; - - const IOSUIModalTransitionStyle._internal(this._value); - - ///Set of all values of [IOSUIModalTransitionStyle]. - static final Set values = [ - IOSUIModalTransitionStyle.COVER_VERTICAL, - IOSUIModalTransitionStyle.FLIP_HORIZONTAL, - IOSUIModalTransitionStyle.CROSS_DISSOLVE, - IOSUIModalTransitionStyle.PARTIAL_CURL, - ].toSet(); - - ///Gets a possible [IOSUIModalTransitionStyle] instance from an [int] value. - static IOSUIModalTransitionStyle? fromValue(int? value) { - if (value != null) { - try { - return IOSUIModalTransitionStyle.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "FLIP_HORIZONTAL"; - case 2: - return "CROSS_DISSOLVE"; - case 3: - return "PARTIAL_CURL"; - case 0: - default: - return "COVER_VERTICAL"; - } - } + const IOSUIModalTransitionStyle_._internal(this._value); ///When the view controller is presented, its view slides up from the bottom of the screen. ///On dismissal, the view slides back down. This is the default transition style. - static const COVER_VERTICAL = const IOSUIModalTransitionStyle._internal(0); + static const COVER_VERTICAL = const IOSUIModalTransitionStyle_._internal(0); ///When the view controller is presented, the current view initiates a horizontal 3D flip from right-to-left, ///resulting in the revealing of the new view as if it were on the back of the previous view. ///On dismissal, the flip occurs from left-to-right, returning to the original view. - static const FLIP_HORIZONTAL = const IOSUIModalTransitionStyle._internal(1); + static const FLIP_HORIZONTAL = const IOSUIModalTransitionStyle_._internal(1); ///When the view controller is presented, the current view fades out while the new view fades in at the same time. ///On dismissal, a similar type of cross-fade is used to return to the original view. - static const CROSS_DISSOLVE = const IOSUIModalTransitionStyle._internal(2); + static const CROSS_DISSOLVE = const IOSUIModalTransitionStyle_._internal(2); ///When the view controller is presented, one corner of the current view curls up to reveal the presented view underneath. ///On dismissal, the curled up page unfurls itself back on top of the presented view. ///A view controller presented using this transition is itself prevented from presenting any additional view controllers. - static const PARTIAL_CURL = const IOSUIModalTransitionStyle._internal(3); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const PARTIAL_CURL = const IOSUIModalTransitionStyle_._internal(3); } \ No newline at end of file diff --git a/lib/src/types/modal_transition_style.g.dart b/lib/src/types/modal_transition_style.g.dart new file mode 100644 index 00000000..4fc55a4d --- /dev/null +++ b/lib/src/types/modal_transition_style.g.dart @@ -0,0 +1,189 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'modal_transition_style.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used to specify the transition style when presenting a view controller. +class ModalTransitionStyle { + final int _value; + final int _nativeValue; + const ModalTransitionStyle._internal(this._value, this._nativeValue); +// ignore: unused_element + factory ModalTransitionStyle._internalMultiPlatform( + int value, Function nativeValue) => + ModalTransitionStyle._internal(value, nativeValue()); + + ///When the view controller is presented, its view slides up from the bottom of the screen. + ///On dismissal, the view slides back down. This is the default transition style. + static const COVER_VERTICAL = ModalTransitionStyle._internal(0, 0); + + ///When the view controller is presented, the current view initiates a horizontal 3D flip from right-to-left, + ///resulting in the revealing of the new view as if it were on the back of the previous view. + ///On dismissal, the flip occurs from left-to-right, returning to the original view. + static const FLIP_HORIZONTAL = ModalTransitionStyle._internal(1, 1); + + ///When the view controller is presented, the current view fades out while the new view fades in at the same time. + ///On dismissal, a similar type of cross-fade is used to return to the original view. + static const CROSS_DISSOLVE = ModalTransitionStyle._internal(2, 2); + + ///When the view controller is presented, one corner of the current view curls up to reveal the presented view underneath. + ///On dismissal, the curled up page unfurls itself back on top of the presented view. + ///A view controller presented using this transition is itself prevented from presenting any additional view controllers. + static const PARTIAL_CURL = ModalTransitionStyle._internal(3, 3); + + ///Set of all values of [ModalTransitionStyle]. + static final Set values = [ + ModalTransitionStyle.COVER_VERTICAL, + ModalTransitionStyle.FLIP_HORIZONTAL, + ModalTransitionStyle.CROSS_DISSOLVE, + ModalTransitionStyle.PARTIAL_CURL, + ].toSet(); + + ///Gets a possible [ModalTransitionStyle] instance from [int] value. + static ModalTransitionStyle? fromValue(int? value) { + if (value != null) { + try { + return ModalTransitionStyle.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [ModalTransitionStyle] instance from a native value. + static ModalTransitionStyle? fromNativeValue(int? value) { + if (value != null) { + try { + return ModalTransitionStyle.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'COVER_VERTICAL'; + case 1: + return 'FLIP_HORIZONTAL'; + case 2: + return 'CROSS_DISSOLVE'; + case 3: + return 'PARTIAL_CURL'; + } + return _value.toString(); + } +} + +///An iOS-specific class used to specify the transition style when presenting a view controller. +///Use [ModalTransitionStyle] instead. +@Deprecated('Use ModalTransitionStyle instead') +class IOSUIModalTransitionStyle { + final int _value; + final int _nativeValue; + const IOSUIModalTransitionStyle._internal(this._value, this._nativeValue); +// ignore: unused_element + factory IOSUIModalTransitionStyle._internalMultiPlatform( + int value, Function nativeValue) => + IOSUIModalTransitionStyle._internal(value, nativeValue()); + + ///When the view controller is presented, its view slides up from the bottom of the screen. + ///On dismissal, the view slides back down. This is the default transition style. + static const COVER_VERTICAL = IOSUIModalTransitionStyle._internal(0, 0); + + ///When the view controller is presented, the current view initiates a horizontal 3D flip from right-to-left, + ///resulting in the revealing of the new view as if it were on the back of the previous view. + ///On dismissal, the flip occurs from left-to-right, returning to the original view. + static const FLIP_HORIZONTAL = IOSUIModalTransitionStyle._internal(1, 1); + + ///When the view controller is presented, the current view fades out while the new view fades in at the same time. + ///On dismissal, a similar type of cross-fade is used to return to the original view. + static const CROSS_DISSOLVE = IOSUIModalTransitionStyle._internal(2, 2); + + ///When the view controller is presented, one corner of the current view curls up to reveal the presented view underneath. + ///On dismissal, the curled up page unfurls itself back on top of the presented view. + ///A view controller presented using this transition is itself prevented from presenting any additional view controllers. + static const PARTIAL_CURL = IOSUIModalTransitionStyle._internal(3, 3); + + ///Set of all values of [IOSUIModalTransitionStyle]. + static final Set values = [ + IOSUIModalTransitionStyle.COVER_VERTICAL, + IOSUIModalTransitionStyle.FLIP_HORIZONTAL, + IOSUIModalTransitionStyle.CROSS_DISSOLVE, + IOSUIModalTransitionStyle.PARTIAL_CURL, + ].toSet(); + + ///Gets a possible [IOSUIModalTransitionStyle] instance from [int] value. + static IOSUIModalTransitionStyle? fromValue(int? value) { + if (value != null) { + try { + return IOSUIModalTransitionStyle.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [IOSUIModalTransitionStyle] instance from a native value. + static IOSUIModalTransitionStyle? fromNativeValue(int? value) { + if (value != null) { + try { + return IOSUIModalTransitionStyle.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'COVER_VERTICAL'; + case 1: + return 'FLIP_HORIZONTAL'; + case 2: + return 'CROSS_DISSOLVE'; + case 3: + return 'PARTIAL_CURL'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/navigation_action.g.dart b/lib/src/types/navigation_action.g.dart index 3d47e45a..09e6e909 100644 --- a/lib/src/types/navigation_action.g.dart +++ b/lib/src/types/navigation_action.g.dart @@ -115,24 +115,23 @@ class NavigationAction { final instance = NavigationAction( request: URLRequest.fromMap(map['request']?.cast())!, isForMainFrame: map['isForMainFrame'], + androidHasGesture: map['hasGesture'], + hasGesture: map['hasGesture'], + androidIsRedirect: map['isRedirect'], + isRedirect: map['isRedirect'], + iosWKNavigationType: + IOSWKNavigationType.fromNativeValue(map['navigationType']), + navigationType: NavigationType.fromNativeValue(map['navigationType']), + iosSourceFrame: + IOSWKFrameInfo.fromMap(map['sourceFrame']?.cast()), + sourceFrame: + FrameInfo.fromMap(map['sourceFrame']?.cast()), + iosTargetFrame: + IOSWKFrameInfo.fromMap(map['targetFrame']?.cast()), + targetFrame: + FrameInfo.fromMap(map['targetFrame']?.cast()), + shouldPerformDownload: map['shouldPerformDownload'], ); - instance.androidHasGesture = map['hasGesture']; - instance.hasGesture = map['hasGesture']; - instance.androidIsRedirect = map['isRedirect']; - instance.isRedirect = map['isRedirect']; - instance.iosWKNavigationType = - IOSWKNavigationType.fromNativeValue(map['navigationType']); - instance.navigationType = - NavigationType.fromNativeValue(map['navigationType']); - instance.iosSourceFrame = - IOSWKFrameInfo.fromMap(map['sourceFrame']?.cast()); - instance.sourceFrame = - FrameInfo.fromMap(map['sourceFrame']?.cast()); - instance.iosTargetFrame = - IOSWKFrameInfo.fromMap(map['targetFrame']?.cast()); - instance.targetFrame = - FrameInfo.fromMap(map['targetFrame']?.cast()); - instance.shouldPerformDownload = map['shouldPerformDownload']; return instance; } diff --git a/lib/src/types/navigation_action_policy.dart b/lib/src/types/navigation_action_policy.dart index 489f4a0e..698b6ded 100644 --- a/lib/src/types/navigation_action_policy.dart +++ b/lib/src/types/navigation_action_policy.dart @@ -1,35 +1,25 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; +part 'navigation_action_policy.g.dart'; + ///Class that is used by [WebView.shouldOverrideUrlLoading] event. ///It represents the policy to pass back to the decision handler. -class NavigationActionPolicy { +@ExchangeableEnum() +class NavigationActionPolicy_ { + // ignore: unused_field final int _value; - - const NavigationActionPolicy._internal(this._value); - - ///Gets [int] value. - int toValue() => _value; + const NavigationActionPolicy_._internal(this._value); ///Cancel the navigation. - static const CANCEL = const NavigationActionPolicy._internal(0); + static const CANCEL = const NavigationActionPolicy_._internal(0); ///Allow the navigation to continue. - static const ALLOW = const NavigationActionPolicy._internal(1); + static const ALLOW = const NavigationActionPolicy_._internal(1); ///Turn the navigation into a download. /// ///**NOTE**: available only on iOS 14.5+. It will fallback to [CANCEL]. - static const DOWNLOAD = const NavigationActionPolicy._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; - - ///Converts instance to a map. - Map toMap() { - return { - "action": _value, - }; - } + static const DOWNLOAD = const NavigationActionPolicy_._internal(2); } \ No newline at end of file diff --git a/lib/src/types/navigation_action_policy.g.dart b/lib/src/types/navigation_action_policy.g.dart new file mode 100644 index 00000000..61b8bf1a --- /dev/null +++ b/lib/src/types/navigation_action_policy.g.dart @@ -0,0 +1,88 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'navigation_action_policy.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class that is used by [WebView.shouldOverrideUrlLoading] event. +///It represents the policy to pass back to the decision handler. +class NavigationActionPolicy { + final int _value; + final int _nativeValue; + const NavigationActionPolicy._internal(this._value, this._nativeValue); +// ignore: unused_element + factory NavigationActionPolicy._internalMultiPlatform( + int value, Function nativeValue) => + NavigationActionPolicy._internal(value, nativeValue()); + + ///Cancel the navigation. + static const CANCEL = NavigationActionPolicy._internal(0, 0); + + ///Allow the navigation to continue. + static const ALLOW = NavigationActionPolicy._internal(1, 1); + + ///Turn the navigation into a download. + /// + ///**NOTE**: available only on iOS 14.5+. It will fallback to [CANCEL]. + static const DOWNLOAD = NavigationActionPolicy._internal(2, 2); + + ///Set of all values of [NavigationActionPolicy]. + static final Set values = [ + NavigationActionPolicy.CANCEL, + NavigationActionPolicy.ALLOW, + NavigationActionPolicy.DOWNLOAD, + ].toSet(); + + ///Gets a possible [NavigationActionPolicy] instance from [int] value. + static NavigationActionPolicy? fromValue(int? value) { + if (value != null) { + try { + return NavigationActionPolicy.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [NavigationActionPolicy] instance from a native value. + static NavigationActionPolicy? fromNativeValue(int? value) { + if (value != null) { + try { + return NavigationActionPolicy.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'CANCEL'; + case 1: + return 'ALLOW'; + case 2: + return 'DOWNLOAD'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/navigation_response.dart b/lib/src/types/navigation_response.dart index dad1a2fe..5c8c81e8 100644 --- a/lib/src/types/navigation_response.dart +++ b/lib/src/types/navigation_response.dart @@ -1,10 +1,15 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; import 'url_response.dart'; +part 'navigation_response.g.dart'; + ///Class that represents the navigation response used by the [WebView.onNavigationResponse] event. -class NavigationResponse { +@ExchangeableObject() +class NavigationResponse_ { ///The URL for the response. - URLResponse? response; + URLResponse_? response; ///A Boolean value that indicates whether the response targets the web view’s main frame. bool isForMainFrame; @@ -12,49 +17,19 @@ class NavigationResponse { ///A Boolean value that indicates whether WebKit is capable of displaying the response’s MIME type natively. bool canShowMIMEType; - NavigationResponse( + NavigationResponse_( {this.response, required this.isForMainFrame, required this.canShowMIMEType}); - - ///Gets a possible [NavigationResponse] instance from a [Map] value. - static NavigationResponse? fromMap(Map? map) { - if (map == null) { - return null; - } - return NavigationResponse( - response: URLResponse.fromMap(map["response"]?.cast()), - isForMainFrame: map["isForMainFrame"], - canShowMIMEType: map["canShowMIMEType"], - ); - } - - ///Converts instance to a map. - Map toMap() { - return { - "response": response?.toMap(), - "isForMainFrame": isForMainFrame, - "canShowMIMEType": canShowMIMEType, - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } ///An iOS-specific Class that represents the navigation response used by the [WebView.onNavigationResponse] event. ///Use [NavigationResponse] instead. @Deprecated("Use NavigationResponse instead") -class IOSWKNavigationResponse { +@ExchangeableObject() +class IOSWKNavigationResponse_ { ///The URL for the response. - IOSURLResponse? response; + IOSURLResponse_? response; ///A Boolean value that indicates whether the response targets the web view’s main frame. bool isForMainFrame; @@ -62,40 +37,8 @@ class IOSWKNavigationResponse { ///A Boolean value that indicates whether WebKit is capable of displaying the response’s MIME type natively. bool canShowMIMEType; - IOSWKNavigationResponse( + IOSWKNavigationResponse_( {this.response, required this.isForMainFrame, required this.canShowMIMEType}); - - ///Gets a possible [IOSWKNavigationResponse] instance from a [Map] value. - static IOSWKNavigationResponse? fromMap(Map? map) { - if (map == null) { - return null; - } - return IOSWKNavigationResponse( - response: - IOSURLResponse.fromMap(map["response"]?.cast()), - isForMainFrame: map["isForMainFrame"], - canShowMIMEType: map["canShowMIMEType"], - ); - } - - ///Converts instance to a map. - Map toMap() { - return { - "response": response?.toMap(), - "isForMainFrame": isForMainFrame, - "canShowMIMEType": canShowMIMEType, - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } \ No newline at end of file diff --git a/lib/src/types/navigation_response.g.dart b/lib/src/types/navigation_response.g.dart new file mode 100644 index 00000000..8aded92e --- /dev/null +++ b/lib/src/types/navigation_response.g.dart @@ -0,0 +1,106 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'navigation_response.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the navigation response used by the [WebView.onNavigationResponse] event. +class NavigationResponse { + ///The URL for the response. + URLResponse? response; + + ///A Boolean value that indicates whether the response targets the web view’s main frame. + bool isForMainFrame; + + ///A Boolean value that indicates whether WebKit is capable of displaying the response’s MIME type natively. + bool canShowMIMEType; + NavigationResponse( + {this.response, + required this.isForMainFrame, + required this.canShowMIMEType}); + + ///Gets a possible [NavigationResponse] instance from a [Map] value. + static NavigationResponse? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = NavigationResponse( + response: URLResponse.fromMap(map['response']?.cast()), + isForMainFrame: map['isForMainFrame'], + canShowMIMEType: map['canShowMIMEType'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "response": response?.toMap(), + "isForMainFrame": isForMainFrame, + "canShowMIMEType": canShowMIMEType, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'NavigationResponse{response: $response, isForMainFrame: $isForMainFrame, canShowMIMEType: $canShowMIMEType}'; + } +} + +///An iOS-specific Class that represents the navigation response used by the [WebView.onNavigationResponse] event. +///Use [NavigationResponse] instead. +@Deprecated('Use NavigationResponse instead') +class IOSWKNavigationResponse { + ///The URL for the response. + IOSURLResponse? response; + + ///A Boolean value that indicates whether the response targets the web view’s main frame. + bool isForMainFrame; + + ///A Boolean value that indicates whether WebKit is capable of displaying the response’s MIME type natively. + bool canShowMIMEType; + IOSWKNavigationResponse( + {this.response, + required this.isForMainFrame, + required this.canShowMIMEType}); + + ///Gets a possible [IOSWKNavigationResponse] instance from a [Map] value. + static IOSWKNavigationResponse? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = IOSWKNavigationResponse( + response: + IOSURLResponse.fromMap(map['response']?.cast()), + isForMainFrame: map['isForMainFrame'], + canShowMIMEType: map['canShowMIMEType'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "response": response?.toMap(), + "isForMainFrame": isForMainFrame, + "canShowMIMEType": canShowMIMEType, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'IOSWKNavigationResponse{response: $response, isForMainFrame: $isForMainFrame, canShowMIMEType: $canShowMIMEType}'; + } +} diff --git a/lib/src/types/navigation_response_action.dart b/lib/src/types/navigation_response_action.dart index 0f53f270..3008af55 100644 --- a/lib/src/types/navigation_response_action.dart +++ b/lib/src/types/navigation_response_action.dart @@ -1,64 +1,42 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; +part 'navigation_response_action.g.dart'; + ///Class that is used by [WebView.onNavigationResponse] event. ///It represents the policy to pass back to the decision handler. -class NavigationResponseAction { +@ExchangeableEnum() +class NavigationResponseAction_ { + // ignore: unused_field final int _value; - - const NavigationResponseAction._internal(this._value); - - ///Gets [int] value. - int toValue() => _value; + const NavigationResponseAction_._internal(this._value); ///Cancel the navigation. - static const CANCEL = const NavigationResponseAction._internal(0); + static const CANCEL = const NavigationResponseAction_._internal(0); ///Allow the navigation to continue. - static const ALLOW = const NavigationResponseAction._internal(1); + static const ALLOW = const NavigationResponseAction_._internal(1); ///Turn the navigation into a download. /// ///**NOTE**: available only on iOS 14.5+. It will fallback to [CANCEL]. - static const DOWNLOAD = const NavigationResponseAction._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; - - Map toMap() { - return { - "action": _value, - }; - } + static const DOWNLOAD = const NavigationResponseAction_._internal(2); } ///Class that is used by [WebView.onNavigationResponse] event. ///It represents the policy to pass back to the decision handler. ///Use [NavigationResponseAction] instead. @Deprecated("Use NavigationResponseAction instead") -class IOSNavigationResponseAction { +@ExchangeableEnum() +class IOSNavigationResponseAction_ { + // ignore: unused_field final int _value; - - const IOSNavigationResponseAction._internal(this._value); - - ///Gets [int] value. - int toValue() => _value; + const IOSNavigationResponseAction_._internal(this._value); ///Cancel the navigation. - static const CANCEL = const IOSNavigationResponseAction._internal(0); + static const CANCEL = const IOSNavigationResponseAction_._internal(0); ///Allow the navigation to continue. - static const ALLOW = const IOSNavigationResponseAction._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; - - Map toMap() { - return { - "action": _value, - }; - } + static const ALLOW = const IOSNavigationResponseAction_._internal(1); } \ No newline at end of file diff --git a/lib/src/types/navigation_response_action.g.dart b/lib/src/types/navigation_response_action.g.dart new file mode 100644 index 00000000..a49b92dd --- /dev/null +++ b/lib/src/types/navigation_response_action.g.dart @@ -0,0 +1,163 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'navigation_response_action.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class that is used by [WebView.onNavigationResponse] event. +///It represents the policy to pass back to the decision handler. +class NavigationResponseAction { + final int _value; + final int _nativeValue; + const NavigationResponseAction._internal(this._value, this._nativeValue); +// ignore: unused_element + factory NavigationResponseAction._internalMultiPlatform( + int value, Function nativeValue) => + NavigationResponseAction._internal(value, nativeValue()); + + ///Cancel the navigation. + static const CANCEL = NavigationResponseAction._internal(0, 0); + + ///Allow the navigation to continue. + static const ALLOW = NavigationResponseAction._internal(1, 1); + + ///Turn the navigation into a download. + /// + ///**NOTE**: available only on iOS 14.5+. It will fallback to [CANCEL]. + static const DOWNLOAD = NavigationResponseAction._internal(2, 2); + + ///Set of all values of [NavigationResponseAction]. + static final Set values = [ + NavigationResponseAction.CANCEL, + NavigationResponseAction.ALLOW, + NavigationResponseAction.DOWNLOAD, + ].toSet(); + + ///Gets a possible [NavigationResponseAction] instance from [int] value. + static NavigationResponseAction? fromValue(int? value) { + if (value != null) { + try { + return NavigationResponseAction.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [NavigationResponseAction] instance from a native value. + static NavigationResponseAction? fromNativeValue(int? value) { + if (value != null) { + try { + return NavigationResponseAction.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'CANCEL'; + case 1: + return 'ALLOW'; + case 2: + return 'DOWNLOAD'; + } + return _value.toString(); + } +} + +///Class that is used by [WebView.onNavigationResponse] event. +///It represents the policy to pass back to the decision handler. +///Use [NavigationResponseAction] instead. +@Deprecated('Use NavigationResponseAction instead') +class IOSNavigationResponseAction { + final int _value; + final int _nativeValue; + const IOSNavigationResponseAction._internal(this._value, this._nativeValue); +// ignore: unused_element + factory IOSNavigationResponseAction._internalMultiPlatform( + int value, Function nativeValue) => + IOSNavigationResponseAction._internal(value, nativeValue()); + + ///Cancel the navigation. + static const CANCEL = IOSNavigationResponseAction._internal(0, 0); + + ///Allow the navigation to continue. + static const ALLOW = IOSNavigationResponseAction._internal(1, 1); + + ///Set of all values of [IOSNavigationResponseAction]. + static final Set values = [ + IOSNavigationResponseAction.CANCEL, + IOSNavigationResponseAction.ALLOW, + ].toSet(); + + ///Gets a possible [IOSNavigationResponseAction] instance from [int] value. + static IOSNavigationResponseAction? fromValue(int? value) { + if (value != null) { + try { + return IOSNavigationResponseAction.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [IOSNavigationResponseAction] instance from a native value. + static IOSNavigationResponseAction? fromNativeValue(int? value) { + if (value != null) { + try { + return IOSNavigationResponseAction.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'CANCEL'; + case 1: + return 'ALLOW'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/over_scroll_mode.dart b/lib/src/types/over_scroll_mode.dart index a679045b..d12ec21b 100644 --- a/lib/src/types/over_scroll_mode.dart +++ b/lib/src/types/over_scroll_mode.dart @@ -1,121 +1,45 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; +part 'over_scroll_mode.g.dart'; + ///Class used to configure the [WebView]'s over-scroll mode. ///Setting the over-scroll mode of a WebView will have an effect only if the [WebView] is capable of scrolling. -class OverScrollMode { +@ExchangeableEnum() +class OverScrollMode_ { + // ignore: unused_field final int _value; - - const OverScrollMode._internal(this._value); - - ///Set of all values of [OverScrollMode]. - static final Set values = [ - OverScrollMode.OVER_SCROLL_ALWAYS, - OverScrollMode.OVER_SCROLL_IF_CONTENT_SCROLLS, - OverScrollMode.OVER_SCROLL_NEVER, - ].toSet(); - - ///Gets a possible [OverScrollMode] instance from an [int] value. - static OverScrollMode? fromValue(int? value) { - if (value != null) { - try { - return OverScrollMode.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "OVER_SCROLL_IF_CONTENT_SCROLLS"; - case 2: - return "OVER_SCROLL_NEVER"; - case 0: - default: - return "OVER_SCROLL_ALWAYS"; - } - } + const OverScrollMode_._internal(this._value); ///Always allow a user to over-scroll this view, provided it is a view that can scroll. - static const OVER_SCROLL_ALWAYS = const OverScrollMode._internal(0); + static const ALWAYS = const OverScrollMode_._internal(0); ///Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll. - static const OVER_SCROLL_IF_CONTENT_SCROLLS = - const OverScrollMode._internal(1); + static const IF_CONTENT_SCROLLS = + const OverScrollMode_._internal(1); ///Never allow a user to over-scroll this view. - static const OVER_SCROLL_NEVER = const OverScrollMode._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const NEVER = const OverScrollMode_._internal(2); } ///An Android-specific class used to configure the [WebView]'s over-scroll mode. ///Setting the over-scroll mode of a WebView will have an effect only if the [WebView] is capable of scrolling. ///Use [OverScrollMode] instead. @Deprecated("Use OverScrollMode instead") -class AndroidOverScrollMode { +@ExchangeableEnum() +class AndroidOverScrollMode_ { + // ignore: unused_field final int _value; - - const AndroidOverScrollMode._internal(this._value); - - ///Set of all values of [AndroidOverScrollMode]. - static final Set values = [ - AndroidOverScrollMode.OVER_SCROLL_ALWAYS, - AndroidOverScrollMode.OVER_SCROLL_IF_CONTENT_SCROLLS, - AndroidOverScrollMode.OVER_SCROLL_NEVER, - ].toSet(); - - ///Gets a possible [AndroidOverScrollMode] instance from an [int] value. - static AndroidOverScrollMode? fromValue(int? value) { - if (value != null) { - try { - return AndroidOverScrollMode.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "OVER_SCROLL_IF_CONTENT_SCROLLS"; - case 2: - return "OVER_SCROLL_NEVER"; - case 0: - default: - return "OVER_SCROLL_ALWAYS"; - } - } + const AndroidOverScrollMode_._internal(this._value); ///Always allow a user to over-scroll this view, provided it is a view that can scroll. - static const OVER_SCROLL_ALWAYS = const AndroidOverScrollMode._internal(0); + static const OVER_SCROLL_ALWAYS = const AndroidOverScrollMode_._internal(0); ///Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll. static const OVER_SCROLL_IF_CONTENT_SCROLLS = - const AndroidOverScrollMode._internal(1); + const AndroidOverScrollMode_._internal(1); ///Never allow a user to over-scroll this view. - static const OVER_SCROLL_NEVER = const AndroidOverScrollMode._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const OVER_SCROLL_NEVER = const AndroidOverScrollMode_._internal(2); } \ No newline at end of file diff --git a/lib/src/types/over_scroll_mode.g.dart b/lib/src/types/over_scroll_mode.g.dart new file mode 100644 index 00000000..8f277823 --- /dev/null +++ b/lib/src/types/over_scroll_mode.g.dart @@ -0,0 +1,168 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'over_scroll_mode.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used to configure the [WebView]'s over-scroll mode. +///Setting the over-scroll mode of a WebView will have an effect only if the [WebView] is capable of scrolling. +class OverScrollMode { + final int _value; + final int _nativeValue; + const OverScrollMode._internal(this._value, this._nativeValue); +// ignore: unused_element + factory OverScrollMode._internalMultiPlatform( + int value, Function nativeValue) => + OverScrollMode._internal(value, nativeValue()); + + ///Always allow a user to over-scroll this view, provided it is a view that can scroll. + static const ALWAYS = OverScrollMode._internal(0, 0); + + ///Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll. + static const IF_CONTENT_SCROLLS = OverScrollMode._internal(1, 1); + + ///Never allow a user to over-scroll this view. + static const NEVER = OverScrollMode._internal(2, 2); + + ///Set of all values of [OverScrollMode]. + static final Set values = [ + OverScrollMode.ALWAYS, + OverScrollMode.IF_CONTENT_SCROLLS, + OverScrollMode.NEVER, + ].toSet(); + + ///Gets a possible [OverScrollMode] instance from [int] value. + static OverScrollMode? fromValue(int? value) { + if (value != null) { + try { + return OverScrollMode.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [OverScrollMode] instance from a native value. + static OverScrollMode? fromNativeValue(int? value) { + if (value != null) { + try { + return OverScrollMode.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'ALWAYS'; + case 1: + return 'IF_CONTENT_SCROLLS'; + case 2: + return 'NEVER'; + } + return _value.toString(); + } +} + +///An Android-specific class used to configure the [WebView]'s over-scroll mode. +///Setting the over-scroll mode of a WebView will have an effect only if the [WebView] is capable of scrolling. +///Use [OverScrollMode] instead. +@Deprecated('Use OverScrollMode instead') +class AndroidOverScrollMode { + final int _value; + final int _nativeValue; + const AndroidOverScrollMode._internal(this._value, this._nativeValue); +// ignore: unused_element + factory AndroidOverScrollMode._internalMultiPlatform( + int value, Function nativeValue) => + AndroidOverScrollMode._internal(value, nativeValue()); + + ///Always allow a user to over-scroll this view, provided it is a view that can scroll. + static const OVER_SCROLL_ALWAYS = AndroidOverScrollMode._internal(0, 0); + + ///Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll. + static const OVER_SCROLL_IF_CONTENT_SCROLLS = + AndroidOverScrollMode._internal(1, 1); + + ///Never allow a user to over-scroll this view. + static const OVER_SCROLL_NEVER = AndroidOverScrollMode._internal(2, 2); + + ///Set of all values of [AndroidOverScrollMode]. + static final Set values = [ + AndroidOverScrollMode.OVER_SCROLL_ALWAYS, + AndroidOverScrollMode.OVER_SCROLL_IF_CONTENT_SCROLLS, + AndroidOverScrollMode.OVER_SCROLL_NEVER, + ].toSet(); + + ///Gets a possible [AndroidOverScrollMode] instance from [int] value. + static AndroidOverScrollMode? fromValue(int? value) { + if (value != null) { + try { + return AndroidOverScrollMode.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [AndroidOverScrollMode] instance from a native value. + static AndroidOverScrollMode? fromNativeValue(int? value) { + if (value != null) { + try { + return AndroidOverScrollMode.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'OVER_SCROLL_ALWAYS'; + case 1: + return 'OVER_SCROLL_IF_CONTENT_SCROLLS'; + case 2: + return 'OVER_SCROLL_NEVER'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/pdf_configuration.dart b/lib/src/types/pdf_configuration.dart index 4f1f3a61..abfac410 100644 --- a/lib/src/types/pdf_configuration.dart +++ b/lib/src/types/pdf_configuration.dart @@ -1,29 +1,19 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; import 'in_app_webview_rect.dart'; +part 'pdf_configuration.g.dart'; + ///Class that represents the configuration data to use when generating a PDF representation of a web view’s contents. -class PDFConfiguration { +@ExchangeableObject() +class PDFConfiguration_ { ///The portion of your web view to capture, specified as a rectangle in the view’s coordinate system. ///The default value of this property is `null`, which captures everything in the view’s bounds rectangle. ///If you specify a custom rectangle, it must lie within the bounds rectangle of the [WebView] object. - InAppWebViewRect? rect; + InAppWebViewRect_? rect; - PDFConfiguration({this.rect}); - - ///Converts instance to a map. - Map toMap() { - return {"rect": rect?.toMap()}; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + PDFConfiguration_({this.rect}); } ///An iOS-specific class that represents the configuration data to use when generating a PDF representation of a web view’s contents. @@ -32,26 +22,12 @@ class PDFConfiguration { /// ///Use [PDFConfiguration] instead. @Deprecated("Use PDFConfiguration instead") -class IOSWKPDFConfiguration { +@ExchangeableObject() +class IOSWKPDFConfiguration_ { ///The portion of your web view to capture, specified as a rectangle in the view’s coordinate system. ///The default value of this property is `null`, which captures everything in the view’s bounds rectangle. ///If you specify a custom rectangle, it must lie within the bounds rectangle of the [WebView] object. - InAppWebViewRect? rect; + InAppWebViewRect_? rect; - IOSWKPDFConfiguration({this.rect}); - - ///Converts instance to a map. - Map toMap() { - return {"rect": rect?.toMap()}; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + IOSWKPDFConfiguration_({this.rect}); } \ No newline at end of file diff --git a/lib/src/types/pdf_configuration.g.dart b/lib/src/types/pdf_configuration.g.dart new file mode 100644 index 00000000..dfcdc54c --- /dev/null +++ b/lib/src/types/pdf_configuration.g.dart @@ -0,0 +1,86 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'pdf_configuration.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the configuration data to use when generating a PDF representation of a web view’s contents. +class PDFConfiguration { + ///The portion of your web view to capture, specified as a rectangle in the view’s coordinate system. + ///The default value of this property is `null`, which captures everything in the view’s bounds rectangle. + ///If you specify a custom rectangle, it must lie within the bounds rectangle of the [WebView] object. + InAppWebViewRect? rect; + PDFConfiguration({this.rect}); + + ///Gets a possible [PDFConfiguration] instance from a [Map] value. + static PDFConfiguration? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = PDFConfiguration( + rect: InAppWebViewRect.fromMap(map['rect']?.cast()), + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "rect": rect?.toMap(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'PDFConfiguration{rect: $rect}'; + } +} + +///An iOS-specific class that represents the configuration data to use when generating a PDF representation of a web view’s contents. +/// +///**NOTE**: available on iOS 14.0+. +/// +///Use [PDFConfiguration] instead. +@Deprecated('Use PDFConfiguration instead') +class IOSWKPDFConfiguration { + ///The portion of your web view to capture, specified as a rectangle in the view’s coordinate system. + ///The default value of this property is `null`, which captures everything in the view’s bounds rectangle. + ///If you specify a custom rectangle, it must lie within the bounds rectangle of the [WebView] object. + InAppWebViewRect? rect; + IOSWKPDFConfiguration({this.rect}); + + ///Gets a possible [IOSWKPDFConfiguration] instance from a [Map] value. + static IOSWKPDFConfiguration? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = IOSWKPDFConfiguration( + rect: InAppWebViewRect.fromMap(map['rect']?.cast()), + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "rect": rect?.toMap(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'IOSWKPDFConfiguration{rect: $rect}'; + } +} diff --git a/lib/src/types/permission_request.dart b/lib/src/types/permission_request.dart index ed669db8..c38657e2 100644 --- a/lib/src/types/permission_request.dart +++ b/lib/src/types/permission_request.dart @@ -1,10 +1,15 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; import 'permission_resource_type.dart'; import 'permission_response.dart'; import 'frame_info.dart'; +part 'permission_request.g.dart'; + ///Class that represents the response used by the [WebView.onPermissionRequest] event. -class PermissionRequest { +@ExchangeableObject() +class PermissionRequest_ { ///The origin of web content which attempt to access the restricted resources. Uri origin; @@ -12,52 +17,11 @@ class PermissionRequest { /// ///**NOTE for iOS**: this list will have only 1 element and will be used by the [PermissionResponse.action] ///as the resource to consider when applying the corresponding action. - List resources; + List resources; ///The frame that initiates the request in the web view. - FrameInfo? frame; + FrameInfo_? frame; - PermissionRequest( + PermissionRequest_( {required this.origin, this.resources = const [], this.frame}); - - ///Gets a possible [PermissionRequest] instance from a [Map] value. - static PermissionRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - - List resources = []; - if (map["resources"] != null) { - (map["resources"].cast() as List).forEach((element) { - var resource = PermissionResourceType.fromNativeValue(element); - if (resource != null) { - resources.add(resource); - } - }); - } - - return PermissionRequest( - origin: Uri.parse(map["origin"]), - resources: resources, - frame: FrameInfo.fromMap(map["frame"]?.cast())); - } - - ///Converts instance to a map. - Map toMap() { - return { - "origin": origin.toString(), - "resources": resources.map((e) => e.toNativeValue()).toList(), - "frame": frame?.toMap() - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } \ No newline at end of file diff --git a/lib/src/types/permission_request.g.dart b/lib/src/types/permission_request.g.dart new file mode 100644 index 00000000..78f90840 --- /dev/null +++ b/lib/src/types/permission_request.g.dart @@ -0,0 +1,57 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'permission_request.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the response used by the [WebView.onPermissionRequest] event. +class PermissionRequest { + ///The origin of web content which attempt to access the restricted resources. + Uri origin; + + ///List of resources the web content wants to access. + /// + ///**NOTE for iOS**: this list will have only 1 element and will be used by the [PermissionResponse.action] + ///as the resource to consider when applying the corresponding action. + List resources; + + ///The frame that initiates the request in the web view. + FrameInfo? frame; + PermissionRequest( + {required this.origin, this.resources = const [], this.frame}); + + ///Gets a possible [PermissionRequest] instance from a [Map] value. + static PermissionRequest? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = PermissionRequest( + origin: Uri.parse(map['origin']), + frame: FrameInfo.fromMap(map['frame']?.cast()), + ); + instance.resources = map['resources'] + .forEach((e) => PermissionResourceType.fromNativeValue(e)!); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "origin": origin.toString(), + "resources": resources.map((e) => e.toNativeValue()).toList(), + "frame": frame?.toMap(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'PermissionRequest{origin: $origin, resources: $resources, frame: $frame}'; + } +} diff --git a/lib/src/types/permission_resource_type.dart b/lib/src/types/permission_resource_type.dart index 0e9e4c90..e750adb5 100644 --- a/lib/src/types/permission_resource_type.dart +++ b/lib/src/types/permission_resource_type.dart @@ -1,131 +1,89 @@ import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'permission_resource_type.g.dart'; ///Class that represents a type of resource used to ask user's permission. -class PermissionResourceType { +@ExchangeableEnum() +class PermissionResourceType_ { + // ignore: unused_field final String _value; - final dynamic _nativeValue; - - const PermissionResourceType._internal(this._value, this._nativeValue); - - ///Set of all values of [PermissionResourceType]. - static final Set values = [ - PermissionResourceType.MIDI_SYSEX, - PermissionResourceType.PROTECTED_MEDIA_ID, - PermissionResourceType.CAMERA, - PermissionResourceType.MICROPHONE, - PermissionResourceType.CAMERA_AND_MICROPHONE, - PermissionResourceType.DEVICE_ORIENTATION_AND_MOTION, - ].toSet(); - - ///Gets a possible [PermissionResourceType] instance from a [String] value. - static PermissionResourceType? fromValue(String? value) { - if (value != null) { - try { - return PermissionResourceType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets a possible [PermissionResourceType] instance from a native value. - static PermissionResourceType? fromNativeValue(dynamic value) { - if (value != null) { - try { - return PermissionResourceType.values - .firstWhere((element) => element.toNativeValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [String] value. - String toValue() => _value; - - ///Gets native value. - dynamic toNativeValue() => _nativeValue; - - @override - String toString() => _value; + // ignore: unused_field + final dynamic _nativeValue = null; + const PermissionResourceType_._internal(this._value); ///Resource belongs to audio capture device, like microphone. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PermissionRequest.RESOURCE_AUDIO_CAPTURE](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_AUDIO_CAPTURE)) - ///- iOS ([Official API - WKMediaCaptureType.microphone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/microphone)) - static final MICROPHONE = PermissionResourceType._internal( - 'MICROPHONE', - (defaultTargetPlatform == TargetPlatform.android) - ? 'android.webkit.resource.AUDIO_CAPTURE' - : ((defaultTargetPlatform == TargetPlatform.iOS || - defaultTargetPlatform == TargetPlatform.macOS) - ? 1 - : null)); + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform( + apiName: 'PermissionRequest.RESOURCE_AUDIO_CAPTURE', + apiUrl: 'https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_AUDIO_CAPTURE', + value: 'android.webkit.resource.AUDIO_CAPTURE' + ), + EnumIOSPlatform( + available: "15.0", + apiName: 'WKMediaCaptureType.microphone', + apiUrl: 'https://developer.apple.com/documentation/webkit/wkmediacapturetype/microphone', + value: 1 + ) + ]) + static const MICROPHONE = PermissionResourceType_._internal('MICROPHONE'); ///Resource will allow sysex messages to be sent to or received from MIDI devices. ///These messages are privileged operations, e.g. modifying sound libraries and sampling data, or even updating the MIDI device's firmware. ///Permission may be requested for this resource in API levels 21 and above, if the Android device has been updated to WebView 45 or above. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PermissionRequest.RESOURCE_MIDI_SYSEX](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_MIDI_SYSEX)) - static final MIDI_SYSEX = PermissionResourceType._internal( - 'MIDI_SYSEX', - (defaultTargetPlatform == TargetPlatform.android) - ? 'android.webkit.resource.MIDI_SYSEX' - : null); + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform( + apiName: 'PermissionRequest.RESOURCE_MIDI_SYSEX', + apiUrl: 'https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_MIDI_SYSEX', + value: 'android.webkit.resource.MIDI_SYSEX' + ), + ]) + static const MIDI_SYSEX = PermissionResourceType_._internal('MIDI_SYSEX'); ///Resource belongs to protected media identifier. After the user grants this resource, the origin can use EME APIs to generate the license requests. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PermissionRequest.RESOURCE_PROTECTED_MEDIA_ID](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_PROTECTED_MEDIA_ID)) - static final PROTECTED_MEDIA_ID = PermissionResourceType._internal( - 'PROTECTED_MEDIA_ID', - (defaultTargetPlatform == TargetPlatform.android) - ? 'android.webkit.resource.PROTECTED_MEDIA_ID' - : null); + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform( + apiName: 'PermissionRequest.RESOURCE_PROTECTED_MEDIA_ID', + apiUrl: 'https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_PROTECTED_MEDIA_ID', + value: 'android.webkit.resource.PROTECTED_MEDIA_ID' + ), + ]) + static const PROTECTED_MEDIA_ID = PermissionResourceType_._internal('PROTECTED_MEDIA_ID'); ///Resource belongs to video capture device, like camera. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PermissionRequest.RESOURCE_VIDEO_CAPTURE](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_VIDEO_CAPTURE)) - ///- iOS ([Official API - WKMediaCaptureType.camera](https://developer.apple.com/documentation/webkit/wkmediacapturetype/camera)) - static final CAMERA = PermissionResourceType._internal( - 'CAMERA', - (defaultTargetPlatform == TargetPlatform.android) - ? 'android.webkit.resource.VIDEO_CAPTURE' - : ((defaultTargetPlatform == TargetPlatform.iOS || - defaultTargetPlatform == TargetPlatform.macOS) - ? 0 - : null)); + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform( + apiName: 'PermissionRequest.RESOURCE_VIDEO_CAPTURE', + apiUrl: 'https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_VIDEO_CAPTURE', + value: 'android.webkit.resource.VIDEO_CAPTURE' + ), + EnumIOSPlatform( + available: "15.0", + apiName: 'WKMediaCaptureType.camera', + apiUrl: 'https://developer.apple.com/documentation/webkit/wkmediacapturetype/camera', + value: 0 + ) + ]) + static const CAMERA = PermissionResourceType_._internal('CAMERA'); ///A media device or devices that can capture audio and video. - /// - ///**Supported Platforms/Implementations**: - ///- iOS ([Official API - WKMediaCaptureType.cameraAndMicrophone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/cameraandmicrophone)) - static final CAMERA_AND_MICROPHONE = PermissionResourceType._internal( - 'CAMERA_AND_MICROPHONE', - (defaultTargetPlatform == TargetPlatform.iOS || - defaultTargetPlatform == TargetPlatform.macOS) - ? 2 - : null); + @EnumSupportedPlatforms(platforms: [ + EnumIOSPlatform( + available: "15.0", + apiName: 'WKMediaCaptureType.cameraAndMicrophone', + apiUrl: 'https://developer.apple.com/documentation/webkit/wkmediacapturetype/cameraandmicrophone', + value: 2 + ) + ]) + static const CAMERA_AND_MICROPHONE = PermissionResourceType_._internal('CAMERA_AND_MICROPHONE'); ///Resource belongs to the device’s orientation and motion. - /// - ///**Supported Platforms/Implementations**: - ///- iOS - static final DEVICE_ORIENTATION_AND_MOTION = PermissionResourceType._internal( - 'DEVICE_ORIENTATION_AND_MOTION', - (defaultTargetPlatform == TargetPlatform.iOS || - defaultTargetPlatform == TargetPlatform.macOS) - ? 'deviceOrientationAndMotion' - : null); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + @EnumSupportedPlatforms(platforms: [ + EnumIOSPlatform( + available: "15.0", + value: 'deviceOrientationAndMotion' + ) + ]) + static const DEVICE_ORIENTATION_AND_MOTION = PermissionResourceType_._internal( + 'DEVICE_ORIENTATION_AND_MOTION'); } diff --git a/lib/src/types/permission_resource_type.g.dart b/lib/src/types/permission_resource_type.g.dart new file mode 100644 index 00000000..36618736 --- /dev/null +++ b/lib/src/types/permission_resource_type.g.dart @@ -0,0 +1,171 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'permission_resource_type.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class that represents a type of resource used to ask user's permission. +class PermissionResourceType { + final String _value; + final dynamic _nativeValue; + const PermissionResourceType._internal(this._value, this._nativeValue); +// ignore: unused_element + factory PermissionResourceType._internalMultiPlatform( + String value, Function nativeValue) => + PermissionResourceType._internal(value, nativeValue()); + + ///Resource belongs to audio capture device, like microphone. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PermissionRequest.RESOURCE_AUDIO_CAPTURE](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_AUDIO_CAPTURE)) + ///- iOS 15.0+ ([Official API - WKMediaCaptureType.microphone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/microphone)) + static final MICROPHONE = + PermissionResourceType._internalMultiPlatform('MICROPHONE', () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 'android.webkit.resource.AUDIO_CAPTURE'; + case TargetPlatform.iOS: + return 1; + default: + break; + } + return null; + }); + + ///Resource will allow sysex messages to be sent to or received from MIDI devices. + ///These messages are privileged operations, e.g. modifying sound libraries and sampling data, or even updating the MIDI device's firmware. + ///Permission may be requested for this resource in API levels 21 and above, if the Android device has been updated to WebView 45 or above. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PermissionRequest.RESOURCE_MIDI_SYSEX](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_MIDI_SYSEX)) + static final MIDI_SYSEX = + PermissionResourceType._internalMultiPlatform('MIDI_SYSEX', () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 'android.webkit.resource.MIDI_SYSEX'; + default: + break; + } + return null; + }); + + ///Resource belongs to protected media identifier. After the user grants this resource, the origin can use EME APIs to generate the license requests. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PermissionRequest.RESOURCE_PROTECTED_MEDIA_ID](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_PROTECTED_MEDIA_ID)) + static final PROTECTED_MEDIA_ID = + PermissionResourceType._internalMultiPlatform('PROTECTED_MEDIA_ID', () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 'android.webkit.resource.PROTECTED_MEDIA_ID'; + default: + break; + } + return null; + }); + + ///Resource belongs to video capture device, like camera. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PermissionRequest.RESOURCE_VIDEO_CAPTURE](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_VIDEO_CAPTURE)) + ///- iOS 15.0+ ([Official API - WKMediaCaptureType.camera](https://developer.apple.com/documentation/webkit/wkmediacapturetype/camera)) + static final CAMERA = + PermissionResourceType._internalMultiPlatform('CAMERA', () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 'android.webkit.resource.VIDEO_CAPTURE'; + case TargetPlatform.iOS: + return 0; + default: + break; + } + return null; + }); + + ///A media device or devices that can capture audio and video. + /// + ///**Supported Platforms/Implementations**: + ///- iOS 15.0+ ([Official API - WKMediaCaptureType.cameraAndMicrophone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/cameraandmicrophone)) + static final CAMERA_AND_MICROPHONE = + PermissionResourceType._internalMultiPlatform('CAMERA_AND_MICROPHONE', + () { + switch (defaultTargetPlatform) { + case TargetPlatform.iOS: + return 2; + default: + break; + } + return null; + }); + + ///Resource belongs to the device’s orientation and motion. + /// + ///**Supported Platforms/Implementations**: + ///- iOS 15.0+ + static final DEVICE_ORIENTATION_AND_MOTION = + PermissionResourceType._internalMultiPlatform( + 'DEVICE_ORIENTATION_AND_MOTION', () { + switch (defaultTargetPlatform) { + case TargetPlatform.iOS: + return 'deviceOrientationAndMotion'; + default: + break; + } + return null; + }); + + ///Set of all values of [PermissionResourceType]. + static final Set values = [ + PermissionResourceType.MICROPHONE, + PermissionResourceType.MIDI_SYSEX, + PermissionResourceType.PROTECTED_MEDIA_ID, + PermissionResourceType.CAMERA, + PermissionResourceType.CAMERA_AND_MICROPHONE, + PermissionResourceType.DEVICE_ORIENTATION_AND_MOTION, + ].toSet(); + + ///Gets a possible [PermissionResourceType] instance from [String] value. + static PermissionResourceType? fromValue(String? value) { + if (value != null) { + try { + return PermissionResourceType.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [PermissionResourceType] instance from a native value. + static PermissionResourceType? fromNativeValue(dynamic value) { + if (value != null) { + try { + return PermissionResourceType.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [dynamic] native value. + dynamic toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} diff --git a/lib/src/types/permission_response.dart b/lib/src/types/permission_response.dart index e5e7600d..7f959ac9 100644 --- a/lib/src/types/permission_response.dart +++ b/lib/src/types/permission_response.dart @@ -1,65 +1,38 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; import 'permission_resource_type.dart'; import 'permission_response_action.dart'; +part 'permission_response.g.dart'; + ///Class that represents the response used by the [WebView.onPermissionRequest] event. -class PermissionResponse { +@ExchangeableObject() +class PermissionResponse_ { ///Resources granted to be accessed by origin. /// ///**NOTE for iOS**: not used. The [action] taken is based on the [PermissionRequest.resources]. - List resources; + List resources; ///Indicate the [PermissionResponseAction] to take in response of a permission request. - PermissionResponseAction? action; + PermissionResponseAction_? action; - PermissionResponse( - {this.resources = const [], this.action = PermissionResponseAction.DENY}); - - ///Converts instance to a map. - Map toMap() { - return { - "resources": resources.map((e) => e.toNativeValue()).toList(), - "action": action?.toValue() - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + PermissionResponse_( + {this.resources = const [], this.action = PermissionResponseAction_.DENY}); } ///Class that represents the response used by the [WebView.androidOnPermissionRequest] event. ///Use [PermissionResponse] instead. @Deprecated("Use PermissionResponse instead") -class PermissionRequestResponse { +@ExchangeableObject() +class PermissionRequestResponse_ { ///Resources granted to be accessed by origin. List resources; ///Indicate the [PermissionRequestResponseAction] to take in response of a permission request. - PermissionRequestResponseAction? action; + PermissionRequestResponseAction_? action; - PermissionRequestResponse( + PermissionRequestResponse_( {this.resources = const [], - this.action = PermissionRequestResponseAction.DENY}); - - ///Converts instance to a map. - Map toMap() { - return {"resources": resources, "action": action?.toValue()}; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + this.action = PermissionRequestResponseAction_.DENY}); } \ No newline at end of file diff --git a/lib/src/types/permission_response.g.dart b/lib/src/types/permission_response.g.dart new file mode 100644 index 00000000..0f1afdda --- /dev/null +++ b/lib/src/types/permission_response.g.dart @@ -0,0 +1,94 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'permission_response.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the response used by the [WebView.onPermissionRequest] event. +class PermissionResponse { + ///Resources granted to be accessed by origin. + /// + ///**NOTE for iOS**: not used. The [action] taken is based on the [PermissionRequest.resources]. + List resources; + + ///Indicate the [PermissionResponseAction] to take in response of a permission request. + PermissionResponseAction? action; + PermissionResponse( + {this.resources = const [], this.action = PermissionResponseAction.DENY}); + + ///Gets a possible [PermissionResponse] instance from a [Map] value. + static PermissionResponse? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = PermissionResponse(); + instance.resources = map['resources'] + .forEach((e) => PermissionResourceType.fromNativeValue(e)!); + instance.action = PermissionResponseAction.fromNativeValue(map['action']); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "resources": resources.map((e) => e.toNativeValue()).toList(), + "action": action?.toNativeValue(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'PermissionResponse{resources: $resources, action: $action}'; + } +} + +///Class that represents the response used by the [WebView.androidOnPermissionRequest] event. +///Use [PermissionResponse] instead. +@Deprecated('Use PermissionResponse instead') +class PermissionRequestResponse { + ///Resources granted to be accessed by origin. + List resources; + + ///Indicate the [PermissionRequestResponseAction] to take in response of a permission request. + PermissionRequestResponseAction? action; + PermissionRequestResponse( + {this.resources = const [], + this.action = PermissionRequestResponseAction.DENY}); + + ///Gets a possible [PermissionRequestResponse] instance from a [Map] value. + static PermissionRequestResponse? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = PermissionRequestResponse(); + instance.resources = map['resources']; + instance.action = + PermissionRequestResponseAction.fromNativeValue(map['action']); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "resources": resources, + "action": action?.toNativeValue(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'PermissionRequestResponse{resources: $resources, action: $action}'; + } +} diff --git a/lib/src/types/permission_response_action.dart b/lib/src/types/permission_response_action.dart index c3507c58..dee4e5c1 100644 --- a/lib/src/types/permission_response_action.dart +++ b/lib/src/types/permission_response_action.dart @@ -1,50 +1,46 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'permission_response.dart'; +part 'permission_response_action.g.dart'; + ///Class used by [PermissionResponse] class. -class PermissionResponseAction { +@ExchangeableEnum() +class PermissionResponseAction_ { + // ignore: unused_field final int _value; - - const PermissionResponseAction._internal(this._value); - - ///Gets [int] value. - int toValue() => _value; + const PermissionResponseAction_._internal(this._value); ///Denies the request. - static const DENY = const PermissionResponseAction._internal(0); + static const DENY = const PermissionResponseAction_._internal(0); ///Grants origin the permission to access the given resources. - static const GRANT = const PermissionResponseAction._internal(1); + static const GRANT = const PermissionResponseAction_._internal(1); ///Prompt the user for permission for the requested resource. - /// - ///**NOTE**: available only on iOS 15.0+. It will fallback to [DENY]. - static const PROMPT = const PermissionResponseAction._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + @EnumSupportedPlatforms(platforms: [ + EnumIOSPlatform( + available: "15.0", + note: "On iOS < 15.0, it will fallback to [DENY]", + value: 2 + ) + ]) + static const PROMPT = const PermissionResponseAction_._internal(2); } ///Class used by [PermissionRequestResponse] class. ///Use [PermissionResponseAction] instead. @Deprecated("Use PermissionResponseAction instead") -class PermissionRequestResponseAction { +@ExchangeableEnum() +class PermissionRequestResponseAction_ { + // ignore: unused_field final int _value; - - const PermissionRequestResponseAction._internal(this._value); - - ///Gets [int] value. - int toValue() => _value; + const PermissionRequestResponseAction_._internal(this._value); ///Denies the request. - static const DENY = const PermissionRequestResponseAction._internal(0); + static const DENY = const PermissionRequestResponseAction_._internal(0); ///Grants origin the permission to access the given resources. - static const GRANT = const PermissionRequestResponseAction._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const GRANT = const PermissionRequestResponseAction_._internal(1); } \ No newline at end of file diff --git a/lib/src/types/permission_response_action.g.dart b/lib/src/types/permission_response_action.g.dart new file mode 100644 index 00000000..551022c3 --- /dev/null +++ b/lib/src/types/permission_response_action.g.dart @@ -0,0 +1,173 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'permission_response_action.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used by [PermissionResponse] class. +class PermissionResponseAction { + final int _value; + final int _nativeValue; + const PermissionResponseAction._internal(this._value, this._nativeValue); +// ignore: unused_element + factory PermissionResponseAction._internalMultiPlatform( + int value, Function nativeValue) => + PermissionResponseAction._internal(value, nativeValue()); + + ///Denies the request. + static const DENY = PermissionResponseAction._internal(0, 0); + + ///Grants origin the permission to access the given resources. + static const GRANT = PermissionResponseAction._internal(1, 1); + + ///Prompt the user for permission for the requested resource. + /// + ///**NOTE for iOS**: On iOS < 15.0, it will fallback to [DENY] + /// + ///**Supported Platforms/Implementations**: + ///- iOS 15.0+ + static final PROMPT = PermissionResponseAction._internalMultiPlatform(2, () { + switch (defaultTargetPlatform) { + case TargetPlatform.iOS: + return 2; + default: + break; + } + return null; + }); + + ///Set of all values of [PermissionResponseAction]. + static final Set values = [ + PermissionResponseAction.DENY, + PermissionResponseAction.GRANT, + PermissionResponseAction.PROMPT, + ].toSet(); + + ///Gets a possible [PermissionResponseAction] instance from [int] value. + static PermissionResponseAction? fromValue(int? value) { + if (value != null) { + try { + return PermissionResponseAction.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [PermissionResponseAction] instance from a native value. + static PermissionResponseAction? fromNativeValue(int? value) { + if (value != null) { + try { + return PermissionResponseAction.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'DENY'; + case 1: + return 'GRANT'; + case 2: + return 'PROMPT'; + } + return _value.toString(); + } +} + +///Class used by [PermissionRequestResponse] class. +///Use [PermissionResponseAction] instead. +@Deprecated('Use PermissionResponseAction instead') +class PermissionRequestResponseAction { + final int _value; + final int _nativeValue; + const PermissionRequestResponseAction._internal( + this._value, this._nativeValue); +// ignore: unused_element + factory PermissionRequestResponseAction._internalMultiPlatform( + int value, Function nativeValue) => + PermissionRequestResponseAction._internal(value, nativeValue()); + + ///Denies the request. + static const DENY = PermissionRequestResponseAction._internal(0, 0); + + ///Grants origin the permission to access the given resources. + static const GRANT = PermissionRequestResponseAction._internal(1, 1); + + ///Set of all values of [PermissionRequestResponseAction]. + static final Set values = [ + PermissionRequestResponseAction.DENY, + PermissionRequestResponseAction.GRANT, + ].toSet(); + + ///Gets a possible [PermissionRequestResponseAction] instance from [int] value. + static PermissionRequestResponseAction? fromValue(int? value) { + if (value != null) { + try { + return PermissionRequestResponseAction.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [PermissionRequestResponseAction] instance from a native value. + static PermissionRequestResponseAction? fromNativeValue(int? value) { + if (value != null) { + try { + return PermissionRequestResponseAction.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'DENY'; + case 1: + return 'GRANT'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/print_job_attributes.dart b/lib/src/types/print_job_attributes.dart index 127c14bf..b683c239 100644 --- a/lib/src/types/print_job_attributes.dart +++ b/lib/src/types/print_job_attributes.dart @@ -1,89 +1,79 @@ import 'package:flutter/rendering.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import '../util.dart'; import '../print_job/main.dart'; -import '../types/main.dart'; +import 'in_app_webview_rect.dart'; +import 'print_job_color_mode.dart'; +import 'print_job_duplex_mode.dart'; +import 'print_job_orientation.dart'; +import 'print_job_media_size.dart'; +import 'print_job_resolution.dart'; + +part 'print_job_attributes.g.dart'; ///Class representing the attributes of a [PrintJobController]. ///These attributes describe how the printed content should be laid out. -class PrintJobAttributes { +@ExchangeableObject() +class PrintJobAttributes_ { ///The color mode. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - int? colorMode; + @SupportedPlatforms(platforms: [AndroidPlatform()]) + 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? duplex; + @SupportedPlatforms( + platforms: [AndroidPlatform(available: "23"), IOSPlatform()] + ) + PrintJobDuplexMode_? duplex; ///The orientation of the printed content, portrait or landscape. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - PrintJobOrientation? orientation; + PrintJobOrientation_? orientation; ///The media size. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - PrintJobMediaSize? mediaSize; + @SupportedPlatforms( + platforms: [AndroidPlatform()] + ) + PrintJobMediaSize_? mediaSize; ///The supported resolution in DPI (dots per inch). - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView - PrintJobResolution? resolution; + @SupportedPlatforms( + platforms: [AndroidPlatform()] + ) + PrintJobResolution_? resolution; ///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 + @SupportedPlatforms(platforms: [IOSPlatform()]) EdgeInsets? margins; ///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 + @SupportedPlatforms(platforms: [IOSPlatform()]) 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 + @SupportedPlatforms(platforms: [IOSPlatform()]) double? headerHeight; ///The area in which printing can occur. /// ///The value of this property is a rectangle that defines the area in which the printer can print content. ///Sometimes this is referred to as the imageable area of the paper. - /// - ///**Supported Platforms/Implementations**: - ///- iOS - InAppWebViewRect? printableRect; + @SupportedPlatforms(platforms: [IOSPlatform()]) + InAppWebViewRect_? printableRect; ///The size of the paper used for printing. /// ///The value of this property is a rectangle that defines the size of paper chosen for the print job. ///The origin is always (0,0). - /// - ///**Supported Platforms/Implementations**: - ///- iOS - InAppWebViewRect? paperRect; + @SupportedPlatforms(platforms: [IOSPlatform()]) + InAppWebViewRect_? paperRect; ///The maximum height of the content area. /// @@ -91,9 +81,7 @@ class PrintJobAttributes { ///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 + @SupportedPlatforms(platforms: [IOSPlatform()]) double? maximumContentHeight; ///The maximum width of the content area. @@ -101,12 +89,10 @@ class PrintJobAttributes { ///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 + @SupportedPlatforms(platforms: [IOSPlatform()]) double? maximumContentWidth; - PrintJobAttributes( + PrintJobAttributes_( {this.colorMode, this.duplex, this.orientation, @@ -119,55 +105,4 @@ class PrintJobAttributes { this.headerHeight, this.paperRect, this.printableRect}); - - ///Gets a possible [PrintJobAttributes] instance from a [Map] value. - static PrintJobAttributes? fromMap(Map? map) { - if (map == null) { - return null; - } - - return PrintJobAttributes( - colorMode: map["colorMode"], - duplex: PrintJobDuplexMode.fromNativeValue(map["duplex"]), - orientation: PrintJobOrientation.fromValue(map["orientation"]), - mediaSize: PrintJobMediaSize.fromMap( - map["mediaSize"]?.cast()), - resolution: PrintJobResolution.fromMap( - map["resolution"]?.cast()), - margins: MapEdgeInsets.fromMap(map["margins"]?.cast()), - maximumContentHeight: map["maximumContentHeight"], - maximumContentWidth: map["maximumContentWidth"], - footerHeight: map["footerHeight"], - headerHeight: map["headerHeight"], - paperRect: InAppWebViewRect.fromMap(map["paperRect"]?.cast()), - printableRect: InAppWebViewRect.fromMap(map["printableRect"]?.cast())); - } - - ///Converts instance to a map. - Map toMap() { - return { - "colorMode": colorMode, - "duplex": duplex?.toNativeValue(), - "orientation": orientation?.toValue(), - "mediaSize": mediaSize?.toMap(), - "resolution": resolution?.toMap(), - "margins": margins?.toMap(), - "maximumContentHeight": maximumContentHeight, - "maximumContentWidth": maximumContentWidth, - "footerHeight": footerHeight, - "headerHeight": headerHeight, - "paperRect": paperRect?.toMap(), - "printableRect": printableRect?.toMap(), - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } diff --git a/lib/src/types/print_job_attributes.g.dart b/lib/src/types/print_job_attributes.g.dart new file mode 100644 index 00000000..e87932fb --- /dev/null +++ b/lib/src/types/print_job_attributes.g.dart @@ -0,0 +1,171 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'print_job_attributes.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class representing the attributes of a [PrintJobController]. +///These attributes describe how the printed content should be laid out. +class PrintJobAttributes { + ///The color mode. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + PrintJobColorMode? colorMode; + + ///The duplex mode to use for the print job. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView 23+ + ///- iOS + PrintJobDuplexMode? duplex; + + ///The orientation of the printed content, portrait or landscape. + PrintJobOrientation? orientation; + + ///The media size. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + PrintJobMediaSize? mediaSize; + + ///The supported resolution in DPI (dots per inch). + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + PrintJobResolution? resolution; + + ///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 + EdgeInsets? margins; + + ///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 area in which printing can occur. + /// + ///The value of this property is a rectangle that defines the area in which the printer can print content. + ///Sometimes this is referred to as the imageable area of the paper. + /// + ///**Supported Platforms/Implementations**: + ///- iOS + InAppWebViewRect? printableRect; + + ///The size of the paper used for printing. + /// + ///The value of this property is a rectangle that defines the size of paper chosen for the print job. + ///The origin is always (0,0). + /// + ///**Supported Platforms/Implementations**: + ///- iOS + InAppWebViewRect? paperRect; + + ///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; + PrintJobAttributes( + {this.colorMode, + this.duplex, + this.orientation, + this.mediaSize, + this.resolution, + this.margins, + this.footerHeight, + this.headerHeight, + this.printableRect, + this.paperRect, + this.maximumContentHeight, + this.maximumContentWidth}); + + ///Gets a possible [PrintJobAttributes] instance from a [Map] value. + static PrintJobAttributes? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = PrintJobAttributes( + colorMode: PrintJobColorMode.fromNativeValue(map['colorMode']), + duplex: PrintJobDuplexMode.fromNativeValue(map['duplex']), + orientation: PrintJobOrientation.fromNativeValue(map['orientation']), + mediaSize: + PrintJobMediaSize.fromMap(map['mediaSize']?.cast()), + resolution: PrintJobResolution.fromMap( + map['resolution']?.cast()), + margins: MapEdgeInsets.fromMap(map['margins']?.cast())!, + footerHeight: map['footerHeight'], + headerHeight: map['headerHeight'], + printableRect: InAppWebViewRect.fromMap( + map['printableRect']?.cast()), + paperRect: + InAppWebViewRect.fromMap(map['paperRect']?.cast()), + maximumContentHeight: map['maximumContentHeight'], + maximumContentWidth: map['maximumContentWidth'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "colorMode": colorMode?.toNativeValue(), + "duplex": duplex?.toNativeValue(), + "orientation": orientation?.toNativeValue(), + "mediaSize": mediaSize?.toMap(), + "resolution": resolution?.toMap(), + "margins": margins?.toMap(), + "footerHeight": footerHeight, + "headerHeight": headerHeight, + "printableRect": printableRect?.toMap(), + "paperRect": paperRect?.toMap(), + "maximumContentHeight": maximumContentHeight, + "maximumContentWidth": maximumContentWidth, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'PrintJobAttributes{colorMode: $colorMode, duplex: $duplex, orientation: $orientation, mediaSize: $mediaSize, resolution: $resolution, margins: $margins, footerHeight: $footerHeight, headerHeight: $headerHeight, printableRect: $printableRect, paperRect: $paperRect, maximumContentHeight: $maximumContentHeight, maximumContentWidth: $maximumContentWidth}'; + } +} diff --git a/lib/src/types/print_job_color_mode.dart b/lib/src/types/print_job_color_mode.dart index 5f7fb1f5..adbf583f 100644 --- a/lib/src/types/print_job_color_mode.dart +++ b/lib/src/types/print_job_color_mode.dart @@ -1,52 +1,19 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../print_job/main.dart'; +part 'print_job_color_mode.g.dart'; + ///Class representing how the printed content of a [PrintJobController] should be laid out. -class PrintJobColorMode { +@ExchangeableEnum() +class PrintJobColorMode_ { + // ignore: unused_field final int _value; - - const PrintJobColorMode._internal(this._value); - - ///Set of all values of [PrintJobColorMode]. - static final Set values = [ - PrintJobColorMode.MONOCHROME, - PrintJobColorMode.COLOR, - ].toSet(); - - ///Gets a possible [PrintJobColorMode] instance from an [int] value. - static PrintJobColorMode? fromValue(int? value) { - if (value != null) { - try { - return PrintJobColorMode.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "MONOCHROME"; - case 2: - default: - return "COLOR"; - } - } + const PrintJobColorMode_._internal(this._value); ///Monochrome color scheme, for example one color is used. - static const MONOCHROME = const PrintJobColorMode._internal(1); + static const MONOCHROME = const PrintJobColorMode_._internal(1); ///Color color scheme, for example many colors are used. - static const COLOR = const PrintJobColorMode._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const COLOR = const PrintJobColorMode_._internal(2); } diff --git a/lib/src/types/print_job_color_mode.g.dart b/lib/src/types/print_job_color_mode.g.dart new file mode 100644 index 00000000..e6a7212e --- /dev/null +++ b/lib/src/types/print_job_color_mode.g.dart @@ -0,0 +1,79 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'print_job_color_mode.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class representing how the printed content of a [PrintJobController] should be laid out. +class PrintJobColorMode { + final int _value; + final int _nativeValue; + const PrintJobColorMode._internal(this._value, this._nativeValue); +// ignore: unused_element + factory PrintJobColorMode._internalMultiPlatform( + int value, Function nativeValue) => + PrintJobColorMode._internal(value, nativeValue()); + + ///Monochrome color scheme, for example one color is used. + static const MONOCHROME = PrintJobColorMode._internal(1, 1); + + ///Color color scheme, for example many colors are used. + static const COLOR = PrintJobColorMode._internal(2, 2); + + ///Set of all values of [PrintJobColorMode]. + static final Set values = [ + PrintJobColorMode.MONOCHROME, + PrintJobColorMode.COLOR, + ].toSet(); + + ///Gets a possible [PrintJobColorMode] instance from [int] value. + static PrintJobColorMode? fromValue(int? value) { + if (value != null) { + try { + return PrintJobColorMode.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [PrintJobColorMode] instance from a native value. + static PrintJobColorMode? fromNativeValue(int? value) { + if (value != null) { + try { + return PrintJobColorMode.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 1: + return 'MONOCHROME'; + case 2: + return 'COLOR'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/print_job_duplex_mode.dart b/lib/src/types/print_job_duplex_mode.dart index d567e107..8568563f 100644 --- a/lib/src/types/print_job_duplex_mode.dart +++ b/lib/src/types/print_job_duplex_mode.dart @@ -1,90 +1,34 @@ import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import '../print_job/main.dart'; +part 'print_job_duplex_mode.g.dart'; + ///Class representing the orientation of a [PrintJobController]. -class PrintJobDuplexMode { +@ExchangeableEnum() +class PrintJobDuplexMode_ { + // ignore: unused_field final String _value; - final int _nativeValue; + // ignore: unused_field + final int _nativeValue = 0; - const PrintJobDuplexMode._internal(this._value, this._nativeValue); - - ///Set of all values of [PrintJobDuplexMode]. - static final Set values = [ - PrintJobDuplexMode.NONE, - PrintJobDuplexMode.LONG_EDGE, - PrintJobDuplexMode.SHORT_EDGE, - ].toSet(); - - ///Gets a possible [PrintJobDuplexMode] instance from a [String] value. - static PrintJobDuplexMode? fromValue(String? value) { - if (value != null) { - try { - return PrintJobDuplexMode.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets a possible [PrintJobDuplexMode] instance from an [int] native value. - static PrintJobDuplexMode? fromNativeValue(int? value) { - if (value != null) { - try { - return PrintJobDuplexMode.values - .firstWhere((element) => element.toNativeValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [String] value. - String toValue() => _value; - - ///Gets native value. - int toNativeValue() => _nativeValue; - - @override - String toString() => _value; + const PrintJobDuplexMode_._internal(this._value); ///No double-sided (duplex) printing; single-sided printing only. - static final NONE = PrintJobDuplexMode._internal( - 'NONE', - (defaultTargetPlatform == TargetPlatform.android) - ? 1 - : ((defaultTargetPlatform == TargetPlatform.iOS || - defaultTargetPlatform == TargetPlatform.macOS) - ? 0 - : 0)); + @EnumSupportedPlatforms( + platforms: [EnumAndroidPlatform(value: 1), EnumIOSPlatform(value: 0)]) + static const NONE = PrintJobDuplexMode_._internal('NONE'); ///Duplex printing that flips the back page along the long edge of the paper. ///Pages are turned sideways along the long edge - like a book. - static final LONG_EDGE = PrintJobDuplexMode._internal( - 'LONG_EDGE', - (defaultTargetPlatform == TargetPlatform.android) - ? 2 - : ((defaultTargetPlatform == TargetPlatform.iOS || - defaultTargetPlatform == TargetPlatform.macOS) - ? 1 - : 0)); + @EnumSupportedPlatforms( + platforms: [EnumAndroidPlatform(value: 2), EnumIOSPlatform(value: 1)]) + static const LONG_EDGE = PrintJobDuplexMode_._internal('LONG_EDGE'); ///Duplex print that flips the back page along the short edge of the paper. ///Pages are turned upwards along the short edge - like a notepad. - static final SHORT_EDGE = PrintJobDuplexMode._internal( - 'SHORT_EDGE', - (defaultTargetPlatform == TargetPlatform.android) - ? 4 - : ((defaultTargetPlatform == TargetPlatform.iOS || - defaultTargetPlatform == TargetPlatform.macOS) - ? 2 - : 0)); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + @EnumSupportedPlatforms( + platforms: [EnumAndroidPlatform(value: 4), EnumIOSPlatform(value: 2)]) + static const SHORT_EDGE = PrintJobDuplexMode_._internal('SHORT_EDGE'); } diff --git a/lib/src/types/print_job_duplex_mode.g.dart b/lib/src/types/print_job_duplex_mode.g.dart new file mode 100644 index 00000000..20956003 --- /dev/null +++ b/lib/src/types/print_job_duplex_mode.g.dart @@ -0,0 +1,123 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'print_job_duplex_mode.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class representing the orientation of a [PrintJobController]. +class PrintJobDuplexMode { + final String _value; + final int _nativeValue; + const PrintJobDuplexMode._internal(this._value, this._nativeValue); +// ignore: unused_element + factory PrintJobDuplexMode._internalMultiPlatform( + String value, Function nativeValue) => + PrintJobDuplexMode._internal(value, nativeValue()); + + ///No double-sided (duplex) printing; single-sided printing only. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + static final NONE = PrintJobDuplexMode._internalMultiPlatform('NONE', () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 1; + case TargetPlatform.iOS: + return 0; + default: + break; + } + return null; + }); + + ///Duplex printing that flips the back page along the long edge of the paper. + ///Pages are turned sideways along the long edge - like a book. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + static final LONG_EDGE = + PrintJobDuplexMode._internalMultiPlatform('LONG_EDGE', () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 2; + case TargetPlatform.iOS: + return 1; + default: + break; + } + return null; + }); + + ///Duplex print that flips the back page along the short edge of the paper. + ///Pages are turned upwards along the short edge - like a notepad. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + static final SHORT_EDGE = + PrintJobDuplexMode._internalMultiPlatform('SHORT_EDGE', () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 4; + case TargetPlatform.iOS: + return 2; + default: + break; + } + return null; + }); + + ///Set of all values of [PrintJobDuplexMode]. + static final Set values = [ + PrintJobDuplexMode.NONE, + PrintJobDuplexMode.LONG_EDGE, + PrintJobDuplexMode.SHORT_EDGE, + ].toSet(); + + ///Gets a possible [PrintJobDuplexMode] instance from [String] value. + static PrintJobDuplexMode? fromValue(String? value) { + if (value != null) { + try { + return PrintJobDuplexMode.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [PrintJobDuplexMode] instance from a native value. + static PrintJobDuplexMode? fromNativeValue(int? value) { + if (value != null) { + try { + return PrintJobDuplexMode.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} diff --git a/lib/src/types/print_job_info.dart b/lib/src/types/print_job_info.dart index f848f337..ec5e0b43 100644 --- a/lib/src/types/print_job_info.dart +++ b/lib/src/types/print_job_info.dart @@ -1,15 +1,21 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../print_job/main.dart'; -import '../types/main.dart'; +import 'print_job_attributes.dart'; +import 'print_job_state.dart'; + +part 'print_job_info.g.dart'; ///Class representing the description of a [PrintJobController]. ///Note that the print jobs state may change over time and this class represents a snapshot of this state. -class PrintJobInfo { +@ExchangeableObject() +class PrintJobInfo_ { ///The state of the print job. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - PrintJobState? state; + PrintJobState_? state; ///How many copies to print. /// @@ -50,9 +56,9 @@ class PrintJobInfo { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - PrintJobAttributes? attributes; + PrintJobAttributes_? attributes; - PrintJobInfo( + PrintJobInfo_( {this.state, this.copies, this.numberOfPages, @@ -60,44 +66,4 @@ class PrintJobInfo { this.label, this.printerId, this.attributes}); - - ///Gets a possible [PrintJobInfo] instance from a [Map] value. - static PrintJobInfo? fromMap(Map? map) { - if (map == null) { - return null; - } - - return PrintJobInfo( - state: PrintJobState.fromValue(map["state"]), - copies: map["copies"], - numberOfPages: map["numberOfPages"], - creationTime: map["creationTime"], - label: map["label"], - printerId: map["printerId"], - attributes: PrintJobAttributes.fromMap( - map["attributes"]?.cast())); - } - - ///Converts instance to a map. - Map toMap() { - return { - "state": state?.toValue(), - "copies": copies, - "numberOfPages": numberOfPages, - "creationTime": creationTime, - "label": label, - "printerId": printerId, - "attributes": attributes?.toMap() - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } diff --git a/lib/src/types/print_job_info.g.dart b/lib/src/types/print_job_info.g.dart new file mode 100644 index 00000000..ef8ca5c5 --- /dev/null +++ b/lib/src/types/print_job_info.g.dart @@ -0,0 +1,108 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'print_job_info.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class representing the description of a [PrintJobController]. +///Note that the print jobs state may change over time and this class represents a snapshot of this state. +class PrintJobInfo { + ///The state of the print job. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + PrintJobState? state; + + ///How many copies to print. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + int? copies; + + ///The number of pages to print. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + int? numberOfPages; + + ///The timestamp when the print job was created. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + int? creationTime; + + ///The human readable print job label. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + String? label; + + ///The unique id of the printer. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + String? printerId; + + ///The attributes of a print job. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + PrintJobAttributes? attributes; + PrintJobInfo( + {this.state, + this.copies, + this.numberOfPages, + this.creationTime, + this.label, + this.printerId, + this.attributes}); + + ///Gets a possible [PrintJobInfo] instance from a [Map] value. + static PrintJobInfo? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = PrintJobInfo( + state: PrintJobState.fromNativeValue(map['state']), + copies: map['copies'], + numberOfPages: map['numberOfPages'], + creationTime: map['creationTime'], + label: map['label'], + printerId: map['printerId'], + attributes: PrintJobAttributes.fromMap( + map['attributes']?.cast()), + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "state": state?.toNativeValue(), + "copies": copies, + "numberOfPages": numberOfPages, + "creationTime": creationTime, + "label": label, + "printerId": printerId, + "attributes": attributes?.toMap(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'PrintJobInfo{state: $state, copies: $copies, numberOfPages: $numberOfPages, creationTime: $creationTime, label: $label, printerId: $printerId, attributes: $attributes}'; + } +} diff --git a/lib/src/types/print_job_media_size.dart b/lib/src/types/print_job_media_size.dart index 1a3a7c93..04645ca5 100644 --- a/lib/src/types/print_job_media_size.dart +++ b/lib/src/types/print_job_media_size.dart @@ -1,8 +1,13 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../print_job/main.dart'; +part 'print_job_media_size.g.dart'; + ///Class representing the supported media size for a [PrintJobController]. ///Media size is the dimension of the media on which the content is printed. -class PrintJobMediaSize { +@ExchangeableObject() +class PrintJobMediaSize_ { ///The unique media size id. /// ///It is unique amongst other media sizes supported by the printer. @@ -19,437 +24,403 @@ class PrintJobMediaSize { ///The media height in mils (thousandths of an inch). final int heightMils; - const PrintJobMediaSize( + const PrintJobMediaSize_( {required this.id, required this.widthMils, required this.heightMils, this.label}); - ///Gets a possible [PrintJobMediaSize] instance from a [Map] value. - static PrintJobMediaSize? fromMap(Map? map) { - if (map == null) { - return null; - } - - return PrintJobMediaSize( - id: map["id"], - widthMils: map["widthMils"], - heightMils: map["heightMils"], - label: map["label"], - ); - } - - ///Converts instance to a map. - Map toMap() { - return { - "id": id, - "widthMils": widthMils, - "heightMils": heightMils, - "label": label - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } - ///Unknown media size in portrait mode. /// ///**NOTE**: This is for specifying orientation without media size. ///You should not use the dimensions reported by this instance. - static const UNKNOWN_PORTRAIT = const PrintJobMediaSize( + static const UNKNOWN_PORTRAIT = const PrintJobMediaSize_( id: "UNKNOWN_PORTRAIT", widthMils: 1, heightMils: 0x7fffffff); ///Unknown media size in portrait mode. /// ///**NOTE**: This is for specifying orientation without media size. ///You should not use the dimensions reported by this instance. - static const UNKNOWN_LANDSCAPE = const PrintJobMediaSize( + static const UNKNOWN_LANDSCAPE = const PrintJobMediaSize_( id: "UNKNOWN_LANDSCAPE", widthMils: 0x7fffffff, heightMils: 1); // ISO sizes ///ISO A0 media size: 841mm x 1189mm (33.11" x 46.81") - static const ISO_A0 = const PrintJobMediaSize( + static const ISO_A0 = const PrintJobMediaSize_( id: "ISO_A0", widthMils: 33110, heightMils: 46810); ///ISO A1 media size: 594mm x 841mm (23.39" x 33.11") - static const ISO_A1 = const PrintJobMediaSize( + static const ISO_A1 = const PrintJobMediaSize_( id: "ISO_A1", widthMils: 23390, heightMils: 33110); ///ISO A2 media size: 420mm x 594mm (16.54" x 23.39") - static const ISO_A2 = const PrintJobMediaSize( + static const ISO_A2 = const PrintJobMediaSize_( id: "ISO_A2", widthMils: 16540, heightMils: 23390); ///ISO A3 media size: 297mm x 420mm (11.69" x 16.54") - static const ISO_A3 = const PrintJobMediaSize( + static const ISO_A3 = const PrintJobMediaSize_( id: "ISO_A3", widthMils: 11690, heightMils: 16540); ///ISO A4 media size: 210mm x 297mm (8.27" x 11.69") static const ISO_A4 = - const PrintJobMediaSize(id: "ISO_A4", widthMils: 8270, heightMils: 11690); + const PrintJobMediaSize_(id: "ISO_A4", widthMils: 8270, heightMils: 11690); ///ISO A5 media size: 148mm x 210mm (5.83" x 8.27") static const ISO_A5 = - const PrintJobMediaSize(id: "ISO_A5", widthMils: 5830, heightMils: 8270); + const PrintJobMediaSize_(id: "ISO_A5", widthMils: 5830, heightMils: 8270); ///ISO A6 media size: 105mm x 148mm (4.13" x 5.83") static const ISO_A6 = - const PrintJobMediaSize(id: "ISO_A6", widthMils: 4130, heightMils: 5830); + const PrintJobMediaSize_(id: "ISO_A6", widthMils: 4130, heightMils: 5830); ///ISO A7 media size: 74mm x 105mm (2.91" x 4.13") static const ISO_A7 = - const PrintJobMediaSize(id: "ISO_A7", widthMils: 2910, heightMils: 4130); + const PrintJobMediaSize_(id: "ISO_A7", widthMils: 2910, heightMils: 4130); ///ISO A8 media size: 52mm x 74mm (2.05" x 2.91") static const ISO_A8 = - const PrintJobMediaSize(id: "ISO_A8", widthMils: 2050, heightMils: 2910); + const PrintJobMediaSize_(id: "ISO_A8", widthMils: 2050, heightMils: 2910); ///ISO A9 media size: 37mm x 52mm (1.46" x 2.05") static const ISO_A9 = - const PrintJobMediaSize(id: "ISO_A9", widthMils: 1460, heightMils: 2050); + const PrintJobMediaSize_(id: "ISO_A9", widthMils: 1460, heightMils: 2050); ///ISO A10 media size: 26mm x 37mm (1.02" x 1.46") static const ISO_A10 = - const PrintJobMediaSize(id: "ISO_A10", widthMils: 1020, heightMils: 1460); + const PrintJobMediaSize_(id: "ISO_A10", widthMils: 1020, heightMils: 1460); ///ISO B0 media size: 1000mm x 1414mm (39.37" x 55.67") - static const ISO_B0 = const PrintJobMediaSize( + static const ISO_B0 = const PrintJobMediaSize_( id: "ISO_B0", widthMils: 39370, heightMils: 55670); ///ISO B1 media size: 707mm x 1000mm (27.83" x 39.37") - static const ISO_B1 = const PrintJobMediaSize( + static const ISO_B1 = const PrintJobMediaSize_( id: "ISO_B1", widthMils: 27830, heightMils: 39370); ///ISO B2 media size: 500mm x 707mm (19.69" x 27.83") - static const ISO_B2 = const PrintJobMediaSize( + static const ISO_B2 = const PrintJobMediaSize_( id: "ISO_B2", widthMils: 19690, heightMils: 27830); ///ISO B3 media size: 353mm x 500mm (13.90" x 19.69") - static const ISO_B3 = const PrintJobMediaSize( + static const ISO_B3 = const PrintJobMediaSize_( id: "ISO_B3", widthMils: 13900, heightMils: 19690); ///ISO B4 media size: 250mm x 353mm (9.84" x 13.90") static const ISO_B4 = - const PrintJobMediaSize(id: "ISO_B4", widthMils: 9840, heightMils: 13900); + const PrintJobMediaSize_(id: "ISO_B4", widthMils: 9840, heightMils: 13900); ///ISO B5 media size: 176mm x 250mm (6.93" x 9.84") static const ISO_B5 = - const PrintJobMediaSize(id: "ISO_B5", widthMils: 6930, heightMils: 9840); + const PrintJobMediaSize_(id: "ISO_B5", widthMils: 6930, heightMils: 9840); ///ISO B6 media size: 125mm x 176mm (4.92" x 6.93") static const ISO_B6 = - const PrintJobMediaSize(id: "ISO_B6", widthMils: 4920, heightMils: 6930); + const PrintJobMediaSize_(id: "ISO_B6", widthMils: 4920, heightMils: 6930); ///ISO B7 media size: 88mm x 125mm (3.46" x 4.92") static const ISO_B7 = - const PrintJobMediaSize(id: "ISO_B7", widthMils: 3460, heightMils: 4920); + const PrintJobMediaSize_(id: "ISO_B7", widthMils: 3460, heightMils: 4920); ///ISO B8 media size: 62mm x 88mm (2.44" x 3.46") static const ISO_B8 = - const PrintJobMediaSize(id: "ISO_B8", widthMils: 2440, heightMils: 3460); + const PrintJobMediaSize_(id: "ISO_B8", widthMils: 2440, heightMils: 3460); ///ISO B9 media size: 44mm x 62mm (1.73" x 2.44") static const ISO_B9 = - const PrintJobMediaSize(id: "ISO_B9", widthMils: 1730, heightMils: 2440); + const PrintJobMediaSize_(id: "ISO_B9", widthMils: 1730, heightMils: 2440); ///ISO B10 media size: 31mm x 44mm (1.22" x 1.73") static const ISO_B10 = - const PrintJobMediaSize(id: "ISO_B10", widthMils: 1220, heightMils: 1730); + const PrintJobMediaSize_(id: "ISO_B10", widthMils: 1220, heightMils: 1730); ///ISO C0 media size: 917mm x 1297mm (36.10" x 51.06") - static const ISO_C0 = const PrintJobMediaSize( + static const ISO_C0 = const PrintJobMediaSize_( id: "ISO_C0", widthMils: 36100, heightMils: 51060); ///ISO C1 media size: 648mm x 917mm (25.51" x 36.10") - static const ISO_C1 = const PrintJobMediaSize( + static const ISO_C1 = const PrintJobMediaSize_( id: "ISO_C1", widthMils: 25510, heightMils: 36100); ///ISO C2 media size: 458mm x 648mm (18.03" x 25.51") - static const ISO_C2 = const PrintJobMediaSize( + static const ISO_C2 = const PrintJobMediaSize_( id: "ISO_C2", widthMils: 18030, heightMils: 25510); ///ISO C3 media size: 324mm x 458mm (12.76" x 18.03") - static const ISO_C3 = const PrintJobMediaSize( + static const ISO_C3 = const PrintJobMediaSize_( id: "ISO_C3", widthMils: 12760, heightMils: 18030); ///ISO C4 media size: 229mm x 324mm (9.02" x 12.76") static const ISO_C4 = - const PrintJobMediaSize(id: "ISO_C4", widthMils: 9020, heightMils: 12760); + const PrintJobMediaSize_(id: "ISO_C4", widthMils: 9020, heightMils: 12760); ///ISO C5 media size: 162mm x 229mm (6.38" x 9.02") static const ISO_C5 = - const PrintJobMediaSize(id: "ISO_C5", widthMils: 6380, heightMils: 9020); + const PrintJobMediaSize_(id: "ISO_C5", widthMils: 6380, heightMils: 9020); ///ISO C6 media size: 114mm x 162mm (4.49" x 6.38") static const ISO_C6 = - const PrintJobMediaSize(id: "ISO_C6", widthMils: 4490, heightMils: 6380); + const PrintJobMediaSize_(id: "ISO_C6", widthMils: 4490, heightMils: 6380); ///ISO C7 media size: 81mm x 114mm (3.19" x 4.49") static const ISO_C7 = - const PrintJobMediaSize(id: "ISO_C7", widthMils: 3190, heightMils: 4490); + const PrintJobMediaSize_(id: "ISO_C7", widthMils: 3190, heightMils: 4490); ///ISO C8 media size: 57mm x 81mm (2.24" x 3.19") static const ISO_C8 = - const PrintJobMediaSize(id: "ISO_C8", widthMils: 2240, heightMils: 3190); + const PrintJobMediaSize_(id: "ISO_C8", widthMils: 2240, heightMils: 3190); ///ISO C9 media size: 40mm x 57mm (1.57" x 2.24") static const ISO_C9 = - const PrintJobMediaSize(id: "ISO_C9", widthMils: 1570, heightMils: 2240); + const PrintJobMediaSize_(id: "ISO_C9", widthMils: 1570, heightMils: 2240); ///ISO C10 media size: 28mm x 40mm (1.10" x 1.57") static const ISO_C10 = - const PrintJobMediaSize(id: "ISO_C10", widthMils: 1100, heightMils: 1570); + const PrintJobMediaSize_(id: "ISO_C10", widthMils: 1100, heightMils: 1570); // North America ///North America Letter media size: 8.5" x 11" (279mm x 216mm) - static const NA_LETTER = const PrintJobMediaSize( + static const NA_LETTER = const PrintJobMediaSize_( id: "NA_LETTER", widthMils: 8500, heightMils: 11000); ///North America Government-Letter media size: 8.0" x 10.5" (203mm x 267mm) - static const NA_GOVT_LETTER = const PrintJobMediaSize( + static const NA_GOVT_LETTER = const PrintJobMediaSize_( id: "NA_GOVT_LETTER", widthMils: 8000, heightMils: 10500); ///North America Legal media size: 8.5" x 14" (216mm x 356mm) - static const NA_LEGAL = const PrintJobMediaSize( + static const NA_LEGAL = const PrintJobMediaSize_( id: "NA_LEGAL", widthMils: 8500, heightMils: 14000); ///North America Junior Legal media size: 8.0" x 5.0" (203mm × 127mm) - static const NA_JUNIOR_LEGAL = const PrintJobMediaSize( + static const NA_JUNIOR_LEGAL = const PrintJobMediaSize_( id: "NA_JUNIOR_LEGAL", widthMils: 8000, heightMils: 5000); ///North America Ledger media size: 17" x 11" (432mm × 279mm) - static const NA_LEDGER = const PrintJobMediaSize( + static const NA_LEDGER = const PrintJobMediaSize_( id: "NA_LEDGER", widthMils: 17000, heightMils: 11000); ///North America Tabloid media size: 11" x 17" (279mm × 432mm) - static const NA_TABLOID = const PrintJobMediaSize( + static const NA_TABLOID = const PrintJobMediaSize_( id: "NA_TABLOID", widthMils: 11000, heightMils: 17000); ///North America Index Card 3x5 media size: 3" x 5" (76mm x 127mm) - static const NA_INDEX_3X5 = const PrintJobMediaSize( + static const NA_INDEX_3X5 = const PrintJobMediaSize_( id: "NA_INDEX_3X5", widthMils: 3000, heightMils: 5000); ///North America Index Card 4x6 media size: 4" x 6" (102mm x 152mm) - static const NA_INDEX_4X6 = const PrintJobMediaSize( + static const NA_INDEX_4X6 = const PrintJobMediaSize_( id: "NA_INDEX_4X6", widthMils: 4000, heightMils: 6000); ///North America Index Card 5x8 media size: 5" x 8" (127mm x 203mm) - static const NA_INDEX_5X8 = const PrintJobMediaSize( + static const NA_INDEX_5X8 = const PrintJobMediaSize_( id: "NA_INDEX_5X8", widthMils: 5000, heightMils: 8000); ///North America Monarch media size: 7.25" x 10.5" (184mm x 267mm) - static const NA_MONARCH = const PrintJobMediaSize( + static const NA_MONARCH = const PrintJobMediaSize_( id: "NA_MONARCH", widthMils: 7250, heightMils: 10500); ///North America Quarto media size: 8" x 10" (203mm x 254mm) - static const NA_QUARTO = const PrintJobMediaSize( + static const NA_QUARTO = const PrintJobMediaSize_( id: "NA_QUARTO", widthMils: 8000, heightMils: 10000); ///North America Foolscap media size: 8" x 13" (203mm x 330mm) - static const NA_FOOLSCAP = const PrintJobMediaSize( + static const NA_FOOLSCAP = const PrintJobMediaSize_( id: "NA_FOOLSCAP", widthMils: 8000, heightMils: 13000); ///North America ANSI C media size: 17" x 22" (432mm x 559mm) - static const ANSI_C = const PrintJobMediaSize( + static const ANSI_C = const PrintJobMediaSize_( id: "ANSI_C", widthMils: 17000, heightMils: 22000); ///North America ANSI D media size: 22" x 34" (559mm x 864mm) - static const ANSI_D = const PrintJobMediaSize( + static const ANSI_D = const PrintJobMediaSize_( id: "ANSI_D", widthMils: 22000, heightMils: 34000); ///North America ANSI E media size: 34" x 44" (864mm x 1118mm) - static const ANSI_E = const PrintJobMediaSize( + static const ANSI_E = const PrintJobMediaSize_( id: "ANSI_E", widthMils: 34000, heightMils: 44000); ///North America ANSI F media size: 28" x 40" (711mm x 1016mm) - static const ANSI_F = const PrintJobMediaSize( + static const ANSI_F = const PrintJobMediaSize_( id: "ANSI_F", widthMils: 28000, heightMils: 40000); ///North America Arch A media size: 9" x 12" (229mm x 305mm) - static const NA_ARCH_A = const PrintJobMediaSize( + static const NA_ARCH_A = const PrintJobMediaSize_( id: "NA_ARCH_A", widthMils: 9000, heightMils: 12000); ///North America Arch B media size: 12" x 18" (305mm x 457mm) - static const NA_ARCH_B = const PrintJobMediaSize( + static const NA_ARCH_B = const PrintJobMediaSize_( id: "NA_ARCH_B", widthMils: 12000, heightMils: 18000); ///North America Arch C media size: 18" x 24" (457mm x 610mm) - static const NA_ARCH_C = const PrintJobMediaSize( + static const NA_ARCH_C = const PrintJobMediaSize_( id: "NA_ARCH_C", widthMils: 18000, heightMils: 24000); ///North America Arch D media size: 24" x 36" (610mm x 914mm) - static const NA_ARCH_D = const PrintJobMediaSize( + static const NA_ARCH_D = const PrintJobMediaSize_( id: "NA_ARCH_D", widthMils: 24000, heightMils: 36000); ///North America Arch E media size: 36" x 48" (914mm x 1219mm) - static const NA_ARCH_E = const PrintJobMediaSize( + static const NA_ARCH_E = const PrintJobMediaSize_( id: "NA_ARCH_E", widthMils: 36000, heightMils: 48000); ///North America Arch E1 media size: 30" x 42" (762mm x 1067mm) - static const NA_ARCH_E1 = const PrintJobMediaSize( + static const NA_ARCH_E1 = const PrintJobMediaSize_( id: "NA_ARCH_E1", widthMils: 30000, heightMils: 42000); ///North America Super B media size: 13" x 19" (330mm x 483mm) - static const NA_SUPER_B = const PrintJobMediaSize( + static const NA_SUPER_B = const PrintJobMediaSize_( id: "NA_SUPER_B", widthMils: 13000, heightMils: 19000); // Chinese ///Chinese ROC 8K media size: 270mm x 390mm (10.629" x 15.3543") - static const ROC_8K = const PrintJobMediaSize( + static const ROC_8K = const PrintJobMediaSize_( id: "ROC_8K", widthMils: 10629, heightMils: 15354); ///Chinese ROC 16K media size: 195mm x 270mm (7.677" x 10.629") - static const ROC_16K = const PrintJobMediaSize( + static const ROC_16K = const PrintJobMediaSize_( id: "ROC_16K", widthMils: 7677, heightMils: 10629); ///Chinese PRC 1 media size: 102mm x 165mm (4.015" x 6.496") static const PRC_1 = - const PrintJobMediaSize(id: "PRC_1", widthMils: 4015, heightMils: 6496); + const PrintJobMediaSize_(id: "PRC_1", widthMils: 4015, heightMils: 6496); ///Chinese PRC 2 media size: 102mm x 176mm (4.015" x 6.929") static const PRC_2 = - const PrintJobMediaSize(id: "PRC_2", widthMils: 4015, heightMils: 6929); + const PrintJobMediaSize_(id: "PRC_2", widthMils: 4015, heightMils: 6929); ///Chinese PRC 3 media size: 125mm x 176mm (4.921" x 6.929") static const PRC_3 = - const PrintJobMediaSize(id: "PRC_3", widthMils: 4921, heightMils: 6929); + const PrintJobMediaSize_(id: "PRC_3", widthMils: 4921, heightMils: 6929); ///Chinese PRC 4 media size: 110mm x 208mm (4.330" x 8.189") static const PRC_4 = - const PrintJobMediaSize(id: "PRC_4", widthMils: 4330, heightMils: 8189); + const PrintJobMediaSize_(id: "PRC_4", widthMils: 4330, heightMils: 8189); ///Chinese PRC 5 media size: 110mm x 220mm (4.330" x 8.661") static const PRC_5 = - const PrintJobMediaSize(id: "PRC_5", widthMils: 4330, heightMils: 8661); + const PrintJobMediaSize_(id: "PRC_5", widthMils: 4330, heightMils: 8661); ///Chinese PRC 6 media size: 120mm x 320mm (4.724" x 12.599") static const PRC_6 = - const PrintJobMediaSize(id: "PRC_6", widthMils: 4724, heightMils: 12599); + const PrintJobMediaSize_(id: "PRC_6", widthMils: 4724, heightMils: 12599); ///Chinese PRC 7 media size: 160mm x 230mm (6.299" x 9.055") static const PRC_7 = - const PrintJobMediaSize(id: "PRC_7", widthMils: 6299, heightMils: 9055); + const PrintJobMediaSize_(id: "PRC_7", widthMils: 6299, heightMils: 9055); ///Chinese PRC 8 media size: 120mm x 309mm (4.724" x 12.165") static const PRC_8 = - const PrintJobMediaSize(id: "PRC_8", widthMils: 4724, heightMils: 12165); + const PrintJobMediaSize_(id: "PRC_8", widthMils: 4724, heightMils: 12165); ///Chinese PRC 9 media size: 229mm x 324mm (9.016" x 12.756") static const PRC_9 = - const PrintJobMediaSize(id: "PRC_9", widthMils: 9016, heightMils: 12756); + const PrintJobMediaSize_(id: "PRC_9", widthMils: 9016, heightMils: 12756); ///Chinese PRC 10 media size: 324mm x 458mm (12.756" x 18.032") - static const PRC_10 = const PrintJobMediaSize( + static const PRC_10 = const PrintJobMediaSize_( id: "PRC_10", widthMils: 12756, heightMils: 18032); ///Chinese PRC 16k media size: 146mm x 215mm (5.749" x 8.465") static const PRC_16K = - const PrintJobMediaSize(id: "PRC_16K", widthMils: 5749, heightMils: 8465); + const PrintJobMediaSize_(id: "PRC_16K", widthMils: 5749, heightMils: 8465); ///Chinese Pa Kai media size: 267mm x 389mm (10.512" x 15.315") - static const OM_PA_KAI = const PrintJobMediaSize( + static const OM_PA_KAI = const PrintJobMediaSize_( id: "OM_PA_KAI", widthMils: 10512, heightMils: 15315); ///Chinese Dai Pa Kai media size: 275mm x 395mm (10.827" x 15.551") - static const OM_DAI_PA_KAI = const PrintJobMediaSize( + static const OM_DAI_PA_KAI = const PrintJobMediaSize_( id: "OM_DAI_PA_KAI", widthMils: 10827, heightMils: 15551); ///Chinese Jurro Ku Kai media size: 198mm x 275mm (7.796" x 10.827") - static const OM_JUURO_KU_KAI = const PrintJobMediaSize( + static const OM_JUURO_KU_KAI = const PrintJobMediaSize_( id: "OM_JUURO_KU_KAI", widthMils: 7796, heightMils: 10827); // Japanese ///Japanese JIS B10 media size: 32mm x 45mm (1.259" x 1.772") static const JIS_B10 = - const PrintJobMediaSize(id: "JIS_B10", widthMils: 1259, heightMils: 1772); + const PrintJobMediaSize_(id: "JIS_B10", widthMils: 1259, heightMils: 1772); ///Japanese JIS B9 media size: 45mm x 64mm (1.772" x 2.52") static const JIS_B9 = - const PrintJobMediaSize(id: "JIS_B9", widthMils: 1772, heightMils: 2520); + const PrintJobMediaSize_(id: "JIS_B9", widthMils: 1772, heightMils: 2520); ///Japanese JIS B8 media size: 64mm x 91mm (2.52" x 3.583") static const JIS_B8 = - const PrintJobMediaSize(id: "JIS_B8", widthMils: 2520, heightMils: 3583); + const PrintJobMediaSize_(id: "JIS_B8", widthMils: 2520, heightMils: 3583); ///Japanese JIS B7 media size: 91mm x 128mm (3.583" x 5.049") static const JIS_B7 = - const PrintJobMediaSize(id: "JIS_B7", widthMils: 3583, heightMils: 5049); + const PrintJobMediaSize_(id: "JIS_B7", widthMils: 3583, heightMils: 5049); ///Japanese JIS B6 media size: 128mm x 182mm (5.049" x 7.165") static const JIS_B6 = - const PrintJobMediaSize(id: "JIS_B6", widthMils: 5049, heightMils: 7165); + const PrintJobMediaSize_(id: "JIS_B6", widthMils: 5049, heightMils: 7165); ///Japanese JIS B5 media size: 182mm x 257mm (7.165" x 10.118") static const JIS_B5 = - const PrintJobMediaSize(id: "JIS_B5", widthMils: 7165, heightMils: 10118); + const PrintJobMediaSize_(id: "JIS_B5", widthMils: 7165, heightMils: 10118); ///Japanese JIS B4 media size: 257mm x 364mm (10.118" x 14.331") - static const JIS_B4 = const PrintJobMediaSize( + static const JIS_B4 = const PrintJobMediaSize_( id: "JIS_B4", widthMils: 10118, heightMils: 14331); ///Japanese JIS B3 media size: 364mm x 515mm (14.331" x 20.276") - static const JIS_B3 = const PrintJobMediaSize( + static const JIS_B3 = const PrintJobMediaSize_( id: "JIS_B3", widthMils: 14331, heightMils: 20276); ///Japanese JIS B2 media size: 515mm x 728mm (20.276" x 28.661") - static const JIS_B2 = const PrintJobMediaSize( + static const JIS_B2 = const PrintJobMediaSize_( id: "JIS_B2", widthMils: 20276, heightMils: 28661); ///Japanese JIS B1 media size: 728mm x 1030mm (28.661" x 40.551") - static const JIS_B1 = const PrintJobMediaSize( + static const JIS_B1 = const PrintJobMediaSize_( id: "JIS_B1", widthMils: 28661, heightMils: 40551); ///Japanese JIS B0 media size: 1030mm x 1456mm (40.551" x 57.323") - static const JIS_B0 = const PrintJobMediaSize( + static const JIS_B0 = const PrintJobMediaSize_( id: "JIS_B0", widthMils: 40551, heightMils: 57323); ///Japanese JIS Exec media size: 216mm x 330mm (8.504" x 12.992") - static const JIS_EXEC = const PrintJobMediaSize( + static const JIS_EXEC = const PrintJobMediaSize_( id: "JIS_EXEC", widthMils: 8504, heightMils: 12992); ///Japanese Chou4 media size: 90mm x 205mm (3.543" x 8.071") - static const JPN_CHOU4 = const PrintJobMediaSize( + static const JPN_CHOU4 = const PrintJobMediaSize_( id: "JPN_CHOU4", widthMils: 3543, heightMils: 8071); ///Japanese Chou3 media size: 120mm x 235mm (4.724" x 9.252") - static const JPN_CHOU3 = const PrintJobMediaSize( + static const JPN_CHOU3 = const PrintJobMediaSize_( id: "JPN_CHOU3", widthMils: 4724, heightMils: 9252); ///Japanese Chou2 media size: 111.1mm x 146mm (4.374" x 5.748") - static const JPN_CHOU2 = const PrintJobMediaSize( + static const JPN_CHOU2 = const PrintJobMediaSize_( id: "JPN_CHOU2", widthMils: 4374, heightMils: 5748); ///Japanese Hagaki media size: 100mm x 148mm (3.937" x 5.827") - static const JPN_HAGAKI = const PrintJobMediaSize( + static const JPN_HAGAKI = const PrintJobMediaSize_( id: "JPN_HAGAKI", widthMils: 3937, heightMils: 5827); ///Japanese Oufuku media size: 148mm x 200mm (5.827" x 7.874") - static const JPN_OUFUKU = const PrintJobMediaSize( + static const JPN_OUFUKU = const PrintJobMediaSize_( id: "JPN_OUFUKU", widthMils: 5827, heightMils: 7874); ///Japanese Kahu media size: 240mm x 322.1mm (9.449" x 12.681") - static const JPN_KAHU = const PrintJobMediaSize( + static const JPN_KAHU = const PrintJobMediaSize_( id: "JPN_KAHU", widthMils: 9449, heightMils: 12681); ///Japanese Kaku2 media size: 240mm x 332mm (9.449" x 13.071") - static const JPN_KAKU2 = const PrintJobMediaSize( + static const JPN_KAKU2 = const PrintJobMediaSize_( id: "JPN_KAKU2", widthMils: 9449, heightMils: 13071); ///Japanese You4 media size: 105mm x 235mm (4.134" x 9.252") - static const JPN_YOU4 = const PrintJobMediaSize( + static const JPN_YOU4 = const PrintJobMediaSize_( id: "JPN_YOU4", widthMils: 4134, heightMils: 9252); ///Japanese Photo L media size: 89mm x 127mm (3.5 x 5") - static const JPN_OE_PHOTO_L = const PrintJobMediaSize( + static const JPN_OE_PHOTO_L = const PrintJobMediaSize_( id: "JPN_OE_PHOTO_L", widthMils: 3500, heightMils: 5000); } diff --git a/lib/src/types/print_job_media_size.g.dart b/lib/src/types/print_job_media_size.g.dart new file mode 100644 index 00000000..4472e551 --- /dev/null +++ b/lib/src/types/print_job_media_size.g.dart @@ -0,0 +1,452 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'print_job_media_size.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class representing the supported media size for a [PrintJobController]. +///Media size is the dimension of the media on which the content is printed. +class PrintJobMediaSize { + ///The unique media size id. + /// + ///It is unique amongst other media sizes supported by the printer. + ///This id is defined by the client that generated the media size + ///instance and should not be interpreted by other parties. + final String id; + + ///The human readable label. + final String? label; + + ///The media width in mils (thousandths of an inch). + final int widthMils; + + ///The media height in mils (thousandths of an inch). + final int heightMils; + + ///Unknown media size in portrait mode. + /// + ///**NOTE**: This is for specifying orientation without media size. + ///You should not use the dimensions reported by this instance. + static const PrintJobMediaSize UNKNOWN_PORTRAIT = const PrintJobMediaSize( + id: "UNKNOWN_PORTRAIT", widthMils: 1, heightMils: 0x7fffffff); + + ///Unknown media size in portrait mode. + /// + ///**NOTE**: This is for specifying orientation without media size. + ///You should not use the dimensions reported by this instance. + static const PrintJobMediaSize UNKNOWN_LANDSCAPE = const PrintJobMediaSize( + id: "UNKNOWN_LANDSCAPE", widthMils: 0x7fffffff, heightMils: 1); + + ///ISO A0 media size: 841mm x 1189mm (33.11" x 46.81") + static const PrintJobMediaSize ISO_A0 = const PrintJobMediaSize( + id: "ISO_A0", widthMils: 33110, heightMils: 46810); + + ///ISO A1 media size: 594mm x 841mm (23.39" x 33.11") + static const PrintJobMediaSize ISO_A1 = const PrintJobMediaSize( + id: "ISO_A1", widthMils: 23390, heightMils: 33110); + + ///ISO A2 media size: 420mm x 594mm (16.54" x 23.39") + static const PrintJobMediaSize ISO_A2 = const PrintJobMediaSize( + id: "ISO_A2", widthMils: 16540, heightMils: 23390); + + ///ISO A3 media size: 297mm x 420mm (11.69" x 16.54") + static const PrintJobMediaSize ISO_A3 = const PrintJobMediaSize( + id: "ISO_A3", widthMils: 11690, heightMils: 16540); + + ///ISO A4 media size: 210mm x 297mm (8.27" x 11.69") + static const PrintJobMediaSize ISO_A4 = + const PrintJobMediaSize(id: "ISO_A4", widthMils: 8270, heightMils: 11690); + + ///ISO A5 media size: 148mm x 210mm (5.83" x 8.27") + static const PrintJobMediaSize ISO_A5 = + const PrintJobMediaSize(id: "ISO_A5", widthMils: 5830, heightMils: 8270); + + ///ISO A6 media size: 105mm x 148mm (4.13" x 5.83") + static const PrintJobMediaSize ISO_A6 = + const PrintJobMediaSize(id: "ISO_A6", widthMils: 4130, heightMils: 5830); + + ///ISO A7 media size: 74mm x 105mm (2.91" x 4.13") + static const PrintJobMediaSize ISO_A7 = + const PrintJobMediaSize(id: "ISO_A7", widthMils: 2910, heightMils: 4130); + + ///ISO A8 media size: 52mm x 74mm (2.05" x 2.91") + static const PrintJobMediaSize ISO_A8 = + const PrintJobMediaSize(id: "ISO_A8", widthMils: 2050, heightMils: 2910); + + ///ISO A9 media size: 37mm x 52mm (1.46" x 2.05") + static const PrintJobMediaSize ISO_A9 = + const PrintJobMediaSize(id: "ISO_A9", widthMils: 1460, heightMils: 2050); + + ///ISO A10 media size: 26mm x 37mm (1.02" x 1.46") + static const PrintJobMediaSize ISO_A10 = + const PrintJobMediaSize(id: "ISO_A10", widthMils: 1020, heightMils: 1460); + + ///ISO B0 media size: 1000mm x 1414mm (39.37" x 55.67") + static const PrintJobMediaSize ISO_B0 = const PrintJobMediaSize( + id: "ISO_B0", widthMils: 39370, heightMils: 55670); + + ///ISO B1 media size: 707mm x 1000mm (27.83" x 39.37") + static const PrintJobMediaSize ISO_B1 = const PrintJobMediaSize( + id: "ISO_B1", widthMils: 27830, heightMils: 39370); + + ///ISO B2 media size: 500mm x 707mm (19.69" x 27.83") + static const PrintJobMediaSize ISO_B2 = const PrintJobMediaSize( + id: "ISO_B2", widthMils: 19690, heightMils: 27830); + + ///ISO B3 media size: 353mm x 500mm (13.90" x 19.69") + static const PrintJobMediaSize ISO_B3 = const PrintJobMediaSize( + id: "ISO_B3", widthMils: 13900, heightMils: 19690); + + ///ISO B4 media size: 250mm x 353mm (9.84" x 13.90") + static const PrintJobMediaSize ISO_B4 = + const PrintJobMediaSize(id: "ISO_B4", widthMils: 9840, heightMils: 13900); + + ///ISO B5 media size: 176mm x 250mm (6.93" x 9.84") + static const PrintJobMediaSize ISO_B5 = + const PrintJobMediaSize(id: "ISO_B5", widthMils: 6930, heightMils: 9840); + + ///ISO B6 media size: 125mm x 176mm (4.92" x 6.93") + static const PrintJobMediaSize ISO_B6 = + const PrintJobMediaSize(id: "ISO_B6", widthMils: 4920, heightMils: 6930); + + ///ISO B7 media size: 88mm x 125mm (3.46" x 4.92") + static const PrintJobMediaSize ISO_B7 = + const PrintJobMediaSize(id: "ISO_B7", widthMils: 3460, heightMils: 4920); + + ///ISO B8 media size: 62mm x 88mm (2.44" x 3.46") + static const PrintJobMediaSize ISO_B8 = + const PrintJobMediaSize(id: "ISO_B8", widthMils: 2440, heightMils: 3460); + + ///ISO B9 media size: 44mm x 62mm (1.73" x 2.44") + static const PrintJobMediaSize ISO_B9 = + const PrintJobMediaSize(id: "ISO_B9", widthMils: 1730, heightMils: 2440); + + ///ISO B10 media size: 31mm x 44mm (1.22" x 1.73") + static const PrintJobMediaSize ISO_B10 = + const PrintJobMediaSize(id: "ISO_B10", widthMils: 1220, heightMils: 1730); + + ///ISO C0 media size: 917mm x 1297mm (36.10" x 51.06") + static const PrintJobMediaSize ISO_C0 = const PrintJobMediaSize( + id: "ISO_C0", widthMils: 36100, heightMils: 51060); + + ///ISO C1 media size: 648mm x 917mm (25.51" x 36.10") + static const PrintJobMediaSize ISO_C1 = const PrintJobMediaSize( + id: "ISO_C1", widthMils: 25510, heightMils: 36100); + + ///ISO C2 media size: 458mm x 648mm (18.03" x 25.51") + static const PrintJobMediaSize ISO_C2 = const PrintJobMediaSize( + id: "ISO_C2", widthMils: 18030, heightMils: 25510); + + ///ISO C3 media size: 324mm x 458mm (12.76" x 18.03") + static const PrintJobMediaSize ISO_C3 = const PrintJobMediaSize( + id: "ISO_C3", widthMils: 12760, heightMils: 18030); + + ///ISO C4 media size: 229mm x 324mm (9.02" x 12.76") + static const PrintJobMediaSize ISO_C4 = + const PrintJobMediaSize(id: "ISO_C4", widthMils: 9020, heightMils: 12760); + + ///ISO C5 media size: 162mm x 229mm (6.38" x 9.02") + static const PrintJobMediaSize ISO_C5 = + const PrintJobMediaSize(id: "ISO_C5", widthMils: 6380, heightMils: 9020); + + ///ISO C6 media size: 114mm x 162mm (4.49" x 6.38") + static const PrintJobMediaSize ISO_C6 = + const PrintJobMediaSize(id: "ISO_C6", widthMils: 4490, heightMils: 6380); + + ///ISO C7 media size: 81mm x 114mm (3.19" x 4.49") + static const PrintJobMediaSize ISO_C7 = + const PrintJobMediaSize(id: "ISO_C7", widthMils: 3190, heightMils: 4490); + + ///ISO C8 media size: 57mm x 81mm (2.24" x 3.19") + static const PrintJobMediaSize ISO_C8 = + const PrintJobMediaSize(id: "ISO_C8", widthMils: 2240, heightMils: 3190); + + ///ISO C9 media size: 40mm x 57mm (1.57" x 2.24") + static const PrintJobMediaSize ISO_C9 = + const PrintJobMediaSize(id: "ISO_C9", widthMils: 1570, heightMils: 2240); + + ///ISO C10 media size: 28mm x 40mm (1.10" x 1.57") + static const PrintJobMediaSize ISO_C10 = + const PrintJobMediaSize(id: "ISO_C10", widthMils: 1100, heightMils: 1570); + + ///North America Letter media size: 8.5" x 11" (279mm x 216mm) + static const PrintJobMediaSize NA_LETTER = const PrintJobMediaSize( + id: "NA_LETTER", widthMils: 8500, heightMils: 11000); + + ///North America Government-Letter media size: 8.0" x 10.5" (203mm x 267mm) + static const PrintJobMediaSize NA_GOVT_LETTER = const PrintJobMediaSize( + id: "NA_GOVT_LETTER", widthMils: 8000, heightMils: 10500); + + ///North America Legal media size: 8.5" x 14" (216mm x 356mm) + static const PrintJobMediaSize NA_LEGAL = const PrintJobMediaSize( + id: "NA_LEGAL", widthMils: 8500, heightMils: 14000); + + ///North America Junior Legal media size: 8.0" x 5.0" (203mm × 127mm) + static const PrintJobMediaSize NA_JUNIOR_LEGAL = const PrintJobMediaSize( + id: "NA_JUNIOR_LEGAL", widthMils: 8000, heightMils: 5000); + + ///North America Ledger media size: 17" x 11" (432mm × 279mm) + static const PrintJobMediaSize NA_LEDGER = const PrintJobMediaSize( + id: "NA_LEDGER", widthMils: 17000, heightMils: 11000); + + ///North America Tabloid media size: 11" x 17" (279mm × 432mm) + static const PrintJobMediaSize NA_TABLOID = const PrintJobMediaSize( + id: "NA_TABLOID", widthMils: 11000, heightMils: 17000); + + ///North America Index Card 3x5 media size: 3" x 5" (76mm x 127mm) + static const PrintJobMediaSize NA_INDEX_3X5 = const PrintJobMediaSize( + id: "NA_INDEX_3X5", widthMils: 3000, heightMils: 5000); + + ///North America Index Card 4x6 media size: 4" x 6" (102mm x 152mm) + static const PrintJobMediaSize NA_INDEX_4X6 = const PrintJobMediaSize( + id: "NA_INDEX_4X6", widthMils: 4000, heightMils: 6000); + + ///North America Index Card 5x8 media size: 5" x 8" (127mm x 203mm) + static const PrintJobMediaSize NA_INDEX_5X8 = const PrintJobMediaSize( + id: "NA_INDEX_5X8", widthMils: 5000, heightMils: 8000); + + ///North America Monarch media size: 7.25" x 10.5" (184mm x 267mm) + static const PrintJobMediaSize NA_MONARCH = const PrintJobMediaSize( + id: "NA_MONARCH", widthMils: 7250, heightMils: 10500); + + ///North America Quarto media size: 8" x 10" (203mm x 254mm) + static const PrintJobMediaSize NA_QUARTO = const PrintJobMediaSize( + id: "NA_QUARTO", widthMils: 8000, heightMils: 10000); + + ///North America Foolscap media size: 8" x 13" (203mm x 330mm) + static const PrintJobMediaSize NA_FOOLSCAP = const PrintJobMediaSize( + id: "NA_FOOLSCAP", widthMils: 8000, heightMils: 13000); + + ///North America ANSI C media size: 17" x 22" (432mm x 559mm) + static const PrintJobMediaSize ANSI_C = const PrintJobMediaSize( + id: "ANSI_C", widthMils: 17000, heightMils: 22000); + + ///North America ANSI D media size: 22" x 34" (559mm x 864mm) + static const PrintJobMediaSize ANSI_D = const PrintJobMediaSize( + id: "ANSI_D", widthMils: 22000, heightMils: 34000); + + ///North America ANSI E media size: 34" x 44" (864mm x 1118mm) + static const PrintJobMediaSize ANSI_E = const PrintJobMediaSize( + id: "ANSI_E", widthMils: 34000, heightMils: 44000); + + ///North America ANSI F media size: 28" x 40" (711mm x 1016mm) + static const PrintJobMediaSize ANSI_F = const PrintJobMediaSize( + id: "ANSI_F", widthMils: 28000, heightMils: 40000); + + ///North America Arch A media size: 9" x 12" (229mm x 305mm) + static const PrintJobMediaSize NA_ARCH_A = const PrintJobMediaSize( + id: "NA_ARCH_A", widthMils: 9000, heightMils: 12000); + + ///North America Arch B media size: 12" x 18" (305mm x 457mm) + static const PrintJobMediaSize NA_ARCH_B = const PrintJobMediaSize( + id: "NA_ARCH_B", widthMils: 12000, heightMils: 18000); + + ///North America Arch C media size: 18" x 24" (457mm x 610mm) + static const PrintJobMediaSize NA_ARCH_C = const PrintJobMediaSize( + id: "NA_ARCH_C", widthMils: 18000, heightMils: 24000); + + ///North America Arch D media size: 24" x 36" (610mm x 914mm) + static const PrintJobMediaSize NA_ARCH_D = const PrintJobMediaSize( + id: "NA_ARCH_D", widthMils: 24000, heightMils: 36000); + + ///North America Arch E media size: 36" x 48" (914mm x 1219mm) + static const PrintJobMediaSize NA_ARCH_E = const PrintJobMediaSize( + id: "NA_ARCH_E", widthMils: 36000, heightMils: 48000); + + ///North America Arch E1 media size: 30" x 42" (762mm x 1067mm) + static const PrintJobMediaSize NA_ARCH_E1 = const PrintJobMediaSize( + id: "NA_ARCH_E1", widthMils: 30000, heightMils: 42000); + + ///North America Super B media size: 13" x 19" (330mm x 483mm) + static const PrintJobMediaSize NA_SUPER_B = const PrintJobMediaSize( + id: "NA_SUPER_B", widthMils: 13000, heightMils: 19000); + + ///Chinese ROC 8K media size: 270mm x 390mm (10.629" x 15.3543") + static const PrintJobMediaSize ROC_8K = const PrintJobMediaSize( + id: "ROC_8K", widthMils: 10629, heightMils: 15354); + + ///Chinese ROC 16K media size: 195mm x 270mm (7.677" x 10.629") + static const PrintJobMediaSize ROC_16K = const PrintJobMediaSize( + id: "ROC_16K", widthMils: 7677, heightMils: 10629); + + ///Chinese PRC 1 media size: 102mm x 165mm (4.015" x 6.496") + static const PrintJobMediaSize PRC_1 = + const PrintJobMediaSize(id: "PRC_1", widthMils: 4015, heightMils: 6496); + + ///Chinese PRC 2 media size: 102mm x 176mm (4.015" x 6.929") + static const PrintJobMediaSize PRC_2 = + const PrintJobMediaSize(id: "PRC_2", widthMils: 4015, heightMils: 6929); + + ///Chinese PRC 3 media size: 125mm x 176mm (4.921" x 6.929") + static const PrintJobMediaSize PRC_3 = + const PrintJobMediaSize(id: "PRC_3", widthMils: 4921, heightMils: 6929); + + ///Chinese PRC 4 media size: 110mm x 208mm (4.330" x 8.189") + static const PrintJobMediaSize PRC_4 = + const PrintJobMediaSize(id: "PRC_4", widthMils: 4330, heightMils: 8189); + + ///Chinese PRC 5 media size: 110mm x 220mm (4.330" x 8.661") + static const PrintJobMediaSize PRC_5 = + const PrintJobMediaSize(id: "PRC_5", widthMils: 4330, heightMils: 8661); + + ///Chinese PRC 6 media size: 120mm x 320mm (4.724" x 12.599") + static const PrintJobMediaSize PRC_6 = + const PrintJobMediaSize(id: "PRC_6", widthMils: 4724, heightMils: 12599); + + ///Chinese PRC 7 media size: 160mm x 230mm (6.299" x 9.055") + static const PrintJobMediaSize PRC_7 = + const PrintJobMediaSize(id: "PRC_7", widthMils: 6299, heightMils: 9055); + + ///Chinese PRC 8 media size: 120mm x 309mm (4.724" x 12.165") + static const PrintJobMediaSize PRC_8 = + const PrintJobMediaSize(id: "PRC_8", widthMils: 4724, heightMils: 12165); + + ///Chinese PRC 9 media size: 229mm x 324mm (9.016" x 12.756") + static const PrintJobMediaSize PRC_9 = + const PrintJobMediaSize(id: "PRC_9", widthMils: 9016, heightMils: 12756); + + ///Chinese PRC 10 media size: 324mm x 458mm (12.756" x 18.032") + static const PrintJobMediaSize PRC_10 = const PrintJobMediaSize( + id: "PRC_10", widthMils: 12756, heightMils: 18032); + + ///Chinese PRC 16k media size: 146mm x 215mm (5.749" x 8.465") + static const PrintJobMediaSize PRC_16K = + const PrintJobMediaSize(id: "PRC_16K", widthMils: 5749, heightMils: 8465); + + ///Chinese Pa Kai media size: 267mm x 389mm (10.512" x 15.315") + static const PrintJobMediaSize OM_PA_KAI = const PrintJobMediaSize( + id: "OM_PA_KAI", widthMils: 10512, heightMils: 15315); + + ///Chinese Dai Pa Kai media size: 275mm x 395mm (10.827" x 15.551") + static const PrintJobMediaSize OM_DAI_PA_KAI = const PrintJobMediaSize( + id: "OM_DAI_PA_KAI", widthMils: 10827, heightMils: 15551); + + ///Chinese Jurro Ku Kai media size: 198mm x 275mm (7.796" x 10.827") + static const PrintJobMediaSize OM_JUURO_KU_KAI = const PrintJobMediaSize( + id: "OM_JUURO_KU_KAI", widthMils: 7796, heightMils: 10827); + + ///Japanese JIS B10 media size: 32mm x 45mm (1.259" x 1.772") + static const PrintJobMediaSize JIS_B10 = + const PrintJobMediaSize(id: "JIS_B10", widthMils: 1259, heightMils: 1772); + + ///Japanese JIS B9 media size: 45mm x 64mm (1.772" x 2.52") + static const PrintJobMediaSize JIS_B9 = + const PrintJobMediaSize(id: "JIS_B9", widthMils: 1772, heightMils: 2520); + + ///Japanese JIS B8 media size: 64mm x 91mm (2.52" x 3.583") + static const PrintJobMediaSize JIS_B8 = + const PrintJobMediaSize(id: "JIS_B8", widthMils: 2520, heightMils: 3583); + + ///Japanese JIS B7 media size: 91mm x 128mm (3.583" x 5.049") + static const PrintJobMediaSize JIS_B7 = + const PrintJobMediaSize(id: "JIS_B7", widthMils: 3583, heightMils: 5049); + + ///Japanese JIS B6 media size: 128mm x 182mm (5.049" x 7.165") + static const PrintJobMediaSize JIS_B6 = + const PrintJobMediaSize(id: "JIS_B6", widthMils: 5049, heightMils: 7165); + + ///Japanese JIS B5 media size: 182mm x 257mm (7.165" x 10.118") + static const PrintJobMediaSize JIS_B5 = + const PrintJobMediaSize(id: "JIS_B5", widthMils: 7165, heightMils: 10118); + + ///Japanese JIS B4 media size: 257mm x 364mm (10.118" x 14.331") + static const PrintJobMediaSize JIS_B4 = const PrintJobMediaSize( + id: "JIS_B4", widthMils: 10118, heightMils: 14331); + + ///Japanese JIS B3 media size: 364mm x 515mm (14.331" x 20.276") + static const PrintJobMediaSize JIS_B3 = const PrintJobMediaSize( + id: "JIS_B3", widthMils: 14331, heightMils: 20276); + + ///Japanese JIS B2 media size: 515mm x 728mm (20.276" x 28.661") + static const PrintJobMediaSize JIS_B2 = const PrintJobMediaSize( + id: "JIS_B2", widthMils: 20276, heightMils: 28661); + + ///Japanese JIS B1 media size: 728mm x 1030mm (28.661" x 40.551") + static const PrintJobMediaSize JIS_B1 = const PrintJobMediaSize( + id: "JIS_B1", widthMils: 28661, heightMils: 40551); + + ///Japanese JIS B0 media size: 1030mm x 1456mm (40.551" x 57.323") + static const PrintJobMediaSize JIS_B0 = const PrintJobMediaSize( + id: "JIS_B0", widthMils: 40551, heightMils: 57323); + + ///Japanese JIS Exec media size: 216mm x 330mm (8.504" x 12.992") + static const PrintJobMediaSize JIS_EXEC = const PrintJobMediaSize( + id: "JIS_EXEC", widthMils: 8504, heightMils: 12992); + + ///Japanese Chou4 media size: 90mm x 205mm (3.543" x 8.071") + static const PrintJobMediaSize JPN_CHOU4 = const PrintJobMediaSize( + id: "JPN_CHOU4", widthMils: 3543, heightMils: 8071); + + ///Japanese Chou3 media size: 120mm x 235mm (4.724" x 9.252") + static const PrintJobMediaSize JPN_CHOU3 = const PrintJobMediaSize( + id: "JPN_CHOU3", widthMils: 4724, heightMils: 9252); + + ///Japanese Chou2 media size: 111.1mm x 146mm (4.374" x 5.748") + static const PrintJobMediaSize JPN_CHOU2 = const PrintJobMediaSize( + id: "JPN_CHOU2", widthMils: 4374, heightMils: 5748); + + ///Japanese Hagaki media size: 100mm x 148mm (3.937" x 5.827") + static const PrintJobMediaSize JPN_HAGAKI = const PrintJobMediaSize( + id: "JPN_HAGAKI", widthMils: 3937, heightMils: 5827); + + ///Japanese Oufuku media size: 148mm x 200mm (5.827" x 7.874") + static const PrintJobMediaSize JPN_OUFUKU = const PrintJobMediaSize( + id: "JPN_OUFUKU", widthMils: 5827, heightMils: 7874); + + ///Japanese Kahu media size: 240mm x 322.1mm (9.449" x 12.681") + static const PrintJobMediaSize JPN_KAHU = const PrintJobMediaSize( + id: "JPN_KAHU", widthMils: 9449, heightMils: 12681); + + ///Japanese Kaku2 media size: 240mm x 332mm (9.449" x 13.071") + static const PrintJobMediaSize JPN_KAKU2 = const PrintJobMediaSize( + id: "JPN_KAKU2", widthMils: 9449, heightMils: 13071); + + ///Japanese You4 media size: 105mm x 235mm (4.134" x 9.252") + static const PrintJobMediaSize JPN_YOU4 = const PrintJobMediaSize( + id: "JPN_YOU4", widthMils: 4134, heightMils: 9252); + + ///Japanese Photo L media size: 89mm x 127mm (3.5 x 5") + static const PrintJobMediaSize JPN_OE_PHOTO_L = const PrintJobMediaSize( + id: "JPN_OE_PHOTO_L", widthMils: 3500, heightMils: 5000); + const PrintJobMediaSize( + {required this.id, + this.label, + required this.widthMils, + required this.heightMils}); + + ///Gets a possible [PrintJobMediaSize] instance from a [Map] value. + static PrintJobMediaSize? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = PrintJobMediaSize( + id: map['id'], + label: map['label'], + widthMils: map['widthMils'], + heightMils: map['heightMils'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "id": id, + "label": label, + "widthMils": widthMils, + "heightMils": heightMils, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'PrintJobMediaSize{id: $id, label: $label, widthMils: $widthMils, heightMils: $heightMils}'; + } +} diff --git a/lib/src/types/print_job_orientation.dart b/lib/src/types/print_job_orientation.dart index 0c6132bd..0a754d05 100644 --- a/lib/src/types/print_job_orientation.dart +++ b/lib/src/types/print_job_orientation.dart @@ -1,52 +1,19 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../print_job/main.dart'; +part 'print_job_orientation.g.dart'; + ///Class representing the orientation of a [PrintJobController]. -class PrintJobOrientation { +@ExchangeableEnum() +class PrintJobOrientation_ { + // ignore: unused_field final int _value; - - const PrintJobOrientation._internal(this._value); - - ///Set of all values of [PrintJobOrientation]. - static final Set values = [ - PrintJobOrientation.PORTRAIT, - PrintJobOrientation.LANDSCAPE, - ].toSet(); - - ///Gets a possible [PrintJobOrientation] instance from an [int] value. - static PrintJobOrientation? fromValue(int? value) { - if (value != null) { - try { - return PrintJobOrientation.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "LANDSCAPE"; - case 0: - default: - return "PORTRAIT"; - } - } + const PrintJobOrientation_._internal(this._value); ///Pages are printed in portrait orientation. - static const PORTRAIT = const PrintJobOrientation._internal(0); + static const PORTRAIT = const PrintJobOrientation_._internal(0); ///Pages are printed in landscape orientation. - static const LANDSCAPE = const PrintJobOrientation._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const LANDSCAPE = const PrintJobOrientation_._internal(1); } diff --git a/lib/src/types/print_job_orientation.g.dart b/lib/src/types/print_job_orientation.g.dart new file mode 100644 index 00000000..c7207c28 --- /dev/null +++ b/lib/src/types/print_job_orientation.g.dart @@ -0,0 +1,79 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'print_job_orientation.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class representing the orientation of a [PrintJobController]. +class PrintJobOrientation { + final int _value; + final int _nativeValue; + const PrintJobOrientation._internal(this._value, this._nativeValue); +// ignore: unused_element + factory PrintJobOrientation._internalMultiPlatform( + int value, Function nativeValue) => + PrintJobOrientation._internal(value, nativeValue()); + + ///Pages are printed in portrait orientation. + static const PORTRAIT = PrintJobOrientation._internal(0, 0); + + ///Pages are printed in landscape orientation. + static const LANDSCAPE = PrintJobOrientation._internal(1, 1); + + ///Set of all values of [PrintJobOrientation]. + static final Set values = [ + PrintJobOrientation.PORTRAIT, + PrintJobOrientation.LANDSCAPE, + ].toSet(); + + ///Gets a possible [PrintJobOrientation] instance from [int] value. + static PrintJobOrientation? fromValue(int? value) { + if (value != null) { + try { + return PrintJobOrientation.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [PrintJobOrientation] instance from a native value. + static PrintJobOrientation? fromNativeValue(int? value) { + if (value != null) { + try { + return PrintJobOrientation.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'PORTRAIT'; + case 1: + return 'LANDSCAPE'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/print_job_output_type.dart b/lib/src/types/print_job_output_type.dart index 9df686a4..f0a9a1e1 100644 --- a/lib/src/types/print_job_output_type.dart +++ b/lib/src/types/print_job_output_type.dart @@ -1,74 +1,35 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../print_job/main.dart'; +part 'print_job_output_type.g.dart'; + ///Class representing the kind of printable content of a [PrintJobController]. -class PrintJobOutputType { +@ExchangeableEnum() +class PrintJobOutputType_ { + // ignore: unused_field final int _value; - - const PrintJobOutputType._internal(this._value); - - ///Set of all values of [PrintJobOutputType]. - static final Set values = [ - PrintJobOutputType.GENERAL, - PrintJobOutputType.PHOTO, - PrintJobOutputType.GRAYSCALE, - PrintJobOutputType.PHOTO_GRAYSCALE - ].toSet(); - - ///Gets a possible [PrintJobOutputType] instance from an [int] value. - static PrintJobOutputType? fromValue(int? value) { - if (value != null) { - try { - return PrintJobOutputType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "PHOTO"; - case 2: - return "GRAYSCALE"; - case 3: - return "PHOTO_GRAYSCALE"; - case 0: - default: - return "GENERAL"; - } - } + const PrintJobOutputType_._internal(this._value); ///Specifies that the printed content consists of mixed text, graphics, and images. ///The default paper is Letter, A4, or similar locale-specific designation. ///Output is normal quality, duplex. - static const GENERAL = const PrintJobOutputType._internal(0); + static const GENERAL = const PrintJobOutputType_._internal(0); ///Specifies that the printed content consists of black-and-white or color images. ///The default paper is 4x6, A6, or similar locale-specific designation. ///Output is high quality, simplex. - static const PHOTO = const PrintJobOutputType._internal(1); + static const PHOTO = const PrintJobOutputType_._internal(1); ///Specifies that the printed content is grayscale. ///Set the output type to this value when your printable content contains no color—for example, it’s black text only. ///The default paper is Letter/A4. Output is grayscale quality, duplex. ///This content type can produce a performance improvement in some cases. - static const GRAYSCALE = const PrintJobOutputType._internal(2); + static const GRAYSCALE = const PrintJobOutputType_._internal(2); ///Specifies that the printed content is a grayscale image. ///Set the output type to this value when your printable content contains no color—for example, it’s black text only. ///The default paper is Letter/A4. ///Output is high quality grayscale, duplex. - static const PHOTO_GRAYSCALE = const PrintJobOutputType._internal(3); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const PHOTO_GRAYSCALE = const PrintJobOutputType_._internal(3); } diff --git a/lib/src/types/print_job_output_type.g.dart b/lib/src/types/print_job_output_type.g.dart new file mode 100644 index 00000000..7708b2d6 --- /dev/null +++ b/lib/src/types/print_job_output_type.g.dart @@ -0,0 +1,101 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'print_job_output_type.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class representing the kind of printable content of a [PrintJobController]. +class PrintJobOutputType { + final int _value; + final int _nativeValue; + const PrintJobOutputType._internal(this._value, this._nativeValue); +// ignore: unused_element + factory PrintJobOutputType._internalMultiPlatform( + int value, Function nativeValue) => + PrintJobOutputType._internal(value, nativeValue()); + + ///Specifies that the printed content consists of mixed text, graphics, and images. + ///The default paper is Letter, A4, or similar locale-specific designation. + ///Output is normal quality, duplex. + static const GENERAL = PrintJobOutputType._internal(0, 0); + + ///Specifies that the printed content consists of black-and-white or color images. + ///The default paper is 4x6, A6, or similar locale-specific designation. + ///Output is high quality, simplex. + static const PHOTO = PrintJobOutputType._internal(1, 1); + + ///Specifies that the printed content is grayscale. + ///Set the output type to this value when your printable content contains no color—for example, it’s black text only. + ///The default paper is Letter/A4. Output is grayscale quality, duplex. + ///This content type can produce a performance improvement in some cases. + static const GRAYSCALE = PrintJobOutputType._internal(2, 2); + + ///Specifies that the printed content is a grayscale image. + ///Set the output type to this value when your printable content contains no color—for example, it’s black text only. + ///The default paper is Letter/A4. + ///Output is high quality grayscale, duplex. + static const PHOTO_GRAYSCALE = PrintJobOutputType._internal(3, 3); + + ///Set of all values of [PrintJobOutputType]. + static final Set values = [ + PrintJobOutputType.GENERAL, + PrintJobOutputType.PHOTO, + PrintJobOutputType.GRAYSCALE, + PrintJobOutputType.PHOTO_GRAYSCALE, + ].toSet(); + + ///Gets a possible [PrintJobOutputType] instance from [int] value. + static PrintJobOutputType? fromValue(int? value) { + if (value != null) { + try { + return PrintJobOutputType.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [PrintJobOutputType] instance from a native value. + static PrintJobOutputType? fromNativeValue(int? value) { + if (value != null) { + try { + return PrintJobOutputType.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'GENERAL'; + case 1: + return 'PHOTO'; + case 2: + return 'GRAYSCALE'; + case 3: + return 'PHOTO_GRAYSCALE'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/print_job_rendering_quality.dart b/lib/src/types/print_job_rendering_quality.dart index 5a83105b..9f25ecd5 100644 --- a/lib/src/types/print_job_rendering_quality.dart +++ b/lib/src/types/print_job_rendering_quality.dart @@ -1,53 +1,20 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../print_job/main.dart'; +part 'print_job_rendering_quality.g.dart'; + ///Class representing the rendering quality of a [PrintJobController]. -class PrintJobRenderingQuality { +@ExchangeableEnum() +class PrintJobRenderingQuality_ { + // ignore: unused_field final int _value; - - const PrintJobRenderingQuality._internal(this._value); - - ///Set of all values of [PrintJobRenderingQuality]. - static final Set values = [ - PrintJobRenderingQuality.BEST, - PrintJobRenderingQuality.RESPONSIVE, - ].toSet(); - - ///Gets a possible [PrintJobRenderingQuality] instance from an [int] value. - static PrintJobRenderingQuality? fromValue(int? value) { - if (value != null) { - try { - return PrintJobRenderingQuality.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "RESPONSIVE"; - case 0: - default: - return "BEST"; - } - } + const PrintJobRenderingQuality_._internal(this._value); ///Renders the printing at the best possible quality, regardless of speed. - static const BEST = const PrintJobRenderingQuality._internal(0); + static const BEST = const PrintJobRenderingQuality_._internal(0); ///Sacrifices the least possible amount of rendering quality for speed to maintain a responsive user interface. ///This option should be used only after establishing that best quality rendering does indeed make the user interface unresponsive. - static const RESPONSIVE = const PrintJobRenderingQuality._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const RESPONSIVE = const PrintJobRenderingQuality_._internal(1); } diff --git a/lib/src/types/print_job_rendering_quality.g.dart b/lib/src/types/print_job_rendering_quality.g.dart new file mode 100644 index 00000000..94a9534d --- /dev/null +++ b/lib/src/types/print_job_rendering_quality.g.dart @@ -0,0 +1,80 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'print_job_rendering_quality.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class representing the rendering quality of a [PrintJobController]. +class PrintJobRenderingQuality { + final int _value; + final int _nativeValue; + const PrintJobRenderingQuality._internal(this._value, this._nativeValue); +// ignore: unused_element + factory PrintJobRenderingQuality._internalMultiPlatform( + int value, Function nativeValue) => + PrintJobRenderingQuality._internal(value, nativeValue()); + + ///Renders the printing at the best possible quality, regardless of speed. + static const BEST = PrintJobRenderingQuality._internal(0, 0); + + ///Sacrifices the least possible amount of rendering quality for speed to maintain a responsive user interface. + ///This option should be used only after establishing that best quality rendering does indeed make the user interface unresponsive. + static const RESPONSIVE = PrintJobRenderingQuality._internal(1, 1); + + ///Set of all values of [PrintJobRenderingQuality]. + static final Set values = [ + PrintJobRenderingQuality.BEST, + PrintJobRenderingQuality.RESPONSIVE, + ].toSet(); + + ///Gets a possible [PrintJobRenderingQuality] instance from [int] value. + static PrintJobRenderingQuality? fromValue(int? value) { + if (value != null) { + try { + return PrintJobRenderingQuality.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [PrintJobRenderingQuality] instance from a native value. + static PrintJobRenderingQuality? fromNativeValue(int? value) { + if (value != null) { + try { + return PrintJobRenderingQuality.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'BEST'; + case 1: + return 'RESPONSIVE'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/print_job_resolution.dart b/lib/src/types/print_job_resolution.dart index d0af8455..52818196 100644 --- a/lib/src/types/print_job_resolution.dart +++ b/lib/src/types/print_job_resolution.dart @@ -1,11 +1,16 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../print_job/main.dart'; +part 'print_job_resolution.g.dart'; + ///Class representing the supported resolution in DPI (dots per inch) for a [PrintJobController]. ///Resolution defines how many points with different color can be placed ///on one inch in horizontal or vertical direction of the target media. ///For example, a printer with 600 DPI can produce higher quality images ///the one with 300 DPI resolution. -class PrintJobResolution { +@ExchangeableObject() +class PrintJobResolution_ { ///The unique resolution id. /// ///It is unique amongst other resolutions supported by the printer. @@ -22,43 +27,9 @@ class PrintJobResolution { ///The horizontal resolution in DPI (dots per inch). final int horizontalDpi; - const PrintJobResolution( + const PrintJobResolution_( {required this.id, required this.label, required this.verticalDpi, required this.horizontalDpi}); - - ///Gets a possible [PrintJobResolution] instance from a [Map] value. - static PrintJobResolution? fromMap(Map? map) { - if (map == null) { - return null; - } - - return PrintJobResolution( - id: map["id"], - label: map["label"], - verticalDpi: map["verticalDpi"], - horizontalDpi: map["horizontalDpi"], - ); - } - - ///Converts instance to a map. - Map toMap() { - return { - "id": id, - "label": label, - "verticalDpi": verticalDpi, - "horizontalDpi": horizontalDpi, - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } diff --git a/lib/src/types/print_job_resolution.g.dart b/lib/src/types/print_job_resolution.g.dart new file mode 100644 index 00000000..f8b6978c --- /dev/null +++ b/lib/src/types/print_job_resolution.g.dart @@ -0,0 +1,69 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'print_job_resolution.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class representing the supported resolution in DPI (dots per inch) for a [PrintJobController]. +///Resolution defines how many points with different color can be placed +///on one inch in horizontal or vertical direction of the target media. +///For example, a printer with 600 DPI can produce higher quality images +///the one with 300 DPI resolution. +class PrintJobResolution { + ///The unique resolution id. + /// + ///It is unique amongst other resolutions supported by the printer. + ///This id is defined by the client that generated the resolution + ///instance and should not be interpreted by other parties. + final String id; + + ///The human readable label. + final String label; + + ///The vertical resolution in DPI (dots per inch). + final int verticalDpi; + + ///The horizontal resolution in DPI (dots per inch). + final int horizontalDpi; + const PrintJobResolution( + {required this.id, + required this.label, + required this.verticalDpi, + required this.horizontalDpi}); + + ///Gets a possible [PrintJobResolution] instance from a [Map] value. + static PrintJobResolution? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = PrintJobResolution( + id: map['id'], + label: map['label'], + verticalDpi: map['verticalDpi'], + horizontalDpi: map['horizontalDpi'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "id": id, + "label": label, + "verticalDpi": verticalDpi, + "horizontalDpi": horizontalDpi, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'PrintJobResolution{id: $id, label: $label, verticalDpi: $verticalDpi, horizontalDpi: $horizontalDpi}'; + } +} diff --git a/lib/src/types/print_job_state.dart b/lib/src/types/print_job_state.dart index ca0b461f..d5c8f227 100644 --- a/lib/src/types/print_job_state.dart +++ b/lib/src/types/print_job_state.dart @@ -1,123 +1,104 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../print_job/main.dart'; +part 'print_job_state.g.dart'; + ///Class representing the state of a [PrintJobController]. -class PrintJobState { +@ExchangeableEnum() +class PrintJobState_ { + // ignore: unused_field final int _value; - - const PrintJobState._internal(this._value); - - ///Set of all values of [PrintJobState]. - static final Set values = [ - PrintJobState.CREATED, - PrintJobState.QUEUED, - PrintJobState.STARTED, - PrintJobState.BLOCKED, - PrintJobState.COMPLETED, - PrintJobState.FAILED, - PrintJobState.CANCELED, - ].toSet(); - - ///Gets a possible [PrintJobState] instance from an [int] value. - static PrintJobState? fromValue(int? value) { - if (value != null) { - try { - return PrintJobState.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 2: - return "QUEUED"; - case 3: - return "STARTED"; - case 4: - return "BLOCKED"; - case 5: - return "COMPLETED"; - case 6: - return "FAILED"; - case 7: - return "CANCELED"; - case 1: - default: - return "CREATED"; - } - } + const PrintJobState_._internal(this._value); ///Print job state: The print job is being created but not yet ready to be printed. /// ///Next valid states: [QUEUED]. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJobInfo.STATE_CREATED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_CREATED)) - ///- iOS - static const CREATED = const PrintJobState._internal(1); + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform( + apiName: 'PrintJobInfo.STATE_CREATED', + apiUrl: 'https://developer.android.com/reference/android/print/PrintJobInfo#STATE_CREATED', + value: 1 + ), + EnumIOSPlatform(value: 1) + ]) + static const CREATED = const PrintJobState_._internal(1); ///Print job state: The print jobs is created, it is ready to be printed and should be processed. /// ///Next valid states: [STARTED], [FAILED], [CANCELED]. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJobInfo.STATE_QUEUED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_QUEUED)) - static const QUEUED = const PrintJobState._internal(2); + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform( + apiName: 'PrintJobInfo.STATE_QUEUED', + apiUrl: 'https://developer.android.com/reference/android/print/PrintJobInfo#STATE_QUEUED', + value: 2 + ) + ]) + static const QUEUED = const PrintJobState_._internal(2); ///Print job state: The print job is being printed. /// ///Next valid states: [COMPLETED], [FAILED], [CANCELED], [BLOCKED]. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJobInfo.STATE_STARTED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_STARTED)) - ///- iOS - static const STARTED = const PrintJobState._internal(3); + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform( + apiName: 'PrintJobInfo.STATE_STARTED', + apiUrl: 'https://developer.android.com/reference/android/print/PrintJobInfo#STATE_STARTED', + value: 3 + ), + EnumIOSPlatform(value: 3) + ]) + static const STARTED = const PrintJobState_._internal(3); ///Print job state: The print job is blocked. /// ///Next valid states: [FAILED], [CANCELED], [STARTED]. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJobInfo.STATE_BLOCKED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_BLOCKED)) - static const BLOCKED = const PrintJobState._internal(4); + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform( + apiName: 'PrintJobInfo.STATE_BLOCKED', + apiUrl: 'https://developer.android.com/reference/android/print/PrintJobInfo#STATE_BLOCKED', + value: 4 + ) + ]) + static const BLOCKED = const PrintJobState_._internal(4); ///Print job state: The print job is successfully printed. This is a terminal state. /// ///Next valid states: None. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJobInfo.STATE_COMPLETED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_COMPLETED)) - ///- iOS - static const COMPLETED = const PrintJobState._internal(5); + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform( + apiName: 'PrintJobInfo.STATE_COMPLETED', + apiUrl: 'https://developer.android.com/reference/android/print/PrintJobInfo#STATE_COMPLETED', + value: 5 + ), + EnumIOSPlatform(value: 5) + ]) + static const COMPLETED = const PrintJobState_._internal(5); ///Print job state: The print job was printing but printing failed. /// ///Next valid states: None. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJobInfo.STATE_FAILED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_FAILED)) - ///- iOS - static const FAILED = const PrintJobState._internal(6); + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform( + apiName: 'PrintJobInfo.STATE_FAILED', + apiUrl: 'https://developer.android.com/reference/android/print/PrintJobInfo#STATE_FAILED', + value: 6 + ), + EnumIOSPlatform(value: 6) + ]) + static const FAILED = const PrintJobState_._internal(6); ///Print job state: The print job is canceled. This is a terminal state. /// ///Next valid states: None. - /// - ///**Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJobInfo.STATE_CANCELED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_CANCELED)) - ///- iOS - static const CANCELED = const PrintJobState._internal(7); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform( + apiName: 'PrintJobInfo.STATE_CANCELED', + apiUrl: 'https://developer.android.com/reference/android/print/PrintJobInfo#STATE_CANCELED', + value: 7 + ), + EnumIOSPlatform(value: 7) + ]) + static const CANCELED = const PrintJobState_._internal(7); } diff --git a/lib/src/types/print_job_state.g.dart b/lib/src/types/print_job_state.g.dart new file mode 100644 index 00000000..06f4ad2d --- /dev/null +++ b/lib/src/types/print_job_state.g.dart @@ -0,0 +1,215 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'print_job_state.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class representing the state of a [PrintJobController]. +class PrintJobState { + final int _value; + final int _nativeValue; + const PrintJobState._internal(this._value, this._nativeValue); +// ignore: unused_element + factory PrintJobState._internalMultiPlatform( + int value, Function nativeValue) => + PrintJobState._internal(value, nativeValue()); + + ///Print job state: The print job is being created but not yet ready to be printed. + /// + ///Next valid states: [QUEUED]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PrintJobInfo.STATE_CREATED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_CREATED)) + ///- iOS + static final CREATED = PrintJobState._internalMultiPlatform(1, () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 1; + case TargetPlatform.iOS: + return 1; + default: + break; + } + return null; + }); + + ///Print job state: The print jobs is created, it is ready to be printed and should be processed. + /// + ///Next valid states: [STARTED], [FAILED], [CANCELED]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PrintJobInfo.STATE_QUEUED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_QUEUED)) + static final QUEUED = PrintJobState._internalMultiPlatform(2, () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 2; + default: + break; + } + return null; + }); + + ///Print job state: The print job is being printed. + /// + ///Next valid states: [COMPLETED], [FAILED], [CANCELED], [BLOCKED]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PrintJobInfo.STATE_STARTED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_STARTED)) + ///- iOS + static final STARTED = PrintJobState._internalMultiPlatform(3, () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 3; + case TargetPlatform.iOS: + return 3; + default: + break; + } + return null; + }); + + ///Print job state: The print job is blocked. + /// + ///Next valid states: [FAILED], [CANCELED], [STARTED]. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PrintJobInfo.STATE_BLOCKED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_BLOCKED)) + static final BLOCKED = PrintJobState._internalMultiPlatform(4, () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 4; + default: + break; + } + return null; + }); + + ///Print job state: The print job is successfully printed. This is a terminal state. + /// + ///Next valid states: None. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PrintJobInfo.STATE_COMPLETED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_COMPLETED)) + ///- iOS + static final COMPLETED = PrintJobState._internalMultiPlatform(5, () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 5; + case TargetPlatform.iOS: + return 5; + default: + break; + } + return null; + }); + + ///Print job state: The print job was printing but printing failed. + /// + ///Next valid states: None. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PrintJobInfo.STATE_FAILED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_FAILED)) + ///- iOS + static final FAILED = PrintJobState._internalMultiPlatform(6, () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 6; + case TargetPlatform.iOS: + return 6; + default: + break; + } + return null; + }); + + ///Print job state: The print job is canceled. This is a terminal state. + /// + ///Next valid states: None. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - PrintJobInfo.STATE_CANCELED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_CANCELED)) + ///- iOS + static final CANCELED = PrintJobState._internalMultiPlatform(7, () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 7; + case TargetPlatform.iOS: + return 7; + default: + break; + } + return null; + }); + + ///Set of all values of [PrintJobState]. + static final Set values = [ + PrintJobState.CREATED, + PrintJobState.QUEUED, + PrintJobState.STARTED, + PrintJobState.BLOCKED, + PrintJobState.COMPLETED, + PrintJobState.FAILED, + PrintJobState.CANCELED, + ].toSet(); + + ///Gets a possible [PrintJobState] instance from [int] value. + static PrintJobState? fromValue(int? value) { + if (value != null) { + try { + return PrintJobState.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [PrintJobState] instance from a native value. + static PrintJobState? fromNativeValue(int? value) { + if (value != null) { + try { + return PrintJobState.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 1: + return 'CREATED'; + case 2: + return 'QUEUED'; + case 3: + return 'STARTED'; + case 4: + return 'BLOCKED'; + case 5: + return 'COMPLETED'; + case 6: + return 'FAILED'; + case 7: + return 'CANCELED'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/proxy_rule.dart b/lib/src/types/proxy_rule.dart index 40a31f6e..031be516 100644 --- a/lib/src/types/proxy_rule.dart +++ b/lib/src/types/proxy_rule.dart @@ -1,36 +1,17 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'proxy_scheme_filter.dart'; +part 'proxy_rule.g.dart'; + ///Class that holds a scheme filter and a proxy URL. -class ProxyRule { +@ExchangeableObject() +class ProxyRule_ { ///Represents the scheme filter. - ProxySchemeFilter? schemeFilter; + ProxySchemeFilter_? schemeFilter; ///Represents the proxy URL. String url; - ProxyRule({required this.url, this.schemeFilter}); - - ///Gets a possible [ProxyRule] instance from a [Map] value. - static ProxyRule? fromMap(Map? map) { - return map != null - ? ProxyRule( - url: map["url"], - schemeFilter: ProxySchemeFilter.fromValue(map["schemeFilter"])) - : null; - } - - ///Converts instance to a map. - Map toMap() { - return {"url": url, "schemeFilter": schemeFilter?.toValue()}; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + ProxyRule_({required this.url, this.schemeFilter}); } diff --git a/lib/src/types/proxy_rule.g.dart b/lib/src/types/proxy_rule.g.dart new file mode 100644 index 00000000..f81094c5 --- /dev/null +++ b/lib/src/types/proxy_rule.g.dart @@ -0,0 +1,47 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'proxy_rule.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that holds a scheme filter and a proxy URL. +class ProxyRule { + ///Represents the scheme filter. + ProxySchemeFilter? schemeFilter; + + ///Represents the proxy URL. + String url; + ProxyRule({this.schemeFilter, required this.url}); + + ///Gets a possible [ProxyRule] instance from a [Map] value. + static ProxyRule? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = ProxyRule( + schemeFilter: ProxySchemeFilter.fromNativeValue(map['schemeFilter']), + url: map['url'], + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "schemeFilter": schemeFilter?.toNativeValue(), + "url": url, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'ProxyRule{schemeFilter: $schemeFilter, url: $url}'; + } +} diff --git a/lib/src/types/proxy_scheme_filter.dart b/lib/src/types/proxy_scheme_filter.dart index 7ebec59b..ed22ad13 100644 --- a/lib/src/types/proxy_scheme_filter.dart +++ b/lib/src/types/proxy_scheme_filter.dart @@ -1,49 +1,23 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../android/proxy_controller.dart'; +part 'proxy_scheme_filter.g.dart'; + ///Class that represent scheme filters used by [ProxyController]. -class ProxySchemeFilter { +@ExchangeableEnum() +class ProxySchemeFilter_ { + // ignore: unused_field final String _value; - - const ProxySchemeFilter._internal(this._value); - - ///Set of all values of [ProxySchemeFilter]. - static final Set values = [ - ProxySchemeFilter.MATCH_ALL_SCHEMES, - ProxySchemeFilter.MATCH_HTTP, - ProxySchemeFilter.MATCH_HTTPS, - ].toSet(); - - ///Gets a possible [ProxySchemeFilter] instance from a [String] value. - static ProxySchemeFilter? fromValue(String? value) { - if (value != null) { - try { - return ProxySchemeFilter.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [String] value. - String toValue() => _value; - - @override - String toString() => _value; + const ProxySchemeFilter_._internal(this._value); ///Matches all schemes. - static const MATCH_ALL_SCHEMES = const ProxySchemeFilter._internal("*"); + static const MATCH_ALL_SCHEMES = const ProxySchemeFilter_._internal("*"); ///HTTP scheme. - static const MATCH_HTTP = const ProxySchemeFilter._internal("http"); + static const MATCH_HTTP = const ProxySchemeFilter_._internal("http"); ///HTTPS scheme. static const MATCH_HTTPS = - const ProxySchemeFilter._internal("https"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + const ProxySchemeFilter_._internal("https"); } \ No newline at end of file diff --git a/lib/src/types/proxy_scheme_filter.g.dart b/lib/src/types/proxy_scheme_filter.g.dart new file mode 100644 index 00000000..6393a5d4 --- /dev/null +++ b/lib/src/types/proxy_scheme_filter.g.dart @@ -0,0 +1,77 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'proxy_scheme_filter.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class that represent scheme filters used by [ProxyController]. +class ProxySchemeFilter { + final String _value; + final String _nativeValue; + const ProxySchemeFilter._internal(this._value, this._nativeValue); +// ignore: unused_element + factory ProxySchemeFilter._internalMultiPlatform( + String value, Function nativeValue) => + ProxySchemeFilter._internal(value, nativeValue()); + + ///Matches all schemes. + static const MATCH_ALL_SCHEMES = ProxySchemeFilter._internal('*', '*'); + + ///HTTP scheme. + static const MATCH_HTTP = ProxySchemeFilter._internal('http', 'http'); + + ///HTTPS scheme. + static const MATCH_HTTPS = ProxySchemeFilter._internal('https', 'https'); + + ///Set of all values of [ProxySchemeFilter]. + static final Set values = [ + ProxySchemeFilter.MATCH_ALL_SCHEMES, + ProxySchemeFilter.MATCH_HTTP, + ProxySchemeFilter.MATCH_HTTPS, + ].toSet(); + + ///Gets a possible [ProxySchemeFilter] instance from [String] value. + static ProxySchemeFilter? fromValue(String? value) { + if (value != null) { + try { + return ProxySchemeFilter.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [ProxySchemeFilter] instance from a native value. + static ProxySchemeFilter? fromNativeValue(String? value) { + if (value != null) { + try { + return ProxySchemeFilter.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [String] native value. + String toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} diff --git a/lib/src/types/pull_to_refresh_size.dart b/lib/src/types/pull_to_refresh_size.dart index 59f4d9ca..ac7e12a6 100644 --- a/lib/src/types/pull_to_refresh_size.dart +++ b/lib/src/types/pull_to_refresh_size.dart @@ -1,103 +1,33 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'pull_to_refresh_size.g.dart'; + ///Class representing the size of the refresh indicator. -class PullToRefreshSize { +@ExchangeableEnum() +class PullToRefreshSize_ { + // ignore: unused_field final int _value; - - const PullToRefreshSize._internal(this._value); - - ///Set of all values of [PullToRefreshSize]. - static final Set values = [ - PullToRefreshSize.DEFAULT, - PullToRefreshSize.LARGE, - ].toSet(); - - ///Gets a possible [PullToRefreshSize] instance from an [int] value. - static PullToRefreshSize? fromValue(int? value) { - if (value != null) { - try { - return PullToRefreshSize.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 0: - return "LARGE"; - case 1: - default: - return "DEFAULT"; - } - } + const PullToRefreshSize_._internal(this._value); ///Default size. - static const DEFAULT = const PullToRefreshSize._internal(1); + static const DEFAULT = const PullToRefreshSize_._internal(1); ///Large size. - static const LARGE = const PullToRefreshSize._internal(0); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const LARGE = const PullToRefreshSize_._internal(0); } ///Android-specific class representing the size of the refresh indicator. ///Use [PullToRefreshSize] instead. @Deprecated("Use PullToRefreshSize instead") -class AndroidPullToRefreshSize { +@ExchangeableEnum() +class AndroidPullToRefreshSize_ { + // ignore: unused_field final int _value; - - const AndroidPullToRefreshSize._internal(this._value); - - ///Set of all values of [AndroidPullToRefreshSize]. - static final Set values = [ - AndroidPullToRefreshSize.DEFAULT, - AndroidPullToRefreshSize.LARGE, - ].toSet(); - - ///Gets a possible [AndroidPullToRefreshSize] instance from an [int] value. - static AndroidPullToRefreshSize? fromValue(int? value) { - if (value != null) { - try { - return AndroidPullToRefreshSize.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 0: - return "LARGE"; - case 1: - default: - return "DEFAULT"; - } - } + const AndroidPullToRefreshSize_._internal(this._value); ///Default size. - static const DEFAULT = const AndroidPullToRefreshSize._internal(1); + static const DEFAULT = const AndroidPullToRefreshSize_._internal(1); ///Large size. - static const LARGE = const AndroidPullToRefreshSize._internal(0); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const LARGE = const AndroidPullToRefreshSize_._internal(0); } \ No newline at end of file diff --git a/lib/src/types/pull_to_refresh_size.g.dart b/lib/src/types/pull_to_refresh_size.g.dart new file mode 100644 index 00000000..bb53e875 --- /dev/null +++ b/lib/src/types/pull_to_refresh_size.g.dart @@ -0,0 +1,153 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'pull_to_refresh_size.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class representing the size of the refresh indicator. +class PullToRefreshSize { + final int _value; + final int _nativeValue; + const PullToRefreshSize._internal(this._value, this._nativeValue); +// ignore: unused_element + factory PullToRefreshSize._internalMultiPlatform( + int value, Function nativeValue) => + PullToRefreshSize._internal(value, nativeValue()); + + ///Default size. + static const DEFAULT = PullToRefreshSize._internal(1, 1); + + ///Large size. + static const LARGE = PullToRefreshSize._internal(0, 0); + + ///Set of all values of [PullToRefreshSize]. + static final Set values = [ + PullToRefreshSize.DEFAULT, + PullToRefreshSize.LARGE, + ].toSet(); + + ///Gets a possible [PullToRefreshSize] instance from [int] value. + static PullToRefreshSize? fromValue(int? value) { + if (value != null) { + try { + return PullToRefreshSize.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [PullToRefreshSize] instance from a native value. + static PullToRefreshSize? fromNativeValue(int? value) { + if (value != null) { + try { + return PullToRefreshSize.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 1: + return 'DEFAULT'; + case 0: + return 'LARGE'; + } + return _value.toString(); + } +} + +///Android-specific class representing the size of the refresh indicator. +///Use [PullToRefreshSize] instead. +@Deprecated('Use PullToRefreshSize instead') +class AndroidPullToRefreshSize { + final int _value; + final int _nativeValue; + const AndroidPullToRefreshSize._internal(this._value, this._nativeValue); +// ignore: unused_element + factory AndroidPullToRefreshSize._internalMultiPlatform( + int value, Function nativeValue) => + AndroidPullToRefreshSize._internal(value, nativeValue()); + + ///Default size. + static const DEFAULT = AndroidPullToRefreshSize._internal(1, 1); + + ///Large size. + static const LARGE = AndroidPullToRefreshSize._internal(0, 0); + + ///Set of all values of [AndroidPullToRefreshSize]. + static final Set values = [ + AndroidPullToRefreshSize.DEFAULT, + AndroidPullToRefreshSize.LARGE, + ].toSet(); + + ///Gets a possible [AndroidPullToRefreshSize] instance from [int] value. + static AndroidPullToRefreshSize? fromValue(int? value) { + if (value != null) { + try { + return AndroidPullToRefreshSize.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [AndroidPullToRefreshSize] instance from a native value. + static AndroidPullToRefreshSize? fromNativeValue(int? value) { + if (value != null) { + try { + return AndroidPullToRefreshSize.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 1: + return 'DEFAULT'; + case 0: + return 'LARGE'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/referrer_policy.dart b/lib/src/types/referrer_policy.dart index 7f655579..c81ffaf2 100644 --- a/lib/src/types/referrer_policy.dart +++ b/lib/src/types/referrer_policy.dart @@ -1,78 +1,47 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'script_html_tag_attributes.dart'; import 'css_link_html_tag_attributes.dart'; +part 'referrer_policy.g.dart'; + ///Class that represents a Referrer-Policy HTTP header. ///It could be used with [ScriptHtmlTagAttributes] and [CSSLinkHtmlTagAttributes] ///when fetching a resource `` or a `