67 lines
1.7 KiB
Dart
67 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_slidable/flutter_slidable.dart';
|
|
|
|
// ignore: must_be_immutable
|
|
class ToDoTile extends StatelessWidget {
|
|
final String taskName;
|
|
final bool taskCompleted;
|
|
Function(bool?)? onChanged;
|
|
Function(BuildContext)? deleteFunction;
|
|
|
|
ToDoTile({
|
|
super.key,
|
|
required this.taskName,
|
|
required this.taskCompleted,
|
|
required this.onChanged,
|
|
required this.deleteFunction,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: const EdgeInsets.only(left: 25, right: 25, top: 25),
|
|
child: Slidable(
|
|
endActionPane: ActionPane(
|
|
motion: const BehindMotion(),
|
|
children: [
|
|
SlidableAction(
|
|
onPressed: deleteFunction,
|
|
icon: Icons.delete,
|
|
backgroundColor: Colors.red,
|
|
borderRadius: BorderRadius.circular(12),
|
|
label: 'Delete',
|
|
)
|
|
],
|
|
),
|
|
child: Container(
|
|
padding: const EdgeInsets.all(24),
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey[200],
|
|
borderRadius: BorderRadius.circular(12),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
// checkbox
|
|
Checkbox(
|
|
value: taskCompleted,
|
|
onChanged: onChanged,
|
|
activeColor: Colors.deepPurple,
|
|
),
|
|
|
|
// task name
|
|
Text(
|
|
taskName,
|
|
style: TextStyle(
|
|
decoration: taskCompleted
|
|
? TextDecoration.lineThrough
|
|
: TextDecoration.none,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|