|
|
|
@ -14,7 +14,6 @@ class MeetingConnectController extends GetxController { |
|
|
|
|
|
|
|
RxString stateStr = '搜索中...'.obs; |
|
|
|
RxBool isRescan = false.obs; |
|
|
|
RxBool isImportedFiles = false.obs; |
|
|
|
RxString importedFilesStr = ''.obs; |
|
|
|
|
|
|
|
late StreamSubscription<List<ScanResult>> _scanResultsSubscription; |
|
|
|
@ -151,10 +150,10 @@ class MeetingConnectController extends GetxController { |
|
|
|
switch (command) { |
|
|
|
case 0x0d: // 是否有导入文件 |
|
|
|
if (value[3] == 0x01) { |
|
|
|
isImportedFiles.value = true; |
|
|
|
importedFilesStr.value = '检查到有新文件,是否导入'; |
|
|
|
stateStr.value = '正在开启Wi-Fi...'; |
|
|
|
importedFilesStr.value = '检查到有新文件,正在准备导入'; |
|
|
|
sendData([0x5a, 0x02, 0x87, 0x01]); |
|
|
|
} else { |
|
|
|
isImportedFiles.value = false; |
|
|
|
importedFilesStr.value = '没有新文件需要导入'; |
|
|
|
} |
|
|
|
break; |
|
|
|
@ -220,19 +219,25 @@ class MeetingConnectController extends GetxController { |
|
|
|
_ftpConnect?.listCommand = ListCommand.LIST; |
|
|
|
List<FTPEntry>? listDirectory = await _ftpConnect?.listDirectoryContent(); |
|
|
|
if (listDirectory != null && listDirectory.isNotEmpty) { |
|
|
|
stateStr.value = '正在下载文件...'; |
|
|
|
isDownload.value = true; |
|
|
|
int totalSize = listDirectory.fold( |
|
|
|
0, |
|
|
|
(sum, entry) => sum + (entry.size ?? 0), |
|
|
|
); |
|
|
|
for (var i = 0; i < listDirectory.length; i++) { |
|
|
|
stateStr.value = '共${listDirectory.length}个文件,正在下载第${i + 1}个文件...'; |
|
|
|
importedFilesStr.value = |
|
|
|
'共${listDirectory.length}个文件,正在下载第${i + 1}个文件'; |
|
|
|
int previousSize = i > 0 ? listDirectory[i - 1].size ?? 0 : 0; |
|
|
|
FTPEntry element = listDirectory[i]; |
|
|
|
await _downloadFile(totalSize, previousSize, element); |
|
|
|
} |
|
|
|
stateStr.value = '下载完成,共${listDirectory.length}个文件'; |
|
|
|
stateStr.value = '下载完成'; |
|
|
|
importedFilesStr.value = '下载完成,共${listDirectory.length}个文件,2秒后自动返回'; |
|
|
|
_disconnect(); |
|
|
|
Future.delayed(const Duration(seconds: 2), () { |
|
|
|
Get.back(); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -249,6 +254,7 @@ class MeetingConnectController extends GetxController { |
|
|
|
await _ftpConnect?.downloadFileWithRetry( |
|
|
|
entry.name, |
|
|
|
localFile, |
|
|
|
pRetryCount: 3, |
|
|
|
onProgress: (double progress, int received, int size) { |
|
|
|
downloadProgress.value = (previousSize + received) / totalSize; |
|
|
|
totalReceived.value = received; |
|
|
|
|