Exemplo n.º 1
0
 public async Task SnackBarSucces(string message, string title, TypeSnackBar typeSnackBar)
 {
     if (typeSnackBar == TypeSnackBar.Bottom)
     {
         Activity           activity                     = CrossCurrentActivity.Current.Activity;
         Android.Views.View activityRootView             = activity.FindViewById(Android.Resource.Id.Content);
         Android.Support.Design.Widget.Snackbar snackBar = Android.Support.Design.Widget.Snackbar.Make(activityRootView, message, Snackbar.LengthLong);
         snackBar.SetActionTextColor(Android.Graphics.Color.ParseColor("#FFFFFF"));
         Android.Views.View snackbarview = snackBar.View;
         snackbarview.SetBackgroundResource(Resource.Drawable.snackBackground);
         ViewGroup.MarginLayoutParams paramss = (ViewGroup.MarginLayoutParams)snackbarview.LayoutParameters;
         paramss.SetMargins(30, 0, 30, 40);
         snackbarview.LayoutParameters = paramss;
         snackbarview.SetBackground(
             MainActivity.Current.ApplicationContext.GetDrawable(Resource.Drawable.snackBackground));
         snackBar.Show();
     }
     else if (typeSnackBar == TypeSnackBar.Top)
     {
         CookieBar.Build(MainActivity.Current)
         .SetIcon(Resource.Drawable.ic_done)
         .SetTitle(title)
         .SetIconAnimation(Resource.Animator.iconspin)
         .SetBackgroundColor(Resource.Color.backgroundcoockiesuccess)
         .SetTitleColor(Resource.Color.cookiebartitle)
         .SetMessageColor(Resource.Color.cookiebartitle)
         .SetMessage(message)
         .SetEnableAutoDismiss(true)
         .SetSwipeToDismiss(true)
         .Show();
     }
 }
Exemplo n.º 2
0
 public async Task SnackBar(string message, TypeSnack typesnack)
 {
     if (typesnack == TypeSnack.Error)
     {
         Activity           activity                     = CrossCurrentActivity.Current.Activity;
         Android.Views.View activityRootView             = activity.FindViewById(Android.Resource.Id.Content);
         Android.Support.Design.Widget.Snackbar snackBar = Android.Support.Design.Widget.Snackbar.Make(activityRootView, message, Snackbar.LengthLong);
         snackBar.SetActionTextColor(Android.Graphics.Color.ParseColor("#FFFFFF"));
         Android.Views.View snackbarview = snackBar.View;
         snackbarview.SetBackgroundResource(Resource.Drawable.snackerror);
         ViewGroup.MarginLayoutParams paramss = (ViewGroup.MarginLayoutParams)snackbarview.LayoutParameters;
         paramss.SetMargins(30, 0, 30, 40);
         snackbarview.SetBackground(
             MainActivity.CurrentActivity.ApplicationContext.GetDrawable(Resource.Drawable.snackerror));
         snackBar.Show();
     }
     else
     {
         Activity           activity                     = CrossCurrentActivity.Current.Activity;
         Android.Views.View activityRootView             = activity.FindViewById(Android.Resource.Id.Content);
         Android.Support.Design.Widget.Snackbar snackBar = Android.Support.Design.Widget.Snackbar.Make(activityRootView, message, Snackbar.LengthLong);
         snackBar.SetActionTextColor(Android.Graphics.Color.ParseColor("#FFFFFF"));
         Android.Views.View snackbarview = snackBar.View;
         snackbarview.SetBackgroundResource(Resource.Drawable.snackBackground);
         ViewGroup.MarginLayoutParams paramss = (ViewGroup.MarginLayoutParams)snackbarview.LayoutParameters;
         paramss.SetMargins(30, 0, 30, 40);
         snackbarview.SetBackground(
             MainActivity.CurrentActivity.ApplicationContext.GetDrawable(Resource.Drawable.snackBackground));
         snackBar.Show();
     }
 }