fix(ui): refine narrow layouts and enable tab swipes

This commit is contained in:
Levi committed 2026-09-15 23:01:48 +08:00
1 parent e47a20a1bd
commit c703c52cbc
17 files changed
+624 -182

No files matched your search

@@ -69,6 +69,7 @@ class FileTreeView<T> extends StatefulWidget {
this.rowHeight = _treeRowHeight,
this.contentTextStyle,
this.iconSize = 18,
this.initialExpandedDepth,
});
final List<FileTreeItem<T>> items;
@@ -85,6 +86,9 @@ class FileTreeView<T> extends StatefulWidget {
final TextStyle? contentTextStyle;
final double iconSize;
/// Number of directory levels initially expanded; null expands all levels.
final int? initialExpandedDepth;
@override
State<FileTreeView<T>> createState() => _FileTreeViewState<T>();
}
@@ -109,7 +113,7 @@ class _FileTreeViewState<T> extends State<FileTreeView<T>> with SingleTickerProv
@override
void initState() {
super.initState();
_nodes = _buildTree(widget.items);
_nodes = _buildTree(widget.items, expandedDepth: widget.initialExpandedDepth);
_allFoldersExpanded = _foldersAreExpanded(_nodes);
_transitionController = AnimationController(vsync: this, duration: _treeTransitionDuration, value: 1)
..addStatusListener(_onTransitionStatus);
@@ -830,8 +834,10 @@ class _BuildNode<T> {
int get size => item?.size ?? children.fold<int>(0, (sum, child) => sum + child.size);
TreeItemNode<FileTreeNode<T>> toTreeItem() {
final childItems = children.map((child) => child.toTreeItem()).toList(growable: false);
TreeItemNode<FileTreeNode<T>> toTreeItem({int? expandedDepth, int depth = 0}) {
final childItems = children
.map((child) => child.toTreeItem(expandedDepth: expandedDepth, depth: depth + 1))
.toList(growable: false);
final leaves = item == null ? [for (final child in childItems) ...child.data.leafItems] : <FileTreeItem<T>>[item!];
return TreeItemNode(
data: FileTreeNode(
@@ -842,13 +848,13 @@ class _BuildNode<T> {
originalIndex: originalIndex,
item: item,
),
expanded: true,
expanded: expandedDepth == null || depth < expandedDepth,
children: childItems,
);
}
}
List<TreeNode<FileTreeNode<T>>> _buildTree<T>(List<FileTreeItem<T>> items) {
List<TreeNode<FileTreeNode<T>>> _buildTree<T>(List<FileTreeItem<T>> items, {int? expandedDepth}) {
final root = <_BuildNode<T>>[];
final folders = <String, _BuildNode<T>>{};
var originalIndex = 0;
@@ -885,7 +891,7 @@ List<TreeNode<FileTreeNode<T>>> _buildTree<T>(List<FileTreeItem<T>> items) {
}
}
return root.map((node) => node.toTreeItem()).toList(growable: false);
return root.map((node) => node.toTreeItem(expandedDepth: expandedDepth)).toList(growable: false);
}
List<String> _visibleNodeKeysInOrder<T>(List<TreeNode<FileTreeNode<T>>> nodes) {