public static void Show(IObservable <bool> hideOnFirstTrue = null, float yPosition = 75) { Top = yPosition; UIApplication.SharedApplication.InvokeOnMainThread(() => { if (_loadingBar != null) { PositionLoadingBar(); } else { _loadingBar = new LoadingBarView(0, Top, (int)UIScreen.MainScreen.Bounds.Width, 2); } _loadingBar.RemoveFromSuperview(); UIApplication.SharedApplication.KeyWindow.AddSubview(_loadingBar); }); if (hideOnFirstTrue == null) { return; } _subscription = hideOnFirstTrue.Subscribe(hide => { if (hide) { Hide(); } }); IsShown = true; }
public static void Hide() { if (_loadingBar == null) { return; } //this should put the whole line blue, but it doesn't appear because the view gets disposed too fast _loadingBar.BackgroundColor = UIColor.Blue; UIApplication.SharedApplication.InvokeOnMainThread(() => _loadingBar.RemoveFromSuperviewAnimated(() => _loadingBar = null)); if (_subscription == null) { return; } _subscription.Dispose(); IsShown = false; }