feat:更新主题色兼容
This commit is contained in:
@@ -16,3 +16,9 @@ bool isToday(DateTime? date) {
|
||||
date.month == now.month &&
|
||||
date.day == now.day;
|
||||
}
|
||||
|
||||
bool isAfterToday(DateTime? date) {
|
||||
if (date == null) return false;
|
||||
|
||||
return date.isAfter(DateTime.now());
|
||||
}
|
||||
|
||||
@@ -25,16 +25,23 @@ List<Todo> getActiveTodos(TodoTab currentTab, List<Todo> todos) {
|
||||
|
||||
// 格式化截止日期
|
||||
String formatDueDate(DateTime dueDate, bool isToday, bool isTomorrow) {
|
||||
if (isToday) return '今天截止';
|
||||
if (isTomorrow) return '明天截止';
|
||||
|
||||
final now = DateTime.now();
|
||||
final difference = dueDate.difference(DateTime(now.year, now.month, now.day));
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
final dueDateStart = DateTime(dueDate.year, dueDate.month, dueDate.day);
|
||||
final difference = dueDateStart.difference(today);
|
||||
|
||||
if (difference.inDays < 7) {
|
||||
return '${difference.inDays}天后截止';
|
||||
// 处理过期情况
|
||||
if (difference.inDays < 0) {
|
||||
final daysPast = -difference.inDays;
|
||||
return '已过期$daysPast天';
|
||||
}
|
||||
|
||||
// 处理未来日期
|
||||
if (difference.inDays == 0) return '今天截止';
|
||||
if (difference.inDays == 1) return '明天截止';
|
||||
if (difference.inDays == 2) return '后天截止';
|
||||
if (difference.inDays < 7) return '${difference.inDays}天后截止';
|
||||
|
||||
return DateFormat("MM-dd").format(dueDate);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user