feat:合并待办和提醒功能
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:flisp_app/models/todo.dart';
|
||||
import 'package:flisp_app/utils/todo_utils.dart';
|
||||
import 'package:flisp_app/widgets/common.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
@@ -125,52 +126,128 @@ Widget _buildTodoTitle(Todo todo) {
|
||||
);
|
||||
}
|
||||
|
||||
// 构建待办事项副标题
|
||||
Widget? _buildTodoSubtitle(Todo todo) {
|
||||
Widget _buildContent(Todo todo) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: Text(
|
||||
todo.content,
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontSize: 13, color: Colors.grey[600], height: 1.3),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDueDateChip(Todo todo) {
|
||||
final isOverdue =
|
||||
todo.dueDate != null &&
|
||||
todo.dueDate!.isBefore(DateTime.now()) &&
|
||||
!todo.isCompleted;
|
||||
todo.dueDate!.isBefore(DateTime.now()) &&
|
||||
!todo.isCompleted;
|
||||
|
||||
final hasContent = todo.content.isNotEmpty == true || todo.dueDate != null;
|
||||
final isDueToday =
|
||||
todo.dueDate != null && isSameDay(todo.dueDate!, DateTime.now());
|
||||
|
||||
final isDueTomorrow =
|
||||
todo.dueDate != null &&
|
||||
isSameDay(todo.dueDate!, DateTime.now().add(Duration(days: 1)));
|
||||
|
||||
return _buildInfoChip(
|
||||
icon: Icons.access_time_rounded,
|
||||
text: formatDueDate(todo.dueDate!, isDueToday, isDueTomorrow),
|
||||
backgroundColor:
|
||||
isOverdue
|
||||
? Colors.red[50]!
|
||||
: (isDueToday ? Colors.orange[50]! : Colors.grey[50]!),
|
||||
borderColor:
|
||||
isOverdue
|
||||
? Colors.red[200]!
|
||||
: (isDueToday ? Colors.orange[200]! : Colors.grey[300]!),
|
||||
textColor:
|
||||
isOverdue
|
||||
? Colors.red[700]!
|
||||
: (isDueToday ? Colors.orange[700]! : Colors.grey[700]!),
|
||||
iconColor:
|
||||
isOverdue
|
||||
? Colors.red[500]!
|
||||
: (isDueToday ? Colors.orange[500]! : Colors.grey[500]!),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildScheduledTimeChip(Todo todo) {
|
||||
return _buildInfoChip(
|
||||
icon: Icons.notifications_active_rounded,
|
||||
text: DateFormat("MM-dd HH:mm").format(todo.scheduledTime!),
|
||||
backgroundColor: Colors.blue[50]!,
|
||||
borderColor: Colors.blue[200]!,
|
||||
textColor: Colors.blue[700]!,
|
||||
iconColor: Colors.blue[500]!,
|
||||
);
|
||||
}
|
||||
|
||||
// 构建待办事项副标题
|
||||
Widget? _buildTodoSubtitle(Todo todo) {
|
||||
final hasContent =
|
||||
todo.content.isNotEmpty == true ||
|
||||
todo.dueDate != null ||
|
||||
todo.scheduledTime != null;
|
||||
|
||||
if (!hasContent) return null;
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 4),
|
||||
if (todo.content.isNotEmpty == true)
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 6),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 内容文本
|
||||
if (todo.content.isNotEmpty == true) _buildContent(todo),
|
||||
// 标签容器
|
||||
Wrap(
|
||||
spacing: 6,
|
||||
runSpacing: 6,
|
||||
children: [
|
||||
// 截止日期标签
|
||||
if (todo.dueDate != null) _buildDueDateChip(todo),
|
||||
// 提醒时间标签
|
||||
if (todo.scheduledTime != null) _buildScheduledTimeChip(todo),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// 构建信息标签
|
||||
Widget _buildInfoChip({
|
||||
required IconData icon,
|
||||
required String text,
|
||||
required Color backgroundColor,
|
||||
required Color borderColor,
|
||||
required Color textColor,
|
||||
required Color iconColor,
|
||||
}) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: borderColor, width: 1),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(icon, size: 12, color: iconColor),
|
||||
const SizedBox(width: 4),
|
||||
Text(
|
||||
todo.content,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: Colors.grey[700],
|
||||
fontSize: 10,
|
||||
color: textColor,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.2,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
if (todo.dueDate != null)
|
||||
Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: isOverdue ? Colors.red[50] : Colors.grey[50],
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(
|
||||
color: isOverdue ? Colors.red[100]! : Colors.grey[300]!,
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
'截止: ${DateFormat("yyyy-MM-dd").format(todo.dueDate!)}',
|
||||
style: TextStyle(
|
||||
fontSize: 11,
|
||||
color: isOverdue ? Colors.red[600] : Colors.grey[600],
|
||||
fontWeight: isOverdue ? FontWeight.w600 : FontWeight.normal,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user