From a2d2d24fc22c633752cd20c5b52fbe3b06ee49ee Mon Sep 17 00:00:00 2001 From: zsolt Date: Thu, 13 Aug 2026 14:20:48 +0200 Subject: [PATCH] Show event todos from info button --- lib/calendar_widgets.dart | 89 +++++++++++++++++++++++++++++++++++---- lib/dialogs.dart | 10 ++++- 2 files changed, 88 insertions(+), 11 deletions(-) diff --git a/lib/calendar_widgets.dart b/lib/calendar_widgets.dart index 67a109c..def31de 100644 --- a/lib/calendar_widgets.dart +++ b/lib/calendar_widgets.dart @@ -915,7 +915,7 @@ class WeekEventPill extends StatelessWidget { fontWeight: FontWeight.w900, ), ), - if (event.hasTodos) ...[ + if (event.todos.isNotEmpty) ...[ const SizedBox(height: 2), Row( mainAxisSize: MainAxisSize.min, @@ -923,9 +923,7 @@ class WeekEventPill extends StatelessWidget { const Icon(Icons.task_alt_rounded, color: sage, size: 12), const SizedBox(width: 3), Text( - event.todos.isEmpty - ? 'teend\u0151' - : '${event.todos.length} db', + '${event.todos.length} db', style: const TextStyle( color: sage, fontSize: 10, @@ -1395,6 +1393,7 @@ class EventCard extends StatelessWidget { @override Widget build(BuildContext context) { + final hasTodoItems = event.todos.isNotEmpty; return Card( child: InkWell( borderRadius: BorderRadius.circular(20), @@ -1450,16 +1449,26 @@ class EventCard extends StatelessWidget { crossAxisAlignment: WrapCrossAlignment.center, children: [ AudienceChip(person: person, event: event), - if (event.hasTodos) TodoBadge(event: event), + if (hasTodoItems) TodoBadge(event: event), ], ), ], ), ), - Icon( - event.hasTodos ? Icons.task_alt_rounded : Icons.more_horiz, - color: event.hasTodos ? sage : Colors.black38, - ), + if (hasTodoItems) + IconButton.filledTonal( + tooltip: 'Teend\u0151k megtekint\u00e9se', + onPressed: () => showEventTodos(context, event), + icon: const Icon(Icons.info_outline_rounded, size: 20), + style: IconButton.styleFrom( + backgroundColor: sage.withValues(alpha: .12), + foregroundColor: sage, + minimumSize: const Size(36, 36), + tapTargetSize: MaterialTapTargetSize.shrinkWrap, + ), + ) + else + const Icon(Icons.more_horiz, color: Colors.black38), ], ), ), @@ -1468,6 +1477,68 @@ class EventCard extends StatelessWidget { } } +void showEventTodos(BuildContext context, CalendarEvent event) { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Row( + children: [ + Container( + width: 36, + height: 36, + decoration: BoxDecoration( + color: sage.withValues(alpha: .12), + borderRadius: BorderRadius.circular(13), + ), + child: const Icon(Icons.task_alt_rounded, color: sage), + ), + const SizedBox(width: 10), + const Expanded(child: Text('Teend\u0151k')), + ], + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + event.title, + style: const TextStyle( + color: ink, + fontWeight: FontWeight.w900, + fontSize: 16, + ), + ), + const SizedBox(height: 12), + ...event.todos.map( + (todo) => Padding( + padding: const EdgeInsets.only(bottom: 8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const Icon(Icons.check_circle_outline, color: sage, size: 20), + const SizedBox(width: 8), + Expanded( + child: Text( + todo, + style: const TextStyle(color: ink, height: 1.35), + ), + ), + ], + ), + ), + ), + ], + ), + actions: [ + TextButton( + onPressed: () => Navigator.pop(context), + child: const Text('Rendben'), + ), + ], + ), + ); +} + class TodoBadge extends StatelessWidget { const TodoBadge({super.key, required this.event}); diff --git a/lib/dialogs.dart b/lib/dialogs.dart index dc44778..7f0fc79 100644 --- a/lib/dialogs.dart +++ b/lib/dialogs.dart @@ -490,6 +490,12 @@ class _EventAddDialogState extends State { FilledButton( onPressed: () { final eventDate = parseDate(date.text) ?? DateTime.now(); + final cleanTodos = hasTodos + ? todos + .map((item) => item.trim()) + .where((item) => item.isNotEmpty) + .toList() + : []; Navigator.pop( context, EventInput( @@ -498,8 +504,8 @@ class _EventAddDialogState extends State { date: eventDate, personId: personId, note: note.text, - hasTodos: hasTodos, - todos: hasTodos ? todos : const [], + hasTodos: cleanTodos.isNotEmpty, + todos: cleanTodos, ), ); },