From dfbdbbdb66e7ae941a06356b662999cc33bfad81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E9=94=8B?= <2535831261@qq.com> Date: Thu, 4 Jun 2026 17:20:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=A7=8B=E5=BD=95=E5=88=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=20=E5=89=AA=E5=88=87=E6=9D=BF=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../recording/model/model_recording.dart | 6 +++ lib/features/recording/recording_page.dart | 40 +++++++++++++++++-- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/lib/features/recording/model/model_recording.dart b/lib/features/recording/model/model_recording.dart index f05f09f..e137f26 100644 --- a/lib/features/recording/model/model_recording.dart +++ b/lib/features/recording/model/model_recording.dart @@ -23,6 +23,12 @@ class RecordingModel { return {'clipboardRecordingModel': clipboardRecordingModel.toJson()}; } + /// 剪切板是否包含可用于命名的 [ClipboardRecordingModel.filename]。 + bool get hasClipboardFilename { + final name = clipboardRecordingModel.filename?.trim(); + return hasValidClipboardInfo && name != null && name.isNotEmpty; + } + RecordingModel copyWith({ ClipboardRecordingModel? clipboardRecordingModel, bool? hasValidClipboardInfo, diff --git a/lib/features/recording/recording_page.dart b/lib/features/recording/recording_page.dart index d8c76a5..f97d867 100644 --- a/lib/features/recording/recording_page.dart +++ b/lib/features/recording/recording_page.dart @@ -72,6 +72,32 @@ class _RecordingPageState extends ConsumerState { return '录制完成'; } + Future _showNoPlayerInfoDialog() { + return showDialog( + context: context, + builder: (dialogContext) { + return AlertDialog( + content: const Text('无选手信息'), + actions: [ + TextButton( + onPressed: () => Navigator.of(dialogContext).pop(), + child: const Text('确定'), + ), + ], + ); + }, + ); + } + + Future _onStartRecording() async { + final recordingInfo = ref.read(recordingViewModelProvider); + if (!recordingInfo.hasClipboardFilename) { + await _showNoPlayerInfoDialog(); + return; + } + await ref.read(recordingSessionControllerProvider.notifier).startRecording(); + } + Future _showRecordingSavedDialogIfNeeded() async { final session = ref.read(recordingSessionControllerProvider); if (session.lastSavedDisplayName == null || session.gallerySaveFailed) { @@ -171,7 +197,7 @@ class _RecordingPageState extends ConsumerState { AppToast.show('无赛事信息'); } }, - onStart: () => controller.startRecording(), + onStart: _onStartRecording, onStop: () async { await controller.stopRecording(); if (!context.mounted) return; @@ -256,8 +282,8 @@ class _RecordingHud extends StatelessWidget { final bool showClipboardHint; final String clipboardAddress; final Future Function() onPasteEventInfo; - final VoidCallback onStart; - final VoidCallback onStop; + final Future Function() onStart; + final Future Function() onStop; final VoidCallback onOpenDnd; final VoidCallback onOpenBattery; final VoidCallback onToggleTouchLock; @@ -346,7 +372,13 @@ class _RecordingHud extends StatelessWidget { child: GestureDetector( onTap: state.isStartingRecording ? null - : (state.isRecording ? onStop : onStart), + : () async { + if (state.isRecording) { + await onStop(); + } else { + await onStart(); + } + }, child: Container( width: 76.w, height: 76.h,