From 9e489b3da8ecf099f7efde48fd881f740c0db4d6 Mon Sep 17 00:00:00 2001 From: hejl Date: Tue, 20 May 2025 13:16:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E8=8A=82=E7=82=B9=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E6=89=A9=E5=B1=95=E5=89=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widgets/template_parser_view.dart | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/win_text_editor/lib/modules/template_parser/widgets/template_parser_view.dart b/win_text_editor/lib/modules/template_parser/widgets/template_parser_view.dart index 5dc4777..df2afd3 100644 --- a/win_text_editor/lib/modules/template_parser/widgets/template_parser_view.dart +++ b/win_text_editor/lib/modules/template_parser/widgets/template_parser_view.dart @@ -133,31 +133,31 @@ class _TemplateParserViewState extends State { final templateNode = node as TemplateNode; final isAttribute = node.depth > 0 && node.name.startsWith('@'); - return Padding( - padding: EdgeInsets.only(left: 12.0 * node.depth), // 动态缩进 - child: ListTile( - dense: true, - leading: - isAttribute - ? const Icon(Icons.code, size: 16, color: Colors.grey) - : const Icon(Icons.label_outline, size: 18, color: Colors.blue), - title: Text( - isAttribute ? templateNode.name.substring(1) : templateNode.name, - style: TextStyle( - color: isAttribute ? Colors.grey[600] : Colors.black, - fontWeight: isAttribute ? FontWeight.normal : FontWeight.w500, + return Consumer( + builder: (context, controller, _) { + return Padding( + padding: EdgeInsets.only(left: 12.0 * node.depth), // 动态缩进 + child: ListTile( + dense: true, + leading: + isAttribute + ? const Icon(Icons.code, size: 16, color: Colors.grey) + : const Icon(Icons.label_outline, size: 18, color: Colors.blue), + title: Text( + isAttribute ? templateNode.name.substring(1) : templateNode.name, + style: TextStyle( + color: isAttribute ? Colors.grey[600] : Colors.black, + fontWeight: isAttribute ? FontWeight.normal : FontWeight.w500, + ), + ), + trailing: + templateNode.isRepeated + ? const Text("(repeated)", style: TextStyle(color: Colors.grey)) + : null, + onTap: () => controller.selectTreeNode(templateNode), ), - ), - trailing: - templateNode.isRepeated - ? const Text("(repeated)", style: TextStyle(color: Colors.grey)) - : null, - onTap: - () => Provider.of( - context, - listen: false, - ).selectTreeNode(templateNode), - ), + ); + }, ); }