feat: add day detail screen with swipe-to-delete and undo
Adds DayDetailScreen showing all entries for a selected day with swipe-to-delete and an undo snackbar. CalendarScreen gains a tappable day header (Today / Yesterday / Month Day) that pushes the detail screen.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../core/providers/mood_provider.dart';
|
||||
import 'day_detail_screen.dart';
|
||||
import 'widgets/calendar_heatmap.dart';
|
||||
import 'widgets/day_entry_card.dart';
|
||||
|
||||
@@ -36,6 +37,15 @@ class _CalendarScreenState extends ConsumerState<CalendarScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
static String _dayLabel(DateTime day) {
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
final yesterday = today.subtract(const Duration(days: 1));
|
||||
if (day == today) return 'Today';
|
||||
if (day == yesterday) return 'Yesterday';
|
||||
return '${_months[day.month - 1]} ${day.day}';
|
||||
}
|
||||
|
||||
bool get _canGoForward {
|
||||
final now = DateTime.now();
|
||||
return _month.year < now.year ||
|
||||
@@ -70,6 +80,28 @@ class _CalendarScreenState extends ConsumerState<CalendarScreen> {
|
||||
},
|
||||
),
|
||||
const Divider(height: 1),
|
||||
InkWell(
|
||||
onTap: () => Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => DayDetailScreen(day: selectedDay),
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
_dayLabel(selectedDay),
|
||||
style: Theme.of(context).textTheme.titleSmall,
|
||||
),
|
||||
const Spacer(),
|
||||
Icon(Icons.chevron_right,
|
||||
color: Theme.of(context).colorScheme.outline),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(height: 1),
|
||||
Expanded(
|
||||
child: entriesAsync.when(
|
||||
data: (entries) => entries.isEmpty
|
||||
|
||||
Reference in New Issue
Block a user