feat:增加主题颜色和暗黑模式
This commit is contained in:
@@ -25,7 +25,7 @@ void showAwesomeDialog({
|
||||
onPressed: onOk,
|
||||
style: ElevatedButton.styleFrom(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.orange,
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
@@ -61,7 +61,7 @@ void showErrorDialog(BuildContext context, String message) {
|
||||
animType: AnimType.scale,
|
||||
title: message,
|
||||
btnOkText: "好的",
|
||||
btnOkColor: Colors.green,
|
||||
btnOkColor: Colors.red,
|
||||
btnOkOnPress: () {},
|
||||
autoHide: Duration(seconds: 2),
|
||||
).show();
|
||||
|
||||
@@ -8,21 +8,25 @@ BoxDecoration buildBoxDecoration() {
|
||||
);
|
||||
}
|
||||
|
||||
Container buildBody({Widget? child}) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
color: Colors.grey[50],
|
||||
padding: EdgeInsets.all(8),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
class BuildCard extends StatelessWidget {
|
||||
final Widget? child;
|
||||
|
||||
Container buildCard({Widget? child}) {
|
||||
return Container(
|
||||
decoration: buildBoxDecoration(),
|
||||
padding: EdgeInsets.all(10),
|
||||
child: child,
|
||||
);
|
||||
const BuildCard({super.key, this.child});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: colors.surface,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(color: colors.outline.withAlpha(50), width: 1),
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void buildModalBottom({
|
||||
|
||||
@@ -11,7 +11,7 @@ Widget buildStatsCard(List<Flisp> flisps) {
|
||||
int workCount = flisps.where((flisp) => flisp.tag == FlispTag.work).length;
|
||||
int studyCount = flisps.where((flisp) => flisp.tag == FlispTag.study).length;
|
||||
|
||||
return buildCard(
|
||||
return BuildCard(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
@@ -42,6 +42,7 @@ Widget _buildStatItem(String label, int count, Color color) {
|
||||
}
|
||||
|
||||
Widget buildTabs({
|
||||
required BuildContext context,
|
||||
required FlispTab currentTab,
|
||||
required ValueChanged<FlispTab> onTabChanged,
|
||||
}) {
|
||||
@@ -53,7 +54,7 @@ Widget buildTabs({
|
||||
initialLabelIndex: FlispTab.values.indexOf(currentTab),
|
||||
totalSwitches: FlispTab.values.length,
|
||||
labels: FlispTab.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,
|
||||
@@ -89,11 +90,15 @@ Widget buildFlispList({
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFlispContent(Flisp flisp) {
|
||||
Widget _buildFlispContent(BuildContext context, Flisp flisp) {
|
||||
return RichText(
|
||||
text: TextSpan(
|
||||
text: flisp.content,
|
||||
style: const TextStyle(color: Colors.black87, fontSize: 16),
|
||||
style: TextStyle(
|
||||
fontFamily: 'CustomFont',
|
||||
color: Theme.of(context).colorScheme.onSurface,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -281,15 +286,13 @@ Widget _buildFlispItem({
|
||||
onDismissed: (direction) {
|
||||
onDelete(flisp);
|
||||
},
|
||||
child: Container(
|
||||
decoration: buildBoxDecoration(),
|
||||
padding: EdgeInsets.all(16),
|
||||
child: BuildCard(
|
||||
child: InkWell(
|
||||
onTap: () => onEdit(flisp),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildFlispContent(flisp),
|
||||
_buildFlispContent(context, flisp),
|
||||
const SizedBox(height: 8),
|
||||
if (hasImage) buildFlispImage(flisp: flisp, showDelete: false),
|
||||
const SizedBox(height: 4),
|
||||
@@ -337,16 +340,19 @@ Widget _buildDismissBackground() {
|
||||
}
|
||||
|
||||
// 空状态
|
||||
Widget buildEmptyState() {
|
||||
Widget buildEmptyState(BuildContext context) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(Icons.flash_on, size: 80, color: Colors.orange.shade600),
|
||||
Icon(Icons.flash_on, size: 80, color: colors.primary),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'📝 还没有闪灵\n点击➕号添加第一个灵感吧~',
|
||||
'📝 还没有该类别闪灵\n点击➕号添加第一个灵感吧~',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(color: Colors.orange.shade600),
|
||||
style: TextStyle(color: colors.onSurface, fontSize: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -38,7 +38,7 @@ class _TodoFormState extends State<TodoForm> {
|
||||
children: [
|
||||
Icon(
|
||||
widget.isEditing ? Icons.edit_note : Icons.add_task,
|
||||
color: Colors.orange,
|
||||
color: Theme.of(context).primaryColor,
|
||||
size: 24,
|
||||
),
|
||||
SizedBox(width: 8),
|
||||
@@ -47,7 +47,7 @@ class _TodoFormState extends State<TodoForm> {
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.orange,
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -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),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user