SG-396 Fix tappable area after hiding account switching (#1956)

This commit is contained in:
Federico Maccaroni 2022-06-16 18:09:50 -03:00 committed by GitHub
parent 7c311fbb55
commit b2500557e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View file

@ -65,6 +65,8 @@ namespace Bit.App.Controls
public bool LongPressAccountEnabled { get; set; } = true; public bool LongPressAccountEnabled { get; set; } = true;
public Action AfterHide { get; set; }
public async Task ToggleVisibilityAsync() public async Task ToggleVisibilityAsync()
{ {
if (IsVisible) if (IsVisible)
@ -137,6 +139,8 @@ namespace Bit.App.Controls
// remove overlay // remove overlay
IsVisible = false; IsVisible = false;
AfterHide?.Invoke();
}); });
} }

View file

@ -32,7 +32,14 @@ namespace Bit.iOS.Core.Utilities
{ {
var overlay = new AccountSwitchingOverlayView() var overlay = new AccountSwitchingOverlayView()
{ {
LongPressAccountEnabled = false LongPressAccountEnabled = false,
AfterHide = () =>
{
if (containerView != null)
{
containerView.Hidden = true;
}
}
}; };
var vm = new AccountSwitchingOverlayViewModel(_stateService, _messagingService, _logger) var vm = new AccountSwitchingOverlayViewModel(_stateService, _messagingService, _logger)
@ -40,6 +47,7 @@ namespace Bit.iOS.Core.Utilities
FromIOSExtension = true FromIOSExtension = true
}; };
overlay.BindingContext = vm; overlay.BindingContext = vm;
overlay.IsVisible = false;
var renderer = Platform.CreateRenderer(overlay.Content); var renderer = Platform.CreateRenderer(overlay.Content);
renderer.SetElementSize(new Size(containerView.Frame.Size.Width, containerView.Frame.Size.Height)); renderer.SetElementSize(new Size(containerView.Frame.Size.Width, containerView.Frame.Size.Height));
@ -63,8 +71,13 @@ namespace Bit.iOS.Core.Utilities
public void OnToolbarItemActivated(AccountSwitchingOverlayView accountSwitchingOverlayView, UIView containerView) public void OnToolbarItemActivated(AccountSwitchingOverlayView accountSwitchingOverlayView, UIView containerView)
{ {
var overlayVisible = accountSwitchingOverlayView.IsVisible; var overlayVisible = accountSwitchingOverlayView.IsVisible;
accountSwitchingOverlayView.ToggleVisibililtyCommand.Execute(null); if (!overlayVisible)
{
// So that the animation doesn't break we only care about showing it
// and the hiding if done through AccountSwitchingOverlayView -> AfterHide
containerView.Hidden = false; containerView.Hidden = false;
}
accountSwitchingOverlayView.ToggleVisibililtyCommand.Execute(null);
containerView.UserInteractionEnabled = !overlayVisible; containerView.UserInteractionEnabled = !overlayVisible;
containerView.Subviews[0].UserInteractionEnabled = !overlayVisible; containerView.Subviews[0].UserInteractionEnabled = !overlayVisible;
} }