154 lines
5.5 KiB
Dart
154 lines
5.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import '../models/task_item.dart';
|
|
|
|
class TaskTile extends StatelessWidget {
|
|
final TaskItem task;
|
|
final int index;
|
|
final bool isPriority;
|
|
final bool isTopOne;
|
|
final VoidCallback onTap;
|
|
final VoidCallback? onFocusTap;
|
|
final VoidCallback onDismissed;
|
|
|
|
const TaskTile({
|
|
super.key,
|
|
required this.task,
|
|
required this.index,
|
|
required this.isPriority,
|
|
this.isTopOne = false,
|
|
required this.onTap,
|
|
this.onFocusTap,
|
|
required this.onDismissed,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
|
|
child: Dismissible(
|
|
key: ValueKey(task.id),
|
|
direction: DismissDirection.startToEnd,
|
|
background: Container(
|
|
alignment: Alignment.centerLeft,
|
|
padding: const EdgeInsets.only(left: 24),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFE0F7FA),
|
|
borderRadius: BorderRadius.circular(20),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
const Icon(Icons.check_circle, color: Color(0xFF006064)),
|
|
const SizedBox(width: 8),
|
|
Text(
|
|
"DONE",
|
|
style: TextStyle(
|
|
color: const Color(0xFF006064).withOpacity(0.8),
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
onDismissed: (d) {
|
|
onDismissed();
|
|
HapticFeedback.mediumImpact();
|
|
},
|
|
child: GestureDetector(
|
|
onTap: onTap,
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
borderRadius: BorderRadius.circular(20),
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: const Color(0xFF4A3B3B).withOpacity(isPriority ? 0.08 : 0.03),
|
|
blurRadius: isPriority ? 24 : 10,
|
|
offset: const Offset(0, 8),
|
|
spreadRadius: -4,
|
|
),
|
|
],
|
|
border: isTopOne
|
|
? Border.all(color: const Color(0xFFFF7F50).withOpacity(0.5), width: 1.5)
|
|
: Border.all(color: Colors.transparent),
|
|
),
|
|
child: IntrinsicHeight(
|
|
child: Row(
|
|
children: [
|
|
if (isTopOne)
|
|
Container(
|
|
width: 6,
|
|
decoration: const BoxDecoration(
|
|
color: Color(0xFFFF7F50),
|
|
borderRadius: BorderRadius.only(
|
|
topLeft: Radius.circular(20),
|
|
bottomLeft: Radius.circular(20),
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Padding(
|
|
padding: EdgeInsets.fromLTRB(isTopOne ? 14 : 20, 18, 16, 18),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
task.title,
|
|
style: TextStyle(
|
|
fontSize: isPriority ? 17 : 16,
|
|
fontWeight: isPriority ? FontWeight.w700 : FontWeight.w500,
|
|
color: task.isCompleted
|
|
? Colors.grey
|
|
: (isPriority ? Colors.black : Colors.grey.shade700),
|
|
decoration: task.isCompleted ? TextDecoration.lineThrough : null,
|
|
decorationColor: Colors.grey.shade300,
|
|
height: 1.2,
|
|
),
|
|
),
|
|
if (task.subtitle != null && task.subtitle!.isNotEmpty) ...[
|
|
const SizedBox(height: 6),
|
|
Text(
|
|
task.subtitle!,
|
|
style: TextStyle(
|
|
fontSize: 13,
|
|
color: isTopOne ? const Color(0xFFFF7F50) : Colors.grey.shade400,
|
|
fontWeight: FontWeight.w500,
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
if (isTopOne && onFocusTap != null)
|
|
GestureDetector(
|
|
onTap: onFocusTap,
|
|
child: Container(
|
|
margin: const EdgeInsets.only(right: 16),
|
|
padding: const EdgeInsets.all(10),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFFF7F50).withOpacity(0.1),
|
|
shape: BoxShape.circle,
|
|
),
|
|
child: const Icon(
|
|
Icons.play_arrow_rounded,
|
|
color: Color(0xFFFF7F50),
|
|
size: 22,
|
|
),
|
|
),
|
|
)
|
|
else if (isPriority)
|
|
Padding(
|
|
padding: const EdgeInsets.only(right: 16),
|
|
child: Icon(Icons.drag_indicator, color: Colors.grey.shade200, size: 20),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|