- Complete MVP with Repository Pattern, SQLite storage - Provider + ChangeNotifier state management - Navigation 2.0 with deep link support - Habit CRUD with twoDayRule, notifications, categories - Backup/Restore via JSON - Statistics with streak tracking - Material You theme support - Biometric lock support - Desktop widget support - 27 languages i18n structure - Comprehensive test suite (87/89 passing)
49 lines
1.1 KiB
Dart
49 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class UIFeedbackService {
|
|
final GlobalKey<ScaffoldMessengerState> _scaffoldKey;
|
|
|
|
UIFeedbackService(this._scaffoldKey);
|
|
|
|
void showSuccess(String message) {
|
|
showMessage(message, Colors.green);
|
|
}
|
|
|
|
void showError(String message) {
|
|
showMessage(message, Colors.red);
|
|
}
|
|
|
|
void showWarning(String message) {
|
|
showMessage(message, Colors.orange);
|
|
}
|
|
|
|
void showMessage(String message, [Color? color]) {
|
|
_scaffoldKey.currentState?.showSnackBar(
|
|
SnackBar(
|
|
content: Text(message),
|
|
backgroundColor: color,
|
|
duration: const Duration(seconds: 2),
|
|
),
|
|
);
|
|
}
|
|
|
|
void showMessageWithAction({
|
|
required String message,
|
|
required String actionLabel,
|
|
required VoidCallback onActionPressed,
|
|
Color? backgroundColor,
|
|
}) {
|
|
_scaffoldKey.currentState?.showSnackBar(
|
|
SnackBar(
|
|
content: Text(message),
|
|
backgroundColor: backgroundColor,
|
|
action: SnackBarAction(
|
|
label: actionLabel,
|
|
onPressed: () => onActionPressed(),
|
|
),
|
|
duration: const Duration(seconds: 4),
|
|
),
|
|
);
|
|
}
|
|
}
|