From c6544b49e93d7eb8597952d740748326ef16ae15 Mon Sep 17 00:00:00 2001 From: Federico Maccaroni Date: Fri, 19 Jan 2024 15:14:22 -0300 Subject: [PATCH] PM-3350 Removed TapGesture Window MAUI hack from iOS.Extension and iOS.ShareExtension --- src/iOS.Core/Handlers/CustomWindowHandler.cs | 24 --------- src/iOS.Core/Utilities/iOSCoreHelpers.cs | 2 - .../LoadingViewController.TapGestureHack.cs | 54 ------------------- src/iOS.Extension/LoadingViewController.cs | 4 +- src/iOS.Extension/iOS.Extension.csproj | 3 -- .../LoadingViewController.TapGestureHack.cs | 22 -------- .../LoadingViewController.cs | 7 --- .../iOS.ShareExtension.csproj | 3 -- 8 files changed, 2 insertions(+), 117 deletions(-) delete mode 100644 src/iOS.Core/Handlers/CustomWindowHandler.cs delete mode 100644 src/iOS.Extension/LoadingViewController.TapGestureHack.cs delete mode 100644 src/iOS.ShareExtension/LoadingViewController.TapGestureHack.cs diff --git a/src/iOS.Core/Handlers/CustomWindowHandler.cs b/src/iOS.Core/Handlers/CustomWindowHandler.cs deleted file mode 100644 index 6927c7a9b..000000000 --- a/src/iOS.Core/Handlers/CustomWindowHandler.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.Maui.Handlers; -using UIKit; - -namespace Bit.iOS.Core.Handlers -{ - public class CustomWindowHandler : ElementHandler, IWindowHandler - { - public static IPropertyMapper Mapper = new PropertyMapper(ElementHandler.ElementMapper) - { - }; - - public CustomWindowHandler() : base(Mapper) - { - } - - protected override UIWindow CreatePlatformElement() - { - // Haven't tested - //return UIApplication.SharedApplication.Delegate.GetWindow(); - return Platform.GetCurrentUIViewController().View.Window; - } - } -} - diff --git a/src/iOS.Core/Utilities/iOSCoreHelpers.cs b/src/iOS.Core/Utilities/iOSCoreHelpers.cs index a9efe2f03..c2efab343 100644 --- a/src/iOS.Core/Utilities/iOSCoreHelpers.cs +++ b/src/iOS.Core/Utilities/iOSCoreHelpers.cs @@ -29,8 +29,6 @@ namespace Bit.iOS.Core.Utilities { 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(); diff --git a/src/iOS.Extension/LoadingViewController.TapGestureHack.cs b/src/iOS.Extension/LoadingViewController.TapGestureHack.cs deleted file mode 100644 index f5e09ca22..000000000 --- a/src/iOS.Extension/LoadingViewController.TapGestureHack.cs +++ /dev/null @@ -1,54 +0,0 @@ -#if ENABLED_TAP_GESTURE_RECOGNIZER_MAUI_EMBEDDED_WORKAROUND - -using System; -using System.Linq; -using Bit.iOS.Core.Utilities; -using Bit.iOS.Extension.Models; -using Microsoft.Maui.Controls; -using Microsoft.Maui.Platform; -using UIKit; - -namespace Bit.iOS.Extension -{ - public partial class LoadingViewController : UIViewController - { - const string STORYBOARD_NAME = "MainInterface"; - Lazy _storyboard = new Lazy(() => UIStoryboard.FromName(STORYBOARD_NAME, null)); - - public void InitWithContext(Context context) - { - _context = context; - _shouldInitialize = false; - } - - public void DismissLockAndContinue() - { - if (UIApplication.SharedApplication.KeyWindow is null) - { - return; - } - - UIApplication.SharedApplication.KeyWindow.RootViewController = _storyboard.Value.InstantiateInitialViewController(); - - if (UIApplication.SharedApplication.KeyWindow?.RootViewController is UINavigationController navContr) - { - var rootVC = navContr.ViewControllers.FirstOrDefault(); - if (rootVC is LoadingViewController loadingVC) - { - loadingVC.InitWithContext(_context); - loadingVC.ContinueOn(); - } - } - } - - private void NavigateToPage(ContentPage page) - { - var navigationPage = new NavigationPage(page); - - var window = new Window(navigationPage); - window.ToHandler(MauiContextSingleton.Instance.MauiContext); - } - } -} - -#endif \ No newline at end of file diff --git a/src/iOS.Extension/LoadingViewController.cs b/src/iOS.Extension/LoadingViewController.cs index 85f77329a..b3874fa64 100644 --- a/src/iOS.Extension/LoadingViewController.cs +++ b/src/iOS.Extension/LoadingViewController.cs @@ -18,6 +18,8 @@ using Bit.iOS.Core.Views; using Bit.iOS.Extension.Models; using CoreNFC; using Foundation; +using Microsoft.Maui.Controls; +using Microsoft.Maui.Platform; using MobileCoreServices; using UIKit; @@ -151,7 +153,6 @@ namespace Bit.iOS.Extension } } -#if !ENABLED_TAP_GESTURE_RECOGNIZER_MAUI_EMBEDDED_WORKAROUND public void DismissLockAndContinue() { Debug.WriteLine("BW Log, Dismissing lock controller."); @@ -166,7 +167,6 @@ namespace Bit.iOS.Extension PresentViewController(uiController, true, null); } -#endif private void ContinueOn() { diff --git a/src/iOS.Extension/iOS.Extension.csproj b/src/iOS.Extension/iOS.Extension.csproj index f374b47be..8829d9423 100644 --- a/src/iOS.Extension/iOS.Extension.csproj +++ b/src/iOS.Extension/iOS.Extension.csproj @@ -9,8 +9,6 @@ 1 False - - $(DefineConstants);ENABLED_TAP_GESTURE_RECOGNIZER_MAUI_EMBEDDED_WORKAROUND 11.0 Bit.iOS.Extension @@ -75,7 +73,6 @@ - diff --git a/src/iOS.ShareExtension/LoadingViewController.TapGestureHack.cs b/src/iOS.ShareExtension/LoadingViewController.TapGestureHack.cs deleted file mode 100644 index 7dc69428c..000000000 --- a/src/iOS.ShareExtension/LoadingViewController.TapGestureHack.cs +++ /dev/null @@ -1,22 +0,0 @@ -#if ENABLED_TAP_GESTURE_RECOGNIZER_MAUI_EMBEDDED_WORKAROUND - -using Bit.iOS.Core.Utilities; -using Microsoft.Maui.Controls; -using Microsoft.Maui.Platform; -using UIKit; - -namespace Bit.iOS.ShareExtension -{ - public partial class LoadingViewController : UIViewController - { - private void NavigateToPage(ContentPage page) - { - var navigationPage = new NavigationPage(page); - - var window = new Window(navigationPage); - window.ToHandler(MauiContextSingleton.Instance.MauiContext); - } - } -} - -#endif diff --git a/src/iOS.ShareExtension/LoadingViewController.cs b/src/iOS.ShareExtension/LoadingViewController.cs index fc3ae0e2d..22cb86fb8 100644 --- a/src/iOS.ShareExtension/LoadingViewController.cs +++ b/src/iOS.ShareExtension/LoadingViewController.cs @@ -137,23 +137,16 @@ namespace Bit.iOS.ShareExtension } } -#if !ENABLED_TAP_GESTURE_RECOGNIZER_MAUI_EMBEDDED_WORKAROUND - private void NavigateToPage(ContentPage page) { var navigationPage = new NavigationPage(page); - var window = new Window(navigationPage); - window.ToHandler(MauiContextSingleton.Instance.MauiContext); - _currentModalController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext); _currentModalController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; _presentingOnNavigationPage = true; PresentViewController(_currentModalController, true, null); } -#endif - public void DismissLockAndContinue() { Debug.WriteLine("BW Log, Dismissing lock controller."); diff --git a/src/iOS.ShareExtension/iOS.ShareExtension.csproj b/src/iOS.ShareExtension/iOS.ShareExtension.csproj index b8718e428..1f357ce2b 100644 --- a/src/iOS.ShareExtension/iOS.ShareExtension.csproj +++ b/src/iOS.ShareExtension/iOS.ShareExtension.csproj @@ -9,8 +9,6 @@ 1 False - - $(DefineConstants);ENABLED_TAP_GESTURE_RECOGNIZER_MAUI_EMBEDDED_WORKAROUND 11.0 Bit.iOS.ShareExtension @@ -67,7 +65,6 @@ ExtensionNavigationController.cs -