You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ShopNCook/UserNotifier.cs

49 lines
1.2 KiB

using CommunityToolkit.Maui.Alerts;
using CommunityToolkit.Maui.Core;
using CommunityToolkit.Maui.Views;
using ShoopNCook.Views.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShoopNCook
{
internal class UserNotifier
{
private static async Task Show(string message, string messageType)
{
CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
// Vous pouvez configurer la durée et la taille de police ici.
ToastDuration duration = ToastDuration.Short;
double fontSize = 14;
var toast = Toast.Make(message, duration, fontSize);
await toast.Show(cancellationTokenSource.Token);
}
public static void Error(string message)
{
Show(message, "Error");
}
public static void Warn(string message)
{
Show(message, "Warning");
}
public static void Notice(string message)
{
Show(message, "Notice");
}
public static void Success(string message)
{
Show(message, "Success");
}
}
}