private async void NegativeButton_Clicked(object sender, EventArgs e)
        {
            await DismissAsync();

            InputTaskCompletionSource.SetResult(_isMultiChoice ? null : -1 as object);
            _checkboxGroup?.SelectedIndices.Clear();
        }
        private async void PositiveButton_Clicked(object sender, EventArgs e)
        {
            await DismissAsync();

            var result = (_radioButtonGroup?.SelectedIndex) ?? _checkboxGroup?.SelectedIndices.ToArray() as object;

            InputTaskCompletionSource.SetResult(result);
            _checkboxGroup?.SelectedIndices.Clear();
        }
        private void CreateActions(List <string> actions, MaterialSimpleDialogConfiguration configuration)
        {
            if (actions == null || actions.Count <= 0)
            {
                throw new ArgumentException("Parameter actions should not be null or empty");
            }

            var actionModels = new List <ActionModel>();

            actions.ForEach(a =>
            {
                var preferredConfig = configuration ?? GlobalConfiguration;
                var actionModel     = new ActionModel
                {
                    Text       = a,
                    TextColor  = preferredConfig?.TextColor ?? Color.FromHex("#DE000000"),
                    FontFamily = preferredConfig != null
                        ? preferredConfig.TextFontFamily
                        : Material.FontFamily.Body1
                };
                actionModel.SelectedCommand = new Command <int>(async(position) =>
                {
                    // Prevent any parrallel execution when clicking fast on the element
                    await SemaphoreSlim.WaitAsync();

                    try
                    {
                        if (InputTaskCompletionSource?.Task.Status != TaskStatus.WaitingForActivation)
                        {
                            return;
                        }

                        actionModel.IsSelected = true;
                        await DismissAsync();
                        InputTaskCompletionSource?.SetResult(position);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        SemaphoreSlim.Release();
                    }
                });

                actionModels.Add(actionModel);
                actionModel.Index = actionModels.IndexOf(actionModel);
            });

            DialogActionList.SetValue(BindableLayout.ItemsSourceProperty, actionModels);
        }
 internal MaterialAlertDialog(string message, string title, string action1Text, string action2Text, MaterialAlertDialogConfiguration configuration = null) : this(configuration)
 {
     Message.Text           = message;
     DialogTitle.Text       = title;
     PositiveButton.Text    = action1Text;
     PositiveButton.Command = new Command(async() =>
     {
         await DismissAsync();
         InputTaskCompletionSource?.SetResult(true);
     });
     NegativeButton.Text    = action2Text;
     NegativeButton.Command = new Command(async() =>
     {
         await DismissAsync();
         InputTaskCompletionSource?.SetResult(false);
     });
 }
        internal MaterialSnackbar(string message, string actionButtonText, int msDuration = DurationLong, MaterialSnackbarConfiguration configuration = null)
        {
            InitializeComponent();
            Configure(configuration);
            Message.Text      = message;
            _duration         = msDuration;
            ActionButton.Text = actionButtonText;
            var primaryActionCommand = new Command(async() =>
            {
                _primaryActionRunning = true;
                await DismissAsync();
                InputTaskCompletionSource?.SetResult(true);
            }, () => !_primaryActionRunning);

            ActionButton.Command = primaryActionCommand;
            _hideAction          = () => InputTaskCompletionSource?.SetResult(false);
        }
        protected override bool OnBackgroundClicked()
        {
            InputTaskCompletionSource?.SetResult(string.Empty);

            return(base.OnBackgroundClicked());
        }
 protected override void OnBackButtonDismissed()
 {
     InputTaskCompletionSource?.SetResult(string.Empty);
 }
 protected override void OnBackButtonDismissed()
 {
     InputTaskCompletionSource.SetResult(-1);
 }
        protected override bool OnBackgroundClicked()
        {
            InputTaskCompletionSource?.SetResult(_isMultiChoice ? null : -1 as object);

            return(base.OnBackgroundClicked());
        }
 protected override void OnBackButtonDismissed()
 {
     InputTaskCompletionSource?.SetResult(_isMultiChoice ? null : -1 as object);
 }