适配深色模式

This commit is contained in:
DelLevin-Home
2026-05-26 05:10:21 +08:00
parent b36f50827f
commit 73f3795e65
53 changed files with 3846 additions and 3211 deletions

View File

@@ -22,13 +22,14 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
final note = context.watch<AppProvider>().notes.firstWhere(
(n) => n.id == widget.note.id,
orElse: () => widget.note,
);
return Scaffold(
backgroundColor: Colors.white,
backgroundColor: colors.surface,
appBar: AppBar(
title: Text(
note.title.isNotEmpty
@@ -42,22 +43,21 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
children: [
Column(
children: [
// 日期 + 字数
Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
decoration: const BoxDecoration(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: Color(0xFFE8E8E8), width: 0.5),
bottom: BorderSide(color: colors.outlineVariant, width: 0.5),
),
),
child: Row(
children: [
Text(
'${note.createdAt.day}',
style: const TextStyle(
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.w200,
color: Color(0xFF333333),
color: colors.onSurface.withValues(alpha: 0.75),
height: 1.0,
),
),
@@ -68,48 +68,44 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
children: [
Text(
'${note.createdAt.year}/${note.createdAt.month.toString().padLeft(2, '0')}${_weekdays[note.createdAt.weekday - 1]}',
style: const TextStyle(fontSize: 11, fontWeight: FontWeight.w500, color: Color(0xFF777777)),
style: TextStyle(fontSize: 11, fontWeight: FontWeight.w500, color: colors.onSurface.withValues(alpha: 0.55)),
),
const SizedBox(height: 1),
Text(
'${note.createdAt.hour.toString().padLeft(2, '0')}:${note.createdAt.minute.toString().padLeft(2, '0')}',
style: const TextStyle(fontSize: 11, color: Color(0xFF999999)),
style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.4)),
),
],
),
const Spacer(),
Text(
'${note.content.length}',
style: const TextStyle(fontSize: 11, color: Color(0xFFAAAAAA)),
style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.35)),
),
],
),
),
// 标签行
if (note.tags.isNotEmpty)
Padding(
padding: const EdgeInsets.only(top: 6),
child: _buildTagRow(note.tags),
),
// 内容
Expanded(
child: Markdown(
data: note.content,
styleSheet: _buildMarkdownStyleSheet(),
styleSheet: _buildMarkdownStyleSheet(colors),
padding: const EdgeInsets.all(16),
// ignore: deprecated_member_use
imageBuilder: (uri, title, alt) => _buildMarkdownImage(uri, note),
),
),
// 图片行
if (note.images.isNotEmpty) _buildImageRow(note.images),
],
),
// 右下角悬浮按钮组
Positioned(
right: 16,
bottom: 24,
@@ -121,6 +117,7 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
}
Widget _buildTagRow(List<String> tags) {
final colors = Theme.of(context).colorScheme;
return Container(
height: 28,
margin: const EdgeInsets.only(bottom: 2),
@@ -133,12 +130,12 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: const Color(0xFFF5F5F5),
color: colors.surfaceContainerHighest,
borderRadius: BorderRadius.circular(6),
),
child: Text(
tags[index],
style: const TextStyle(fontSize: 11, color: Color(0xFF666666)),
style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.6)),
),
);
},
@@ -147,12 +144,13 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
}
Widget _buildImageRow(List<String> images) {
final colors = Theme.of(context).colorScheme;
return Container(
height: 80,
decoration: BoxDecoration(
color: Colors.white,
border: const Border(
top: BorderSide(color: Color(0xFFE8E8E8), width: 0.5),
color: colors.surface,
border: Border(
top: BorderSide(color: colors.outlineVariant, width: 0.5),
),
boxShadow: [
BoxShadow(
@@ -175,15 +173,15 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
height: 64,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
border: Border.all(color: const Color(0xFFE8E8E8), width: 0.5),
border: Border.all(color: colors.outlineVariant, width: 0.5),
),
clipBehavior: Clip.antiAlias,
child: Image.file(
File(images[index]),
fit: BoxFit.cover,
errorBuilder: (_, __, ___) => Container(
color: const Color(0xFFF5F5F5),
child: const Icon(Icons.broken_image_outlined, size: 20, color: Color(0xFFCCCCCC)),
color: colors.surfaceContainerHighest,
child: Icon(Icons.broken_image_outlined, size: 20, color: colors.onSurface.withValues(alpha: 0.25)),
),
),
),
@@ -193,37 +191,37 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
);
}
MarkdownStyleSheet _buildMarkdownStyleSheet() {
MarkdownStyleSheet _buildMarkdownStyleSheet(ColorScheme colors) {
return MarkdownStyleSheet(
h1: const TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: Color(0xFF1A1A1A), height: 1.4),
h2: const TextStyle(fontSize: 20, fontWeight: FontWeight.w600, color: Color(0xFF1A1A1A), height: 1.4),
h3: const TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: Color(0xFF1A1A1A), height: 1.4),
h4: const TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: Color(0xFF1A1A1A), height: 1.4),
p: const TextStyle(fontSize: 15, color: Color(0xFF333333), height: 1.8),
code: const TextStyle(fontSize: 14, color: Color(0xFF1A1A1A), backgroundColor: Color(0xFFF5F5F5), fontFamily: 'monospace'),
h1: TextStyle(fontSize: 24, fontWeight: FontWeight.w600, color: colors.onSurface, height: 1.4),
h2: TextStyle(fontSize: 20, fontWeight: FontWeight.w600, color: colors.onSurface, height: 1.4),
h3: TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: colors.onSurface, height: 1.4),
h4: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: colors.onSurface, height: 1.4),
p: TextStyle(fontSize: 15, color: colors.onSurface.withValues(alpha: 0.75), height: 1.8),
code: TextStyle(fontSize: 14, color: colors.onSurface, backgroundColor: colors.surfaceContainerHighest, fontFamily: 'monospace'),
codeblockDecoration: BoxDecoration(
color: const Color(0xFFF8F8F8),
border: Border.all(color: const Color(0xFFE5E5E5)),
color: colors.surfaceContainerHigh,
border: Border.all(color: colors.outline),
borderRadius: BorderRadius.circular(6),
),
codeblockPadding: const EdgeInsets.all(12),
blockquote: const TextStyle(fontSize: 15, color: Color(0xFF666666), fontStyle: FontStyle.italic, height: 1.8),
blockquoteDecoration: const BoxDecoration(
border: Border(left: BorderSide(color: Color(0xFF999999), width: 4)),
blockquote: TextStyle(fontSize: 15, color: colors.onSurface.withValues(alpha: 0.6), fontStyle: FontStyle.italic, height: 1.8),
blockquoteDecoration: BoxDecoration(
border: Border(left: BorderSide(color: colors.onSurface.withValues(alpha: 0.4), width: 4)),
),
blockquotePadding: const EdgeInsets.only(left: 12, top: 4, bottom: 4),
listBullet: const TextStyle(fontSize: 15, color: Color(0xFF1A1A1A)),
listBullet: TextStyle(fontSize: 15, color: colors.onSurface),
listIndent: 24,
a: const TextStyle(fontSize: 15, color: Color(0xFF4A90D9), decoration: TextDecoration.underline),
tableHead: const TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: Color(0xFF1A1A1A)),
tableBody: const TextStyle(fontSize: 14, color: Color(0xFF333333)),
tableBorder: TableBorder.all(color: const Color(0xFFE5E5E5), width: 0.5),
tableHead: TextStyle(fontSize: 14, fontWeight: FontWeight.w600, color: colors.onSurface),
tableBody: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.75)),
tableBorder: TableBorder.all(color: colors.outline, width: 0.5),
tableColumnWidth: const FlexColumnWidth(),
tableCellsDecoration: const BoxDecoration(color: Colors.white),
tableCellsDecoration: BoxDecoration(color: colors.surface),
tablePadding: const EdgeInsets.all(8),
strong: const TextStyle(fontWeight: FontWeight.w600, color: Color(0xFF1A1A1A)),
em: const TextStyle(fontStyle: FontStyle.italic, color: Color(0xFF333333)),
del: const TextStyle(decoration: TextDecoration.lineThrough, color: Color(0xFF999999)),
strong: TextStyle(fontWeight: FontWeight.w600, color: colors.onSurface),
em: TextStyle(fontStyle: FontStyle.italic, color: colors.onSurface.withValues(alpha: 0.75)),
del: TextStyle(decoration: TextDecoration.lineThrough, color: colors.onSurface.withValues(alpha: 0.4)),
);
}
@@ -272,7 +270,6 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
);
}
/// 截取内容前N个字作为标题
String _truncateContent(String content) {
final cleaned = content
.replaceAll(RegExp(r'^#+\s+', multiLine: true), '')
@@ -298,8 +295,8 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
});
}
/// 右下角悬浮按钮组
Widget _buildFloatingActionButtons() {
final colors = Theme.of(context).colorScheme;
return Column(
mainAxisSize: MainAxisSize.min,
children: [
@@ -307,13 +304,16 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
icon: Icons.edit_outlined,
onPressed: () => _navigateToEdit(context),
tooltip: '编辑',
backgroundColor: colors.primary,
foregroundColor: colors.onPrimary,
),
const SizedBox(height: 12),
_buildFloatingButton(
icon: Icons.delete_outline,
onPressed: () => _showDeleteDialog(context),
tooltip: '删除',
backgroundColor: Colors.red,
backgroundColor: colors.error,
foregroundColor: colors.onError,
),
const SizedBox(height: 12),
_buildFloatingButton(
@@ -321,6 +321,7 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
onPressed: _shareNote,
tooltip: '分享',
backgroundColor: const Color(0xFF4CAF50),
foregroundColor: Colors.white,
),
],
);
@@ -330,7 +331,8 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
required IconData icon,
required VoidCallback onPressed,
required String tooltip,
Color backgroundColor = const Color(0xFF1A1A1A),
required Color backgroundColor,
required Color foregroundColor,
}) {
return Material(
color: Colors.transparent,
@@ -349,7 +351,7 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
],
),
child: IconButton(
icon: Icon(icon, size: 18, color: Colors.white),
icon: Icon(icon, size: 18, color: foregroundColor),
onPressed: onPressed,
padding: EdgeInsets.zero,
tooltip: tooltip,
@@ -375,7 +377,7 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
context.read<AppProvider>().removeNote(widget.note.id);
Navigator.pop(context);
},
child: const Text('删除', style: TextStyle(color: Colors.red)),
child: Text('删除', style: TextStyle(color: Theme.of(context).colorScheme.error)),
),
],
),

View File

@@ -59,8 +59,9 @@ class _NoteFormPageState extends State<NoteFormPage> {
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: Colors.white,
backgroundColor: colors.surface,
resizeToAvoidBottomInset: true,
appBar: AppBar(
title: GestureDetector(
@@ -73,8 +74,8 @@ class _NoteFormPageState extends State<NoteFormPage> {
child: TextButton(
onPressed: _saveNote,
style: TextButton.styleFrom(
backgroundColor: const Color(0xFF1A1A1A),
foregroundColor: Colors.white,
backgroundColor: colors.primary,
foregroundColor: colors.onPrimary,
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20),
@@ -96,9 +97,9 @@ class _NoteFormPageState extends State<NoteFormPage> {
// 顶部信息栏
Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
decoration: const BoxDecoration(
decoration: BoxDecoration(
border: Border(
bottom: BorderSide(color: Color(0xFFE8E8E8), width: 0.5),
bottom: BorderSide(color: colors.outline, width: 0.5),
),
),
child: Column(
@@ -110,10 +111,10 @@ class _NoteFormPageState extends State<NoteFormPage> {
// 大日号
Text(
'${_createdAt.day}',
style: const TextStyle(
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.w200,
color: Color(0xFF333333),
color: colors.onSurface.withValues(alpha: 0.75),
height: 1.0,
),
),
@@ -125,18 +126,18 @@ class _NoteFormPageState extends State<NoteFormPage> {
children: [
Text(
'${_createdAt.year}/${_createdAt.month.toString().padLeft(2, '0')}${_weekdays[_createdAt.weekday - 1]}',
style: const TextStyle(
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.w500,
color: Color(0xFF777777),
color: colors.onSurface.withValues(alpha: 0.6),
),
),
const SizedBox(height: 1),
Text(
'${_createdAt.hour.toString().padLeft(2, '0')}:${_createdAt.minute.toString().padLeft(2, '0')}',
style: const TextStyle(
style: TextStyle(
fontSize: 11,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
],
@@ -145,9 +146,9 @@ class _NoteFormPageState extends State<NoteFormPage> {
// 字数统计
Text(
'$_charCount',
style: const TextStyle(
style: TextStyle(
fontSize: 11,
color: Color(0xFFAAAAAA),
color: colors.onSurface.withValues(alpha: 0.35),
),
),
],
@@ -208,13 +209,14 @@ class _NoteFormPageState extends State<NoteFormPage> {
/// 现代极简底部工具栏
Widget _buildFloatingToolbar() {
final colors = Theme.of(context).colorScheme;
return Container(
margin: const EdgeInsets.fromLTRB(12, 8, 12, 10),
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
decoration: BoxDecoration(
color: const Color(0xFFFAFAFA),
color: colors.surfaceContainerHigh,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: const Color(0xFFEAEAEA), width: 0.5),
border: Border.all(color: colors.outlineVariant, width: 0.5),
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.04),
@@ -251,7 +253,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
// 视图模式切换
const SizedBox(width: 8),
Container(
width: 1, height: 20, color: const Color(0xFFE5E5E5),
width: 1, height: 20, color: colors.outline,
),
const SizedBox(width: 8),
_modeSwitch(Icons.edit, 'edit'),
@@ -262,6 +264,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
}
Widget _toolBtn(IconData icon, String tooltip, VoidCallback onTap) {
final colors = Theme.of(context).colorScheme;
return Material(
color: Colors.transparent,
child: InkWell(
@@ -271,7 +274,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
message: tooltip,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 6),
child: Icon(icon, size: 21, color: const Color(0xFF555555)),
child: Icon(icon, size: 21, color: colors.onSurface.withValues(alpha: 0.7)),
),
),
),
@@ -279,16 +282,18 @@ class _NoteFormPageState extends State<NoteFormPage> {
}
Widget _toolGap() {
return const Padding(
padding: EdgeInsets.symmetric(horizontal: 6),
final colors = Theme.of(context).colorScheme;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 6),
child: SizedBox(
height: 18,
child: VerticalDivider(width: 0, thickness: 0.5, color: Color(0xFFE0E0E0)),
child: VerticalDivider(width: 0, thickness: 0.5, color: colors.outline),
),
);
}
Widget _modeSwitch(IconData icon, String mode) {
final colors = Theme.of(context).colorScheme;
final active = _editorMode == mode;
return Material(
color: Colors.transparent,
@@ -298,13 +303,13 @@ class _NoteFormPageState extends State<NoteFormPage> {
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 6),
decoration: BoxDecoration(
color: active ? const Color(0xFF1A1A1A) : Colors.transparent,
color: active ? colors.primary : Colors.transparent,
borderRadius: BorderRadius.circular(8),
),
child: Icon(
icon,
size: 18,
color: active ? Colors.white : const Color(0xFFAAAAAA),
color: active ? colors.onPrimary : colors.onSurface.withValues(alpha: 0.35),
),
),
),
@@ -374,6 +379,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
/// 编辑器
Widget _buildEditor() {
final colors = Theme.of(context).colorScheme;
return TextField(
controller: _contentController,
maxLines: null,
@@ -384,40 +390,41 @@ class _NoteFormPageState extends State<NoteFormPage> {
height: 1.6,
fontSize: 16,
),
style: const TextStyle(
style: TextStyle(
fontSize: 16,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
height: 1.6,
),
decoration: const InputDecoration(
decoration: InputDecoration(
hintText: '使用 Markdown 格式书写...',
hintStyle: TextStyle(
fontSize: 16,
color: Color(0xFFCCCCCC),
color: colors.onSurface.withValues(alpha: 0.25),
height: 1.6,
),
border: InputBorder.none,
focusedBorder: InputBorder.none,
contentPadding: EdgeInsets.all(16),
contentPadding: const EdgeInsets.all(16),
),
);
}
/// 实时 Markdown 预览(点击回到编辑)
Widget _buildPreview() {
final colors = Theme.of(context).colorScheme;
final text = _contentController.text;
return GestureDetector(
onTap: () => setState(() => _editorMode = 'edit'),
behavior: HitTestBehavior.opaque,
child: Container(
color: const Color(0xFFFAFAFA),
color: colors.surfaceContainerHigh,
child: text.isEmpty
? const Center(
? Center(
child: Text(
'预览区域',
style: TextStyle(
fontSize: 14,
color: Color(0xFFCCCCCC),
color: colors.onSurface.withValues(alpha: 0.25),
),
),
)
@@ -426,45 +433,45 @@ class _NoteFormPageState extends State<NoteFormPage> {
selectable: true,
padding: const EdgeInsets.all(16),
styleSheet: MarkdownStyleSheet(
h1: const TextStyle(
h1: TextStyle(
fontSize: 22,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
height: 1.4,
),
h2: const TextStyle(
h2: TextStyle(
fontSize: 19,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
height: 1.4,
),
h3: const TextStyle(
h3: TextStyle(
fontSize: 17,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
height: 1.4,
),
p: const TextStyle(
p: TextStyle(
fontSize: 15,
color: Color(0xFF333333),
color: colors.onSurface.withValues(alpha: 0.75),
height: 1.7,
),
code: const TextStyle(
code: TextStyle(
fontSize: 14,
color: Color(0xFF1A1A1A),
backgroundColor: Color(0xFFF0F0F0),
color: colors.onSurface,
backgroundColor: colors.outlineVariant,
),
codeblockDecoration: BoxDecoration(
color: const Color(0xFFF0F0F0),
color: colors.outlineVariant,
borderRadius: BorderRadius.circular(6),
),
blockquote: const TextStyle(
blockquote: TextStyle(
fontSize: 15,
color: Color(0xFF666666),
color: colors.onSurface.withValues(alpha: 0.6),
),
blockquoteDecoration: const BoxDecoration(
blockquoteDecoration: BoxDecoration(
border: Border(
left: BorderSide(color: Color(0xFFCCCCCC), width: 3),
left: BorderSide(color: colors.onSurface.withValues(alpha: 0.25), width: 3),
),
),
),
@@ -494,10 +501,11 @@ class _NoteFormPageState extends State<NoteFormPage> {
}
Widget _buildTagChip(int index) {
final colors = Theme.of(context).colorScheme;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
decoration: BoxDecoration(
color: const Color(0xFFF5F5F5),
color: colors.surfaceContainerHighest,
borderRadius: BorderRadius.circular(6),
),
child: Row(
@@ -505,12 +513,12 @@ class _NoteFormPageState extends State<NoteFormPage> {
children: [
Text(
_tags[index],
style: const TextStyle(fontSize: 11, color: Color(0xFF666666)),
style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.6)),
),
const SizedBox(width: 3),
GestureDetector(
onTap: () => setState(() => _tags.removeAt(index)),
child: const Icon(Icons.close, size: 10, color: Color(0xFFBBBBBB)),
child: Icon(Icons.close, size: 10, color: colors.onSurface.withValues(alpha: 0.3)),
),
],
),
@@ -518,20 +526,21 @@ class _NoteFormPageState extends State<NoteFormPage> {
}
Widget _buildAddTagButton() {
final colors = Theme.of(context).colorScheme;
return GestureDetector(
onTap: _showAddTagDialog,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
border: Border.all(color: const Color(0xFFDDDDDD), width: 1),
border: Border.all(color: colors.onSurface.withValues(alpha: 0.25), width: 1),
),
child: const Row(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.add, size: 12, color: Color(0xFFAAAAAA)),
SizedBox(width: 2),
Text('标签', style: TextStyle(fontSize: 11, color: Color(0xFFAAAAAA))),
Icon(Icons.add, size: 12, color: colors.onSurface.withValues(alpha: 0.35)),
const SizedBox(width: 2),
Text('标签', style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.35))),
],
),
),
@@ -550,18 +559,20 @@ class _NoteFormPageState extends State<NoteFormPage> {
showDialog(
context: context,
builder: (ctx) => StatefulBuilder(
builder: (ctx) {
final colors = Theme.of(context).colorScheme;
return StatefulBuilder(
builder: (ctx, setDialogState) => AlertDialog(
backgroundColor: Colors.white,
backgroundColor: colors.surface,
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
titlePadding: const EdgeInsets.fromLTRB(24, 24, 24, 0),
title: const Text(
title: Text(
'添加标签',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
),
),
contentPadding: const EdgeInsets.fromLTRB(24, 16, 24, 0),
@@ -575,13 +586,13 @@ class _NoteFormPageState extends State<NoteFormPage> {
TextField(
controller: controller,
autofocus: true,
style: const TextStyle(fontSize: 14, color: Color(0xFF1A1A1A)),
cursorColor: const Color(0xFF1A1A1A),
style: TextStyle(fontSize: 14, color: colors.onSurface),
cursorColor: colors.primary,
decoration: InputDecoration(
hintText: '输入新标签名称',
hintStyle: const TextStyle(fontSize: 14, color: Color(0xFFBBBBBB)),
hintStyle: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.3)),
filled: true,
fillColor: const Color(0xFFF8F8F8),
fillColor: colors.surfaceContainerHigh,
contentPadding: const EdgeInsets.symmetric(horizontal: 14, vertical: 12),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
@@ -593,11 +604,11 @@ class _NoteFormPageState extends State<NoteFormPage> {
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
borderSide: const BorderSide(color: Color(0xFF1A1A1A), width: 1),
borderSide: BorderSide(color: colors.primary, width: 1),
),
suffixIcon: controller.text.isNotEmpty
? IconButton(
icon: const Icon(Icons.clear, size: 16, color: Color(0xFFAAAAAA)),
icon: Icon(Icons.clear, size: 16, color: colors.onSurface.withValues(alpha: 0.35)),
onPressed: () => controller.clear(),
)
: null,
@@ -613,11 +624,11 @@ class _NoteFormPageState extends State<NoteFormPage> {
// 已有标签列表
if (availableTags.isNotEmpty) ...[
const SizedBox(height: 20),
const Text(
Text(
'或选择已有标签',
style: TextStyle(
fontSize: 12,
color: Color(0xFFAAAAAA),
color: colors.onSurface.withValues(alpha: 0.35),
),
),
const SizedBox(height: 12),
@@ -637,15 +648,15 @@ class _NoteFormPageState extends State<NoteFormPage> {
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: const Color(0xFFF5F5F5),
color: colors.surfaceContainerHighest,
borderRadius: BorderRadius.circular(16),
border: Border.all(color: const Color(0xFFE8E8E8), width: 0.5),
border: Border.all(color: colors.outline, width: 0.5),
),
child: Text(
tag,
style: const TextStyle(
style: TextStyle(
fontSize: 13,
color: Color(0xFF555555),
color: colors.onSurface.withValues(alpha: 0.7),
),
),
),
@@ -673,7 +684,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
TextButton(
onPressed: () => Navigator.pop(ctx),
style: TextButton.styleFrom(
foregroundColor: const Color(0xFF999999),
foregroundColor: colors.onSurface.withValues(alpha: 0.4),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
),
child: const Text('取消', style: TextStyle(fontSize: 14)),
@@ -684,8 +695,8 @@ class _NoteFormPageState extends State<NoteFormPage> {
Navigator.pop(ctx);
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF1A1A1A),
foregroundColor: Colors.white,
backgroundColor: colors.primary,
foregroundColor: colors.onPrimary,
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 8),
@@ -695,10 +706,11 @@ class _NoteFormPageState extends State<NoteFormPage> {
],
actionsPadding: const EdgeInsets.fromLTRB(16, 8, 16, 16),
),
),
);
},
);
}
/// 获取所有已有标签(从所有笔记中收集)
List<String> _getAllExistingTags(AppProvider provider) {
final allTags = <String>{};
@@ -717,6 +729,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
}
Widget _buildAppBarTitle() {
final colors = Theme.of(context).colorScheme;
final base = _isEditing ? '编辑笔记' : '新建笔记';
final t = _titleController.text.trim();
if (t.isEmpty) {
@@ -725,7 +738,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
children: [
Text(base),
const SizedBox(width: 6),
const Icon(Icons.edit, size: 14, color: Color(0xFF999999)),
Icon(Icons.edit, size: 14, color: colors.onSurface.withValues(alpha: 0.4)),
],
);
}
@@ -738,8 +751,10 @@ class _NoteFormPageState extends State<NoteFormPage> {
final controller = TextEditingController(text: _titleController.text);
showDialog(
context: context,
builder: (context) => AlertDialog(
backgroundColor: Colors.white,
builder: (context) {
final colors = Theme.of(context).colorScheme;
return AlertDialog(
backgroundColor: colors.surface,
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
title: const Text(
@@ -749,23 +764,23 @@ class _NoteFormPageState extends State<NoteFormPage> {
content: TextField(
controller: controller,
autofocus: true,
style: const TextStyle(fontSize: 16, color: Color(0xFF1A1A1A)),
style: TextStyle(fontSize: 16, color: colors.onSurface),
decoration: InputDecoration(
hintText: '输入标题...',
hintStyle: const TextStyle(fontSize: 14, color: Color(0xFFCCCCCC)),
hintStyle: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.25)),
filled: true,
fillColor: const Color(0xFFFAFAFA),
fillColor: colors.surfaceContainerHigh,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: const BorderSide(color: Color(0xFFE8E8E8), width: 0.5),
borderSide: BorderSide(color: colors.outline, width: 0.5),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: const BorderSide(color: Color(0xFFE8E8E8), width: 0.5),
borderSide: BorderSide(color: colors.outline, width: 0.5),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(8),
borderSide: const BorderSide(color: Color(0xFF1A1A1A), width: 1),
borderSide: BorderSide(color: colors.primary, width: 1),
),
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
),
@@ -778,7 +793,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
TextButton(
onPressed: () => Navigator.pop(context),
style: TextButton.styleFrom(
foregroundColor: const Color(0xFF666666),
foregroundColor: colors.onSurface.withValues(alpha: 0.6),
),
child: const Text('取消'),
),
@@ -788,8 +803,8 @@ class _NoteFormPageState extends State<NoteFormPage> {
Navigator.pop(context);
},
style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF1A1A1A),
foregroundColor: Colors.white,
backgroundColor: colors.primary,
foregroundColor: colors.onPrimary,
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
),
@@ -797,7 +812,8 @@ class _NoteFormPageState extends State<NoteFormPage> {
),
],
actionsPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
),
);
},
);
}
@@ -826,7 +842,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
} else {
// 添加新笔记 - 先创建笔记获取ID
final noteId = now.millisecondsSinceEpoch.toString();
// 如果有图片需要移动到正确的ID目录
List<String> finalImages = [];
if (_images.isNotEmpty) {
@@ -835,7 +851,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
final newNoteId = noteId;
finalImages = await _moveImagesToNewId(oldNoteId, newNoteId);
}
final title = _titleController.text.trim();
final newNote = Note(
@@ -856,17 +872,17 @@ class _NoteFormPageState extends State<NoteFormPage> {
// 刷新笔记列表
await context.read<AppProvider>().loadNotes();
if (!mounted) return;
Navigator.pop(context);
}
/// 将图片从临时ID目录移动到新ID目录
Future<List<String>> _moveImagesToNewId(String oldNoteId, String newNoteId) async {
final List<String> newPaths = [];
final newDir = await ImagePathHelper.instance.getNoteImagesDir(newNoteId);
for (final imagePath in _images) {
// 使用路径分隔符检查,兼容 Windows 和 Unix
final normalizedPath = imagePath.replaceAll('\\', '/');
@@ -874,9 +890,9 @@ class _NoteFormPageState extends State<NoteFormPage> {
// 需要移动的文件
final fileName = p.basename(imagePath);
final newPath = p.join(newDir, fileName);
await ImagePathHelper.instance.ensureDirExists(newDir);
// 检查源文件是否存在
final sourceFile = File(imagePath);
if (await sourceFile.exists()) {
@@ -888,14 +904,14 @@ class _NoteFormPageState extends State<NoteFormPage> {
newPaths.add(imagePath);
}
}
// 删除旧目录
try {
await ImagePathHelper.instance.deleteNoteImages(oldNoteId);
} catch (e) {
// 忽略删除失败
}
return newPaths;
}
@@ -908,11 +924,11 @@ class _NoteFormPageState extends State<NoteFormPage> {
maxHeight: 1920,
imageQuality: 85,
);
if (image != null) {
// 生成唯一的文件名
final fileName = '${DateTime.now().millisecondsSinceEpoch}.jpg';
// 如果是编辑模式使用现有笔记ID如果是新建模式使用临时ID保存时会替换
String noteId;
if (_isEditing) {
@@ -922,14 +938,14 @@ class _NoteFormPageState extends State<NoteFormPage> {
noteId = _tempNoteId ?? DateTime.now().millisecondsSinceEpoch.toString();
_tempNoteId = noteId;
}
// 复制图片到应用目录: images/notes/{noteId}/{fileName}
final targetDir = await ImagePathHelper.instance.getNoteImagesDir(noteId);
await ImagePathHelper.instance.ensureDirExists(targetDir);
final targetPath = p.join(targetDir, fileName);
await File(image.path).copy(targetPath);
setState(() => _images.add(targetPath));
}
} catch (e) {
@@ -939,11 +955,12 @@ class _NoteFormPageState extends State<NoteFormPage> {
/// 构建图片横向滚动行
Widget _buildImageRow() {
final colors = Theme.of(context).colorScheme;
if (_images.isEmpty) {
return Container(
height: 80,
decoration: const BoxDecoration(
color: Colors.white,
decoration: BoxDecoration(
color: colors.surface,
),
child: ListView(
scrollDirection: Axis.horizontal,
@@ -958,7 +975,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
return Container(
height: 88,
decoration: BoxDecoration(
color: Colors.white,
color: colors.surface,
boxShadow: [
BoxShadow(
color: Colors.black.withValues(alpha: 0.02),
@@ -984,6 +1001,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
/// 添加图片按钮
Widget _buildAddImageButton() {
final colors = Theme.of(context).colorScheme;
return InkWell(
onTap: _pickImage,
borderRadius: BorderRadius.circular(12),
@@ -992,13 +1010,13 @@ class _NoteFormPageState extends State<NoteFormPage> {
height: 64,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: const Color(0xFFF8F8F8),
border: Border.all(color: const Color(0xFFE8E8E8), width: 0.5),
color: colors.surfaceContainerHigh,
border: Border.all(color: colors.outline, width: 0.5),
),
child: const Icon(
child: Icon(
Icons.add_photo_alternate_outlined,
size: 24,
color: Color(0xFFBBBBBB),
color: colors.onSurface.withValues(alpha: 0.3),
),
),
);
@@ -1006,6 +1024,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
/// 构建图片项
Widget _buildImageItem(int index) {
final colors = Theme.of(context).colorScheme;
return InkWell(
onTap: () => _showImagePreview(index),
onLongPress: () => _showDeleteImageDialog(index),
@@ -1015,7 +1034,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
height: 64,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border: Border.all(color: const Color(0xFFE8E8E8), width: 0.5),
border: Border.all(color: colors.outline, width: 0.5),
),
clipBehavior: Clip.antiAlias,
child: Image.file(
@@ -1056,8 +1075,10 @@ class _NoteFormPageState extends State<NoteFormPage> {
void _showDeleteImageDialog(int index) {
showDialog(
context: context,
builder: (context) => AlertDialog(
backgroundColor: Colors.white,
builder: (context) {
final colors = Theme.of(context).colorScheme;
return AlertDialog(
backgroundColor: colors.surface,
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
title: const Text(
@@ -1067,11 +1088,11 @@ class _NoteFormPageState extends State<NoteFormPage> {
fontWeight: FontWeight.w600,
),
),
content: const Text(
content: Text(
'确定要删除这张图片吗?此操作不可恢复。',
style: TextStyle(
fontSize: 14,
color: Color(0xFF666666),
color: colors.onSurface.withValues(alpha: 0.6),
height: 1.5,
),
),
@@ -1079,7 +1100,7 @@ class _NoteFormPageState extends State<NoteFormPage> {
TextButton(
onPressed: () => Navigator.pop(context),
style: TextButton.styleFrom(
foregroundColor: const Color(0xFF666666),
foregroundColor: colors.onSurface.withValues(alpha: 0.6),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
),
child: const Text('取消'),
@@ -1090,8 +1111,8 @@ class _NoteFormPageState extends State<NoteFormPage> {
Navigator.pop(context);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
foregroundColor: Colors.white,
backgroundColor: colors.error,
foregroundColor: colors.onError,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
@@ -1102,7 +1123,8 @@ class _NoteFormPageState extends State<NoteFormPage> {
),
],
actionsPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
),
);
},
);
}
}

View File

@@ -26,21 +26,22 @@ class _NoteSharePageState extends State<NoteSharePage> {
@override
Widget build(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
backgroundColor: colors.surfaceContainerHighest,
appBar: AppBar(
backgroundColor: Colors.white,
backgroundColor: colors.surface,
elevation: 0,
leading: IconButton(
icon: const Icon(Icons.close, color: Color(0xFF1A1A1A)),
icon: Icon(Icons.close, color: colors.onSurface),
onPressed: () => Navigator.pop(context),
),
title: const Text(
title: Text(
'分享笔记',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
),
),
centerTitle: true,
@@ -53,12 +54,12 @@ class _NoteSharePageState extends State<NoteSharePage> {
height: 20,
child: CircularProgressIndicator(strokeWidth: 2),
)
: const Text(
: Text(
'分享',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
),
),
),
@@ -78,6 +79,7 @@ class _NoteSharePageState extends State<NoteSharePage> {
}
Widget _buildPosterWidget() {
final colors = Theme.of(context).colorScheme;
final note = widget.note;
final hasImages = note.images.isNotEmpty;
final dateStr =
@@ -88,7 +90,7 @@ class _NoteSharePageState extends State<NoteSharePage> {
return Container(
width: 320,
decoration: BoxDecoration(
color: Colors.white,
color: colors.surface,
borderRadius: BorderRadius.circular(16),
boxShadow: [
BoxShadow(
@@ -124,10 +126,10 @@ class _NoteSharePageState extends State<NoteSharePage> {
if (note.title.isNotEmpty) ...[
Text(
note.title,
style: const TextStyle(
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.bold,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
),
),
const SizedBox(height: 4),
@@ -136,9 +138,9 @@ class _NoteSharePageState extends State<NoteSharePage> {
// 日期
Text(
dateStr,
style: const TextStyle(
style: TextStyle(
fontSize: 12,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
),
),
@@ -152,12 +154,12 @@ class _NoteSharePageState extends State<NoteSharePage> {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
decoration: BoxDecoration(
color: const Color(0xFFF0F0F0),
color: colors.outlineVariant,
borderRadius: BorderRadius.circular(4),
),
child: Text(
tag,
style: const TextStyle(fontSize: 11, color: Color(0xFF888888)),
style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.5)),
),
);
}).toList(),
@@ -165,7 +167,7 @@ class _NoteSharePageState extends State<NoteSharePage> {
],
const SizedBox(height: 16),
Container(height: 0.5, color: const Color(0xFFE8E8E8)),
Container(height: 0.5, color: colors.outline),
const SizedBox(height: 16),
// 正文内容
@@ -173,9 +175,9 @@ class _NoteSharePageState extends State<NoteSharePage> {
note.content,
maxLines: 12,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
style: TextStyle(
fontSize: 14,
color: Color(0xFF333333),
color: colors.onSurface.withValues(alpha: 0.75),
height: 1.8,
),
),
@@ -191,11 +193,11 @@ class _NoteSharePageState extends State<NoteSharePage> {
],
const Spacer(),
// Mooknote 品牌
const Text(
Text(
'Mooknote',
style: TextStyle(
fontSize: 11,
color: Color(0xFFCCCCCC),
color: colors.onSurface.withValues(alpha: 0.25),
fontWeight: FontWeight.w500,
),
),
@@ -210,14 +212,15 @@ class _NoteSharePageState extends State<NoteSharePage> {
}
Widget _buildMetaChip(IconData icon, String text) {
final colors = Theme.of(context).colorScheme;
return Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(icon, size: 13, color: const Color(0xFFAAAAAA)),
Icon(icon, size: 13, color: colors.onSurface.withValues(alpha: 0.35)),
const SizedBox(width: 4),
Text(
text,
style: const TextStyle(fontSize: 11, color: Color(0xFFAAAAAA)),
style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.35)),
),
],
);

View File

@@ -23,7 +23,7 @@ class _NoteTabPageState extends State<NoteTabPage> {
bool _hasMore = true;
final ScrollController _scrollController = ScrollController();
int _layoutStyle = 0; // 0: 列表, 1: 瀑布流, 2: 时间线
int _layoutStyle = 0;
bool _firstLoad = true;
@override
@@ -110,7 +110,6 @@ class _NoteTabPageState extends State<NoteTabPage> {
Widget build(BuildContext context) {
return Column(
children: [
// 笔记内容
Expanded(
child: Consumer<AppProvider>(
builder: (context, provider, child) {
@@ -122,10 +121,11 @@ class _NoteTabPageState extends State<NoteTabPage> {
}
if (allNotes.isEmpty && _displayedNotes.isEmpty) {
final colors = Theme.of(context).colorScheme;
return RefreshIndicator(
onRefresh: _refresh,
color: const Color(0xFF1A1A1A),
backgroundColor: Colors.white,
color: colors.primary,
backgroundColor: colors.surface,
child: ListView(
physics: const AlwaysScrollableScrollPhysics(),
children: [_buildEmptyState(context)],
@@ -159,6 +159,7 @@ class _NoteTabPageState extends State<NoteTabPage> {
}
Widget _buildWaterfallSkeleton() {
final colors = Theme.of(context).colorScheme;
return SingleChildScrollView(
padding: const EdgeInsets.fromLTRB(12, 8, 12, 100),
child: Row(
@@ -168,7 +169,7 @@ class _NoteTabPageState extends State<NoteTabPage> {
children: List.generate(4, (_) => Container(
margin: const EdgeInsets.only(bottom: 8),
decoration: BoxDecoration(
color: Colors.white,
color: colors.surface,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(color: Colors.black.withValues(alpha: 0.04), blurRadius: 6, offset: const Offset(0, 2)),
@@ -200,25 +201,24 @@ class _NoteTabPageState extends State<NoteTabPage> {
);
}
// ─── 列表视图 ────────────────────────────────────────────────────────
Widget _buildListView() {
final colors = Theme.of(context).colorScheme;
return RefreshIndicator(
onRefresh: _refresh,
color: const Color(0xFF1A1A1A),
backgroundColor: Colors.white,
color: colors.primary,
backgroundColor: colors.surface,
child: ListView.builder(
controller: _scrollController,
padding: const EdgeInsets.fromLTRB(12, 10, 12, 100),
itemCount: _displayedNotes.length + (_hasMore ? 1 : 0),
itemBuilder: (context, index) {
if (index >= _displayedNotes.length) {
return const Padding(
padding: EdgeInsets.symmetric(vertical: 16),
return Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Center(
child: SizedBox(
width: 20, height: 20,
child: CircularProgressIndicator(strokeWidth: 2, color: Color(0xFF1A1A1A)),
child: CircularProgressIndicator(strokeWidth: 2, color: colors.primary),
),
),
);
@@ -229,24 +229,23 @@ class _NoteTabPageState extends State<NoteTabPage> {
);
}
// ─── 时间线视图 ──────────────────────────────────────────────────────
Widget _buildTimelineView() {
final colors = Theme.of(context).colorScheme;
return RefreshIndicator(
onRefresh: _refresh,
color: const Color(0xFF1A1A1A),
backgroundColor: Colors.white,
color: colors.primary,
backgroundColor: colors.surface,
child: ListView.builder(
controller: _scrollController,
padding: const EdgeInsets.fromLTRB(12, 8, 12, 100),
itemCount: _displayedNotes.length + (_hasMore ? 1 : 0),
itemBuilder: (context, index) {
if (index >= _displayedNotes.length) {
return const Padding(
padding: EdgeInsets.symmetric(vertical: 16),
return Padding(
padding: const EdgeInsets.symmetric(vertical: 16),
child: Center(
child: SizedBox(width: 20, height: 20,
child: CircularProgressIndicator(strokeWidth: 2, color: Color(0xFF1A1A1A))),
child: CircularProgressIndicator(strokeWidth: 2, color: colors.primary)),
),
);
}
@@ -257,6 +256,7 @@ class _NoteTabPageState extends State<NoteTabPage> {
}
Widget _buildTimelineItem(Note note) {
final colors = Theme.of(context).colorScheme;
return GestureDetector(
onTap: () {
Navigator.pushNamed(context, '/note-detail', arguments: note).then((_) async {
@@ -268,72 +268,60 @@ class _NoteTabPageState extends State<NoteTabPage> {
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// 左侧时间线
SizedBox(
width: 40,
child: Column(
children: [
// 圆点
Container(
width: 10,
height: 10,
decoration: BoxDecoration(
color: const Color(0xFF1A1A1A),
color: colors.primary,
shape: BoxShape.circle,
border: Border.all(color: Colors.white, width: 2),
border: Border.all(color: colors.surface, width: 2),
),
),
// 连线
Expanded(
child: Container(
width: 1,
color: const Color(0xFFE5E5E5),
color: colors.outline,
),
),
],
),
),
// 右侧内容
Expanded(
child: Container(
margin: const EdgeInsets.only(bottom: 16),
padding: const EdgeInsets.all(14),
decoration: BoxDecoration(
color: const Color(0xFFFAFAFA),
color: colors.surfaceContainerHigh,
borderRadius: BorderRadius.circular(12),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
// 时间
Text(
_formatFullDate(note.updatedAt),
style: const TextStyle(fontSize: 11, color: Color(0xFF999999)),
style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.4)),
),
// 标题
if (note.title.isNotEmpty) ...[
const SizedBox(height: 6),
Text(
note.title,
style: const TextStyle(fontSize: 15, fontWeight: FontWeight.w600, color: Color(0xFF1A1A1A)),
style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600, color: colors.onSurface),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
// 内容预览
const SizedBox(height: 6),
Text(
_getPreviewText(note),
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: const TextStyle(fontSize: 13, color: Color(0xFF888888), height: 1.5),
style: TextStyle(fontSize: 13, color: colors.onSurface.withValues(alpha: 0.5), height: 1.5),
),
// 标签
if (note.tags.isNotEmpty) ...[
const SizedBox(height: 8),
Wrap(
@@ -342,10 +330,10 @@ class _NoteTabPageState extends State<NoteTabPage> {
children: note.tags.map((tag) => Container(
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 2),
decoration: BoxDecoration(
color: Colors.white,
color: colors.surface,
borderRadius: BorderRadius.circular(4),
),
child: Text(tag, style: const TextStyle(fontSize: 10, color: Color(0xFF999999))),
child: Text(tag, style: TextStyle(fontSize: 10, color: colors.onSurface.withValues(alpha: 0.4))),
)).toList(),
),
],
@@ -364,10 +352,8 @@ class _NoteTabPageState extends State<NoteTabPage> {
'${date.hour.toString().padLeft(2, '0')}:${date.minute.toString().padLeft(2, '0')}';
}
// ─── 瀑布流视图 ──────────────────────────────────────────────────────
Widget _buildWaterfallView() {
// 分为左右两列
final colors = Theme.of(context).colorScheme;
final leftItems = <Note>[];
final rightItems = <Note>[];
for (int i = 0; i < _displayedNotes.length; i++) {
@@ -380,8 +366,8 @@ class _NoteTabPageState extends State<NoteTabPage> {
return RefreshIndicator(
onRefresh: _refresh,
color: const Color(0xFF1A1A1A),
backgroundColor: Colors.white,
color: colors.primary,
backgroundColor: colors.surface,
child: SingleChildScrollView(
controller: _scrollController,
padding: const EdgeInsets.fromLTRB(12, 8, 12, 100),
@@ -398,6 +384,7 @@ class _NoteTabPageState extends State<NoteTabPage> {
}
Widget _buildWaterfallCard(Note note) {
final colors = Theme.of(context).colorScheme;
final contentText = _getPreviewText(note);
final images = note.images;
final hasImage = images.isNotEmpty;
@@ -413,7 +400,7 @@ class _NoteTabPageState extends State<NoteTabPage> {
child: Container(
margin: const EdgeInsets.only(bottom: 8),
decoration: BoxDecoration(
color: Colors.white,
color: colors.surface,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
@@ -428,7 +415,6 @@ class _NoteTabPageState extends State<NoteTabPage> {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
// 顶部图片
if (hasImage)
Stack(
children: [
@@ -458,8 +444,6 @@ class _NoteTabPageState extends State<NoteTabPage> {
),
],
),
// 底部文字区域
Padding(
padding: const EdgeInsets.fromLTRB(10, 8, 10, 10),
child: Column(
@@ -471,47 +455,45 @@ class _NoteTabPageState extends State<NoteTabPage> {
note.title,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w600,
color: Color(0xFF1A1A1A),
color: colors.onSurface,
height: 1.3,
),
),
if (contentText.isNotEmpty && contentText != '(无内容)') ...[
if (note.title.isNotEmpty) const SizedBox(height: 4),
Text(
contentText,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
style: TextStyle(
fontSize: 11,
color: Color(0xFF999999),
color: colors.onSurface.withValues(alpha: 0.4),
height: 1.4,
),
),
],
const SizedBox(height: 6),
Row(
children: [
Expanded(
child: Text(
_formatTime(note.updatedAt),
style: const TextStyle(fontSize: 10, color: Color(0xFFCCCCCC)),
style: TextStyle(fontSize: 10, color: colors.onSurface.withValues(alpha: 0.25)),
),
),
if (note.tags.isNotEmpty)
Container(
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1),
decoration: BoxDecoration(
color: const Color(0xFFF5F5F5),
color: colors.surfaceContainerHighest,
borderRadius: BorderRadius.circular(3),
),
child: Text(
note.tags.first,
style: const TextStyle(fontSize: 10, color: Color(0xFF999999)),
style: TextStyle(fontSize: 10, color: colors.onSurface.withValues(alpha: 0.4)),
),
),
],
@@ -546,20 +528,21 @@ class _NoteTabPageState extends State<NoteTabPage> {
}
void _showDeleteDialog(BuildContext context, Note note) {
final colors = Theme.of(context).colorScheme;
showDialog(
context: context,
builder: (context) => AlertDialog(
backgroundColor: Colors.white,
backgroundColor: colors.surface,
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
title: const Text('确认删除', style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600)),
content: const Text('确定要删除这条笔记吗?删除后可在回收站恢复。',
style: TextStyle(fontSize: 14, color: Color(0xFF666666), height: 1.5)),
title: Text('确认删除', style: TextStyle(fontSize: 18, fontWeight: FontWeight.w600, color: colors.onSurface)),
content: Text('确定要删除这条笔记吗?删除后可在回收站恢复。',
style: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.6), height: 1.5)),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
style: TextButton.styleFrom(
foregroundColor: const Color(0xFF666666),
foregroundColor: colors.onSurface.withValues(alpha: 0.6),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
),
child: const Text('取消'),
@@ -570,8 +553,8 @@ class _NoteTabPageState extends State<NoteTabPage> {
Navigator.pop(context);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
foregroundColor: Colors.white,
backgroundColor: colors.error,
foregroundColor: colors.onError,
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
@@ -584,8 +567,6 @@ class _NoteTabPageState extends State<NoteTabPage> {
);
}
// ─── 数据同步 ────────────────────────────────────────────────────────
void _syncDisplayedNotes(List<Note> allNotes) {
final validNoteIds = allNotes.map((n) => n.id).toSet();
final initialLength = _displayedNotes.length;
@@ -611,9 +592,8 @@ class _NoteTabPageState extends State<NoteTabPage> {
}
}
// ─── 空状态 ──────────────────────────────────────────────────────────
Widget _buildEmptyState(BuildContext context) {
final colors = Theme.of(context).colorScheme;
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
@@ -621,24 +601,24 @@ class _NoteTabPageState extends State<NoteTabPage> {
Container(
width: 80, height: 80,
decoration: BoxDecoration(
color: const Color(0xFFF5F5F5),
color: colors.surfaceContainerHighest,
borderRadius: BorderRadius.circular(20),
),
child: const Icon(Icons.note_outlined, size: 40, color: Color(0xFFCCCCCC)),
child: Icon(Icons.note_outlined, size: 40, color: colors.onSurface.withValues(alpha: 0.25)),
),
const SizedBox(height: 20),
const Text('暂无笔记', style: TextStyle(fontSize: 16, color: Color(0xFF999999))),
Text('暂无笔记', style: TextStyle(fontSize: 16, color: colors.onSurface.withValues(alpha: 0.4))),
const SizedBox(height: 24),
InkWell(
onTap: () => Navigator.pushNamed(context, '/note-form'),
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
decoration: BoxDecoration(
color: const Color(0xFF1A1A1A),
color: colors.primary,
borderRadius: BorderRadius.circular(8),
),
child: const Text('添加记录',
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: Colors.white)),
child: Text('添加记录',
style: TextStyle(fontSize: 14, fontWeight: FontWeight.w500, color: colors.onPrimary)),
),
),
],