public void Hide()
 {
     _app.SafeInvokeOnMainThread(() =>
     {
         _hub.Hide(true);
     });
 }
        public static IProgressDialog Progress(UIApplication app, UIView view, ProgressConfig config)
        {
            app.SafeInvokeOnMainThread(() =>
            {
                _progressHub = MBProgressHUD.ShowHUD(view, true);
                //_progressHub.Mode = MBProgressHUDMode.DeterminateHorizontalBar;
                _progressHub.Mode                = MBProgressHUDMode.Determinate;
                _progressHub.Label.Text          = config.Text;
                _progressHub.Label.LineBreakMode = UILineBreakMode.WordWrap;
                _progressHub.Label.Lines         = int.MaxValue;
                _progressHub.MinShowTime         = 1; // The minimum time (in seconds) that the HUD is shown.

                if (config.MarkType == MarkType.Black)
                {
                    _progressHub.BackgroundView.Style = MBProgressHUDBackgroundStyle.SolidColor;
                    _progressHub.BackgroundView.Color = UIColor.Black.ColorWithAlpha(0.5f);
                }

                if (config.Cancellable)
                {
                    _progressHub.Button.SetTitle(config.CancelText, UIControlState.Normal);
                    _progressHub.Button.AddTarget((_1, _2) =>
                    {
                        config.CancelAction?.Invoke();
                        _progressHub.Hide(true);
                    }, UIControlEvent.TouchUpInside);
                }

                _progressHub.Show(true);
            });

            return(new DefaultProgressDialog(app, config, _progressHub));
        }
        public IDisposable Build(UIApplication app, SnackbarConfig config)
        {
            app.SafeInvokeOnMainThread(() =>
            {
                _snackbar?.Dismiss();

                _snackbar               = new TTGSnackbar(config.Message);
                _snackbar.Duration      = config.Duration;
                _snackbar.AnimationType = TTGSnackbarAnimationType.FadeInFadeOut;

                if (config.ActionText != null)
                {
                    _snackbar.ActionText  = config.ActionText;
                    _snackbar.ActionBlock = (_) => config.Action?.Invoke();

                    if (config.ActionTextColor != null)
                    {
                        _snackbar.ActionTextColor = config.ActionTextColor.Value.ToNative();
                    }
                }

                if (config.TextColor != null)
                {
                    _snackbar.MessageTextColor = config.TextColor.Value.ToNative();
                }

                if (config.BackgroundColor != null)
                {
                    _snackbar.BackgroundColor = config.BackgroundColor.Value.ToNative();
                }

                _snackbar.Show();
            });

            return(new DisposableAction(() => app.SafeInvokeOnMainThread(() => _snackbar?.Dismiss())));
        }
Example #4
0
        public static IDisposable Loading(UIApplication app, UIView view, LoadingConfig config)
        {
            app.SafeInvokeOnMainThread(() =>
            {
                _loadingHub                     = MBProgressHUD.ShowHUD(view, true);
                _loadingHub.Mode                = MBProgressHUDMode.Indeterminate;
                _loadingHub.Label.Text          = config.Text;
                _loadingHub.Label.LineBreakMode = UILineBreakMode.WordWrap;
                _loadingHub.Label.Lines         = int.MaxValue;
                _loadingHub.MinShowTime         = 1;         // The minimum time (in seconds) that the HUD is shown.

                if (config.MarkType == MarkType.Black)
                {
                    _loadingHub.BackgroundView.Style = MBProgressHUDBackgroundStyle.SolidColor;
                    _loadingHub.BackgroundView.Color = UIColor.Black.ColorWithAlpha(0.5f);
                }

                if (config.Cancellable)
                {
                    _loadingHub.Button.SetTitle(config.CancelText, UIControlState.Normal);
                    _loadingHub.Button.AddTarget((_1, _2) =>
                    {
                        config.CancelAction?.Invoke();
                        _loadingHub.Hide(true);
                    }, UIControlEvent.TouchUpInside);
                }

                _loadingHub.Show(true);

                if (config.Duration.HasValue)
                {
                    _loadingHub.Hide(true, config.Duration.Value.TotalSeconds);
                }

                //_loadingHub.Hide(true, 3);  // seconds
            });

            return(new DisposableAction(() => _loadingHub.Hide(true)));
        }
Example #5
0
        public static void Build(UIApplication app, UIView view, ToastConfig config)
        {
            app.SafeInvokeOnMainThread(() =>
            {
                _hub                     = MBProgressHUD.ShowHUD(view, true);
                _hub.Mode                = MBProgressHUDMode.Text;
                _hub.Label.Text          = config.Message;
                _hub.Label.LineBreakMode = UILineBreakMode.WordWrap;
                _hub.Label.Lines         = int.MaxValue;
                _hub.MinShowTime         = 1; // The minimum time (in seconds) that the HUD is shown.

                _hub.UserInteractionEnabled = false;

                if (config.TextColor.HasValue)
                {
                    _hub.Label.TextColor = config.TextColor.Value.ToNative();
                }

                if (config.BackgroundColor.HasValue)
                {
                    _hub.BezelView.BackgroundColor = config.BackgroundColor.Value.ToNative();
                }

                if (config.Position == ToastPosition.Top)
                {
                    _hub.Offset = new CoreGraphics.CGPoint(0, 0);
                }
                else if (config.Position == ToastPosition.Bottom || config.Position == ToastPosition.Default)
                {
                    _hub.Offset = new CoreGraphics.CGPoint(0, 10000);
                }

                _hub.Show(true);

                _hub.Hide(true, config.Duration.TotalSeconds);
            });
        }