3 changed files with 253 additions and 24 deletions
@ -0,0 +1,176 @@ |
|||
import 'package:flutter/material.dart'; |
|||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|||
import 'package:get/get.dart'; |
|||
import 'package:record/record.dart'; |
|||
|
|||
import '../controllers/voice_replication_controller.dart'; |
|||
|
|||
class RecorderBottomSheet extends StatefulWidget { |
|||
const RecorderBottomSheet({super.key}); |
|||
|
|||
@override |
|||
State<RecorderBottomSheet> createState() => _RecorderBottomSheetState(); |
|||
} |
|||
|
|||
class _RecorderBottomSheetState extends State<RecorderBottomSheet> { |
|||
final _controller = Get.find<VoiceReplicationController>(); |
|||
|
|||
final _record = AudioRecorder(); |
|||
|
|||
bool _isRecording = false; |
|||
|
|||
@override |
|||
void initState() { |
|||
super.initState(); |
|||
} |
|||
|
|||
@override |
|||
void dispose() { |
|||
_record.dispose(); |
|||
super.dispose(); |
|||
} |
|||
|
|||
@override |
|||
Widget build(BuildContext context) { |
|||
return Padding( |
|||
padding: EdgeInsets.symmetric(horizontal: 12.w), |
|||
child: Column( |
|||
mainAxisSize: MainAxisSize.min, |
|||
children: [ |
|||
Container( |
|||
padding: EdgeInsets.symmetric(vertical: 10.w), |
|||
child: Row( |
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|||
children: [ |
|||
Text( |
|||
'同意并朗读使用个人语音', |
|||
style: TextStyle( |
|||
fontSize: 16.sp, |
|||
color: Colors.black87, |
|||
fontWeight: FontWeight.bold, |
|||
), |
|||
), |
|||
GestureDetector( |
|||
onTap: () => Get.back(), |
|||
child: Container( |
|||
width: 26.w, |
|||
height: 26.w, |
|||
decoration: BoxDecoration( |
|||
color: Colors.white, |
|||
borderRadius: BorderRadius.circular(26.r), |
|||
), |
|||
child: Icon( |
|||
Icons.close, |
|||
size: 18.w, |
|||
color: Colors.grey[400], |
|||
), |
|||
), |
|||
) |
|||
], |
|||
), |
|||
), |
|||
Divider( |
|||
height: 1, |
|||
color: Colors.grey[300], |
|||
), |
|||
Container( |
|||
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 20.w), |
|||
margin: EdgeInsets.symmetric(vertical: 20.w), |
|||
decoration: BoxDecoration( |
|||
color: Colors.white, |
|||
borderRadius: BorderRadius.circular(12.w), |
|||
boxShadow: [ |
|||
BoxShadow( |
|||
color: Colors.black.withValues(alpha: 0.05), |
|||
blurRadius: 10, |
|||
offset: const Offset(0, 2), |
|||
), |
|||
], |
|||
), |
|||
child: Column( |
|||
crossAxisAlignment: CrossAxisAlignment.start, |
|||
children: [ |
|||
Text( |
|||
'请朗读:', |
|||
style: TextStyle( |
|||
fontSize: 14.sp, |
|||
color: Colors.black87, |
|||
), |
|||
), |
|||
Padding( |
|||
padding: EdgeInsets.only(top: 20.w, bottom: 50.w), |
|||
child: Text( |
|||
'我(你的姓名)确认我的声音将会被(深圳市云衍智能科技有限公司)使用于创建合成版本语音。', |
|||
style: TextStyle( |
|||
fontSize: 16.sp, |
|||
color: Colors.red, |
|||
), |
|||
), |
|||
), |
|||
Text( |
|||
'例:我(李伟)确认我的声音将会被(深圳市云衍智能科技有限公司)使用于创建合成版本语音。', |
|||
style: TextStyle( |
|||
fontSize: 12.sp, |
|||
color: Colors.grey, |
|||
), |
|||
), |
|||
], |
|||
), |
|||
), |
|||
Padding( |
|||
padding: EdgeInsets.only(bottom: 20.w), |
|||
child: Row( |
|||
children: [ |
|||
Expanded( |
|||
child: GestureDetector( |
|||
onTap: () => Get.back(), |
|||
child: Container( |
|||
height: 48.w, |
|||
alignment: Alignment.center, |
|||
decoration: BoxDecoration( |
|||
color: Colors.grey[300], |
|||
borderRadius: BorderRadius.circular(12.r), |
|||
), |
|||
child: Text( |
|||
'cancel'.tr, // 取消 |
|||
style: TextStyle( |
|||
fontSize: 16.sp, |
|||
color: Colors.black, |
|||
), |
|||
), |
|||
), |
|||
), |
|||
), |
|||
10.horizontalSpace, |
|||
Expanded( |
|||
child: GestureDetector( |
|||
onTap: () { |
|||
setState(() { |
|||
_isRecording = !_isRecording; |
|||
}); |
|||
}, |
|||
child: Container( |
|||
height: 48.w, |
|||
alignment: Alignment.center, |
|||
decoration: BoxDecoration( |
|||
color: _isRecording ? Colors.blue : Colors.red, |
|||
borderRadius: BorderRadius.circular(12.r), |
|||
), |
|||
child: Text( |
|||
_isRecording ? 'confirm'.tr : 'startRecording'.tr, // 确认 |
|||
style: TextStyle( |
|||
fontSize: 16.sp, |
|||
color: Colors.white, |
|||
), |
|||
), |
|||
), |
|||
), |
|||
), |
|||
], |
|||
), |
|||
), |
|||
], |
|||
), |
|||
); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue