public async Task ShowAsync(string message, SnackbarDuration duration, string buttonText, ICommand command)
        {
            this.Text       = message;
            this.ButtonText = buttonText;
            this.Command    = command;

            await OpenAsync();

            if (duration == SnackbarDuration.SHORT)
            {
                await Task.Delay(TimeSpan.FromSeconds(3));
            }
            else
            {
                await Task.Delay(TimeSpan.FromSeconds(5));
            }

            await CloseAsync();
        }
        public static Snackbar Make(Grid Grid, String Message, SnackbarDuration Length)
        {
            Snackbar snack = new Snackbar()
            {
                InAppNotification = new InAppNotification()
                {
                    Style = Application.Current.Resources["MSEdgeNotificationStyle"] as Style
                },
                RootGrid = Grid,
                Message  = Message,
                Duration = (int)Length
            };

            snack.InAppNotification.Closed += (sender, e) =>
            {
                snack.RootGrid.Children.Remove(snack.InAppNotification);
            };

            return(snack);
        }
Esempio n. 3
0
        public static async Task ShowSuccessSnackBarAsync(this Page page, string message, SnackbarDuration duration = SnackbarDuration.Short)
        {
            var messageOptions = new MessageOptions
            {
                Foreground = Color.White,
                Message    = message
            };

            var options = new SnackBarOptions()
            {
                MessageOptions  = messageOptions,
                Duration        = duration == SnackbarDuration.Long ? TimeSpan.FromMilliseconds(5000) : TimeSpan.FromMilliseconds(2500),
                BackgroundColor = Color.FromHex("20be28"),
                IsRtl           = false,
            };
            await page.DisplaySnackBarAsync(options);
        }
Esempio n. 4
0
 public static async Task ShowWarningSnackBarAsync(this Page page, string message, SnackbarDuration duration = SnackbarDuration.Short)
 {
     var messageOptions = new MessageOptions
     {
         Foreground = Color.Black,
         Message    = message
     };
     var options = new ToastOptions
     {
         MessageOptions  = messageOptions,
         Duration        = duration == SnackbarDuration.Long ? TimeSpan.FromMilliseconds(5000) : TimeSpan.FromMilliseconds(2500),
         BackgroundColor = Color.FromHex("ffd000"),
         IsRtl           = false,
     };
     await page.DisplayToastAsync(options);
 }
 public ISnackbarExtension WithDuration(SnackbarDuration duration) => WithDuration((int)duration);