feat:更新待办事项对话框功能
This commit is contained in:
@@ -72,7 +72,7 @@ Widget buildTabs({
|
||||
Widget buildTodoList({
|
||||
required List<TodoItem> todos,
|
||||
required ValueChanged<String> onToggleTodo,
|
||||
required ValueChanged<TodoItem> onEditTodo
|
||||
required ValueChanged<TodoItem> onEditTodo,
|
||||
}) {
|
||||
return ListView.separated(
|
||||
itemCount: todos.length,
|
||||
@@ -82,7 +82,7 @@ Widget buildTodoList({
|
||||
return _buildTodoItem(
|
||||
todo: todo,
|
||||
onToggle: onToggleTodo,
|
||||
onEdit: onEditTodo
|
||||
onEdit: onEditTodo,
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -91,13 +91,18 @@ Widget buildTodoList({
|
||||
Widget _buildTodoItem({
|
||||
required TodoItem todo,
|
||||
required ValueChanged<String> onToggle,
|
||||
required ValueChanged<TodoItem> onEdit
|
||||
required ValueChanged<TodoItem> onEdit,
|
||||
}) {
|
||||
return buildCard(
|
||||
child: ListTile(
|
||||
leading: Checkbox(
|
||||
value: todo.isCompleted,
|
||||
onChanged: (value) => onToggle(todo.id),
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 0),
|
||||
leading: SizedBox(
|
||||
width: 24,
|
||||
child: Checkbox(
|
||||
value: todo.isCompleted,
|
||||
onChanged: (value) => onToggle(todo.id.toString()),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
),
|
||||
title: _buildTodoTitle(todo),
|
||||
subtitle: _buildTodoSubtitle(todo),
|
||||
@@ -126,8 +131,7 @@ Widget? _buildTodoSubtitle(TodoItem todo) {
|
||||
todo.dueDate!.isBefore(DateTime.now()) &&
|
||||
!todo.isCompleted;
|
||||
|
||||
final hasContent =
|
||||
todo.description?.isNotEmpty == true || todo.dueDate != null;
|
||||
final hasContent = todo.content.isNotEmpty == true || todo.dueDate != null;
|
||||
|
||||
if (!hasContent) return null;
|
||||
|
||||
@@ -135,9 +139,9 @@ Widget? _buildTodoSubtitle(TodoItem todo) {
|
||||
direction: Axis.vertical,
|
||||
spacing: 5,
|
||||
children: [
|
||||
if (todo.description?.isNotEmpty == true)
|
||||
if (todo.content.isNotEmpty == true)
|
||||
Text(
|
||||
todo.description!,
|
||||
todo.content,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 12, color: Colors.grey.shade600),
|
||||
@@ -160,11 +164,7 @@ Widget _buildPriorityBadge(TodoPriority priority) {
|
||||
return Chip(
|
||||
label: Text(priority.label),
|
||||
backgroundColor: priority.color,
|
||||
labelStyle: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
labelStyle: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
side: BorderSide(color: Colors.white),
|
||||
@@ -175,7 +175,7 @@ Widget _buildPriorityBadge(TodoPriority priority) {
|
||||
}
|
||||
|
||||
// 空状态
|
||||
Widget buildEmptyState(TodoTab currentFilter) {
|
||||
Widget buildEmptyState(TodoTab tab) {
|
||||
final messages = {
|
||||
TodoTab.all: '📝 还没有待办事项\n点击➕号添加第一个任务吧~',
|
||||
TodoTab.active: '🎯 没有待完成的任务\n享受轻松时光吧!✨',
|
||||
@@ -188,11 +188,10 @@ Widget buildEmptyState(TodoTab currentFilter) {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.checklist, size: 80, color: Colors.orange.shade600),
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
messages[currentFilter] ?? '暂无数据',
|
||||
messages[tab] ?? '暂无数据',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 16, color: Colors.orange.shade600),
|
||||
style: TextStyle(color: Colors.orange.shade600),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user