mirror of
https://github.com/bitwarden/android.git
synced 2024-12-27 11:28:28 +03:00
PM-3350 iOS applied workaround on the iOS Autofill and Share extension to maui embed the navigation page with its content page in the Window
This commit is contained in:
parent
a5804df6a3
commit
7f4bbafe3c
5 changed files with 33 additions and 85 deletions
|
@ -79,20 +79,6 @@ namespace Bit.App.Pages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//protected override void OnHandlerChanged()
|
|
||||||
//{
|
|
||||||
// base.OnHandlerChanged();
|
|
||||||
|
|
||||||
// if (!_appOptions.IosExtension)
|
|
||||||
// {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// var window = new Window();
|
|
||||||
// window.ToHandler(this.Handler.MauiContext);
|
|
||||||
// window.Page = this;
|
|
||||||
//}
|
|
||||||
|
|
||||||
protected override void OnNavigatingFrom(NavigatingFromEventArgs args)
|
protected override void OnNavigatingFrom(NavigatingFromEventArgs args)
|
||||||
{
|
{
|
||||||
base.OnNavigatingFrom(args);
|
base.OnNavigatingFrom(args);
|
||||||
|
|
|
@ -22,30 +22,6 @@ using UIKit;
|
||||||
|
|
||||||
namespace Bit.iOS.Autofill
|
namespace Bit.iOS.Autofill
|
||||||
{
|
{
|
||||||
public partial class NavigationPageFix : NavigationPage
|
|
||||||
{
|
|
||||||
public NavigationPageFix()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public NavigationPageFix(Page root) : base(root)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnHandlerChanged()
|
|
||||||
{
|
|
||||||
base.OnHandlerChanged();
|
|
||||||
|
|
||||||
var window = new Window(this);
|
|
||||||
|
|
||||||
//window.Page = this;
|
|
||||||
window.ToHandler(this.Handler.MauiContext);
|
|
||||||
|
|
||||||
//window.Page = this;
|
|
||||||
//window.ToHandler(MauiContextSingleton.Instance.MauiContext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public partial class CredentialProviderViewController : ASCredentialProviderViewController, IAccountsManagerHost
|
public partial class CredentialProviderViewController : ASCredentialProviderViewController, IAccountsManagerHost
|
||||||
{
|
{
|
||||||
private Context _context;
|
private Context _context;
|
||||||
|
@ -164,10 +140,8 @@ namespace Bit.iOS.Autofill
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
UIPasteboard.General.String = ex.ToString();
|
LoggerHelper.LogEvenIfCantBeResolved(ex);
|
||||||
_labelErr.Text = ex.ToString();
|
throw;
|
||||||
//LoggerHelper.LogEvenIfCantBeResolved(ex);
|
|
||||||
//throw;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,6 +261,7 @@ namespace Bit.iOS.Autofill
|
||||||
PerformSegue("setupSegue", this);
|
PerformSegue("setupSegue", this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_context.ServiceIdentifiers == null || _context.ServiceIdentifiers.Length == 0)
|
if (_context.ServiceIdentifiers == null || _context.ServiceIdentifiers.Length == 0)
|
||||||
{
|
{
|
||||||
PerformSegue("loginSearchSegue", this);
|
PerformSegue("loginSearchSegue", this);
|
||||||
|
@ -432,6 +407,19 @@ 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()
|
private void LaunchHomePage()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -450,10 +438,7 @@ namespace Bit.iOS.Autofill
|
||||||
vm.CloseAction = () => CompleteRequest();
|
vm.CloseAction = () => CompleteRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPageFix(homePage);
|
NavigateToPage(homePage);
|
||||||
var loginController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext);
|
|
||||||
loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
|
||||||
PresentViewController(loginController, true, null);
|
|
||||||
|
|
||||||
LogoutIfAuthed();
|
LogoutIfAuthed();
|
||||||
}
|
}
|
||||||
|
@ -476,10 +461,7 @@ namespace Bit.iOS.Autofill
|
||||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPageFix(environmentPage);
|
NavigateToPage(environmentPage);
|
||||||
var loginController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext);
|
|
||||||
loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
|
||||||
PresentViewController(loginController, true, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LaunchRegisterFlow()
|
private void LaunchRegisterFlow()
|
||||||
|
@ -494,10 +476,7 @@ namespace Bit.iOS.Autofill
|
||||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPageFix(registerPage);
|
NavigateToPage(registerPage);
|
||||||
var loginController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext);
|
|
||||||
loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
|
||||||
PresentViewController(loginController, true, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LaunchLoginFlow(string email = null)
|
private void LaunchLoginFlow(string email = null)
|
||||||
|
@ -517,10 +496,7 @@ namespace Bit.iOS.Autofill
|
||||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPageFix(loginPage);
|
NavigateToPage(loginPage);
|
||||||
var loginController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext);
|
|
||||||
loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
|
||||||
PresentViewController(loginController, true, null);
|
|
||||||
|
|
||||||
LogoutIfAuthed();
|
LogoutIfAuthed();
|
||||||
}
|
}
|
||||||
|
@ -540,10 +516,7 @@ namespace Bit.iOS.Autofill
|
||||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPageFix(loginWithDevicePage);
|
NavigateToPage(loginWithDevicePage);
|
||||||
var loginController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext);
|
|
||||||
loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
|
||||||
PresentViewController(loginController, true, null);
|
|
||||||
|
|
||||||
LogoutIfAuthed();
|
LogoutIfAuthed();
|
||||||
}
|
}
|
||||||
|
@ -564,10 +537,7 @@ namespace Bit.iOS.Autofill
|
||||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPageFix(loginPage);
|
NavigateToPage(loginPage);
|
||||||
var loginController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext);
|
|
||||||
loginController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
|
||||||
PresentViewController(loginController, true, null);
|
|
||||||
|
|
||||||
LogoutIfAuthed();
|
LogoutIfAuthed();
|
||||||
}
|
}
|
||||||
|
@ -594,10 +564,7 @@ namespace Bit.iOS.Autofill
|
||||||
vm.UpdateTempPasswordAction = () => DismissViewController(false, () => LaunchUpdateTempPasswordFlow());
|
vm.UpdateTempPasswordAction = () => DismissViewController(false, () => LaunchUpdateTempPasswordFlow());
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPageFix(twoFactorPage);
|
NavigateToPage(twoFactorPage);
|
||||||
var twoFactorController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext);
|
|
||||||
twoFactorController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
|
||||||
PresentViewController(twoFactorController, true, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LaunchSetPasswordFlow()
|
private void LaunchSetPasswordFlow()
|
||||||
|
@ -613,10 +580,7 @@ namespace Bit.iOS.Autofill
|
||||||
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
vm.CloseAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPageFix(setPasswordPage);
|
NavigateToPage(setPasswordPage);
|
||||||
var setPasswordController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext);
|
|
||||||
setPasswordController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
|
||||||
PresentViewController(setPasswordController, true, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LaunchUpdateTempPasswordFlow()
|
private void LaunchUpdateTempPasswordFlow()
|
||||||
|
@ -631,10 +595,7 @@ namespace Bit.iOS.Autofill
|
||||||
vm.LogOutAction = () => DismissViewController(false, () => LaunchHomePage());
|
vm.LogOutAction = () => DismissViewController(false, () => LaunchHomePage());
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPageFix(updateTempPasswordPage);
|
NavigateToPage(updateTempPasswordPage);
|
||||||
var updateTempPasswordController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext);
|
|
||||||
updateTempPasswordController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
|
||||||
PresentViewController(updateTempPasswordController, true, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LaunchDeviceApprovalOptionsFlow()
|
private void LaunchDeviceApprovalOptionsFlow()
|
||||||
|
@ -650,10 +611,7 @@ namespace Bit.iOS.Autofill
|
||||||
vm.LogInWithDeviceAction = () => DismissViewController(false, () => LaunchLoginWithDevice(AuthRequestType.AuthenticateAndUnlock, vm.Email, true));
|
vm.LogInWithDeviceAction = () => DismissViewController(false, () => LaunchLoginWithDevice(AuthRequestType.AuthenticateAndUnlock, vm.Email, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
var navigationPage = new NavigationPageFix(loginApproveDevicePage);
|
NavigateToPage(loginApproveDevicePage);
|
||||||
var loginApproveDeviceController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext);
|
|
||||||
loginApproveDeviceController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
|
||||||
PresentViewController(loginApproveDeviceController, true, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task SetPreviousPageInfoAsync() => Task.CompletedTask;
|
public Task SetPreviousPageInfoAsync() => Task.CompletedTask;
|
||||||
|
|
|
@ -16,8 +16,8 @@ namespace Bit.iOS.Core.Handlers
|
||||||
protected override UIWindow CreatePlatformElement()
|
protected override UIWindow CreatePlatformElement()
|
||||||
{
|
{
|
||||||
// Haven't tested
|
// Haven't tested
|
||||||
return UIApplication.SharedApplication.Delegate.GetWindow();
|
//return UIApplication.SharedApplication.Delegate.GetWindow();
|
||||||
//return Platform.GetCurrentUIViewController().View.Window;
|
return Platform.GetCurrentUIViewController().View.Window;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Bit.iOS.Core.Utilities
|
||||||
})
|
})
|
||||||
.UseMauiEmbedding<Application>();
|
.UseMauiEmbedding<Application>();
|
||||||
// Register the Window
|
// Register the Window
|
||||||
builder.Services.Add(new ServiceDescriptor(typeof(UIWindow), UIApplication.SharedApplication.KeyWindow));
|
builder.Services.Add(new ServiceDescriptor(typeof(UIWindow), _ => UIApplication.SharedApplication.KeyWindow, ServiceLifetime.Singleton));
|
||||||
var mauiApp = builder.Build();
|
var mauiApp = builder.Build();
|
||||||
|
|
||||||
MauiContextSingleton.Instance.Init(new MauiContext(mauiApp.Services));
|
MauiContextSingleton.Instance.Init(new MauiContext(mauiApp.Services));
|
||||||
|
|
|
@ -200,6 +200,10 @@ namespace Bit.iOS.ShareExtension
|
||||||
private void NavigateToPage(ContentPage page)
|
private void NavigateToPage(ContentPage page)
|
||||||
{
|
{
|
||||||
var navigationPage = new NavigationPage(page);
|
var navigationPage = new NavigationPage(page);
|
||||||
|
|
||||||
|
var window = new Window(navigationPage);
|
||||||
|
window.ToHandler(MauiContextSingleton.Instance.MauiContext);
|
||||||
|
|
||||||
_currentModalController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext);
|
_currentModalController = navigationPage.ToUIViewController(MauiContextSingleton.Instance.MauiContext);
|
||||||
_currentModalController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
_currentModalController.ModalPresentationStyle = UIModalPresentationStyle.FullScreen;
|
||||||
_presentingOnNavigationPage = true;
|
_presentingOnNavigationPage = true;
|
||||||
|
|
Loading…
Reference in a new issue