public Snackbar Add(string message, Severity severity = Severity.Normal, Action <SnackbarOptions> configure = null) { if (message.IsEmpty()) { return(null); } message = message.Trimmed(); var options = new SnackbarOptions(severity, Configuration); configure?.Invoke(options); var snackbar = new Snackbar(message, options); SnackBarLock.EnterWriteLock(); try { if (Configuration.PreventDuplicates && SnackbarAlreadyPresent(snackbar)) { return(null); } snackbar.OnClose += Remove; SnackBarList.Add(snackbar); } finally { SnackBarLock.ExitWriteLock(); } OnSnackbarsUpdated?.Invoke(); return(snackbar); }
public void Add(SnackbarType type, string message, Action <SnackbarOptions> configure) { if (message.IsEmpty()) { return; } message = message.Trimmed(); var options = new SnackbarOptions(type, Configuration); configure?.Invoke(options); var toast = new Snackbar(message, options); SnackBarLock.EnterWriteLock(); try { if (Configuration.PreventDuplicates && ToastAlreadyPresent(toast)) { return; } toast.OnClose += Remove; SnackBarList.Add(toast); } finally { SnackBarLock.ExitWriteLock(); } OnSnackbarsUpdated?.Invoke(); }