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(); }
public void Clear() { SnackBarLock.EnterWriteLock(); try { RemoveAllSnackbars(SnackBarList); } finally { SnackBarLock.ExitWriteLock(); } OnSnackbarsUpdated?.Invoke(); }
public void Remove(Snackbar snackbar) { snackbar.Dispose(); snackbar.OnClose -= Remove; SnackBarLock.EnterWriteLock(); try { var index = SnackBarList.IndexOf(snackbar); if (index < 0) { return; } SnackBarList.RemoveAt(index); } finally { SnackBarLock.ExitWriteLock(); } OnSnackbarsUpdated?.Invoke(); }
private void ConfigurationUpdated() { OnSnackbarsUpdated?.Invoke(); }