|
|
@@ -1,19 +1,30 @@
|
|
|
import 'dart:async';
|
|
|
+import 'dart:io';
|
|
|
|
|
|
import 'package:electronic_assistant/base/base_controller.dart';
|
|
|
-import 'package:electronic_assistant/data/repositories/talk_repository.dart';
|
|
|
import 'package:electronic_assistant/module/talk/summary/view.dart';
|
|
|
import 'package:electronic_assistant/module/talk/todo/view.dart';
|
|
|
+import 'package:electronic_assistant/resource/assets.gen.dart';
|
|
|
+import 'package:electronic_assistant/resource/colors.gen.dart';
|
|
|
import 'package:electronic_assistant/resource/string.gen.dart';
|
|
|
-import 'package:electronic_assistant/utils/toast_util.dart';
|
|
|
+import 'package:electronic_assistant/utils/expand.dart';
|
|
|
+import 'package:electronic_assistant/utils/mmkv_util.dart';
|
|
|
+import 'package:flutter/cupertino.dart';
|
|
|
+import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
-
|
|
|
+import 'package:connectivity_plus/connectivity_plus.dart';
|
|
|
import '../../data/bean/agenda_list_all_bean.dart';
|
|
|
import '../../data/bean/talks.dart';
|
|
|
import '../../data/repositories/agenda_repository.dart';
|
|
|
+import '../../data/repositories/talk_repository.dart';
|
|
|
+import '../../dialog/alert_dialog.dart';
|
|
|
+import '../../utils/toast_util.dart';
|
|
|
+import '../record/controller.dart';
|
|
|
import 'original/view.dart';
|
|
|
|
|
|
class TalkController extends BaseController {
|
|
|
+ final String uploadNoPrompts = "UPLOAD_NO_PROMPTS";
|
|
|
+
|
|
|
final Rxn<TalkBean> talkBean = Rxn();
|
|
|
|
|
|
final isShowElectricLow = false.obs;
|
|
|
@@ -55,7 +66,94 @@ class TalkController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- void checkCanAnalyze() {
|
|
|
+ void _checkFileSizeAndNet() async {
|
|
|
+ String? id = talkBean.value?.id;
|
|
|
+ if (id == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ File file = await RecordController.getRecordFile(id);
|
|
|
+ if (!file.existsSync()) {
|
|
|
+ ToastUtil.showToast(StringName.talkUploadFileNotExist.tr);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ bool isCheckRemind = KVUtil.getBool(uploadNoPrompts, false);
|
|
|
+ if (isCheckRemind) {
|
|
|
+ _requestAnalyze(file);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //如果文件大小低于250MB 不弹窗提醒
|
|
|
+ if (file.lengthSync() < 250 * 1024 * 1024) {
|
|
|
+ _requestAnalyze(file);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ final List<ConnectivityResult> connectivityResult =
|
|
|
+ await (Connectivity().checkConnectivity());
|
|
|
+ if (connectivityResult.contains(ConnectivityResult.wifi)) {
|
|
|
+ _requestAnalyze(file);
|
|
|
+ } else {
|
|
|
+ _showTrafficRemindDialog(file.lengthSync().toReadableSize(),
|
|
|
+ confirmOnTap: (isCheckRemind) {
|
|
|
+ if (isCheckRemind) {
|
|
|
+ KVUtil.putBool(uploadNoPrompts, true);
|
|
|
+ }
|
|
|
+ _requestAnalyze(file);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void _showTrafficRemindDialog(String holderTxt,
|
|
|
+ {void Function(bool isCheckRemind)? confirmOnTap}) {
|
|
|
+ final remindTrafficConsume = false.obs;
|
|
|
+
|
|
|
+ Widget getSelectIcon() {
|
|
|
+ return Obx(() {
|
|
|
+ return remindTrafficConsume.value
|
|
|
+ ? Assets.images.iconSelectTrue.image()
|
|
|
+ : Assets.images.iconSelectFalse.image();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ Assets.images.iconSelectTrue.image();
|
|
|
+
|
|
|
+ EAAlertDialog.show(
|
|
|
+ contentWidget: Column(
|
|
|
+ children: [
|
|
|
+ Text(
|
|
|
+ StringName.talkTrafficRemindTitle.tr
|
|
|
+ .replacePlaceholders([holderTxt]),
|
|
|
+ style:
|
|
|
+ TextStyle(fontSize: 15.sp, color: ColorName.primaryTextColor),
|
|
|
+ ),
|
|
|
+ SizedBox(height: 8.h),
|
|
|
+ GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ remindTrafficConsume.value = !remindTrafficConsume.value;
|
|
|
+ },
|
|
|
+ child: IntrinsicWidth(
|
|
|
+ child: Row(
|
|
|
+ children: [
|
|
|
+ SizedBox(width: 20.w, height: 20.w, child: getSelectIcon()),
|
|
|
+ SizedBox(width: 5.w),
|
|
|
+ Text(
|
|
|
+ StringName.talkTrafficRemindTips.tr,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 15.sp, color: ColorName.tertiaryTextColor),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ cancelText: StringName.cancel.tr,
|
|
|
+ confirmText: StringName.sure.tr,
|
|
|
+ confirmOnTap: () {
|
|
|
+ confirmOnTap?.call(remindTrafficConsume.value);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ void checkCanAnalyze() async {
|
|
|
String? id = talkBean.value?.id;
|
|
|
double? duration = talkBean.value?.duration;
|
|
|
if (id == null || duration == null) {
|
|
|
@@ -63,8 +161,8 @@ class TalkController extends BaseController {
|
|
|
}
|
|
|
talkRepository.checkElectric(duration).then((data) {
|
|
|
if (data.enough) {
|
|
|
- //提交分析
|
|
|
- _requestAnalyze();
|
|
|
+ //检查网络以及文件大小
|
|
|
+ _checkFileSizeAndNet();
|
|
|
} else {
|
|
|
ToastUtil.showToast(StringName.talkAnalyseLowToast.tr);
|
|
|
isShowElectricLow.value = true;
|
|
|
@@ -74,7 +172,7 @@ class TalkController extends BaseController {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- void _requestAnalyze() {
|
|
|
+ void _requestAnalyze(File file) {
|
|
|
//提交文件
|
|
|
}
|
|
|
|