mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-09 14:47:23 +00:00
73 lines
2.2 KiB
Dart
73 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:syncrow_web/utils/color_manager.dart';
|
|
import 'package:syncrow_web/utils/navigation_service.dart';
|
|
|
|
class CustomSnackBar {
|
|
static displaySnackBar(String message) {
|
|
final key = NavigationService.snackbarKey;
|
|
if (key != null) {
|
|
final snackBar = SnackBar(content: Text(message));
|
|
key.currentState?.clearSnackBars();
|
|
key.currentState?.showSnackBar(snackBar);
|
|
}
|
|
}
|
|
|
|
static redSnackBar(String message) {
|
|
final key = NavigationService.snackbarKey;
|
|
BuildContext? currentContext = key?.currentContext;
|
|
if (key != null && currentContext != null) {
|
|
final snackBar = SnackBar(
|
|
padding: const EdgeInsets.all(16),
|
|
backgroundColor: ColorsManager.red,
|
|
content: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
|
const Icon(
|
|
Icons.check_circle,
|
|
color: ColorsManager.whiteColors,
|
|
size: 32,
|
|
),
|
|
const SizedBox(
|
|
width: 8,
|
|
),
|
|
Text(
|
|
message,
|
|
style: Theme.of(currentContext)
|
|
.textTheme
|
|
.bodySmall!
|
|
.copyWith(fontSize: 14, fontWeight: FontWeight.w500, color: Colors.green),
|
|
)
|
|
]),
|
|
);
|
|
key.currentState?.showSnackBar(snackBar);
|
|
}
|
|
}
|
|
|
|
static greenSnackBar(String message) {
|
|
final key = NavigationService.snackbarKey;
|
|
BuildContext? currentContext = key?.currentContext;
|
|
if (key != null && currentContext != null) {
|
|
final snackBar = SnackBar(
|
|
padding: const EdgeInsets.all(16),
|
|
backgroundColor: Colors.green,
|
|
content: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
|
const Icon(
|
|
Icons.check_circle,
|
|
color: Colors.white,
|
|
size: 32,
|
|
),
|
|
const SizedBox(
|
|
width: 8,
|
|
),
|
|
Text(
|
|
message,
|
|
style: Theme.of(currentContext)
|
|
.textTheme
|
|
.bodySmall!
|
|
.copyWith(fontSize: 14, fontWeight: FontWeight.w500, color: Colors.green),
|
|
)
|
|
]),
|
|
);
|
|
key.currentState?.showSnackBar(snackBar);
|
|
}
|
|
}
|
|
}
|