From a4a3d31c1955e4f18a6c3a58a3f5e5f90a3cf0b2 Mon Sep 17 00:00:00 2001 From: Federico Maccaroni Date: Thu, 7 Dec 2023 17:40:20 -0300 Subject: [PATCH] PM-3350 Fix iOS extensions navigation and Window/RootViewController handling for TapGestureRecognizer to work --- ...alProviderViewController.TapGestureHack.cs | 51 +++++++ .../CredentialProviderViewController.cs | 139 +++++++++--------- ...edentialProviderViewController.designer.cs | 8 - src/iOS.Autofill/MainInterface.storyboard | 14 +- src/iOS.Autofill/iOS.Autofill.csproj | 3 + .../LoadingViewController.TapGestureHack.cs | 68 +++++++++ src/iOS.Extension/LoadingViewController.cs | 87 ++++++----- src/iOS.Extension/iOS.Extension.csproj | 3 + .../LoadingViewController.TapGestureHack.cs | 22 +++ .../LoadingViewController.cs | 30 ++-- .../iOS.ShareExtension.csproj | 3 + 11 files changed, 279 insertions(+), 149 deletions(-) create mode 100644 src/iOS.Autofill/CredentialProviderViewController.TapGestureHack.cs create mode 100644 src/iOS.Extension/LoadingViewController.TapGestureHack.cs create mode 100644 src/iOS.ShareExtension/LoadingViewController.TapGestureHack.cs diff --git a/src/iOS.Autofill/CredentialProviderViewController.TapGestureHack.cs b/src/iOS.Autofill/CredentialProviderViewController.TapGestureHack.cs new file mode 100644 index 000000000..b1330ce8d --- /dev/null +++ b/src/iOS.Autofill/CredentialProviderViewController.TapGestureHack.cs @@ -0,0 +1,51 @@ +#if ENABLED_TAP_GESTURE_RECOGNIZER_MAUI_EMBEDDED_WORKAROUND + +using System; +using AuthenticationServices; +using Bit.App.Abstractions; +using Bit.Core.Utilities; +using Bit.iOS.Autofill.Models; +using Bit.iOS.Core.Utilities; +using Microsoft.Maui.Controls; +using Microsoft.Maui.Platform; +using UIKit; + +namespace Bit.iOS.Autofill +{ + public partial class CredentialProviderViewController : ASCredentialProviderViewController, IAccountsManagerHost + { + const string STORYBOARD_NAME = "MainInterface"; + Lazy _storyboard = new Lazy(() => UIStoryboard.FromName(STORYBOARD_NAME, null)); + + public void InitWithContext(Context context) + { + _context = context; + } + + public void DismissLockAndContinue() + { + if (UIApplication.SharedApplication.KeyWindow is null) + { + return; + } + + UIApplication.SharedApplication.KeyWindow.RootViewController = _storyboard.Value.InstantiateInitialViewController(); + + if (UIApplication.SharedApplication.KeyWindow?.RootViewController is CredentialProviderViewController cpvc) + { + cpvc.InitWithContext(_context); + cpvc.OnLockDismissedAsync().FireAndForget(); + } + } + + 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.Autofill/CredentialProviderViewController.cs b/src/iOS.Autofill/CredentialProviderViewController.cs index 352762264..242e4d149 100644 --- a/src/iOS.Autofill/CredentialProviderViewController.cs +++ b/src/iOS.Autofill/CredentialProviderViewController.cs @@ -1,4 +1,5 @@ using System; +using System.Text; using System.Threading.Tasks; using AuthenticationServices; using Bit.App.Abstractions; @@ -16,8 +17,7 @@ using Bit.iOS.Core.Views; using CoreFoundation; using CoreNFC; using Foundation; -using Microsoft.Maui.Controls; -using Microsoft.Maui.Platform; +using Microsoft.Maui.ApplicationModel; using UIKit; namespace Bit.iOS.Autofill @@ -29,7 +29,7 @@ namespace Bit.iOS.Autofill private Core.NFCReaderDelegate _nfcDelegate = null; private IAccountsManager _accountsManager; - private readonly LazyResolve _stateService = new LazyResolve("stateService"); + private readonly LazyResolve _stateService = new LazyResolve(); public CredentialProviderViewController(IntPtr handle) : base(handle) @@ -37,11 +37,13 @@ namespace Bit.iOS.Autofill ModalPresentationStyle = UIModalPresentationStyle.FullScreen; } + private ASCredentialProviderExtensionContext ASExtensionContext => _context?.ExtContext as ASCredentialProviderExtensionContext; + public override void ViewDidLoad() { try { - InitApp(); + InitAppIfNeeded(); base.ViewDidLoad(); @@ -51,6 +53,7 @@ namespace Bit.iOS.Autofill { ExtContext = ExtensionContext }; + } catch (Exception ex) { @@ -171,7 +174,7 @@ namespace Bit.iOS.Autofill if ((_context?.Configuring ?? true) && string.IsNullOrWhiteSpace(password)) { ServiceContainer.Reset(); - ExtensionContext?.CompleteExtensionConfigurationRequest(); + ASExtensionContext?.CompleteExtensionConfigurationRequest(); return; } @@ -180,7 +183,7 @@ namespace Bit.iOS.Autofill ServiceContainer.Reset(); var err = new NSError(new NSString("ASExtensionErrorDomain"), Convert.ToInt32(ASExtensionErrorCode.UserCanceled), null); - NSRunLoop.Main.BeginInvokeOnMainThread(() => ExtensionContext?.CancelRequest(err)); + NSRunLoop.Main.BeginInvokeOnMainThread(() => ASExtensionContext?.CancelRequest(err)); return; } @@ -198,7 +201,7 @@ namespace Bit.iOS.Autofill await eventService.CollectAsync(Bit.Core.Enums.EventType.Cipher_ClientAutofilled, id); } ServiceContainer.Reset(); - ExtensionContext?.CompleteRequest(cred, null); + ASExtensionContext?.CompleteRequest(cred, null); }); } @@ -245,38 +248,53 @@ namespace Bit.iOS.Autofill } } - public void DismissLockAndContinue() +#if !ENABLED_TAP_GESTURE_RECOGNIZER_MAUI_EMBEDDED_WORKAROUND + public async void DismissLockAndContinue() { - DismissViewController(false, async () => - { - try - { - if (_context.CredentialIdentity != null) - { - await ProvideCredentialAsync(); - return; - } - if (_context.Configuring) - { - PerformSegue("setupSegue", this); - return; - } + ClipLogger.Log("Dismiss lock and continue"); - if (_context.ServiceIdentifiers == null || _context.ServiceIdentifiers.Length == 0) - { - PerformSegue("loginSearchSegue", this); - } - else - { - PerformSegue("loginListSegue", this); - } - } - catch (Exception ex) + DismissViewController(false, async () => await OnLockDismissedAsync()); + } + + private void NavigateToPage(ContentPage page) + { + var navigationPage = new NavigationPage(page); + var uiController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext); + uiController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; + + PresentViewController(uiController, true, null); + } +#endif + + public async Task OnLockDismissedAsync() + { + try + { + if (_context.CredentialIdentity != null) { - LoggerHelper.LogEvenIfCantBeResolved(ex); - throw; + await MainThread.InvokeOnMainThreadAsync(() => ProvideCredentialAsync()); + return; } - }); + if (_context.Configuring) + { + await MainThread.InvokeOnMainThreadAsync(() => PerformSegue("setupSegue", this)); + return; + } + + if (_context.ServiceIdentifiers == null || _context.ServiceIdentifiers.Length == 0) + { + await MainThread.InvokeOnMainThreadAsync(() => PerformSegue("loginSearchSegue", this)); + } + else + { + await MainThread.InvokeOnMainThreadAsync(() => PerformSegue("loginListSegue", this)); + } + } + catch (Exception ex) + { + LoggerHelper.LogEvenIfCantBeResolved(ex); + throw; + } } private async Task ProvideCredentialAsync(bool userInteraction = true) @@ -407,46 +425,25 @@ namespace Bit.iOS.Autofill } } - private void NavigateToPage(ContentPage page) - { - var navigationPage = new NavigationPage(page); - - var window = new Window(navigationPage); - window.ToHandler(MauiContextSingleton.Instance.MauiContext); - - var uiController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext); - uiController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; - - PresentViewController(uiController, true, null); - } - private void LaunchHomePage() { - try + var appOptions = new AppOptions { IosExtension = true }; + var homePage = new HomePage(appOptions); + var app = new App.App(appOptions); + ThemeManager.SetTheme(app.Resources); + ThemeManager.ApplyResourcesTo(homePage); + if (homePage.BindingContext is HomeViewModel vm) { - var appOptions = new AppOptions { IosExtension = true }; - var homePage = new HomePage(appOptions); - var app = new App.App(appOptions); - ThemeManager.SetTheme(app.Resources); - ThemeManager.ApplyResourcesTo(homePage); - if (homePage.BindingContext is HomeViewModel vm) - { - vm.StartLoginAction = () => DismissViewController(false, () => LaunchLoginFlow(vm.Email)); - vm.StartRegisterAction = () => DismissViewController(false, () => LaunchRegisterFlow()); - vm.StartSsoLoginAction = () => DismissViewController(false, () => LaunchLoginSsoFlow()); - vm.StartEnvironmentAction = () => DismissViewController(false, () => LaunchEnvironmentFlow()); - vm.CloseAction = () => CompleteRequest(); - } - - NavigateToPage(homePage); - - LogoutIfAuthed(); - } - catch (Exception ex) - { - UIPasteboard.General.String = ex.ToString(); - _labelErr.Text = ex.ToString(); + vm.StartLoginAction = () => DismissViewController(false, () => LaunchLoginFlow(vm.Email)); + vm.StartRegisterAction = () => DismissViewController(false, () => LaunchRegisterFlow()); + vm.StartSsoLoginAction = () => DismissViewController(false, () => LaunchLoginSsoFlow()); + vm.StartEnvironmentAction = () => DismissViewController(false, () => LaunchEnvironmentFlow()); + vm.CloseAction = () => CompleteRequest(); } + + NavigateToPage(homePage); + + LogoutIfAuthed(); } private void LaunchEnvironmentFlow() diff --git a/src/iOS.Autofill/CredentialProviderViewController.designer.cs b/src/iOS.Autofill/CredentialProviderViewController.designer.cs index 88a1680eb..b00f6f16a 100644 --- a/src/iOS.Autofill/CredentialProviderViewController.designer.cs +++ b/src/iOS.Autofill/CredentialProviderViewController.designer.cs @@ -12,9 +12,6 @@ namespace Bit.iOS.Autofill [Register ("CredentialProviderViewController")] partial class CredentialProviderViewController { - [Outlet] - UIKit.UILabel _labelErr { get; set; } - [Outlet] [GeneratedCode ("iOS Designer", "1.0")] UIKit.UIImageView Logo { get; set; } @@ -25,11 +22,6 @@ namespace Bit.iOS.Autofill Logo.Dispose (); Logo = null; } - - if (_labelErr != null) { - _labelErr.Dispose (); - _labelErr = null; - } } } } diff --git a/src/iOS.Autofill/MainInterface.storyboard b/src/iOS.Autofill/MainInterface.storyboard index 2c59ecd8c..7bc66f197 100644 --- a/src/iOS.Autofill/MainInterface.storyboard +++ b/src/iOS.Autofill/MainInterface.storyboard @@ -18,28 +18,18 @@ - + - - + - - - - diff --git a/src/iOS.Autofill/iOS.Autofill.csproj b/src/iOS.Autofill/iOS.Autofill.csproj index 5adbf0d98..cf8fd71b3 100644 --- a/src/iOS.Autofill/iOS.Autofill.csproj +++ b/src/iOS.Autofill/iOS.Autofill.csproj @@ -10,6 +10,8 @@ False + $(DefineConstants);ENABLED_TAP_GESTURE_RECOGNIZER_MAUI_EMBEDDED_WORKAROUND + 12.0 @@ -78,6 +80,7 @@ + diff --git a/src/iOS.Extension/LoadingViewController.TapGestureHack.cs b/src/iOS.Extension/LoadingViewController.TapGestureHack.cs new file mode 100644 index 000000000..822ba9c96 --- /dev/null +++ b/src/iOS.Extension/LoadingViewController.TapGestureHack.cs @@ -0,0 +1,68 @@ +#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) + { + ClipLogger.Log($"InitWithContext: {context?.UrlString}"); + _context = context; + _shouldInitialize = false; + } + + public void DismissLockAndContinue() + { + ClipLogger.Log("DismissLockAndContinue"); + if (UIApplication.SharedApplication.KeyWindow is null) + { + ClipLogger.Log("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) + { + ClipLogger.Log("Re-initing"); + loadingVC.InitWithContext(_context); + loadingVC.ContinueOn(); + } + else + { + ClipLogger.Log($"Not LVC: {rootVC?.GetType().FullName}"); + } + } + else + { + ClipLogger.Log($"DismissLockAndContinue RVC not correct: {UIApplication.SharedApplication.KeyWindow?.RootViewController?.GetType().FullName}"); + } + ClipLogger.Log("DismissLockAndContinue Done"); + } + + private void NavigateToPage(ContentPage page) + { + ClipLogger.Log($"NavigateToPage {page?.GetType().FullName}"); + 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 f8a8060e0..4daeb7670 100644 --- a/src/iOS.Extension/LoadingViewController.cs +++ b/src/iOS.Extension/LoadingViewController.cs @@ -12,15 +12,12 @@ using Bit.Core.Enums; using Bit.Core.Services; using Bit.Core.Utilities; using Bit.iOS.Core; -using Bit.iOS.Core.Controllers; using Bit.iOS.Core.Models; using Bit.iOS.Core.Utilities; 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; @@ -32,6 +29,8 @@ namespace Bit.iOS.Extension private NFCNdefReaderSession _nfcSession = null; private Core.NFCReaderDelegate _nfcDelegate = null; + private bool _shouldInitialize = true; + public LoadingViewController(IntPtr handle) : base(handle) { } @@ -44,8 +43,14 @@ namespace Bit.iOS.Extension base.ViewDidLoad(); Logo.Image = new UIImage(ThemeHelpers.LightTheme ? "logo.png" : "logo_white.png"); View.BackgroundColor = ThemeHelpers.SplashBackgroundColor; + + if (!_shouldInitialize) + { + return; + } + _context.ExtContext = ExtensionContext; - foreach (var item in ExtensionContext.InputItems) + foreach (var item in _context.ExtContext.InputItems) { var processed = false; foreach (var itemProvider in item.Attachments) @@ -77,6 +82,11 @@ namespace Bit.iOS.Extension public override async void ViewDidAppear(bool animated) { + if (!_shouldInitialize) + { + return; + } + try { base.ViewDidAppear(animated); @@ -111,6 +121,7 @@ namespace Bit.iOS.Extension { if (navController.TopViewController is LoginListViewController listLoginController) { + listLoginController.Context = _context; listLoginController.LoadingController = this; segue.DestinationViewController.PresentationController.Delegate = @@ -140,12 +151,23 @@ namespace Bit.iOS.Extension } } +#if !ENABLED_TAP_GESTURE_RECOGNIZER_MAUI_EMBEDDED_WORKAROUND public void DismissLockAndContinue() { Debug.WriteLine("BW Log, Dismissing lock controller."); DismissViewController(false, () => ContinueOn()); } + private void NavigateToPage(ContentPage page) + { + var navigationPage = new NavigationPage(page); + var uiController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext); + uiController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; + + PresentViewController(uiController, true, null); + } +#endif + private void ContinueOn() { Debug.WriteLine("BW Log, Segue to setup, login add or list."); @@ -221,7 +243,7 @@ namespace Bit.iOS.Extension await eventService.CollectAsync(Bit.Core.Enums.EventType.Cipher_ClientAutofilled, id); } ServiceContainer.Reset(); - ExtensionContext?.CompleteRequest(returningItems, null); + _context?.ExtContext?.CompleteRequest(returningItems, null); }); } @@ -413,6 +435,11 @@ namespace Bit.iOS.Extension private void InitApp() { + if (!_shouldInitialize) + { + return; + } + // TODO: Change for iOSCoreHelpers.InitApp(...) when implementing IAccountsManager here iOSCoreHelpers.SetupMaui(); @@ -481,10 +508,7 @@ namespace Bit.iOS.Extension vm.CloseAction = () => CompleteRequest(null, null); } - var navigationPage = new NavigationPage(homePage); - var loginController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext); - loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; - PresentViewController(loginController, true, null); + NavigateToPage(homePage); LogoutIfAuthed(); } @@ -501,10 +525,7 @@ namespace Bit.iOS.Extension vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage()); } - var navigationPage = new NavigationPage(environmentPage); - var loginController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext); - loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; - PresentViewController(loginController, true, null); + NavigateToPage(environmentPage); } private void LaunchRegisterFlow() @@ -519,10 +540,7 @@ namespace Bit.iOS.Extension vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage()); } - var navigationPage = new NavigationPage(registerPage); - var loginController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext); - loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; - PresentViewController(loginController, true, null); + NavigateToPage(registerPage); } private void LaunchLoginFlow(string email = null) @@ -542,10 +560,7 @@ namespace Bit.iOS.Extension vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage()); } - var navigationPage = new NavigationPage(loginPage); - var loginController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext); - loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; - PresentViewController(loginController, true, null); + NavigateToPage(loginPage); LogoutIfAuthed(); } @@ -565,10 +580,7 @@ namespace Bit.iOS.Extension vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage()); } - var navigationPage = new NavigationPage(loginWithDevicePage); - var loginController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext); - loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; - PresentViewController(loginController, true, null); + NavigateToPage(loginWithDevicePage); LogoutIfAuthed(); } @@ -589,10 +601,7 @@ namespace Bit.iOS.Extension vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage()); } - var navigationPage = new NavigationPage(loginPage); - var loginController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext); - loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; - PresentViewController(loginController, true, null); + NavigateToPage(loginPage); LogoutIfAuthed(); } @@ -619,10 +628,7 @@ namespace Bit.iOS.Extension vm.UpdateTempPasswordAction = () => DismissViewController(false, () => LaunchUpdateTempPasswordFlow()); } - var navigationPage = new NavigationPage(twoFactorPage); - var twoFactorController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext); - twoFactorController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; - PresentViewController(twoFactorController, true, null); + NavigateToPage(twoFactorPage); } private void LaunchSetPasswordFlow() @@ -638,10 +644,7 @@ namespace Bit.iOS.Extension vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage()); } - var navigationPage = new NavigationPage(setPasswordPage); - var setPasswordController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext); - setPasswordController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; - PresentViewController(setPasswordController, true, null); + NavigateToPage(setPasswordPage); } private void LaunchUpdateTempPasswordFlow() @@ -656,10 +659,7 @@ namespace Bit.iOS.Extension vm.LogOutAction = () => DismissViewController(false, () => LaunchHomePage()); } - var navigationPage = new NavigationPage(updateTempPasswordPage); - var updateTempPasswordController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext); - updateTempPasswordController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; - PresentViewController(updateTempPasswordController, true, null); + NavigateToPage(updateTempPasswordPage); } private void LaunchDeviceApprovalOptionsFlow() @@ -675,10 +675,7 @@ namespace Bit.iOS.Extension vm.LogInWithDeviceAction = () => DismissViewController(false, () => LaunchLoginWithDevice(AuthRequestType.AuthenticateAndUnlock, vm.Email, true)); } - var navigationPage = new NavigationPage(loginApproveDevicePage); - var loginApproveDeviceController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext); - loginApproveDeviceController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen; - PresentViewController(loginApproveDeviceController, true, null); + NavigateToPage(loginApproveDevicePage); } } } diff --git a/src/iOS.Extension/iOS.Extension.csproj b/src/iOS.Extension/iOS.Extension.csproj index dcd703b9e..0b0df3a2f 100644 --- a/src/iOS.Extension/iOS.Extension.csproj +++ b/src/iOS.Extension/iOS.Extension.csproj @@ -9,6 +9,8 @@ 1 False + + $(DefineConstants);ENABLED_TAP_GESTURE_RECOGNIZER_MAUI_EMBEDDED_WORKAROUND 11.0 Bit.iOS.Extension @@ -70,6 +72,7 @@ + diff --git a/src/iOS.ShareExtension/LoadingViewController.TapGestureHack.cs b/src/iOS.ShareExtension/LoadingViewController.TapGestureHack.cs new file mode 100644 index 000000000..7dc69428c --- /dev/null +++ b/src/iOS.ShareExtension/LoadingViewController.TapGestureHack.cs @@ -0,0 +1,22 @@ +#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 9ec181254..c77582ca1 100644 --- a/src/iOS.ShareExtension/LoadingViewController.cs +++ b/src/iOS.ShareExtension/LoadingViewController.cs @@ -137,6 +137,23 @@ 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."); @@ -197,19 +214,6 @@ namespace Bit.iOS.ShareExtension NavigateToPage(sendPage); } - 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); - } - private async Task<(string, byte[])> LoadDataBytesAsync() { var itemProvider = ExtensionContext?.InputItems.FirstOrDefault()?.Attachments?.FirstOrDefault(); diff --git a/src/iOS.ShareExtension/iOS.ShareExtension.csproj b/src/iOS.ShareExtension/iOS.ShareExtension.csproj index 34cf7d446..59c11fa82 100644 --- a/src/iOS.ShareExtension/iOS.ShareExtension.csproj +++ b/src/iOS.ShareExtension/iOS.ShareExtension.csproj @@ -9,6 +9,8 @@ 1 False + + $(DefineConstants);ENABLED_TAP_GESTURE_RECOGNIZER_MAUI_EMBEDDED_WORKAROUND 11.0 Bit.iOS.ShareExtension @@ -62,6 +64,7 @@ ExtensionNavigationController.cs +