开始录制增加 剪切板参数校验
This commit is contained in:
@@ -23,6 +23,12 @@ class RecordingModel {
|
|||||||
return {'clipboardRecordingModel': clipboardRecordingModel.toJson()};
|
return {'clipboardRecordingModel': clipboardRecordingModel.toJson()};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 剪切板是否包含可用于命名的 [ClipboardRecordingModel.filename]。
|
||||||
|
bool get hasClipboardFilename {
|
||||||
|
final name = clipboardRecordingModel.filename?.trim();
|
||||||
|
return hasValidClipboardInfo && name != null && name.isNotEmpty;
|
||||||
|
}
|
||||||
|
|
||||||
RecordingModel copyWith({
|
RecordingModel copyWith({
|
||||||
ClipboardRecordingModel? clipboardRecordingModel,
|
ClipboardRecordingModel? clipboardRecordingModel,
|
||||||
bool? hasValidClipboardInfo,
|
bool? hasValidClipboardInfo,
|
||||||
|
|||||||
@@ -72,6 +72,32 @@ class _RecordingPageState extends ConsumerState<RecordingPage> {
|
|||||||
return '录制完成';
|
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 {
|
Future<void> _showRecordingSavedDialogIfNeeded() async {
|
||||||
final session = ref.read(recordingSessionControllerProvider);
|
final session = ref.read(recordingSessionControllerProvider);
|
||||||
if (session.lastSavedDisplayName == null || session.gallerySaveFailed) {
|
if (session.lastSavedDisplayName == null || session.gallerySaveFailed) {
|
||||||
@@ -171,7 +197,7 @@ class _RecordingPageState extends ConsumerState<RecordingPage> {
|
|||||||
AppToast.show('无赛事信息');
|
AppToast.show('无赛事信息');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onStart: () => controller.startRecording(),
|
onStart: _onStartRecording,
|
||||||
onStop: () async {
|
onStop: () async {
|
||||||
await controller.stopRecording();
|
await controller.stopRecording();
|
||||||
if (!context.mounted) return;
|
if (!context.mounted) return;
|
||||||
@@ -256,8 +282,8 @@ class _RecordingHud extends StatelessWidget {
|
|||||||
final bool showClipboardHint;
|
final bool showClipboardHint;
|
||||||
final String clipboardAddress;
|
final String clipboardAddress;
|
||||||
final Future<void> Function() onPasteEventInfo;
|
final Future<void> Function() onPasteEventInfo;
|
||||||
final VoidCallback onStart;
|
final Future<void> Function() onStart;
|
||||||
final VoidCallback onStop;
|
final Future<void> Function() onStop;
|
||||||
final VoidCallback onOpenDnd;
|
final VoidCallback onOpenDnd;
|
||||||
final VoidCallback onOpenBattery;
|
final VoidCallback onOpenBattery;
|
||||||
final VoidCallback onToggleTouchLock;
|
final VoidCallback onToggleTouchLock;
|
||||||
@@ -346,7 +372,13 @@ class _RecordingHud extends StatelessWidget {
|
|||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: state.isStartingRecording
|
onTap: state.isStartingRecording
|
||||||
? null
|
? null
|
||||||
: (state.isRecording ? onStop : onStart),
|
: () async {
|
||||||
|
if (state.isRecording) {
|
||||||
|
await onStop();
|
||||||
|
} else {
|
||||||
|
await onStart();
|
||||||
|
}
|
||||||
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
width: 76.w,
|
width: 76.w,
|
||||||
height: 76.h,
|
height: 76.h,
|
||||||
|
|||||||
Reference in New Issue
Block a user