mirror of
https://github.com/vleeuwenmenno/supplements.git
synced 2025-09-11 18:29:12 +02:00
Refactor and enhance UI components across multiple screens
- Updated date and time formatting in debug notifications screen for clarity. - Wrapped context-dependent state updates in post-frame callbacks in history screen to ensure proper context usage. - Improved layout and styling in settings screen by reordering radio list tiles. - Enhanced logging in auto sync service for better error tracking. - Added context mounted checks in notification router to prevent errors during navigation. - Updated bulk take dialog to use new UI components from shadcn_ui package. - Refactored take supplement dialog to utilize shadcn_ui for a more modern look and feel. - Adjusted info chip and supplement card widgets to use updated color schemes and layouts. - Updated pubspec.yaml and pubspec.lock to include new dependencies and versions.
This commit is contained in:
@@ -232,7 +232,7 @@ class AutoSyncService {
|
||||
if (_consecutiveFailures >= _autoDisableThreshold) {
|
||||
_autoDisabledDueToErrors = true;
|
||||
if (kDebugMode) {
|
||||
printLog('AutoSyncService: Auto-sync disabled due to ${_consecutiveFailures} consecutive failures');
|
||||
printLog('AutoSyncService: Auto-sync disabled due to $_consecutiveFailures consecutive failures');
|
||||
}
|
||||
|
||||
// For configuration errors, disable immediately
|
||||
|
@@ -93,6 +93,7 @@ class NotificationRouter {
|
||||
}
|
||||
|
||||
final context = _navigatorKey!.currentContext!;
|
||||
if (!context.mounted) return;
|
||||
final provider = context.read<SupplementProvider>();
|
||||
|
||||
if (payload == null) {
|
||||
@@ -113,6 +114,7 @@ class NotificationRouter {
|
||||
if (s == null) {
|
||||
// Attempt reload once
|
||||
await provider.loadSupplements();
|
||||
if (!context.mounted) return;
|
||||
try {
|
||||
s = provider.supplements.firstWhere((el) => el.id == id);
|
||||
} catch (_) {
|
||||
@@ -124,6 +126,7 @@ class NotificationRouter {
|
||||
// Ensure we close any existing dialog first
|
||||
_popAnyDialog(context);
|
||||
await showTakeSupplementDialog(context, s, hideTime: false);
|
||||
if (!context.mounted) return;
|
||||
} else {
|
||||
printLog('⚠️ Supplement id=$id not found for single-take routing');
|
||||
_showSnack(context, 'Supplement not found');
|
||||
@@ -145,6 +148,7 @@ class NotificationRouter {
|
||||
|
||||
_popAnyDialog(context);
|
||||
await showBulkTakeDialog(context, list);
|
||||
if (!context.mounted) return;
|
||||
}
|
||||
} else {
|
||||
printLog('⚠️ Unknown payload type: $type');
|
||||
@@ -158,8 +162,9 @@ class NotificationRouter {
|
||||
}
|
||||
|
||||
// Try to wait for providers to be ready to build rich content.
|
||||
final ready = await _waitUntilReady(timeout: const Duration(seconds: 5));
|
||||
BuildContext? ctx = _navigatorKey?.currentContext;
|
||||
final ready = await _waitUntilReady(timeout: const Duration(seconds: 5));
|
||||
if (ctx != null && !ctx.mounted) ctx = null;
|
||||
|
||||
SupplementProvider? provider;
|
||||
if (ready && ctx != null) {
|
||||
@@ -262,6 +267,7 @@ class NotificationRouter {
|
||||
final key = _navigatorKey;
|
||||
final ctx = key?.currentContext;
|
||||
if (ctx != null) {
|
||||
if (!ctx.mounted) continue;
|
||||
try {
|
||||
final provider = Provider.of<SupplementProvider>(ctx, listen: false);
|
||||
if (!provider.isLoading) {
|
||||
@@ -283,8 +289,10 @@ class NotificationRouter {
|
||||
}
|
||||
|
||||
void _showSnack(BuildContext context, String message) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(message)),
|
||||
);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(message)),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user