Exemplo n.º 1
0
        public async override void DisplayToast(MessageDisplayParams messageParams, bool quick)
        {
            var alert = new UIAlertView(string.Empty, messageParams.Message, null, null, null);
            alert.Show();

            await Task.Delay(quick ? ShortToastDuration : LongToastDuration);
            alert.DismissWithClickedButtonIndex(0, true);
        }
        public override void DisplayMessage(MessageDisplayParams messageParams)
        {
            Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this.context);
            builder.SetTitle(messageParams.Title);
            builder.SetMessage(messageParams.Message);

            if (messageParams.PositiveAction != null)
            {
                builder.SetPositiveButton(messageParams.PositiveLabel ?? DefaultPositiveLabel, (s, e) =>
                    {
                        messageParams.PositiveAction();
                    });
            }

            if (messageParams.NegativeAction != null)
            {
                builder.SetNegativeButton(messageParams.NegativeLabel ?? DefaultNegativeLabel, (s, e) =>
                    {
                        messageParams.NegativeAction();
                    });
            }

            if (messageParams.NeutralAction != null)
            {
                builder.SetNeutralButton(messageParams.NeutralLabel ?? string.Empty, (s, e) =>
                    {
                        messageParams.NeutralAction();
                    });
            }

            var dialog = builder.Create();
            dialog.DismissEvent += (sender, e) => {
                this.messages.Remove(messageParams);
            };

            this.messages.Add(messageParams);
            this.dialogs.Add(dialog);

            dialog.Show();
        }
Exemplo n.º 3
0
        public override void DisplayMessage(MessageDisplayParams messageParams)
        {
            var labels = new List<string>();
            // TODO: read up on the HIG to get the buttons the right way around, currently cancel shows up on the left when I thought it was supposed
            // to be the right
            if (messageParams.PositiveAction != null)
            {
                // index 1
                labels.Add(messageParams.PositiveLabel ?? DefaultPositiveLabel); 
            }

            if (messageParams.NeutralAction != null)
            {
                // index 2
                labels.Add(messageParams.NeutralLabel ?? string.Empty); 
            }

            var alert = new UIAlertView(messageParams.Title, messageParams.Message, null, messageParams.NegativeLabel ?? DefaultNegativeLabel, labels.ToArray());
            alert.Clicked += (sender, e) => {
                this.HandleButtonClicked(messageParams, (UIAlertView)sender, e.ButtonIndex);
            };
            alert.Show();
        }
Exemplo n.º 4
0
 protected virtual void HandleButtonClicked(MessageDisplayParams messageParams, UIAlertView alert, nint buttonIndex)
 {
     switch (buttonIndex)
     {
         case 0:
             if (messageParams.NegativeAction != null)
             {
                 messageParams.NegativeAction();
             }
             break;
         case 1:
             if (messageParams.PositiveAction != null)
             {
                 messageParams.PositiveAction();
             }
             break;
         case 2:
             if (messageParams.NeutralAction != null)
             {
                 messageParams.NeutralAction();
             }
             break;
     }
 }
Exemplo n.º 5
0
 public virtual void DisplayToast(MessageDisplayParams messageParams, bool quick)
 {
 }
Exemplo n.º 6
0
 public virtual void DisplayMessage(MessageDisplayParams messageParams)
 {
 }
 public override void DisplayToast(MessageDisplayParams messageParams, bool quick)
 {
     Toast.MakeText(this.context, messageParams.Message, quick ? ToastLength.Short : ToastLength.Long).Show();
 }