From a3a1adbc52e8b9fdcb15b5e61e4507abe6befdfa Mon Sep 17 00:00:00 2001 From: DelLevin-Home Date: Tue, 14 Jul 2026 23:40:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96win=E7=9A=84=E6=96=B0?= =?UTF-8?q?=E5=A2=9E/=E7=BC=96=E8=BE=91=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/note/note_add_page.dart | 176 ++++++++++++++++++++---------- 1 file changed, 116 insertions(+), 60 deletions(-) diff --git a/lib/pages/note/note_add_page.dart b/lib/pages/note/note_add_page.dart index 0661abd..36d7170 100644 --- a/lib/pages/note/note_add_page.dart +++ b/lib/pages/note/note_add_page.dart @@ -122,6 +122,7 @@ class _NoteAddPageState extends State { } Widget _buildEditArea(ColorScheme colors) { + final isWin = Platform.isWindows; return Column(children: [ // 标题输入 Container( @@ -134,13 +135,58 @@ class _NoteAddPageState extends State { decoration: InputDecoration( hintText: '添加标题', hintStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.w700, color: colors.onSurface.withValues(alpha: 0.2)), - border: InputBorder.none, + border: InputBorder.none, enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, isDense: true, contentPadding: EdgeInsets.zero, ), onChanged: (_) => setState(() {}), ), ), + // Windows: 标签栏移到标题下方(靠左) + if (isWin) + Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4), + decoration: BoxDecoration(border: Border(bottom: BorderSide(color: colors.outlineVariant, width: 0.5))), + child: Align( + alignment: Alignment.centerLeft, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row(mainAxisSize: MainAxisSize.min, children: [ + for (int i = 0; i < _tags.length; i++) + Padding( + padding: const EdgeInsets.only(right: 4), + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration(color: colors.surfaceContainerHighest, borderRadius: BorderRadius.circular(6)), + child: Row(mainAxisSize: MainAxisSize.min, children: [ + Text(_tags[i], style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.6))), + const SizedBox(width: 3), + GestureDetector( + onTap: () => setState(() => _tags.removeAt(i)), + child: Icon(Icons.close, size: 10, color: colors.onSurface.withValues(alpha: 0.3)), + ), + ]), + ), + ), + GestureDetector( + onTap: _showTagPanel, + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6), + border: Border.all(color: colors.onSurface.withValues(alpha: 0.25), width: 1), + ), + child: Row(mainAxisSize: MainAxisSize.min, children: [ + 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))), + ]), + ), + ), + ]), + ), + ), + ), // 内容编辑 Expanded( child: TextField( @@ -153,7 +199,7 @@ class _NoteAddPageState extends State { decoration: InputDecoration( hintText: '使用 Markdown 格式书写...', hintStyle: TextStyle(fontSize: 14, color: colors.onSurface.withValues(alpha: 0.25), height: 1.6), - border: InputBorder.none, + border: InputBorder.none, enabledBorder: InputBorder.none, focusedBorder: InputBorder.none, contentPadding: const EdgeInsets.all(16), ), onChanged: (_) => setState(() {}), @@ -161,69 +207,79 @@ class _NoteAddPageState extends State { ), // 图片行 if (_images.isNotEmpty) _buildImageRow(colors), - // 标签 + 工具栏 - Container( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6), - decoration: BoxDecoration(border: Border(top: BorderSide(color: colors.outlineVariant, width: 0.5))), - child: Column(children: [ - // 标签行 - Wrap(spacing: 6, runSpacing: 4, children: [ - for (int i = 0; i < _tags.length; i++) Container( - padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), - decoration: BoxDecoration(color: colors.surfaceContainerHighest, borderRadius: BorderRadius.circular(6)), - child: Row(mainAxisSize: MainAxisSize.min, children: [ - Text(_tags[i], style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.6))), - const SizedBox(width: 3), - GestureDetector( - onTap: () => setState(() => _tags.removeAt(i)), - child: Icon(Icons.close, size: 10, color: colors.onSurface.withValues(alpha: 0.3)), - ), - ]), - ), - GestureDetector( - onTap: _showTagPanel, - child: Container( - padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(6), - border: Border.all(color: colors.onSurface.withValues(alpha: 0.25), width: 1), - ), + // 底部标签 + 工具栏(仅非 Windows) + if (!isWin) + Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6), + decoration: BoxDecoration(border: Border(top: BorderSide(color: colors.outlineVariant, width: 0.5))), + child: Column(children: [ + // 标签行 + Wrap(spacing: 6, runSpacing: 4, children: [ + for (int i = 0; i < _tags.length; i++) Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + decoration: BoxDecoration(color: colors.surfaceContainerHighest, borderRadius: BorderRadius.circular(6)), child: Row(mainAxisSize: MainAxisSize.min, children: [ - 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))), + Text(_tags[i], style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.6))), + const SizedBox(width: 3), + GestureDetector( + onTap: () => setState(() => _tags.removeAt(i)), + child: Icon(Icons.close, size: 10, color: colors.onSurface.withValues(alpha: 0.3)), + ), ]), ), - ), + GestureDetector( + onTap: _showTagPanel, + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6), + border: Border.all(color: colors.onSurface.withValues(alpha: 0.25), width: 1), + ), + child: Row(mainAxisSize: MainAxisSize.min, children: [ + 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))), + ]), + ), + ), + ]), + const SizedBox(height: 6), + // 工具栏 + Row(children: [ + Expanded( + child: SingleChildScrollView(scrollDirection: Axis.horizontal, child: Row(children: [ + _toolBtn(Icons.title, '标题', _insertHeading), + _toolBtn(Icons.format_bold, '粗体', () => _insertMarkdown('**', '**')), + _toolBtn(Icons.format_italic, '斜体', () => _insertMarkdown('*', '*')), + _toolBtn(Icons.format_strikethrough, '删除线', () => _insertMarkdown('~~', '~~')), + _toolGap(colors), + _toolBtn(Icons.format_list_bulleted, '无序列表', () => _insertMarkdown('- ', '')), + _toolBtn(Icons.format_list_numbered, '有序列表', () => _insertMarkdown('1. ', '')), + _toolBtn(Icons.format_quote, '引用', () => _insertMarkdown('> ', '')), + _toolBtn(Icons.insert_link, '链接', () => _insertMarkdown('[', '](url)')), + _toolGap(colors), + _toolBtn(Icons.code, '行内代码', () => _insertMarkdown('`', '`')), + _toolBtn(Icons.data_object, '代码块', () => _insertMarkdown('```\n', '\n```')), + _toolBtn(Icons.horizontal_rule, '分割线', () => _insertMarkdown('---\n', '')), + _toolGap(colors), + _toolBtn(Icons.add_photo_alternate_outlined, '图片', _pickImage), + ])), + ), + const SizedBox(width: 8), + Text('${_contentCtrl.text.length} 字', + style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.3))), + ]), ]), - const SizedBox(height: 6), - // 工具栏 - Row(children: [ - Expanded( - child: SingleChildScrollView(scrollDirection: Axis.horizontal, child: Row(children: [ - _toolBtn(Icons.title, '标题', _insertHeading), - _toolBtn(Icons.format_bold, '粗体', () => _insertMarkdown('**', '**')), - _toolBtn(Icons.format_italic, '斜体', () => _insertMarkdown('*', '*')), - _toolBtn(Icons.format_strikethrough, '删除线', () => _insertMarkdown('~~', '~~')), - _toolGap(colors), - _toolBtn(Icons.format_list_bulleted, '无序列表', () => _insertMarkdown('- ', '')), - _toolBtn(Icons.format_list_numbered, '有序列表', () => _insertMarkdown('1. ', '')), - _toolBtn(Icons.format_quote, '引用', () => _insertMarkdown('> ', '')), - _toolBtn(Icons.insert_link, '链接', () => _insertMarkdown('[', '](url)')), - _toolGap(colors), - _toolBtn(Icons.code, '行内代码', () => _insertMarkdown('`', '`')), - _toolBtn(Icons.data_object, '代码块', () => _insertMarkdown('```\n', '\n```')), - _toolBtn(Icons.horizontal_rule, '分割线', () => _insertMarkdown('---\n', '')), - _toolGap(colors), - _toolBtn(Icons.add_photo_alternate_outlined, '图片', _pickImage), - ])), - ), - const SizedBox(width: 8), - Text('${_contentCtrl.text.length} 字', - style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.3))), + ), + // Windows: 底部只显示字数 + if (isWin) + Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6), + decoration: BoxDecoration(border: Border(top: BorderSide(color: colors.outlineVariant, width: 0.5))), + child: Row(mainAxisAlignment: MainAxisAlignment.end, children: [ + Text('${_contentCtrl.text.length} 字', style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.3))), ]), - ]), - ), + ), ]); }