feat:增加主题色

This commit is contained in:
2026-04-26 17:22:14 +08:00
parent 8f6e4cc23e
commit db52de7b56
11 changed files with 108 additions and 93 deletions

View File

@@ -20,12 +20,11 @@ class _TaskPageState extends State<TaskPage> {
String _sortBy = 'created';
List<Task> get _filteredTasks {
List<Task> tasks =
_tasks.where((task) {
if (_filter == 'active') return !task.isCompleted;
if (_filter == 'completed') return task.isCompleted;
return true;
}).toList();
List<Task> tasks = _tasks.where((task) {
if (_filter == 'active') return !task.isCompleted;
if (_filter == 'completed') return task.isCompleted;
return true;
}).toList();
tasks.sort((a, b) {
switch (_sortBy) {
@@ -48,32 +47,30 @@ class _TaskPageState extends State<TaskPage> {
void _addTask() {
showDialog(
context: context,
builder:
(context) => TaskDialog(
onSave: (task) {
setState(() {
_tasks.add(task);
});
},
),
builder: (context) => TaskDialog(
onSave: (task) {
setState(() {
_tasks.add(task);
});
},
),
);
}
void _editTask(Task task) {
showDialog(
context: context,
builder:
(context) => TaskDialog(
task: task,
onSave: (editedTask) {
setState(() {
final index = _tasks.indexWhere((t) => t.id == task.id);
if (index != -1) {
_tasks[index] = editedTask;
}
});
},
),
builder: (context) => TaskDialog(
task: task,
onSave: (editedTask) {
setState(() {
final index = _tasks.indexWhere((t) => t.id == task.id);
if (index != -1) {
_tasks[index] = editedTask;
}
});
},
),
);
}
@@ -137,7 +134,7 @@ class _TaskPageState extends State<TaskPage> {
final activeCount = _tasks.length - completedCount;
return Card(
backgroundColor: Colors.grey[20],
backgroundColor: FluentTheme.of(context).accentColor.lighter,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Row(
@@ -157,10 +154,14 @@ class _TaskPageState extends State<TaskPage> {
children: [
Text(
value,
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
const SizedBox(height: 4),
Text(label, style: TextStyle(color: Colors.grey)),
Text(label, style: TextStyle(color: Colors.white)),
],
);
}
@@ -232,7 +233,11 @@ class _TaskPageState extends State<TaskPage> {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(FluentIcons.check_list, size: 64, color: Colors.blue),
Icon(
FluentIcons.check_list,
size: 64,
color: FluentTheme.of(context).accentColor,
),
const SizedBox(height: 20),
const Text(
'还没有任务',
@@ -256,7 +261,7 @@ class _TaskPageState extends State<TaskPage> {
task: task,
onToggleComplete: () => _toggleTaskComplete(task),
onEdit: () => _editTask(task),
onDelete: () => _deleteTask(task.id)
onDelete: () => _deleteTask(task.id),
),
);
},