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.
65 lines
1.3 KiB
65 lines
1.3 KiB
2 months ago
|
import 'package:flutter/material.dart';
|
||
|
import 'package:win_text_editor/shared/components/tree_view.dart';
|
||
|
|
||
|
class TemplateNode implements TreeNode {
|
||
2 months ago
|
@override
|
||
2 months ago
|
final String name;
|
||
2 months ago
|
@override
|
||
2 months ago
|
final List<TemplateNode> children;
|
||
2 months ago
|
@override
|
||
2 months ago
|
final int depth;
|
||
2 months ago
|
@override
|
||
2 months ago
|
bool isExpanded;
|
||
2 months ago
|
|
||
|
final String path;
|
||
2 months ago
|
bool isRepeated;
|
||
|
bool isAttribute;
|
||
|
int repreatCount;
|
||
2 months ago
|
bool isChecked; // 新增属性,用于记录节点是否被选中
|
||
2 months ago
|
|
||
|
TemplateNode({
|
||
|
required this.name,
|
||
|
required this.children,
|
||
2 months ago
|
required this.depth,
|
||
2 months ago
|
required this.path,
|
||
2 months ago
|
this.isExpanded = false,
|
||
|
this.isRepeated = false,
|
||
2 months ago
|
this.isAttribute = false,
|
||
|
this.repreatCount = 1,
|
||
2 months ago
|
this.isChecked = false, // 初始化默认未选中
|
||
2 months ago
|
});
|
||
|
|
||
|
@override
|
||
|
bool get isDirectory => children.isNotEmpty;
|
||
2 months ago
|
|
||
2 months ago
|
@override
|
||
|
IconData? get iconData => isAttribute ? Icons.code : Icons.label_outline;
|
||
2 months ago
|
|
||
|
@override
|
||
|
String get id => path;
|
||
2 months ago
|
}
|
||
|
|
||
2 months ago
|
enum NodeType { element, attribute, text }
|
||
|
|
||
2 months ago
|
class TemplateItem {
|
||
|
final int id;
|
||
2 months ago
|
final String rowId;
|
||
2 months ago
|
final String content;
|
||
|
final String xPath;
|
||
|
final String value;
|
||
2 months ago
|
final NodeType nodeType;
|
||
|
|
||
|
TemplateItem({
|
||
|
required this.id,
|
||
2 months ago
|
required this.rowId,
|
||
2 months ago
|
required this.content,
|
||
|
required this.xPath,
|
||
|
required this.value,
|
||
|
required this.nodeType,
|
||
|
});
|
||
2 months ago
|
|
||
2 months ago
|
bool matchesPath(String path) {
|
||
|
return xPath == path;
|
||
2 months ago
|
}
|
||
|
}
|