Files
todo/lib/utils/todo_tile.dart
streaper2 7d391194f5 - séparation des taches faite et non,
- rapettisage de la taille des taches
2023-10-10 20:20:27 +02:00

70 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
class ToDoTile extends StatelessWidget {
const ToDoTile(
{Key? key,
required this.taskName,
required this.taskCompleted,
required this.onChanged,
required this.deleteFunction})
: super(key: key);
final String taskName;
final bool taskCompleted;
final Function(bool?)? onChanged;
final Function(BuildContext)? deleteFunction;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.fromLTRB(15.0, 15, 15, 0),
child: Slidable(
endActionPane: ActionPane(
motion: const StretchMotion(),
children: [
SlidableAction(
onPressed: deleteFunction,
icon: Icons.delete,
backgroundColor: Color.fromARGB(255, 249, 137, 135),
borderRadius: BorderRadius.circular(12),
)
],
),
child: Container(
padding: const EdgeInsets.all(10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
taskName,
style: TextStyle(
color: Colors.white,
decoration: taskCompleted
? TextDecoration.lineThrough
: TextDecoration.none),
),
Checkbox(
value: taskCompleted,
onChanged: onChanged,
side:
MaterialStateBorderSide.resolveWith((states) => BorderSide(
width: 2,
color: Colors.white,
)),
focusColor: Colors.white,
checkColor: Colors.white,
activeColor: taskCompleted ? Colors.grey : Colors.redAccent,
)
],
),
decoration: BoxDecoration(
color: taskCompleted ? Colors.grey : Theme.of(context).primaryColor,
borderRadius: BorderRadius.circular(10.0),
),
),
),
);
}
}