Esempio n. 1
0
        public void Show(Snack snack)
        {
            if (SnackBar.Bar != null)
            {
                SnackBar.Bar.Dismiss();
            }

            var activity = (Activity)Forms.Context;
            var view     = activity.FindViewById(Id.Content);

            SnackBar.Bar = Snackbar.Make(view, snack.Text, Snackbar.LengthLong);

            if (snack.Duration == -1)
            {
                SnackBar.Bar.SetDuration(Snackbar.LengthIndefinite);
            }
            else
            {
                SnackBar.Bar.SetDuration(snack.Duration);
            }

            var snackbarView = SnackBar.Bar.View;

            snackbarView.SetBackgroundColor(snack.Background.ToAndroid());

            var snackbarId = GetResourceIdByName("snackbar_text");
            var textView   = (TextView)snackbarView.FindViewById(snackbarId);

            textView.SetTextColor(snack.TextColor.ToAndroid());


            if (!string.IsNullOrEmpty(snack.ActionText))
            {
                SnackBar.Bar.SetAction(snack.ActionText, snack.Action);
                SnackBar.Bar.SetActionTextColor(snack.ActionTextColor.ToAndroid());
            }

            SnackBar.Bar.Show();
        }