diff --git a/src/iOS.Core/Views/Toast.cs b/src/iOS.Core/Views/Toast.cs index f99c51210..80ec96a57 100644 --- a/src/iOS.Core/Views/Toast.cs +++ b/src/iOS.Core/Views/Toast.cs @@ -12,7 +12,8 @@ namespace Bit.iOS.Core.Views private NSLayoutConstraint _rightMarginConstraint; private NSLayoutConstraint _bottomMarginConstraint; - public Toast(string text) : base(CoreGraphics.CGRect.FromLTRB(0, 0, 320, 44)) + public Toast(string text) + : base(CoreGraphics.CGRect.FromLTRB(0, 0, 320, 44)) { TranslatesAutoresizingMaskIntoConstraints = false; BackgroundColor = UIColor.DarkGray; @@ -53,7 +54,7 @@ namespace Bit.iOS.Core.Views public UILabel MessageLabel { get; set; } public nfloat LeftMargin { get; set; } = 5; public nfloat RightMargin { get; set; } = 5; - public nfloat BottomMargin { get; set; } = 55; + public nfloat BottomMargin { get; set; } = 5; public nfloat Height { get; set; } = 44; public void Show() diff --git a/src/iOS/Controls/ExtendedTabbedPageRenderer.cs b/src/iOS/Controls/ExtendedTabbedPageRenderer.cs index 21b66c87c..225003486 100644 --- a/src/iOS/Controls/ExtendedTabbedPageRenderer.cs +++ b/src/iOS/Controls/ExtendedTabbedPageRenderer.cs @@ -35,8 +35,7 @@ namespace Bit.iOS.Controls return; } - var tabs = Element as TabbedPage; - if(tabs != null) + if(Element is TabbedPage tabs) { for(int i = 0; i < TabBar.Items.Length; i++) { diff --git a/src/iOS/Services/DeviceActionService.cs b/src/iOS/Services/DeviceActionService.cs index 5e49ea8ba..82da6657a 100644 --- a/src/iOS/Services/DeviceActionService.cs +++ b/src/iOS/Services/DeviceActionService.cs @@ -31,10 +31,17 @@ namespace Bit.iOS.Services public void Toast(string text, bool longDuration = false) { - new Toast(text) + var t = new Toast(text) { Duration = TimeSpan.FromSeconds(longDuration ? 5 : 3) - }.Show(); + }; + + if(TabBarVisible()) + { + t.BottomMargin = 55; + } + + t.Show(); } public void CopyToClipboard(string text) @@ -278,13 +285,8 @@ namespace Bit.iOS.Services _progressAlert.View.TintColor = UIColor.Black; _progressAlert.View.Add(loadingIndicator); - var window = UIApplication.SharedApplication.KeyWindow; - var vc = window.RootViewController; - while(vc.PresentedViewController != null) - { - vc = vc.PresentedViewController; - } - vc.PresentViewController(_progressAlert, true, null); + var vc = GetPresentedViewController(); + vc?.PresentViewController(_progressAlert, true, null); } public void HideLoading() @@ -304,5 +306,23 @@ namespace Bit.iOS.Services { throw new NotImplementedException(); } + + private UIViewController GetPresentedViewController() + { + var window = UIApplication.SharedApplication.KeyWindow; + var vc = window.RootViewController; + while(vc.PresentedViewController != null) + { + vc = vc.PresentedViewController; + } + + return vc; + } + + private bool TabBarVisible() + { + var vc = GetPresentedViewController(); + return vc?.TabBarController != null && !vc.TabBarController.TabBar.Hidden; + } } }