2026-03-03 12:20:57 -05:00
|
|
|
import 'package:flutter/material.dart';
|
2026-05-27 11:38:16 -04:00
|
|
|
import '../theme/app_colors.dart';
|
2026-03-03 12:20:57 -05:00
|
|
|
|
|
|
|
|
class UISnackbars {
|
|
|
|
|
static void showError(BuildContext context, String message) {
|
2026-05-27 17:43:01 -04:00
|
|
|
final colorScheme = Theme.of(context).colorScheme;
|
|
|
|
|
_show(context, message, colorScheme.error, colorScheme.onError);
|
2026-03-03 12:20:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void showSuccess(BuildContext context, String message) {
|
2026-05-27 11:38:16 -04:00
|
|
|
final appColors = Theme.of(context).extension<AppColorExtension>()!;
|
2026-05-27 17:43:01 -04:00
|
|
|
_show(context, message, appColors.success, appColors.onSuccess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void showWarning(BuildContext context, String message) {
|
|
|
|
|
final appColors = Theme.of(context).extension<AppColorExtension>()!;
|
|
|
|
|
_show(context, message, appColors.warning, appColors.onWarning);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void showInfo(BuildContext context, String message) {
|
|
|
|
|
final appColors = Theme.of(context).extension<AppColorExtension>()!;
|
|
|
|
|
_show(context, message, appColors.info, appColors.onInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void _show(
|
|
|
|
|
BuildContext context,
|
|
|
|
|
String message,
|
|
|
|
|
Color background,
|
|
|
|
|
Color foreground,
|
|
|
|
|
) {
|
|
|
|
|
final messenger = ScaffoldMessenger.of(context);
|
|
|
|
|
messenger.clearSnackBars();
|
|
|
|
|
messenger.showSnackBar(
|
2026-03-03 12:20:57 -05:00
|
|
|
SnackBar(
|
2026-05-27 17:43:01 -04:00
|
|
|
content: Text(message, style: TextStyle(color: foreground)),
|
2026-03-03 12:20:57 -05:00
|
|
|
behavior: SnackBarBehavior.floating,
|
|
|
|
|
showCloseIcon: true,
|
2026-05-27 17:43:01 -04:00
|
|
|
backgroundColor: background,
|
2026-03-03 12:20:57 -05:00
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|