diff --git a/lib/data/services/meeting/meeting_upload_service.dart b/lib/data/services/meeting/meeting_upload_service.dart index f22fd6759..65ebdd805 100644 --- a/lib/data/services/meeting/meeting_upload_service.dart +++ b/lib/data/services/meeting/meeting_upload_service.dart @@ -26,10 +26,15 @@ class MeetingUploadService extends GetxService { void _getUploadList() { uploadList.value = _storage.read("meeting_upload_list") ?? []; - _executeUpload(); + executeUpload(); } - void addUpload(int id, String filePath, String rootDir) async { + void addUpload( + int id, + String filePath, + String rootDir, { + bool isUpload = true, + }) async { uploadList.add({ 'id': id, 'filepath': filePath, @@ -38,10 +43,12 @@ class MeetingUploadService extends GetxService { 'isTask': false, }); _storage.write("meeting_upload_list", uploadList); - _executeUpload(); + if (isUpload) { + executeUpload(); + } } - void _executeUpload() async { + void executeUpload() async { if (_isUpload) return; _isUpload = true; _handled = 0; diff --git a/lib/modules/meeting/controllers/meeting_connect_controller.dart b/lib/modules/meeting/controllers/meeting_connect_controller.dart index fd1642779..56c7b213f 100644 --- a/lib/modules/meeting/controllers/meeting_connect_controller.dart +++ b/lib/modules/meeting/controllers/meeting_connect_controller.dart @@ -7,6 +7,7 @@ import 'package:path_provider/path_provider.dart'; import 'package:wifi_iot/wifi_iot.dart'; import '../../../core/utils/ftpconnect/ftpconnect.dart'; +import '../../../data/services/meeting/meeting_upload_service.dart'; import 'meeting_home_controller.dart'; class MeetingConnectController extends GetxController { @@ -69,7 +70,6 @@ class MeetingConnectController extends GetxController { _scanResultsSubscription.cancel(); _isScanningSubscription.cancel(); _valueReceivedSubscription?.cancel(); - _ftpConnect?.disconnect(); _stopScan(); _disconnect(); super.onClose(); @@ -100,6 +100,7 @@ class MeetingConnectController extends GetxController { } Future _disconnect() async { + _ftpConnect?.disconnect(); await WiFiForIoTPlugin.forceWifiUsage(false); await WiFiForIoTPlugin.disconnect(); await _device?.disconnect(); @@ -233,10 +234,11 @@ class MeetingConnectController extends GetxController { await _downloadFile(totalSize, previousSize, element); await _ftpConnect?.deleteFile(element.name); } + await _disconnect(); stateStr.value = '下载完成'; importedFilesStr.value = '下载完成,共${listDirectory.length}个文件,2秒后自动返回'; - _disconnect(); Future.delayed(const Duration(seconds: 2), () { + _executeUpload(); Get.back(); }); } @@ -262,7 +264,17 @@ class MeetingConnectController extends GetxController { fileSize.value = size; }, ); - await _meetingController.insertMeetingAudio(entry.name, filePath); + await _meetingController.insertMeetingAudio( + entry.name, + filePath, + isUpload: false, + ); + } + + Future _executeUpload() async { + await Future.delayed(const Duration(seconds: 3)); + final meetingUploadService = Get.find(); + meetingUploadService.executeUpload(); } String _decodePassword(List data) { diff --git a/lib/modules/meeting/controllers/meeting_controller.dart b/lib/modules/meeting/controllers/meeting_controller.dart index 4f7b41e36..f5ead752e 100644 --- a/lib/modules/meeting/controllers/meeting_controller.dart +++ b/lib/modules/meeting/controllers/meeting_controller.dart @@ -15,6 +15,8 @@ class MeetingController extends GetxController { const MeetingMineView(), ]; + int type = 1; + RxInt pageIndex = 0.obs; RxMap user = {}.obs; diff --git a/lib/modules/meeting/controllers/meeting_home_controller.dart b/lib/modules/meeting/controllers/meeting_home_controller.dart index 97b6bffee..d2c0eb3a9 100644 --- a/lib/modules/meeting/controllers/meeting_home_controller.dart +++ b/lib/modules/meeting/controllers/meeting_home_controller.dart @@ -327,7 +327,11 @@ class MeetingHomeController extends GetxController { EasyLoading.dismiss(); } - Future insertMeetingAudio(String fileName, String filePath) async { + Future insertMeetingAudio( + String fileName, + String filePath, { + bool isUpload = true, + }) async { await _audioPlayer.setAudioSource(AudioSource.file(filePath)); int seconds = _audioPlayer.duration?.inSeconds ?? 0; int creationTime = DateTime.now().millisecondsSinceEpoch; @@ -342,7 +346,12 @@ class MeetingHomeController extends GetxController { }; final meetingId = await SqfliteApi.insertMeeting(data); if (meetingId != null) { - meetingUploadService.addUpload(meetingId, filePath, 'ExternalAudio'); + meetingUploadService.addUpload( + meetingId, + filePath, + 'ExternalAudio', + isUpload: isUpload, + ); originalDataList.insert(0, { 'id': meetingId, ...data, diff --git a/lib/modules/meeting/views/meeting_home_view.dart b/lib/modules/meeting/views/meeting_home_view.dart index 712078790..9c4d4ee84 100644 --- a/lib/modules/meeting/views/meeting_home_view.dart +++ b/lib/modules/meeting/views/meeting_home_view.dart @@ -87,8 +87,8 @@ class _MeetingHomeViewState extends State vertical: 10.w, ), decoration: BoxDecoration( - color: isDarkMode - ? MeetingUIUtils.getTranslucentWhite(0.05) + color: isDarkMode + ? MeetingUIUtils.getTranslucentWhite(0.05) : MeetingUIUtils.getCardColor(isDarkMode), borderRadius: BorderRadius.circular(12.w), boxShadow: MeetingUIUtils.getCardShadow(isDarkMode), @@ -127,8 +127,8 @@ class _MeetingHomeViewState extends State vertical: 10.w, ), decoration: BoxDecoration( - color: isDarkMode - ? MeetingUIUtils.getTranslucentWhite(0.05) + color: isDarkMode + ? MeetingUIUtils.getTranslucentWhite(0.05) : MeetingUIUtils.getCardColor(isDarkMode), borderRadius: BorderRadius.circular(50.w), boxShadow: MeetingUIUtils.getCardShadow(isDarkMode), @@ -220,8 +220,8 @@ class _MeetingHomeViewState extends State padding: EdgeInsets.symmetric(horizontal: 15.w, vertical: 10.w), margin: EdgeInsets.symmetric(vertical: 5.w), decoration: BoxDecoration( - color: isDarkMode - ? MeetingUIUtils.getTranslucentWhite(0.05) + color: isDarkMode + ? MeetingUIUtils.getTranslucentWhite(0.05) : MeetingUIUtils.getCardColor(isDarkMode), borderRadius: BorderRadius.circular(12.w), boxShadow: MeetingUIUtils.getCardShadow(isDarkMode), diff --git a/lib/modules/meeting/views/meeting_view.dart b/lib/modules/meeting/views/meeting_view.dart index 372cf8f24..e433fc38c 100644 --- a/lib/modules/meeting/views/meeting_view.dart +++ b/lib/modules/meeting/views/meeting_view.dart @@ -30,93 +30,97 @@ class MeetingView extends GetView { child: const FiltrateDrawer(), ), drawerEnableOpenDragGesture: false, - bottomNavigationBar: Stack( - alignment: Alignment.center, - clipBehavior: Clip.none, - children: [ - Obx( - () => BottomNavigationBar( - items: const [ - BottomNavigationBarItem( - icon: Icon(Icons.folder_outlined), - activeIcon: Icon(Icons.folder), - label: '文件', - ), - BottomNavigationBarItem( - icon: SizedBox(), - label: '', - ), - BottomNavigationBarItem( - icon: Icon(Icons.person_outline), - activeIcon: Icon(Icons.person), - label: '我的', - ), - ], - backgroundColor: - isDarkMode ? const Color(0xFF1A1A1A) : Colors.white, - currentIndex: controller.pageIndex.value, - unselectedItemColor: Colors.grey, - selectedItemColor: isDarkMode ? Colors.white : Colors.blue, - unselectedFontSize: 10.sp, - selectedFontSize: 10.sp, - onTap: (int index) { - if (index == 1 || index == controller.pageIndex.value) return; - if (index == 0) { - controller.pageIndex.value = 0; - controller.pageController.jumpToPage(0); - } else { - controller.pageIndex.value = 2; - controller.pageController.jumpToPage(1); - } - }, - ), - ), - Positioned( - top: -18.w, - child: GestureDetector( - onTap: () { - Get.bottomSheet( - BackdropFilter( - filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), - child: const NavigationBarBottomSheet(), + bottomNavigationBar: controller.type == 0 + ? Stack( + alignment: Alignment.center, + clipBehavior: Clip.none, + children: [ + Obx( + () => BottomNavigationBar( + items: const [ + BottomNavigationBarItem( + icon: Icon(Icons.folder_outlined), + activeIcon: Icon(Icons.folder), + label: '文件', + ), + BottomNavigationBarItem( + icon: SizedBox(), + label: '', + ), + BottomNavigationBarItem( + icon: Icon(Icons.person_outline), + activeIcon: Icon(Icons.person), + label: '我的', + ), + ], + backgroundColor: + isDarkMode ? const Color(0xFF1A1A1A) : Colors.white, + currentIndex: controller.pageIndex.value, + unselectedItemColor: Colors.grey, + selectedItemColor: isDarkMode ? Colors.white : Colors.blue, + unselectedFontSize: 10.sp, + selectedFontSize: 10.sp, + onTap: (int index) { + if (index == 1 || index == controller.pageIndex.value) + return; + if (index == 0) { + controller.pageIndex.value = 0; + controller.pageController.jumpToPage(0); + } else { + controller.pageIndex.value = 2; + controller.pageController.jumpToPage(1); + } + }, ), - isScrollControlled: true, - ); - }, - child: Container( - width: 60.w, - height: 60.w, - padding: EdgeInsets.all(5.w), - alignment: Alignment.center, - decoration: BoxDecoration( - color: isDarkMode ? const Color(0xFF1A1A1A) : Colors.white, - borderRadius: BorderRadius.circular(60.w), - boxShadow: [ - BoxShadow( - color: Colors.black - .withValues(alpha: isDarkMode ? 0.3 : 0.1), - blurRadius: 8, - offset: const Offset(0, 2), - ), - ], ), - child: Container( - alignment: Alignment.center, - decoration: BoxDecoration( - color: MeetingUIUtils.getButtonColor(isDarkMode), - borderRadius: BorderRadius.circular(60.w), - ), - child: Icon( - Icons.add, - color: Colors.white, - size: 30.w, + Positioned( + top: -18.w, + child: GestureDetector( + onTap: () { + Get.bottomSheet( + BackdropFilter( + filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), + child: const NavigationBarBottomSheet(), + ), + isScrollControlled: true, + ); + }, + child: Container( + width: 60.w, + height: 60.w, + padding: EdgeInsets.all(5.w), + alignment: Alignment.center, + decoration: BoxDecoration( + color: + isDarkMode ? const Color(0xFF1A1A1A) : Colors.white, + borderRadius: BorderRadius.circular(60.w), + boxShadow: [ + BoxShadow( + color: Colors.black + .withValues(alpha: isDarkMode ? 0.3 : 0.1), + blurRadius: 8, + offset: const Offset(0, 2), + ), + ], + ), + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + color: MeetingUIUtils.getButtonColor(isDarkMode), + borderRadius: BorderRadius.circular(60.w), + ), + child: Icon( + Icons.add, + color: Colors.white, + size: 30.w, + ), + ), + ), ), ), - ), - ), - ), - ], - ), + ], + ) + : null, ); } }