feat(mobile-app): show all nodes in team tree with horizontal scroll
Remove the ellipsis logic that hides nodes when there are too many. Now all nodes are displayed and users can scroll horizontally to see them. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
ef80a2f23b
commit
f0f44aeb39
|
|
@ -113,30 +113,7 @@ class _TeamTreeWidgetState extends State<TeamTreeWidget> {
|
|||
Widget _buildTreeLevel(List<TeamTreeNode> nodes, int level) {
|
||||
if (nodes.isEmpty) return const SizedBox.shrink();
|
||||
|
||||
// 使用容器实际宽度计算最大节点数(减去 padding)
|
||||
final availableWidth = _containerWidth - 16; // 减去左右 padding (8*2)
|
||||
final maxVisibleNodes = ((availableWidth + nodeHorizontalSpacing) / (nodeWidth + nodeHorizontalSpacing)).floor().clamp(1, 100);
|
||||
|
||||
// 分离需要显示的节点和隐藏的节点
|
||||
List<TeamTreeNode> visibleNodes;
|
||||
List<TeamTreeNode> hiddenNodes;
|
||||
|
||||
if (nodes.length <= maxVisibleNodes) {
|
||||
visibleNodes = nodes;
|
||||
hiddenNodes = [];
|
||||
} else {
|
||||
// 显示前几个和最后一个,中间显示省略号
|
||||
final showCount = maxVisibleNodes - 1; // 留一个位置给省略号
|
||||
final frontCount = (showCount / 2).ceil();
|
||||
final backCount = showCount - frontCount;
|
||||
|
||||
visibleNodes = [
|
||||
...nodes.sublist(0, frontCount),
|
||||
...nodes.sublist(nodes.length - backCount),
|
||||
];
|
||||
hiddenNodes = nodes.sublist(frontCount, nodes.length - backCount);
|
||||
}
|
||||
|
||||
// 显示所有节点,允许左右滚动
|
||||
return Column(
|
||||
children: [
|
||||
// 当前层的节点
|
||||
|
|
@ -144,14 +121,9 @@ class _TeamTreeWidgetState extends State<TeamTreeWidget> {
|
|||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
for (int i = 0; i < visibleNodes.length; i++) ...[
|
||||
if (i == (maxVisibleNodes - 1) ~/ 2 && hiddenNodes.isNotEmpty) ...[
|
||||
// 在中间位置插入省略号节点
|
||||
_buildEllipsisNode(hiddenNodes),
|
||||
SizedBox(width: nodeHorizontalSpacing),
|
||||
],
|
||||
_buildNodeWithChildren(visibleNodes[i]),
|
||||
if (i < visibleNodes.length - 1) SizedBox(width: nodeHorizontalSpacing),
|
||||
for (int i = 0; i < nodes.length; i++) ...[
|
||||
_buildNodeWithChildren(nodes[i]),
|
||||
if (i < nodes.length - 1) SizedBox(width: nodeHorizontalSpacing),
|
||||
],
|
||||
],
|
||||
),
|
||||
|
|
|
|||
Loading…
Reference in New Issue