You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.3 KiB
64 lines
1.3 KiB
import 'package:flutter/material.dart'; |
|
import 'package:win_text_editor/shared/components/tree_view.dart'; |
|
|
|
class TemplateNode implements TreeNode { |
|
@override |
|
final String name; |
|
@override |
|
final List<TemplateNode> children; |
|
@override |
|
final int depth; |
|
@override |
|
bool isExpanded; |
|
|
|
final String path; |
|
bool isRepeated; |
|
bool isAttribute; |
|
int repreatCount; |
|
bool isChecked; // 新增属性,用于记录节点是否被选中 |
|
|
|
TemplateNode({ |
|
required this.name, |
|
required this.children, |
|
required this.depth, |
|
required this.path, |
|
this.isExpanded = false, |
|
this.isRepeated = false, |
|
this.isAttribute = false, |
|
this.repreatCount = 1, |
|
this.isChecked = false, // 初始化默认未选中 |
|
}); |
|
|
|
@override |
|
bool get isDirectory => children.isNotEmpty; |
|
|
|
@override |
|
IconData? get iconData => isAttribute ? Icons.code : Icons.label_outline; |
|
|
|
@override |
|
String get id => path; |
|
} |
|
|
|
enum NodeType { element, attribute, text } |
|
|
|
class TemplateItem { |
|
final int id; |
|
final String rowId; |
|
final String content; |
|
final String xPath; |
|
final String value; |
|
final NodeType nodeType; |
|
|
|
TemplateItem({ |
|
required this.id, |
|
required this.rowId, |
|
required this.content, |
|
required this.xPath, |
|
required this.value, |
|
required this.nodeType, |
|
}); |
|
|
|
bool matchesPath(String path) { |
|
return xPath == path; |
|
} |
|
}
|
|
|