mirror of
https://github.com/immich-app/immich
synced 2026-08-15 13:03:57 +00:00
37 lines
892 B
Dart
37 lines
892 B
Dart
import 'dart:async';
|
|
|
|
import 'package:immich_ui/immich_ui.dart';
|
|
|
|
class ToastOption {
|
|
final Duration? timeout;
|
|
final FutureOr<void> Function()? onUndo;
|
|
|
|
const ToastOption({this.timeout, this.onUndo});
|
|
}
|
|
|
|
class ToastService {
|
|
const ToastService();
|
|
|
|
FutureOr<void> success(String message, {ToastOption? toast}) {
|
|
snackbar.success(message, duration: toast?.timeout, action: toast?.action);
|
|
}
|
|
|
|
FutureOr<void> info(String message, {ToastOption? toast}) {
|
|
snackbar.info(message, duration: toast?.timeout, action: toast?.action);
|
|
}
|
|
|
|
FutureOr<void> error(String message, {ToastOption? toast}) {
|
|
snackbar.error(message, duration: toast?.timeout, action: toast?.action);
|
|
}
|
|
}
|
|
|
|
extension on ToastOption {
|
|
SnackbarAction? get action {
|
|
final onUndo = this.onUndo;
|
|
if (onUndo == null) {
|
|
return null;
|
|
}
|
|
|
|
return SnackbarAction(onPressed: onUndo);
|
|
}
|
|
}
|