feat:增加主题颜色和暗黑模式

This commit is contained in:
2025-11-11 20:02:09 +08:00
parent 703a5a6aeb
commit 741d6842b8
13 changed files with 446 additions and 183 deletions

View File

@@ -13,7 +13,7 @@ Widget buildStatsCard(List<Todo> todos) {
int completedCount = todos.where((todo) => todo.isCompleted).length;
return buildCard(
return BuildCard(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
@@ -44,6 +44,7 @@ Widget _buildStatItem(String label, int count, Color color) {
// Tab页
Widget buildTabs({
required BuildContext context,
required TodoTab currentTab,
required ValueChanged<TodoTab> onTabChanged,
}) {
@@ -55,7 +56,7 @@ Widget buildTabs({
initialLabelIndex: TodoTab.values.indexOf(currentTab),
totalSwitches: TodoTab.values.length,
labels: TodoTab.values.map((e) => e.label).toList(),
activeBgColor: [Colors.orange.shade600],
activeBgColor: [Theme.of(context).colorScheme.primary],
activeFgColor: Colors.white,
inactiveBgColor: Colors.grey.shade200,
inactiveFgColor: Colors.grey.shade700,
@@ -94,7 +95,7 @@ Widget _buildTodoItem({
required ValueChanged<Todo> onToggle,
required ValueChanged<Todo> onEdit,
}) {
return buildCard(
return BuildCard(
child: ListTile(
contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 0),
leading: SizedBox(
@@ -267,7 +268,7 @@ Widget _buildPriorityBadge(TodoPriority priority) {
}
// 空状态
Widget buildEmptyState(TodoTab tab) {
Widget buildEmptyState(BuildContext context, TodoTab tab) {
final messages = {
TodoTab.all: '📝 还没有待办事项\n点击➕号添加第一个任务吧~',
TodoTab.active: '🎯 没有待完成的任务\n享受轻松时光吧!✨',
@@ -275,15 +276,18 @@ Widget buildEmptyState(TodoTab tab) {
TodoTab.today: '📅 今天没有安排任务\n好好放松一下吧~😊',
};
final colors = Theme.of(context).colorScheme;
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.checklist, size: 80, color: Colors.orange.shade600),
Icon(Icons.checklist, size: 80, color: colors.primary),
const SizedBox(height: 16),
Text(
messages[tab] ?? '暂无数据',
textAlign: TextAlign.center,
style: TextStyle(color: Colors.orange.shade600),
style: TextStyle(color: colors.onSurface, fontSize: 16),
),
],
),