Initial commit of Doormile CRM Mobile with UI modernizations
This commit is contained in:
83
lib/utils/snackbar_utils.dart
Normal file
83
lib/utils/snackbar_utils.dart
Normal file
@@ -0,0 +1,83 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
|
||||
class SnackbarUtils {
|
||||
static void showSuccess(BuildContext context, String message) {
|
||||
_showSnackBar(
|
||||
context,
|
||||
message,
|
||||
icon: Icons.check_circle_outline,
|
||||
backgroundColor: AppColors.greenDark,
|
||||
);
|
||||
}
|
||||
|
||||
static void showError(BuildContext context, String message) {
|
||||
_showSnackBar(
|
||||
context,
|
||||
message,
|
||||
icon: Icons.error_outline,
|
||||
backgroundColor: AppColors.primaryDark,
|
||||
);
|
||||
}
|
||||
|
||||
static void showWarning(BuildContext context, String message) {
|
||||
_showSnackBar(
|
||||
context,
|
||||
message,
|
||||
icon: Icons.warning_amber_rounded,
|
||||
backgroundColor: const Color(0xFFE87C00), // Orange
|
||||
);
|
||||
}
|
||||
|
||||
static void _showSnackBar(
|
||||
BuildContext context,
|
||||
String message, {
|
||||
required IconData icon,
|
||||
required Color backgroundColor,
|
||||
}) {
|
||||
if (!context.mounted) return;
|
||||
|
||||
final snackBar = SnackBar(
|
||||
elevation: 0,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
backgroundColor: Colors.transparent,
|
||||
padding: EdgeInsets.zero,
|
||||
content: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: backgroundColor.withValues(alpha: 0.3),
|
||||
blurRadius: 10,
|
||||
offset: const Offset(0, 4),
|
||||
)
|
||||
],
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(icon, color: Colors.white, size: 22),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
message,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
duration: const Duration(seconds: 3),
|
||||
margin: const EdgeInsets.only(bottom: 24, left: 16, right: 16),
|
||||
);
|
||||
|
||||
ScaffoldMessenger.of(context)
|
||||
..hideCurrentSnackBar()
|
||||
..showSnackBar(snackBar);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user