generated from dellevin/template
笔记编辑功能修复
This commit is contained in:
@@ -12,6 +12,7 @@ import '../../utils/toast_util.dart';
|
||||
import '../../utils/image_path_helper.dart';
|
||||
import '../../utils/responsive.dart';
|
||||
import '../../widgets/vditor_editor.dart';
|
||||
import '../../widgets/tag_side_panel.dart';
|
||||
import 'note_share_page.dart';
|
||||
|
||||
/// 笔记详情页
|
||||
@@ -444,7 +445,6 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
|
||||
// 标题输入
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
decoration: BoxDecoration(border: Border(bottom: BorderSide(color: colors.outlineVariant, width: 0.5))),
|
||||
child: Center(child: ConstrainedBox(constraints: const BoxConstraints(maxWidth: 720),
|
||||
child: TextField(controller: _titleCtrl, maxLines: 1,
|
||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w700, color: colors.onSurface, height: 1.4),
|
||||
@@ -454,6 +454,13 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
|
||||
onChanged: (_) => setState(() {})),
|
||||
)),
|
||||
),
|
||||
// 标签行 — 标题下面,靠左
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 6),
|
||||
child: Center(child: ConstrainedBox(constraints: const BoxConstraints(maxWidth: 720),
|
||||
child: Align(alignment: Alignment.centerLeft, child: _buildEditTagRow(colors)),
|
||||
)),
|
||||
),
|
||||
// 内容编辑
|
||||
Expanded(
|
||||
child: VditorEditor(
|
||||
@@ -480,6 +487,64 @@ class _NoteDetailPageState extends State<NoteDetailPage> {
|
||||
]);
|
||||
}
|
||||
|
||||
Widget _buildEditTagRow(ColorScheme colors) {
|
||||
return Wrap(
|
||||
spacing: 6,
|
||||
runSpacing: 4,
|
||||
children: [
|
||||
for (final tag in _editTags)
|
||||
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(tag, style: TextStyle(fontSize: 11, color: colors.onSurface.withValues(alpha: 0.6))),
|
||||
const SizedBox(width: 3),
|
||||
GestureDetector(
|
||||
onTap: () => setState(() => _editTags.remove(tag)),
|
||||
child: Icon(Icons.close, size: 10, color: colors.onSurface.withValues(alpha: 0.3)),
|
||||
),
|
||||
]),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: _showEditTagPanel,
|
||||
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))),
|
||||
]),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showEditTagPanel() async {
|
||||
final provider = context.read<AppProvider>();
|
||||
final tagRows = await provider.getTags('note_tag');
|
||||
final allTags = tagRows.map((t) => t['name'] as String).toSet();
|
||||
for (final note in provider.notes) {
|
||||
allTags.addAll(note.tags);
|
||||
}
|
||||
if (!mounted) return;
|
||||
TagSidePanel.show(
|
||||
context: context,
|
||||
selectedTags: List.from(_editTags),
|
||||
allAvailableTags: allTags.toList()..sort(),
|
||||
onTagsChanged: (newTags) {
|
||||
setState(() => _editTags = newTags);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildPreviewArea(ColorScheme colors, Note note) {
|
||||
return ListView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 24),
|
||||
|
||||
Reference in New Issue
Block a user