开始录制增加 剪切板参数校验
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -72,6 +72,32 @@ class _RecordingPageState extends ConsumerState<RecordingPage> {
|
||||
return '录制完成';
|
||||
}
|
||||
|
||||
Future<void> _showNoPlayerInfoDialog() {
|
||||
return showDialog<void>(
|
||||
context: context,
|
||||
builder: (dialogContext) {
|
||||
return AlertDialog(
|
||||
content: const Text('无选手信息'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(dialogContext).pop(),
|
||||
child: const Text('确定'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _onStartRecording() async {
|
||||
final recordingInfo = ref.read(recordingViewModelProvider);
|
||||
if (!recordingInfo.hasClipboardFilename) {
|
||||
await _showNoPlayerInfoDialog();
|
||||
return;
|
||||
}
|
||||
await ref.read(recordingSessionControllerProvider.notifier).startRecording();
|
||||
}
|
||||
|
||||
Future<void> _showRecordingSavedDialogIfNeeded() async {
|
||||
final session = ref.read(recordingSessionControllerProvider);
|
||||
if (session.lastSavedDisplayName == null || session.gallerySaveFailed) {
|
||||
@@ -171,7 +197,7 @@ class _RecordingPageState extends ConsumerState<RecordingPage> {
|
||||
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<void> Function() onPasteEventInfo;
|
||||
final VoidCallback onStart;
|
||||
final VoidCallback onStop;
|
||||
final Future<void> Function() onStart;
|
||||
final Future<void> 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,
|
||||
|
||||
Reference in New Issue
Block a user