Ejemplo n.º 1
0
        /// <summary>
        /// Show dialog with title and list of buttons.
        /// </summary>
        /// <param name="title">dialog title</param>
        /// <param name="buttonsText">texts for buttons</param>
        /// <returns>the text of touched button</returns>
        public static async Task <string> ShowAsyncAlertWithTitleAndListButtons(string title, string[] buttonsText)
        {
            UniroidDialog.ShowListButtons(title, buttonsText);

            int?result = null;

            OnClickEvent += WaitForClickEvent;

            while (!result.HasValue)
            {
                await Task.Delay(TimeSpan.FromMilliseconds(50));
            }

            return(buttonsText[result.Value]);


            void WaitForClickEvent(int clickResult)
            {
                OnClickEvent -= WaitForClickEvent;
                result        = clickResult;
            }
        }