|
|
|
@ -6,18 +6,231 @@ import 'package:get/get.dart'; |
|
|
|
import '../controllers/meeting_record_controller.dart'; |
|
|
|
import '../../../core/theme/app_colors.dart'; |
|
|
|
|
|
|
|
enum _MeetingRecordExitAction { |
|
|
|
saveAndEnd, |
|
|
|
endWithoutSave, |
|
|
|
continueInBackground, |
|
|
|
cancel, |
|
|
|
} |
|
|
|
|
|
|
|
class MeetingRecordView extends GetView<MeetingRecordController> { |
|
|
|
const MeetingRecordView({super.key}); |
|
|
|
|
|
|
|
Future<_MeetingRecordExitAction?> _showExitConfirmDialog(bool isDarkMode) { |
|
|
|
return Get.dialog<_MeetingRecordExitAction>( |
|
|
|
Dialog( |
|
|
|
insetPadding: EdgeInsets.symmetric(horizontal: 24.w, vertical: 24.h), |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(16.r), |
|
|
|
), |
|
|
|
backgroundColor: isDarkMode ? AppColors.cardBackground : Colors.white, |
|
|
|
child: Container( |
|
|
|
width: 320.w, |
|
|
|
padding: EdgeInsets.all(20.w), |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: isDarkMode ? AppColors.cardBackground : Colors.white, |
|
|
|
borderRadius: BorderRadius.circular(16.r), |
|
|
|
), |
|
|
|
child: Column( |
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
children: [ |
|
|
|
Container( |
|
|
|
width: 56.w, |
|
|
|
height: 56.w, |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: (isDarkMode ? Colors.white : Colors.blue) |
|
|
|
.withValues(alpha: 0.12), |
|
|
|
borderRadius: BorderRadius.circular(28.r), |
|
|
|
), |
|
|
|
child: Icon( |
|
|
|
Icons.mic_rounded, |
|
|
|
size: 28.sp, |
|
|
|
color: isDarkMode ? Colors.white : Colors.blue, |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(height: 14.h), |
|
|
|
Text( |
|
|
|
'meetingRecordExitTitle'.tr, // 对应中文:退出录音 |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 18.sp, |
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
color: isDarkMode ? Colors.white : Colors.black87, |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(height: 8.h), |
|
|
|
Text( |
|
|
|
'meetingRecordExitMessage'.tr, // 对应中文:请选择离开后的操作 |
|
|
|
textAlign: TextAlign.center, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.sp, |
|
|
|
height: 1.4, |
|
|
|
color: isDarkMode ? Colors.white70 : Colors.black54, |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(height: 18.h), |
|
|
|
SizedBox( |
|
|
|
width: double.infinity, |
|
|
|
child: Column( |
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch, |
|
|
|
children: [ |
|
|
|
ElevatedButton( |
|
|
|
onPressed: () => Get.back( |
|
|
|
result: _MeetingRecordExitAction.saveAndEnd, |
|
|
|
), |
|
|
|
style: ElevatedButton.styleFrom( |
|
|
|
backgroundColor: |
|
|
|
isDarkMode ? AppColors.primary : Colors.blue, |
|
|
|
foregroundColor: Colors.white, |
|
|
|
padding: EdgeInsets.symmetric(vertical: 12.h), |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
), |
|
|
|
elevation: 0, |
|
|
|
), |
|
|
|
child: Text( |
|
|
|
'meetingRecordEndAndSave'.tr, // 对应中文:结束录音并保存 |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.sp, |
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(height: 10.h), |
|
|
|
OutlinedButton( |
|
|
|
onPressed: () => Get.back( |
|
|
|
result: _MeetingRecordExitAction.continueInBackground, |
|
|
|
), |
|
|
|
style: OutlinedButton.styleFrom( |
|
|
|
foregroundColor: |
|
|
|
isDarkMode ? Colors.white70 : Colors.grey[800], |
|
|
|
side: BorderSide( |
|
|
|
color: |
|
|
|
isDarkMode ? Colors.white30 : Colors.grey[400]!, |
|
|
|
), |
|
|
|
padding: EdgeInsets.symmetric(vertical: 12.h), |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
), |
|
|
|
), |
|
|
|
child: Text( |
|
|
|
'meetingRecordContinueInBackground'.tr, // 对应中文:后台继续录音 |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.sp, |
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(height: 10.h), |
|
|
|
OutlinedButton( |
|
|
|
onPressed: () => Get.back( |
|
|
|
result: _MeetingRecordExitAction.endWithoutSave, |
|
|
|
), |
|
|
|
style: OutlinedButton.styleFrom( |
|
|
|
foregroundColor: |
|
|
|
isDarkMode ? Colors.red[300] : Colors.red[600], |
|
|
|
side: BorderSide( |
|
|
|
color: |
|
|
|
isDarkMode ? Colors.red[300]! : Colors.red[300]!, |
|
|
|
), |
|
|
|
padding: EdgeInsets.symmetric(vertical: 12.h), |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
), |
|
|
|
), |
|
|
|
child: Text( |
|
|
|
'meetingRecordEndWithoutSave'.tr, // 对应中文:结束录音不保存 |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.sp, |
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(height: 10.h), |
|
|
|
TextButton( |
|
|
|
onPressed: () => |
|
|
|
Get.back(result: _MeetingRecordExitAction.cancel), |
|
|
|
style: TextButton.styleFrom( |
|
|
|
padding: EdgeInsets.symmetric(vertical: 12.h), |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(12.r), |
|
|
|
side: BorderSide( |
|
|
|
color: |
|
|
|
isDarkMode ? Colors.white24 : Colors.grey[300]!, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
child: Text( |
|
|
|
'cancel'.tr, // 对应中文:取消 |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 14.sp, |
|
|
|
fontWeight: FontWeight.w500, |
|
|
|
color: isDarkMode ? Colors.white70 : Colors.grey[700], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
barrierDismissible: true, |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
final isDarkMode = Theme.of(context).brightness == Brightness.dark; |
|
|
|
controller.applyRouteArgumentsIfIdle(); |
|
|
|
|
|
|
|
return WillPopScope( |
|
|
|
onWillPop: () async { |
|
|
|
return PopScope( |
|
|
|
canPop: false, |
|
|
|
onPopInvokedWithResult: (didPop, result) async { |
|
|
|
if (didPop) return; |
|
|
|
|
|
|
|
if (!controller.isRecording.value) { |
|
|
|
Get.back(); |
|
|
|
Future.microtask(() { |
|
|
|
if (Get.isRegistered<MeetingRecordController>()) { |
|
|
|
Get.delete<MeetingRecordController>(force: true); |
|
|
|
} |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
final action = await _showExitConfirmDialog(isDarkMode); |
|
|
|
if (action == null || action == _MeetingRecordExitAction.cancel) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
switch (action) { |
|
|
|
case _MeetingRecordExitAction.saveAndEnd: |
|
|
|
await controller.saveTitleChange(); |
|
|
|
await controller.saveRecording(); |
|
|
|
return true; |
|
|
|
Get.back(result: 'meeting_record_saved'); |
|
|
|
Future.microtask(() { |
|
|
|
if (Get.isRegistered<MeetingRecordController>()) { |
|
|
|
Get.delete<MeetingRecordController>(force: true); |
|
|
|
} |
|
|
|
}); |
|
|
|
return; |
|
|
|
case _MeetingRecordExitAction.endWithoutSave: |
|
|
|
await controller.discardRecording(); |
|
|
|
Get.back(result: 'meeting_record_discarded'); |
|
|
|
Future.microtask(() { |
|
|
|
if (Get.isRegistered<MeetingRecordController>()) { |
|
|
|
Get.delete<MeetingRecordController>(force: true); |
|
|
|
} |
|
|
|
}); |
|
|
|
return; |
|
|
|
case _MeetingRecordExitAction.continueInBackground: |
|
|
|
await controller.saveTitleChange(); |
|
|
|
Get.back(result: 'meeting_record_background'); |
|
|
|
return; |
|
|
|
case _MeetingRecordExitAction.cancel: |
|
|
|
return; |
|
|
|
} |
|
|
|
}, |
|
|
|
child: Scaffold( |
|
|
|
appBar: AppBar( |
|
|
|
|