1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-30 15:13:24 +00:00

PM-3350 iOS extensions TapGestureRecognizer try Window workaround

This commit is contained in:
Federico Maccaroni
2023-11-29 18:42:39 -03:00
parent bfa2a51608
commit a5804df6a3
8 changed files with 174 additions and 78 deletions

View File

@@ -0,0 +1,24 @@
using Microsoft.Maui.Handlers;
using UIKit;
namespace Bit.iOS.Core.Handlers
{
public class CustomWindowHandler : ElementHandler<IWindow, UIWindow>, IWindowHandler
{
public static IPropertyMapper<IWindow, IWindowHandler> Mapper = new PropertyMapper<IWindow, IWindowHandler>(ElementHandler.ElementMapper)
{
};
public CustomWindowHandler() : base(Mapper)
{
}
protected override UIWindow CreatePlatformElement()
{
// Haven't tested
return UIApplication.SharedApplication.Delegate.GetWindow();
//return Platform.GetCurrentUIViewController().View.Window;
}
}
}

View File

@@ -27,7 +27,12 @@ namespace Bit.iOS.Core.Utilities
public static void SetupMaui()
{
var builder = Bit.Core.MauiProgram.ConfigureMauiAppBuilder(ConfigureMAUIEffects, ConfigureMAUIHandlers)
var builder = Bit.Core.MauiProgram.ConfigureMauiAppBuilder(ConfigureMAUIEffects, handlers =>
{
// WORKAROUND: This is needed to make TapGestureRecognizer work on extensions.
handlers.AddHandler(typeof(Window), typeof(Handlers.CustomWindowHandler));
ConfigureMAUIHandlers(handlers);
})
.UseMauiEmbedding<Application>();
// Register the Window
builder.Services.Add(new ServiceDescriptor(typeof(UIWindow), UIApplication.SharedApplication.KeyWindow));