feat:增加待办提醒功能

This commit is contained in:
2026-04-29 19:21:57 +08:00
parent 3804164cfd
commit 0e6fe4ad4b
16 changed files with 297 additions and 64 deletions

View File

@@ -1,4 +1,5 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:intl/intl.dart';
import 'package:task_hub/models/task.dart';
class TaskItem extends StatelessWidget {
@@ -39,11 +40,14 @@ class TaskItem extends StatelessWidget {
Expanded(child: _buildTitle(context)),
],
),
const SizedBox(height: 4),
if (task.desc != null && task.desc!.isNotEmpty) _buildDesc(),
const SizedBox(height: 4),
if (task.dueDate != null || task.scheduleTime != null)
if (task.desc != null && task.desc!.isNotEmpty) ...[
const SizedBox(height: 4),
_buildDesc(),
],
if (task.dueDate != null || task.scheduleTime != null) ...[
const SizedBox(height: 4),
_buildDate(),
]
],
),
),
@@ -92,7 +96,7 @@ class TaskItem extends StatelessWidget {
Icon(FluentIcons.calendar, size: 12, color: Colors.grey),
const SizedBox(width: 4),
Text(
'截止日期: ${_formatDate(task.dueDate!)}',
'截止日期: ${DateFormat('yyyy-MM-dd').format(task.dueDate!)}',
style: TextStyle(color: Colors.grey, fontSize: 12),
),
const SizedBox(width: 4),
@@ -101,7 +105,7 @@ class TaskItem extends StatelessWidget {
Icon(FluentIcons.clock, size: 12, color: Colors.grey),
const SizedBox(width: 4),
Text(
'提醒日期: ${_formatDate(task.scheduleTime!)}',
'提醒日期: ${DateFormat('yyyy-MM-dd HH:mm:ss').format(task.scheduleTime!)}',
style: TextStyle(color: Colors.grey, fontSize: 12),
),
],
@@ -181,8 +185,4 @@ class TaskItem extends StatelessWidget {
),
);
}
String _formatDate(DateTime date) {
return '${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}';
}
}