|
@@ -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> {
|
|
|
|
|
|
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();
|
|
|
+ }
|
|
|
+
|
|
|
+ _timer = Timer(Duration(seconds: 30), () {
|
|
|
+ PromptBox.toast('采集成功');
|
|
|
+ setState(() {
|
|
|
+ isRecording = false;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ void _cancelTimer() {
|
|
|
+ if (_timer != null) {
|
|
|
+ _timer!.cancel();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|