summaryrefslogtreecommitdiff
path: root/lib/widgets/event_item.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/widgets/event_item.dart')
-rw-r--r--lib/widgets/event_item.dart96
1 files changed, 83 insertions, 13 deletions
diff --git a/lib/widgets/event_item.dart b/lib/widgets/event_item.dart
index e00d328..eb65566 100644
--- a/lib/widgets/event_item.dart
+++ b/lib/widgets/event_item.dart
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
+import 'package:provider/provider.dart';
import '../models/event.dart';
+import '../providers/events_provider.dart';
class EventItem extends StatelessWidget {
final Event event;
@@ -16,25 +18,93 @@ class EventItem extends StatelessWidget {
@override
Widget build(BuildContext context) {
final txtDate = Text(
- event.date.toIso8601String(),
- style: Theme.of(context).typography.englishLike.labelMedium,
+ event.date.toString().split(' ').first,
+ style: Theme.of(context).typography.englishLike.labelMedium?.copyWith(
+ color: Theme.of(context).colorScheme.onSurfaceVariant,
+ ),
);
final txtDesc = Text(
event.description,
- style: Theme.of(context).typography.englishLike.bodyLarge,
+ style: Theme.of(context).typography.englishLike.bodyLarge?.copyWith(
+ color: Theme.of(context).colorScheme.onSurfaceVariant,
+ decoration: event.completed == true
+ ? TextDecoration.lineThrough
+ : TextDecoration.none,
+ ),
);
+ EventsProvider provider = context.watch<EventsProvider>();
+
return Card(
- child: Padding(
- padding: EdgeInsets.all(padding),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- txtDesc,
- spacer,
- txtDate,
- ],
+ semanticContainer: true,
+ clipBehavior: Clip.antiAliasWithSaveLayer,
+ child: InkWell(
+ onTap: () {
+ showDialog(
+ context: context,
+ builder: (BuildContext context) => AlertDialog(
+ title: Text(event.description),
+ content: Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ ListTile(
+ title: const Text('ID'),
+ subtitle: Text(event.id.toString()),
+ ),
+ ListTile(
+ title: const Text('Fecha'),
+ subtitle: Text(event.date.toIso8601String()),
+ ),
+ ListTile(
+ title: const Text('Completado'),
+ subtitle: Text(event.completed == true ? "Sí" : "No"),
+ ),
+ ],
+ ),
+ actions: [
+ TextButton(
+ child: const Text('OK'),
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ )
+ ],
+ ),
+ );
+ },
+ child: Padding(
+ padding: EdgeInsets.all(padding),
+ child: Row(
+ children: [
+ Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ txtDesc,
+ spacer,
+ txtDate,
+ ],
+ ),
+ const Expanded(child: SizedBox.shrink()),
+ ButtonBar(
+ children: [
+ IconButton(
+ icon: const Icon(Icons.edit),
+ onPressed: () {
+ Navigator.of(context)
+ .pushNamed('/newevent', arguments: event);
+ },
+ ),
+ IconButton(
+ icon: const Icon(Icons.delete),
+ onPressed: () {
+ provider.deleteEvent(event.id);
+ },
+ )
+ ],
+ ),
+ ],
+ ),
),
),
);