diff --git a/src/App/Handlers/HybridWebViewHandler.cs b/src/App/Handlers/HybridWebViewHandler.cs deleted file mode 100644 index eb8acc495..000000000 --- a/src/App/Handlers/HybridWebViewHandler.cs +++ /dev/null @@ -1,25 +0,0 @@ -#if IOS || MACCATALYST -using PlatformView = WebKit.WKWebView; -#elif ANDROID -using PlatformView = Android.Webkit.WebView; -#elif (NETSTANDARD || !PLATFORM) || (NET6_0_OR_GREATER && !IOS && !ANDROID) -using PlatformView = System.Object; -#endif - -using Bit.App.Controls; -using Microsoft.Maui.Handlers; - -namespace Bit.App.Handlers -{ - public partial class HybridWebViewHandler - { - public static PropertyMapper PropertyMapper = new PropertyMapper(ViewHandler.ViewMapper) - { - [nameof(HybridWebView.Uri)] = MapUri - }; - - public HybridWebViewHandler() : base(PropertyMapper) - { - } - } -} diff --git a/src/App/MauiProgram.cs b/src/App/MauiProgram.cs index 0822e59a7..1157399e5 100644 --- a/src/App/MauiProgram.cs +++ b/src/App/MauiProgram.cs @@ -13,7 +13,6 @@ }, handlers => { - handlers.AddHandler(typeof(Bit.App.Controls.HybridWebView), typeof(Bit.App.Handlers.HybridWebViewHandler)); #if ANDROID Bit.App.Handlers.EntryHandlerMappings.Setup(); Bit.App.Handlers.EditorHandlerMappings.Setup(); @@ -28,6 +27,7 @@ Bit.App.Handlers.ButtonHandlerMappings.Setup(); Bit.App.Handlers.ToolbarHandlerMappings.Setup(); + handlers.AddHandler(typeof(Bit.App.Controls.HybridWebView), typeof(Bit.App.Handlers.HybridWebViewHandler)); handlers.AddHandler(typeof(Bit.App.Pages.TabsPage), typeof(Bit.App.Handlers.CustomTabbedPageHandler)); handlers.AddHandler(typeof(Bit.App.Controls.ExtendedDatePicker), typeof(Bit.App.Handlers.ExtendedDatePickerHandler)); #else diff --git a/src/App/Platforms/Android/Handlers/HybridWebViewHandler.cs b/src/App/Platforms/Android/Handlers/HybridWebViewHandler.cs index 7c7bcfbd5..708b72743 100644 --- a/src/App/Platforms/Android/Handlers/HybridWebViewHandler.cs +++ b/src/App/Platforms/Android/Handlers/HybridWebViewHandler.cs @@ -6,10 +6,19 @@ using AWebkit = Android.Webkit; namespace Bit.App.Handlers { - public partial class HybridWebViewHandler : ViewHandler + public class HybridWebViewHandler : ViewHandler { private const string JSFunction = "function invokeCSharpAction(data){jsBridge.invokeAction(data);}"; + public static PropertyMapper PropertyMapper = new PropertyMapper(ViewHandler.ViewMapper) + { + [nameof(HybridWebView.Uri)] = MapUri + }; + + public HybridWebViewHandler() : base(PropertyMapper) + { + } + public HybridWebViewHandler([NotNull] IPropertyMapper mapper, CommandMapper commandMapper = null) : base(mapper, commandMapper) { } diff --git a/src/App/Platforms/iOS/Handlers/HybridWebViewHandler.cs b/src/iOS.Core/Handlers/HybridWebViewHandler.cs similarity index 86% rename from src/App/Platforms/iOS/Handlers/HybridWebViewHandler.cs rename to src/iOS.Core/Handlers/HybridWebViewHandler.cs index 694128f42..537555dec 100644 --- a/src/App/Platforms/iOS/Handlers/HybridWebViewHandler.cs +++ b/src/iOS.Core/Handlers/HybridWebViewHandler.cs @@ -5,15 +5,24 @@ using Foundation; using Microsoft.Maui.Handlers; using WebKit; -namespace Bit.App.Handlers +namespace Bit.iOS.Core.Handlers { - public partial class HybridWebViewHandler : ViewHandler + public class HybridWebViewHandler : ViewHandler { private const string JSFunction = "function invokeCSharpAction(data){window.webkit.messageHandlers.invokeAction.postMessage(data);}"; private WKUserContentController _userController; + public static PropertyMapper PropertyMapper = new PropertyMapper(ViewHandler.ViewMapper) + { + [nameof(HybridWebView.Uri)] = MapUri + }; + + public HybridWebViewHandler() : base(PropertyMapper) + { + } + public HybridWebViewHandler([NotNull] IPropertyMapper mapper, CommandMapper commandMapper = null) : base(mapper, commandMapper) { } diff --git a/src/iOS.Core/Utilities/iOSCoreHelpers.cs b/src/iOS.Core/Utilities/iOSCoreHelpers.cs index cf679e9ab..8e55434f1 100644 --- a/src/iOS.Core/Utilities/iOSCoreHelpers.cs +++ b/src/iOS.Core/Utilities/iOSCoreHelpers.cs @@ -48,6 +48,7 @@ namespace Bit.iOS.Core.Utilities public static void ConfigureMAUIHandlers(IMauiHandlersCollection handlers) { + handlers.AddHandler(typeof(HybridWebView), typeof(Handlers.HybridWebViewHandler)); handlers.AddHandler(typeof(TabsPage), typeof(Handlers.CustomTabbedHandler)); handlers.AddHandler(typeof(NavigationPage), typeof(Handlers.CustomNavigationHandler)); handlers.AddHandler(typeof(ViewCell), typeof(Handlers.CustomViewCellHandler));