|
|
|
@ -79,18 +79,9 @@ class _FileExplorerState extends State<FileExplorer> {
@@ -79,18 +79,9 @@ class _FileExplorerState extends State<FileExplorer> {
|
|
|
|
|
Logger().info('没有活动选项卡,创建新选项卡'); |
|
|
|
|
editorProvider.addTab(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 更新内容 |
|
|
|
|
Logger().info('准备更新选项卡内容'); |
|
|
|
|
editorProvider.updateContent(editorProvider.activeTabId!, content); |
|
|
|
|
|
|
|
|
|
// 更新标题为文件名 |
|
|
|
|
final activeTab = editorProvider.activeTab; |
|
|
|
|
if (activeTab != null) { |
|
|
|
|
activeTab.title = node.name; |
|
|
|
|
Logger().debug('更新选项卡标题为: ${node.name}'); |
|
|
|
|
editorProvider.notifyListeners(); |
|
|
|
|
} |
|
|
|
|
editorProvider.updateContent(editorProvider.activeTabId!, content, node.name); |
|
|
|
|
|
|
|
|
|
if (context.mounted) { |
|
|
|
|
Logger().debug('已加载: ${node.name}'); |
|
|
|
@ -146,44 +137,47 @@ class _FileExplorerState extends State<FileExplorer> {
@@ -146,44 +137,47 @@ class _FileExplorerState extends State<FileExplorer> {
|
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
Expanded( |
|
|
|
|
child: |
|
|
|
|
fileProvider.isLoading |
|
|
|
|
? const Center(child: CircularProgressIndicator()) |
|
|
|
|
: fileProvider.fileNodes.isEmpty |
|
|
|
|
? Center(child: _buildEmptyPrompt(context)) |
|
|
|
|
: Scrollbar( |
|
|
|
|
// 外层:垂直滚动条 |
|
|
|
|
controller: _verticalScrollController, |
|
|
|
|
thumbVisibility: true, |
|
|
|
|
child: SingleChildScrollView( |
|
|
|
|
// 中层:水平滚动 |
|
|
|
|
scrollDirection: Axis.horizontal, |
|
|
|
|
controller: _horizontalScrollController, |
|
|
|
|
child: Scrollbar( |
|
|
|
|
// 内层:水平滚动条(横向) |
|
|
|
|
child: ClipRect( |
|
|
|
|
// 添加ClipRect防止视觉效果溢出 |
|
|
|
|
child: |
|
|
|
|
fileProvider.isLoading |
|
|
|
|
? const Center(child: CircularProgressIndicator()) |
|
|
|
|
: fileProvider.fileNodes.isEmpty |
|
|
|
|
? Center(child: _buildEmptyPrompt(context)) |
|
|
|
|
: Scrollbar( |
|
|
|
|
// 外层:垂直滚动条 |
|
|
|
|
controller: _verticalScrollController, |
|
|
|
|
thumbVisibility: true, |
|
|
|
|
child: SingleChildScrollView( |
|
|
|
|
// 中层:水平滚动 |
|
|
|
|
scrollDirection: Axis.horizontal, |
|
|
|
|
controller: _horizontalScrollController, |
|
|
|
|
thumbVisibility: true, |
|
|
|
|
scrollbarOrientation: ScrollbarOrientation.bottom, // 横向滚动条在底部 |
|
|
|
|
child: SizedBox( |
|
|
|
|
width: calculateTotalWidth(context, fileProvider), // 动态计算总宽度 |
|
|
|
|
child: ListView.builder( |
|
|
|
|
// 内层:垂直列表 |
|
|
|
|
controller: _verticalScrollController, |
|
|
|
|
itemCount: _countVisibleNodes(fileProvider.fileNodes), |
|
|
|
|
itemBuilder: (context, index) { |
|
|
|
|
final node = _getVisibleNode(fileProvider.fileNodes, index); |
|
|
|
|
return _FileNodeWidget( |
|
|
|
|
key: ValueKey(node.path), |
|
|
|
|
node: node, |
|
|
|
|
onTap: () => _handleNodeTap(context, node), |
|
|
|
|
onDoubleTap: () => _handleNodeDoubleTap(context, node), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
child: Scrollbar( |
|
|
|
|
// 内层:水平滚动条(横向) |
|
|
|
|
controller: _horizontalScrollController, |
|
|
|
|
thumbVisibility: true, |
|
|
|
|
scrollbarOrientation: ScrollbarOrientation.bottom, |
|
|
|
|
child: SizedBox( |
|
|
|
|
width: calculateTotalWidth(context, fileProvider), |
|
|
|
|
child: ListView.builder( |
|
|
|
|
// 内层:垂直列表 |
|
|
|
|
controller: _verticalScrollController, |
|
|
|
|
itemCount: _countVisibleNodes(fileProvider.fileNodes), |
|
|
|
|
itemBuilder: (context, index) { |
|
|
|
|
final node = _getVisibleNode(fileProvider.fileNodes, index); |
|
|
|
|
return _FileNodeWidget( |
|
|
|
|
key: ValueKey(node.path), |
|
|
|
|
node: node, |
|
|
|
|
onTap: () => _handleNodeTap(context, node), |
|
|
|
|
onDoubleTap: () => _handleNodeDoubleTap(context, node), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
@ -238,7 +232,9 @@ class _FileNodeWidget extends StatelessWidget {
@@ -238,7 +232,9 @@ class _FileNodeWidget extends StatelessWidget {
|
|
|
|
|
|
|
|
|
|
return InkWell( |
|
|
|
|
onTap: onTap, |
|
|
|
|
onDoubleTap: onDoubleTap, // 添加双击事件 |
|
|
|
|
onDoubleTap: onDoubleTap, |
|
|
|
|
splashColor: Colors.transparent, // 移除水波纹效果 |
|
|
|
|
highlightColor: Colors.grey.withOpacity(0.1), // 使用更柔和的悬停颜色 |
|
|
|
|
child: Container( |
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 0), |
|
|
|
|
child: ListTile( |
|
|
|
|