Browse Source

fixed: 0018654: 【超声工作站软件】在采集窗口页面,截图或视频录制结束后,窗口无任何提示,应提示“采集成功”

loki.wu 10 months ago
parent
commit
caae00541a
1 changed files with 27 additions and 0 deletions
  1. 27 0
      lib/pages/consultation_record_view/widgets/capture_page.dart

+ 27 - 0
lib/pages/consultation_record_view/widgets/capture_page.dart

@@ -1,3 +1,5 @@
+import 'dart:async';
+
 import 'package:flutter/material.dart';
 import 'package:vitalapp/architecture/utils/prompt_box.dart';
 import 'package:vitalapp/components/button.dart';
@@ -15,6 +17,7 @@ class CapturePage extends StatefulWidget {
 class _CapturePageState extends State<CapturePage> {
   // 状态变量,true表示“开始录制”,false表示“结束录制”
   bool isRecording = false;
+  Timer? _timer;
   ShellSonopostPlayController controller = ShellSonopostPlayController();
   @override
   void initState() {
@@ -26,6 +29,7 @@ class _CapturePageState extends State<CapturePage> {
   @override
   void dispose() {
     super.dispose();
+    _timer?.cancel();
     controller.stop();
     rpc.platform.stopPreviewSonopost();
   }
@@ -80,7 +84,10 @@ class _CapturePageState extends State<CapturePage> {
                       onTap: () {
                         rpc.platform.keypadPressF2();
                         if (isRecording) {
+                          _cancelTimer();
                           PromptBox.toast('采集成功');
+                        } else {
+                          _startTimer();
                         }
                         setState(() {
                           isRecording = !isRecording;
@@ -109,4 +116,24 @@ class _CapturePageState extends State<CapturePage> {
       ),
     );
   }
+
+  void _startTimer() {
+    // 如果已有定时器在运行,先取消
+    if (_timer != null) {
+      _timer!.cancel();
+    }
+    // 创建一个延迟30秒执行的任务
+    _timer = Timer(Duration(seconds: 30), () {
+      PromptBox.toast('采集成功');
+      setState(() {
+        isRecording = false;
+      });
+    });
+  }
+
+  void _cancelTimer() {
+    if (_timer != null) {
+      _timer!.cancel();
+    }
+  }
 }