@@ -2,6 +2,7 @@ import 'dart:developer';
2
2
import 'dart:io' ;
3
3
4
4
import 'package:file_server_fe/common/env.dart' ;
5
+ import 'package:file_server_fe/pages/media_player.dart' ;
5
6
import 'package:file_server_fe/pages/video_player.dart' ;
6
7
import 'package:file_server_fe/widgets/dir_path_widget.dart' ;
7
8
import 'package:file_server_fe/widgets/dir_tree_widget.dart' ;
@@ -163,6 +164,24 @@ class _FileExplorerState extends State<FileExplorer> {
163
164
ImageViewer (images: imageFiles, selectedIndex: initialIndex)));
164
165
}
165
166
167
+ void _fileClickShowMediaViewerFunc (File file) {
168
+ // 弹出图片浏览
169
+ var initialIndex = 0 ;
170
+ var index = 0 ;
171
+ var mediaFiles = files
172
+ .where ((item) => item.group == "image" || item.group == "video" ).toList ();
173
+ mediaFiles.sort ((a, b) => a.path.compareTo (b.path));
174
+ for (var item in mediaFiles) {
175
+ if (item.path == file.path) {
176
+ initialIndex = index;
177
+ }
178
+ index = index + 1 ;
179
+ }
180
+ Navigator .of (context).push (MaterialPageRoute (
181
+ builder: (context) =>
182
+ MediaPlayerPage (files: mediaFiles, selectedIndex: initialIndex)));
183
+ }
184
+
166
185
void _fileClickPlayVideoFunc (File file) {
167
186
// 弹出视频播放
168
187
Navigator .of (context).push (MaterialPageRoute (
@@ -174,13 +193,18 @@ class _FileExplorerState extends State<FileExplorer> {
174
193
if (file.group == "dir" ) {
175
194
_fileClickChangePathFunc (file);
176
195
}
177
- if (file.group == "image" ) {
178
- _fileClickShowImageViewerFunc (file);
179
-
180
- }
181
- if (file.group == "video" ) {
182
- _fileClickPlayVideoFunc (file);
196
+ if (file.group == "image" || file.group == "video" ) {
197
+ // 下载文件
198
+ // _fileClickDownloadFunc(file);
199
+ _fileClickShowMediaViewerFunc (file);
183
200
}
201
+ // if (file.group == "image") {
202
+ // _fileClickShowImageViewerFunc(file);
203
+
204
+ // }
205
+ // if (file.group == "video") {
206
+ // _fileClickPlayVideoFunc(file);
207
+ // }
184
208
}
185
209
}
186
210
0 commit comments