From 6ee71132a9d7d30132bd7beb79c0940d8a1e8db0 Mon Sep 17 00:00:00 2001 From: SimpleLove520 <1960997571@qq.com> Date: Fri, 7 Feb 2025 14:09:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8DContextMenuItem=E7=B1=BB?= =?UTF-8?q?=E6=9C=AA=E9=80=82=E9=85=8Dohos=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SimpleLove520 <1960997571@qq.com> --- .../src/in_app_webview/in_app_webview_controller.dart | 3 +++ .../src/in_app_webview/in_app_webview_controller.dart | 3 +++ .../src/in_app_webview/in_app_webview_controller.dart | 3 +++ .../src/in_app_webview/in_app_webview_controller.dart | 3 +++ .../lib/src/context_menu/context_menu_item.dart | 10 +++++++++- .../lib/src/context_menu/context_menu_item.g.dart | 10 +++++++++- .../lib/src/util.dart | 3 +++ 7 files changed, 33 insertions(+), 2 deletions(-) diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart index ceb4bc9a..410b39cf 100644 --- a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart @@ -1238,6 +1238,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (contextMenu != null) { int? androidId = call.arguments["androidId"]; + int? ohosId = call.arguments["ohosId"]; String? iosId = call.arguments["iosId"]; dynamic id = call.arguments["id"]; String title = call.arguments["title"]; @@ -1247,6 +1248,8 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController // ignore: deprecated_member_use_from_same_package androidId: androidId, // ignore: deprecated_member_use_from_same_package + ohosId: ohosId, + // ignore: deprecated_member_use_from_same_package iosId: iosId, title: title, action: null); diff --git a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart index 7e847f14..61dd3249 100644 --- a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart @@ -1234,6 +1234,7 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController if (contextMenu != null) { int? androidId = call.arguments["androidId"]; + int? ohosId = call.arguments["ohosId"]; String? iosId = call.arguments["iosId"]; dynamic id = call.arguments["id"]; String title = call.arguments["title"]; @@ -1243,6 +1244,8 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController // ignore: deprecated_member_use_from_same_package androidId: androidId, // ignore: deprecated_member_use_from_same_package + ohosId: ohosId, + // ignore: deprecated_member_use_from_same_package iosId: iosId, title: title, action: null); diff --git a/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart index 38ab1bc7..721a64ee 100644 --- a/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart @@ -1235,6 +1235,7 @@ class MacOSInAppWebViewController extends PlatformInAppWebViewController if (contextMenu != null) { int? androidId = call.arguments["androidId"]; + int? ohosId = call.arguments["ohosId"]; String? iosId = call.arguments["iosId"]; dynamic id = call.arguments["id"]; String title = call.arguments["title"]; @@ -1244,6 +1245,8 @@ class MacOSInAppWebViewController extends PlatformInAppWebViewController // ignore: deprecated_member_use_from_same_package androidId: androidId, // ignore: deprecated_member_use_from_same_package + ohosId: ohosId, + // ignore: deprecated_member_use_from_same_package iosId: iosId, title: title, action: null); diff --git a/flutter_inappwebview_ohos/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_ohos/lib/src/in_app_webview/in_app_webview_controller.dart index 926c3c68..c461b138 100644 --- a/flutter_inappwebview_ohos/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_ohos/lib/src/in_app_webview/in_app_webview_controller.dart @@ -1253,6 +1253,7 @@ class OhosInAppWebViewController extends PlatformInAppWebViewController if (contextMenu != null) { int? androidId = call.arguments["androidId"]; + int? ohosId = call.arguments["ohosId"]; String? iosId = call.arguments["iosId"]; dynamic id = call.arguments["id"]; String title = call.arguments["title"]; @@ -1262,6 +1263,8 @@ class OhosInAppWebViewController extends PlatformInAppWebViewController // ignore: deprecated_member_use_from_same_package androidId: androidId, // ignore: deprecated_member_use_from_same_package + ohosId: ohosId, + // ignore: deprecated_member_use_from_same_package iosId: iosId, title: title, action: null); diff --git a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.dart index ec7a29bc..7b5cd5c2 100644 --- a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.dart +++ b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.dart @@ -12,6 +12,10 @@ class ContextMenuItem_ { @Deprecated("Use id instead") int? androidId; + ///Use [id] instead. + @Deprecated("Use id instead") + int? ohosId; + ///Use [id] instead. @Deprecated("Use id instead") String? iosId; @@ -31,6 +35,7 @@ class ContextMenuItem_ { ContextMenuItem_( {this.id, @Deprecated("Use id instead") this.androidId, + @Deprecated("Use id instead") this.ohosId, @Deprecated("Use id instead") this.iosId, required this.title, this.action}) { @@ -38,6 +43,9 @@ class ContextMenuItem_ { // ignore: deprecated_member_use_from_same_package this.id = this.id ?? this.androidId; assert(this.id is int); + }else if (Util.isOhos) { + // ignore: deprecated_member_use_from_same_package + this.id = this.id ?? this.ohosId; } else if (Util.isIOS) { // ignore: deprecated_member_use_from_same_package this.id = this.id ?? this.iosId; @@ -48,6 +56,6 @@ class ContextMenuItem_ { @ExchangeableObjectMethod(toMapMergeWith: true) // ignore: unused_element Map _toMapMergeWith() { - return {"androidId": androidId, "iosId": iosId}; + return {"androidId": androidId, "ohosId": ohosId, "iosId": iosId}; } } diff --git a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.g.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.g.dart index 242c1f2b..0c623827 100644 --- a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.g.dart @@ -24,17 +24,24 @@ class ContextMenuItem { @Deprecated('Use id instead') String? iosId; + ///Use [id] instead. + @Deprecated('Use id instead') + int? ohosId; + ///Menu item title. String title; ContextMenuItem( {this.id, @Deprecated("Use id instead") this.androidId, + @Deprecated("Use id instead") this.ohosId, @Deprecated("Use id instead") this.iosId, required this.title, this.action}) { if (Util.isAndroid) { this.id = this.id ?? this.androidId; assert(this.id is int); + } else if (Util.isOhos) { + this.id = this.id ?? this.ohosId; } else if (Util.isIOS) { this.id = this.id ?? this.iosId; } @@ -50,6 +57,7 @@ class ContextMenuItem { androidId: map['id'], id: map['id'], iosId: map['id'], + ohosId: map['id'], title: map['title'], ); return instance; @@ -57,7 +65,7 @@ class ContextMenuItem { @ExchangeableObjectMethod(toMapMergeWith: true) Map _toMapMergeWith() { - return {"androidId": androidId, "iosId": iosId}; + return {"androidId": androidId, "ohosId": ohosId, "iosId": iosId}; } ///Converts instance to a map. diff --git a/flutter_inappwebview_platform_interface/lib/src/util.dart b/flutter_inappwebview_platform_interface/lib/src/util.dart index 113ccf78..7ca5f269 100644 --- a/flutter_inappwebview_platform_interface/lib/src/util.dart +++ b/flutter_inappwebview_platform_interface/lib/src/util.dart @@ -15,6 +15,9 @@ class Util { static bool get isAndroid => !isWeb && defaultTargetPlatform == TargetPlatform.android; + static bool get isOhos => + !isWeb && defaultTargetPlatform == TargetPlatform.ohos; + static bool get isIOS => !isWeb && defaultTargetPlatform == TargetPlatform.iOS; -- Gitee From a188042e0f66bc690e6918aefd9b7b155bdbce20 Mon Sep 17 00:00:00 2001 From: SimpleLove520 <1960997571@qq.com> Date: Sat, 8 Feb 2025 09:34:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SimpleLove520 <1960997571@qq.com> --- .../lib/src/context_menu/context_menu_item.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.dart index 7b5cd5c2..7a614ace 100644 --- a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.dart +++ b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_item.dart @@ -43,7 +43,7 @@ class ContextMenuItem_ { // ignore: deprecated_member_use_from_same_package this.id = this.id ?? this.androidId; assert(this.id is int); - }else if (Util.isOhos) { + } else if (Util.isOhos) { // ignore: deprecated_member_use_from_same_package this.id = this.id ?? this.ohosId; } else if (Util.isIOS) { -- Gitee