feat:增加主题色存储本地的功能
This commit is contained in:
@@ -50,31 +50,22 @@ Widget buildTabs({
|
||||
}) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: ToggleSwitch(
|
||||
minWidth: 90.0,
|
||||
minHeight: 40.0,
|
||||
initialLabelIndex: TodoTab.values.indexOf(currentTab),
|
||||
totalSwitches: TodoTab.values.length,
|
||||
child: buildToggleSwitch(
|
||||
context: context,
|
||||
currentTab: currentTab,
|
||||
tabValues: TodoTab.values,
|
||||
labels: TodoTab.values.map((e) => e.label).toList(),
|
||||
activeBgColor: [Theme.of(context).colorScheme.primary],
|
||||
activeFgColor: Colors.white,
|
||||
inactiveBgColor: Colors.grey.shade200,
|
||||
inactiveFgColor: Colors.grey.shade700,
|
||||
cornerRadius: 12.0,
|
||||
customTextStyles: [TextStyle(fontSize: 12, fontWeight: FontWeight.w500)],
|
||||
onToggle: (index) {
|
||||
if (index != null) {
|
||||
onTabChanged(TodoTab.values[index]);
|
||||
}
|
||||
},
|
||||
onTabChanged: onTabChanged,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildTodoList({
|
||||
required BuildContext context,
|
||||
required List<Todo> todos,
|
||||
required ValueChanged<Todo> onToggleTodo,
|
||||
required ValueChanged<Todo> onEditTodo,
|
||||
required ValueChanged<Todo> onDelete,
|
||||
}) {
|
||||
return ListView.separated(
|
||||
itemCount: todos.length,
|
||||
@@ -82,35 +73,44 @@ Widget buildTodoList({
|
||||
itemBuilder: (context, index) {
|
||||
final todo = todos[index];
|
||||
return _buildTodoItem(
|
||||
context: context,
|
||||
todo: todo,
|
||||
onToggle: onToggleTodo,
|
||||
onEdit: onEditTodo,
|
||||
onDelete: onDelete,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTodoItem({
|
||||
required BuildContext context,
|
||||
required Todo todo,
|
||||
required ValueChanged<Todo> onToggle,
|
||||
required ValueChanged<Todo> onEdit,
|
||||
required ValueChanged<Todo> onDelete,
|
||||
}) {
|
||||
return BuildCard(
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 0),
|
||||
leading: SizedBox(
|
||||
width: 24,
|
||||
child: Checkbox(
|
||||
value: todo.isCompleted,
|
||||
onChanged: (value) => onToggle(todo),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
return buildDismissible(
|
||||
context: context,
|
||||
id: todo.id,
|
||||
onDelete: () => onDelete(todo),
|
||||
child: BuildCard(
|
||||
child: ListTile(
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 8, vertical: 0),
|
||||
leading: SizedBox(
|
||||
width: 24,
|
||||
child: Checkbox(
|
||||
value: todo.isCompleted,
|
||||
onChanged: (value) => onToggle(todo),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
),
|
||||
title: _buildTodoTitle(todo),
|
||||
subtitle: _buildTodoSubtitle(todo),
|
||||
trailing: _buildPriorityBadge(todo.priority),
|
||||
onTap: () => onEdit(todo),
|
||||
// onLongPress: () => onShowOptions(todo),
|
||||
),
|
||||
title: _buildTodoTitle(todo),
|
||||
subtitle: _buildTodoSubtitle(todo),
|
||||
trailing: _buildPriorityBadge(todo.priority),
|
||||
onTap: () => onEdit(todo),
|
||||
// onLongPress: () => onShowOptions(todo),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user