62 lines
1.7 KiB
Dart
62 lines
1.7 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(25.0, 25, 25, 0),
|
|
child: Slidable(
|
|
endActionPane: ActionPane(
|
|
motion: StretchMotion(),
|
|
children: [
|
|
SlidableAction(
|
|
onPressed: deleteFunction,
|
|
icon: Icons.delete,
|
|
backgroundColor: const Color.fromARGB(255, 249, 137, 135),
|
|
borderRadius: BorderRadius.circular(12),
|
|
)
|
|
],
|
|
),
|
|
child: Container(
|
|
padding: EdgeInsets.all(24.0),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
taskName,
|
|
style: TextStyle(
|
|
decoration: taskCompleted
|
|
? TextDecoration.lineThrough
|
|
: TextDecoration.none),
|
|
),
|
|
Checkbox(
|
|
value: taskCompleted,
|
|
onChanged: onChanged,
|
|
activeColor: Colors.redAccent,
|
|
)
|
|
],
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: Theme.of(context).primaryColor,
|
|
borderRadius: BorderRadius.circular(10.0),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|