Example #1
0
 public Task SnackbarAsync(
     string message,
     int msDuration = MaterialSnackbar.DurationLong,
     MaterialSnackbarConfiguration configuration = null)
 {
     return(MaterialSnackbar.ShowAsync(message, msDuration, configuration));
 }
        internal static async Task <MaterialSnackbar> Loading(string message, MaterialSnackbarConfiguration configuration = null)
        {
            var snackbar = new MaterialSnackbar(message, null, null, null, DURATION_INDEFINITE, configuration);
            await snackbar.ShowAsync();

            return(snackbar);
        }
        internal static async Task <IMaterialModalPage> Loading(string message, MaterialSnackbarConfiguration configuration = null)
        {
            var snackbar = new MaterialSnackbar(message, null, DurationIndefinite, configuration);
            await snackbar.ShowAsync();

            return(snackbar);
        }
Example #4
0
 public Task <bool> SnackbarAsync(
     string message,
     string actionButtonText,
     int msDuration = MaterialSnackbar.DurationLong,
     MaterialSnackbarConfiguration configuration = null)
 {
     return(MaterialSnackbar.ShowAsync(message, actionButtonText, msDuration, configuration));
 }
Example #5
0
        protected override void OnInitialized()
        {
            InitializeComponent();
            XF.Material.Forms.Material.Init(this);
            client = new HttpClient();
            StartUp();

            snackBarConfiguration = new MaterialSnackbarConfiguration()
            {
                MessageTextColor = Color.FromHex("FFFFFF"),
                TintColor        = Color.Red.MultiplyAlpha(0.8),
                CornerRadius     = 5
            };
        }
Example #6
0
        private async void ToolbarItem_Activated(object sender, EventArgs e)
        {
            try
            {
                var snackbarConfiguration = new MaterialSnackbarConfiguration()
                {
                    BackgroundColor  = XF.Material.Forms.Material.GetResource <Color>(MaterialConstants.Color.ON_BACKGROUND),
                    ButtonAllCaps    = true,
                    TintColor        = Color.White,
                    MessageTextColor = XF.Material.Forms.Material.GetResource <Color>(MaterialConstants.Color.ON_PRIMARY).MultiplyAlpha(0.8)
                };

                var res = await MaterialDialog.Instance.SnackbarAsync(message : "Confirme para eliminar",
                                                                      actionButtonText : "Eliminar",
                                                                      configuration : snackbarConfiguration);

                if (res == true)
                {
                    control.ShowLoading("Eliminando");
                    string url = baseurl + "/Api/lista_espera/delete.php?idlista=" + ids;

                    HttpClient          client  = new HttpClient();
                    HttpResponseMessage connect = await client.GetAsync(url);

                    if (connect.StatusCode == HttpStatusCode.OK)
                    {
                        url     = baseurl + "/Api/item_espera/delete.php?idlista=" + ids;
                        connect = await client.GetAsync(url);

                        if (connect.StatusCode == HttpStatusCode.OK)
                        {
                            control.ShowAlert("Lista de espera eliminada", "Eliminada", "Ok");
                            getLists(ids);
                        }
                        else
                        {
                            control.ShowAlert("No se pudo eliminar los items", "Error", "Ok");
                        }
                    }
                    else
                    {
                        control.ShowAlert("No se pudo eliminar la lista", "Error", "Ok");
                    }
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Error", "Error: " + ex, "ok");
            }
        }
        private void Configure(MaterialSnackbarConfiguration configuration)
        {
            var preferredConfig = configuration ?? GlobalConfiguration;

            if (preferredConfig != null)
            {
                Message.FontFamily        = preferredConfig.MessageFontFamily;
                Message.TextColor         = preferredConfig.MessageTextColor;
                Container.BackgroundColor = preferredConfig.BackgroundColor;
                ActionButton.TextColor    = preferredConfig.TintColor;
                ActionButton.FontFamily   = preferredConfig.ButtonFontFamily;
                ActionButton.AllCaps      = preferredConfig.ButtonAllCaps;
            }
        }
        private void Configure(MaterialSnackbarConfiguration configuration)
        {
            var preferredConfig = configuration ?? GlobalConfiguration;

            if (preferredConfig == null)
            {
                return;
            }
            Message.FontFamily        = preferredConfig.MessageFontFamily;
            Message.TextColor         = preferredConfig.MessageTextColor;
            Container.BackgroundColor = preferredConfig.BackgroundColor;
            ActionButton.TextColor    = preferredConfig.TintColor;
            ActionButton.FontFamily   = preferredConfig.ButtonFontFamily;
            ActionButton.AllCaps      = preferredConfig.ButtonAllCaps;
            Container.Margin          = new Thickness(8, 0, 8, preferredConfig.BottomOffset);
        }
        private void Configure(MaterialSnackbarConfiguration configuration)
        {
            var preferredConfig = configuration ?? GlobalConfiguration;

            if (preferredConfig == null)
            {
                return;
            }
            Message.FontFamily        = preferredConfig.MessageFontFamily;
            Message.TextColor         = preferredConfig.MessageTextColor;
            Container.BackgroundColor = preferredConfig.BackgroundColor;
            ActionButton.TextColor    = preferredConfig.TintColor;
            ActionButton.FontFamily   = preferredConfig.ButtonFontFamily;
            ActionButton.AllCaps      = preferredConfig.ButtonAllCaps;
            Container.Margin          = preferredConfig.Margin == default ? Material.GetResource <Thickness>("Material.Snackbar.Margin") : preferredConfig.Margin;
        }
Example #10
0
        public static async Task ShowSnackbarMessage(string message, bool isDurationLong = false, bool isError = false)
        {
            MaterialSnackbarConfiguration msc = new MaterialSnackbarConfiguration
            {
                BackgroundColor = isError ? XF.Material.Forms.Material.GetResource <Color>(MaterialConstants.Color.ERROR)
                                    : XF.Material.Forms.Material.GetResource <Color>(MaterialConstants.Color.PRIMARY),
                CornerRadius     = 4,
                MessageTextColor = Color.White,
                ScrimColor       = Color.Transparent,
                TintColor        = Color.AliceBlue
            };
            int duration = isDurationLong ? MaterialSnackbar.DurationLong : MaterialSnackbar.DurationShort;

            await MaterialDialog.Instance.SnackbarAsync(message : message,
                                                        msDuration : duration,
                                                        configuration : msc);
        }
Example #11
0
 public void SetGlobalStyles(
     MaterialAlertDialogConfiguration dialogConfiguration                    = null,
     MaterialLoadingDialogConfiguration loadingDialogConfiguration           = null,
     MaterialSnackbarConfiguration snackbarConfiguration                     = null,
     MaterialSimpleDialogConfiguration simpleDialogConfiguration             = null,
     MaterialConfirmationDialogConfiguration confirmationDialogConfiguration = null,
     MaterialInputDialogConfiguration inputDialogConfiguration               = null,
     MaterialAlertDialogConfiguration customContentDialogConfiguration       = null)
 {
     MaterialAlertDialog.GlobalConfiguration        = dialogConfiguration;
     MaterialLoadingDialog.GlobalConfiguration      = loadingDialogConfiguration;
     MaterialSnackbar.GlobalConfiguration           = snackbarConfiguration;
     MaterialSimpleDialog.GlobalConfiguration       = simpleDialogConfiguration;
     MaterialConfirmationDialog.GlobalConfiguration = confirmationDialogConfiguration;
     MaterialInputDialog.GlobalConfiguration        = inputDialogConfiguration;
     MaterialDialogFragment.GlobalConfiguration     = customContentDialogConfiguration;
 }
Example #12
0
        private async void  BtnClick_ClickedAsync(object sender, EventArgs e)
        {
            using (await MaterialDialog.Instance.LoadingDialogAsync(message: $"Something is running...{txti.Text}"))
            {
                await Task.Delay(5000);  // Represents a task that is running.
            }

            var config = new MaterialInputDialogConfiguration()
            {
                InputType             = MaterialTextFieldInputType.Password,
                CornerRadius          = 8,
                BackgroundColor       = Color.FromHex("#2c3e50"),
                InputTextColor        = Color.White,
                InputPlaceholderColor = Color.White.MultiplyAlpha(0.6),
                TintColor             = Color.White,
                TitleTextColor        = Color.White,
                MessageTextColor      = Color.FromHex("#DEFFFFFF")
            };

            var input = await MaterialDialog.Instance.InputAsync(title : "Deactivate account",
                                                                 message : "To continue, please enter your current password",
                                                                 inputPlaceholder : "Password",
                                                                 confirmingText : "Deactivate",
                                                                 configuration : config);

            await MaterialDialog.Instance.LoadingDialogAsync(message : $"{input}");

            await Task.Delay(5000);

            var snackbarConfiguration = new MaterialSnackbarConfiguration()
            {
                BackgroundColor   = XF.Material.Forms.Material.GetResource <Color>(MaterialConstants.Color.PRIMARY),
                MessageFontFamily = XF.Material.Forms.Material.GetResource <OnPlatform <string> >("FontFamily.OpenSansRegular"),
                ButtonAllCaps     = true,
                ButtonFontFamily  = XF.Material.Forms.Material.GetResource <OnPlatform <string> >("FontFamily.OpenSansSemiBold"),
                TintColor         = Color.White,
                MessageTextColor  = XF.Material.Forms.Material.GetResource <Color>(MaterialConstants.Color.ON_PRIMARY).MultiplyAlpha(0.8)
            };

            await Task.Delay(5000);

            await MaterialDialog.Instance.SnackbarAsync(message : "This is a snackbar.", actionButtonText : "Got It", configuration : snackbarConfiguration);

            await Task.Delay(5000);
        }
Example #13
0
        protected override bool OnBackButtonPressed()
        {
            // return base.OnBackButtonPressed();
            var snackBarconfiguration = new MaterialSnackbarConfiguration()
            {
                TintColor    = Color.FromHex("#00FF01"),
                CornerRadius = 20,
                //  MessageTextColor = Color.White.MultiplyAlpha(0.6),
                MessageTextColor = Color.White,
                BackgroundColor  = Color.FromHex("#010088")
            };

            MaterialDialog.Instance.SnackbarAsync(message: "Click on the top Back arrow to exit ",
                                                  actionButtonText: "OK",
                                                  msDuration: 3000,
                                                  configuration: snackBarconfiguration);

            return(true);
        }
Example #14
0
 /// <summary>
 /// Shows a snackbar indicating a running task.
 /// </summary>
 /// <param name="message">The message of the snackbar.</param>
 /// <param name="configuration">The style of the snackbar.</param>
 public static async Task <IMaterialModalPage> ShowLoadingSnackbarAsync(string message, MaterialSnackbarConfiguration configuration = null)
 {
     return(await MaterialSnackbar.Loading(message, configuration));
 }
        internal static async Task <bool> ShowAsync(string message, string actionButtonText, int msDuration = DURATION_LONG, MaterialSnackbarConfiguration configuration = null)
        {
            var tcs      = new TaskCompletionSource <bool>();
            var snackbar = new MaterialSnackbar(message, actionButtonText, () => tcs.SetResult(true), () => tcs.SetResult(false), msDuration, configuration);
            await snackbar.ShowAsync();

            return(await tcs.Task);
        }
 internal static async Task ShowAsync(string message, int msDuration = 3000, MaterialSnackbarConfiguration configuration = null)
 {
     var snackbar = new MaterialSnackbar(message, null, null, null, msDuration, configuration);
     await snackbar.ShowAsync();
 }
Example #17
0
 /// <summary>
 /// Shows a snackbar with no action.
 /// </summary>
 /// <param name="message">The message of the snackbar.</param>
 /// <param name="msDuration">The duration, in milliseconds, before the snackbar is automatically dismissed.</param>
 /// <param name="configuration">The style of the snackbar.</param>
 public static async Task ShowSnackbarAsync(string message, int msDuration = MaterialSnackbar.DURATION_LONG, MaterialSnackbarConfiguration configuration = null)
 {
     await MaterialSnackbar.ShowAsync(message, msDuration, configuration);
 }
 internal MaterialSnackbar(string message, string actionButtonText, Action primaryAction = null, Action hideAction = null, int msDuration = DURATION_LONG, MaterialSnackbarConfiguration configuration = null)
 {
     this.InitializeComponent();
     this.Configure(configuration);
     Message.Text          = message;
     _duration             = msDuration;
     ActionButton.Text     = actionButtonText;
     _primaryActionCommand = new Command(() => this.RunPrimaryAction(primaryAction), () => !_primaryActionRunning);
     ActionButton.Command  = _primaryActionCommand;
     _hideAction           = hideAction;
 }
Example #19
0
 /// <summary>
 /// Sets the global styles for <see cref="MaterialAlertDialog"/>, <see cref="MaterialLoadingDialog"/>,and <see cref="MaterialSnackbar"/>.
 /// </summary>
 /// <param name="dialogConfiguration">Global style for <see cref="MaterialAlertDialog"/>.</param>
 /// <param name="loadingDialogConfiguration">Global style for <see cref="MaterialLoadingDialog"/>.</param>
 /// <param name="snackbarConfiguration">Global style for <see cref="MaterialSnackbar"/>.</param>
 public static void SetGlobalStyles(MaterialAlertDialogConfiguration dialogConfiguration, MaterialLoadingDialogConfiguration loadingDialogConfiguration, MaterialSnackbarConfiguration snackbarConfiguration)
 {
     MaterialAlertDialog.GlobalConfiguration   = dialogConfiguration;
     MaterialLoadingDialog.GlobalConfiguration = loadingDialogConfiguration;
     MaterialSnackbar.GlobalConfiguration      = snackbarConfiguration;
 }
Example #20
0
 public Task <IMaterialModalPage> LoadingSnackbarAsync(
     string message,
     MaterialSnackbarConfiguration configuration = null)
 {
     return(MaterialSnackbar.Loading(message, configuration));
 }
 internal MaterialSnackbar(string message, string actionButtonText, int msDuration = DurationLong, MaterialSnackbarConfiguration configuration = null)
 {
     this.InitializeComponent();
     this.Configure(configuration);
     Message.Text          = message;
     _duration             = msDuration;
     ActionButton.Text     = actionButtonText;
     _primaryActionCommand = new Command(async() =>
     {
         _primaryActionRunning = true;
         await this.DismissAsync();
         this.InputTaskCompletionSource?.SetResult(true);
     }, () => !_primaryActionRunning);
     ActionButton.Command = _primaryActionCommand;
     _hideAction          = () => this.InputTaskCompletionSource?.SetResult(false);
 }
Example #22
0
        protected override async void OnResume()
        {
            lstMessage = new List <clsMessages>();
            var snackbarConfiguration = new MaterialSnackbarConfiguration()
            {
                TintColor        = Color.White,
                MessageTextColor = HttpRequest.CheckConnection() ? Color.White : Color.Red
            };

            if (!HttpRequest.CheckConnection())
            {
                await DependencyService.Get <IXSnack>().ShowMessageAsync("You are not connected to internet.");
            }
            else
            {
                await DependencyService.Get <IXSnack>().ShowMessageAsync("You are connected to internet.");

                DependencyService.Get <IProgressBar>().Show(Resx.AppResources.pleaseWait);
                var data = App.database.GetBooking();
                if (data != null)
                {
                    if (data.Count > 0)
                    {
                        try
                        {
                            await DependencyService.Get <IXSnack>().ShowMessageAsync("Syncing Data. Please wait..");

                            foreach (var item in data)
                            {
                                clsMessages messagedata          = new clsMessages();
                                var         locjsonStringOfflone = Newtonsoft.Json.JsonConvert.DeserializeObject <LocationData>(item.Location);
                                var         locationData         = new LocationData()
                                {
                                    lat    = locjsonStringOfflone.lat,
                                    lng    = locjsonStringOfflone.lng,
                                    radius = locjsonStringOfflone.radius
                                };
                                var locjsonString = Newtonsoft.Json.JsonConvert.SerializeObject(locationData);

                                var postData = new List <BookingModel>()
                                {
                                    new BookingModel()
                                    {
                                        DateTime        = item.DateTime,
                                        Direction       = item.Direction,
                                        Location        = locjsonString,
                                        HappinessOption = item.HappinessOption,
                                        ReasonCode      = item.ReasonCode
                                    }
                                };
                                var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(postData);

                                var loginInfo = await CommonMethods.BookingAttendance(jsonString);

                                if (loginInfo.Status)
                                {
                                    messagedata.Status  = loginInfo.Status;
                                    messagedata.Message = loginInfo.Message;
                                    App.database.ClearBookingBasedOnId(item);
                                    //await MaterialDialog.Instance.SnackbarAsync(message: "Data successfully synced to the server.",
                                    //msDuration: MaterialSnackbar.DurationLong);
                                }
                                else
                                {
                                    messagedata.Status  = loginInfo.Status;
                                    messagedata.Message = loginInfo.Message;

                                    DependencyService.Get <IProgressBar>().Hide();
                                    //await MaterialDialog.Instance.SnackbarAsync(message: "Error syncing data to the server.",
                                    //  msDuration: MaterialSnackbar.DurationLong);
                                }
                                lstMessage.Add(messagedata);
                            }
                        }
                        catch (Exception ex)
                        {
                            DependencyService.Get <IProgressBar>().Hide();
                            await DependencyService.Get <IXSnack>().ShowMessageAsync(ex.Message);
                        }
                        finally
                        {
                            DependencyService.Get <IProgressBar>().Hide();
                            if (lstMessage.Any(x => x.Status == false))
                            {
                                await DependencyService.Get <IXSnack>().ShowMessageAsync("Error syncing data to the server.");
                            }
                            else
                            {
                                await DependencyService.Get <IXSnack>().ShowMessageAsync("Data successfully synced to the server.");
                            }
                        }
                    }
                    else
                    {
                        DependencyService.Get <IProgressBar>().Hide();
                        Device.BeginInvokeOnMainThread(async() =>
                        {
                            await DependencyService.Get <IXSnack>().ShowMessageAsync("There is no record stored locally.");
                        });
                    }
                }
                else
                {
                    DependencyService.Get <IProgressBar>().Hide();
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        await DependencyService.Get <IXSnack>().ShowMessageAsync(Resx.AppResources.ErrorLoadingData);
                    });
                }
            }
        }
Example #23
0
 /// <summary>
 /// Sets the global styles for <see cref="MaterialAlertDialog"/>, <see cref="MaterialLoadingDialog"/>, <see cref="MaterialSimpleDialog"/>, <see cref="MaterialConfirmationDialog"/>, and <see cref="MaterialSnackbar"/>. Parameters can be null.
 /// </summary>
 /// <param name="dialogConfiguration">Global style for <see cref="MaterialAlertDialog"/>.</param>
 /// <param name="loadingDialogConfiguration">Global style for <see cref="MaterialLoadingDialog"/>.</param>
 /// <param name="snackbarConfiguration">Global style for <see cref="MaterialSnackbar"/>.</param>
 /// <param name="simpleDialogConfiguration">Global style for <see cref="MaterialSimpleDialog"/>.</param>
 /// <param name="confirmationDialogConfiguration">Global style for <see cref="MaterialConfirmationDialog"/>.</param>
 /// <param name="inputDialogConfiguration">Global style for <see cref="MaterialInputDialog"/>.</param>
 public void SetGlobalStyles(MaterialAlertDialogConfiguration dialogConfiguration, MaterialLoadingDialogConfiguration loadingDialogConfiguration, MaterialSnackbarConfiguration snackbarConfiguration, MaterialSimpleDialogConfiguration simpleDialogConfiguration, MaterialConfirmationDialogConfiguration confirmationDialogConfiguration, MaterialInputDialogConfiguration inputDialogConfiguration)
 {
     MaterialAlertDialog.GlobalConfiguration        = dialogConfiguration;
     MaterialLoadingDialog.GlobalConfiguration      = loadingDialogConfiguration;
     MaterialSnackbar.GlobalConfiguration           = snackbarConfiguration;
     MaterialSimpleDialog.GlobalConfiguration       = simpleDialogConfiguration;
     MaterialConfirmationDialog.GlobalConfiguration = confirmationDialogConfiguration;
     MaterialInputDialog.GlobalConfiguration        = inputDialogConfiguration;
 }
        internal static async Task <bool> ShowAsync(string message, string actionButtonText, int msDuration = DurationLong, MaterialSnackbarConfiguration configuration = null)
        {
            var snackbar = new MaterialSnackbar(message, actionButtonText, msDuration, configuration)
            {
                InputTaskCompletionSource = new TaskCompletionSource <bool>()
            };
            await snackbar.ShowAsync();

            return(await snackbar.InputTaskCompletionSource.Task);
        }
Example #25
0
        async void SignUp()
        {
            var network = Connectivity.NetworkAccess;

            if (network != NetworkAccess.Internet)
            {
                // using display alert with MVVM
                await Application.Current.MainPage.DisplayAlert("Alert", "Please check your internet connection ", "Ok");

                return;
            }
            if (Surname == null || Firstname == null || Email == null || Address == null || MobileNumber == null || Password == null || ConfirmPassword == null)
            {
                await Application.Current.MainPage.DisplayAlert("Alert", "Please input all fields", "Ok");

                return;
            }
            if (Password != ConfirmPassword)
            {
                await Application.Current.MainPage.DisplayAlert("Alert", "Please make sure Password and confirm passwoed are the same  ", "Ok");

                return;
            }
            IsBusy = false;

            //  add loading dialog here
            var loadingDialogConfiguration = new MaterialLoadingDialogConfiguration()
            {
                BackgroundColor  = Color.FromHex("010088"),
                MessageTextColor = Color.FromHex("FFFFFF"),
                //  MessageFontFamily =
                TintColor    = Color.FromHex("FFFFFF"),
                CornerRadius = 20,
                // ScrimColor =
            };

            var snackBarconfiguration = new MaterialSnackbarConfiguration()
            {
                TintColor    = Color.FromHex("#00FF01"),
                CornerRadius = 20,
                //  MessageTextColor = Color.White.MultiplyAlpha(0.6),
                MessageTextColor = Color.White,
                BackgroundColor  = Color.FromHex("#010088")
            };

            var loadingDialog = await MaterialDialog.Instance.LoadingDialogAsync(message : "Something is running...", configuration : loadingDialogConfiguration);

            // also add validation of user here oo or add in the remote class

            var signUp = new SignUp
            {
                Surname         = this.Surname,
                FirstName       = this.Firstname,
                Email           = this.Email,
                Address         = this.Address,
                MobileNumber    = this.MobileNumber,
                Password        = this.Password,
                ConfrimPassword = this.ConfirmPassword
            };

            var user = await remoteServices.SignUpAsync(signUp);

            await loadingDialog.DismissAsync();

            IsBusy = true;
            if (user)
            {
                Surname         = null;
                Firstname       = null;
                Email           = null;
                Address         = null;
                MobileNumber    = null;
                Password        = null;
                ConfirmPassword = null;

                await MaterialDialog.Instance.SnackbarAsync(message : "Account created successfully .",
                                                            actionButtonText : "OK",
                                                            msDuration : 3000,
                                                            configuration : snackBarconfiguration);

                await NavigationService.NavigateAsync("LoginPage");
            }
            else
            {
                await MaterialDialog.Instance.SnackbarAsync(message : "Sign up failed! Retry",
                                                            actionButtonText : "OK",
                                                            msDuration : 3000,
                                                            configuration : snackBarconfiguration);

                // await Application.Current.MainPage.DisplayAlert("Alert", "Sign up failed ", "Ok");
            }
        }
Example #26
0
 /// <summary>
 /// Shows a snackbar with an action. Returns true if the snackbar's action button was clicked, or false if the snackbar was automatically dismissed.
 /// </summary>
 /// <param name="message">The message of the snackbar.</param>
 /// <param name="actionButtonText">The label text of the snackbar's button.</param>
 /// <param name="msDuration">The duration, in milliseconds, before the snackbar is automatically dismissed.</param>
 /// <param name="configuration">The style of the snackbar.</param>
 public static async Task <bool> ShowSnackbarAsync(string message, string actionButtonText, int msDuration = MaterialSnackbar.DURATION_LONG, MaterialSnackbarConfiguration configuration = null)
 {
     return(await MaterialSnackbar.ShowAsync(message, actionButtonText, msDuration, configuration));
 }