1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-02 00:23:15 +00:00

PM-3350 Fix iOS extensions navigation and Window/RootViewController handling for TapGestureRecognizer to work

This commit is contained in:
Federico Maccaroni
2023-12-07 17:40:20 -03:00
parent a5888827c9
commit a4a3d31c19
11 changed files with 279 additions and 149 deletions

View File

@@ -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

View File

@@ -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();

View File

@@ -9,6 +9,8 @@
<ApplicationVersion>1</ApplicationVersion>
<EnableDefaultCompileItems>False</EnableDefaultCompileItems>
<DefineConstants>$(DefineConstants);ENABLED_TAP_GESTURE_RECOGNIZER_MAUI_EMBEDDED_WORKAROUND</DefineConstants>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<RootNamespace>Bit.iOS.ShareExtension</RootNamespace>
@@ -62,6 +64,7 @@
<Compile Include="ExtensionNavigationController.designer.cs">
<DependentUpon>ExtensionNavigationController.cs</DependentUpon>
</Compile>
<Compile Include="LoadingViewController.TapGestureHack.cs" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="..\iOS\Resources\logo_white%403x.png">