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:
@@ -55,7 +55,9 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
||||
_selectedMonth--;
|
||||
}
|
||||
});
|
||||
context.read<SupplementProvider>().loadMonthlyIntakes(_selectedYear, _selectedMonth);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.read<SupplementProvider>().loadMonthlyIntakes(_selectedYear, _selectedMonth);
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.chevron_left),
|
||||
),
|
||||
@@ -85,7 +87,9 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
||||
_selectedMonth++;
|
||||
}
|
||||
});
|
||||
context.read<SupplementProvider>().loadMonthlyIntakes(_selectedYear, _selectedMonth);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.read<SupplementProvider>().loadMonthlyIntakes(_selectedYear, _selectedMonth);
|
||||
});
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.chevron_right),
|
||||
@@ -187,12 +191,15 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
||||
);
|
||||
|
||||
if (picked != null) {
|
||||
if (!context.mounted) return;
|
||||
setState(() {
|
||||
_selectedMonth = picked.month;
|
||||
_selectedYear = picked.year;
|
||||
_selectedDay = picked; // Set the selected day to the picked date
|
||||
});
|
||||
context.read<SupplementProvider>().loadMonthlyIntakes(_selectedYear, _selectedMonth);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.read<SupplementProvider>().loadMonthlyIntakes(_selectedYear, _selectedMonth);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,13 +217,16 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await context.read<SupplementProvider>().deleteIntake(intakeId);
|
||||
if (!context.mounted) return;
|
||||
Navigator.of(context).pop();
|
||||
|
||||
// Force refresh of the UI
|
||||
setState(() {});
|
||||
|
||||
// Force refresh of the current view data
|
||||
context.read<SupplementProvider>().loadMonthlyIntakes(_selectedYear, _selectedMonth);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
context.read<SupplementProvider>().loadMonthlyIntakes(_selectedYear, _selectedMonth);
|
||||
});
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
@@ -252,7 +262,7 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
||||
final calendarHeight = isWideScreen ? 400.0 : calendarContentHeight;
|
||||
|
||||
return Card(
|
||||
child: Container(
|
||||
child: SizedBox(
|
||||
height: calendarHeight,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
@@ -261,20 +271,98 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
||||
children: [
|
||||
// Calendar header (weekdays)
|
||||
Row(
|
||||
children: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
|
||||
.map((day) => Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
day,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
fontSize: isWideScreen ? 14 : 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
))
|
||||
.toList(),
|
||||
children: [
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Mon',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
fontSize: isWideScreen ? 14 : 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Tue',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
fontSize: isWideScreen ? 14 : 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Wed',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
fontSize: isWideScreen ? 14 : 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Thu',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
fontSize: isWideScreen ? 14 : 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Fri',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
fontSize: isWideScreen ? 14 : 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Sat',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
fontSize: isWideScreen ? 14 : 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 4),
|
||||
Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Sun',
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
fontSize: isWideScreen ? 14 : 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// Calendar grid
|
||||
@@ -293,7 +381,7 @@ class _HistoryScreenState extends State<HistoryScreen> {
|
||||
final dayNumber = index - firstWeekday + 2;
|
||||
|
||||
if (dayNumber < 1 || dayNumber > daysInMonth) {
|
||||
return const SizedBox(); // Empty cell
|
||||
return const SizedBox.shrink(); // Empty cell
|
||||
}
|
||||
|
||||
final date = DateTime(_selectedYear, _selectedMonth, dayNumber);
|
||||
|
Reference in New Issue
Block a user