cpd_2024_todo/lib/presentation/ToDoExpandableWidget.dart

59 lines
1.9 KiB
Dart
Raw Normal View History

2024-10-22 10:38:22 +02:00
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../buisness/ToDoItem.dart';
import '../buisness/ToDoProvider.dart';
class ToDoExpandableWidget extends StatelessWidget {
final ToDoItem toDoItem;
2024-10-29 13:13:10 +01:00
final int id;
2024-10-22 10:38:22 +02:00
const ToDoExpandableWidget({
Key? key,
required this.toDoItem,
2024-10-29 13:13:10 +01:00
required this.id,
2024-10-22 10:38:22 +02:00
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Card(
color: Colors.orange[100],
child: ExpansionTile(
title: Text(toDoItem.name, style: TextStyle(color: Colors.black)),
subtitle: Text('Due: ${toDoItem.dueDate.toLocal()}'),
children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Description: ${toDoItem.description}', style: TextStyle(color: Colors.black)),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('Status: ', style: TextStyle(color: Colors.black)),
DropdownButton<String>(
value: toDoItem.status,
items: ['Pending', 'In Progress', 'Completed']
.map((status) => DropdownMenuItem(
value: status,
child: Text(status),
))
.toList(),
onChanged: (value) {
if (value != null) {
2024-10-29 13:13:10 +01:00
Provider.of<ToDoProvider>(context, listen: false).updateStatus(id, value);
2024-10-22 10:38:22 +02:00
}
},
),
],
),
],
),
),
],
),
);
}
}