3 changed files with 173 additions and 120 deletions
@ -0,0 +1,162 @@ |
|||
import 'package:flutter/material.dart'; |
|||
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
|||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|||
import 'package:get/get.dart'; |
|||
import 'package:share_plus/share_plus.dart'; |
|||
|
|||
import '../controllers/meeting_details_controller.dart'; |
|||
|
|||
class ShareBottomSheet extends StatefulWidget { |
|||
const ShareBottomSheet({super.key}); |
|||
|
|||
@override |
|||
State<ShareBottomSheet> createState() => _ShareBottomSheetState(); |
|||
} |
|||
|
|||
class _ShareBottomSheetState extends State<ShareBottomSheet> { |
|||
final _controller = Get.find<MeetingDetailsController>(); |
|||
|
|||
@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( |
|||
children: [ |
|||
Icon( |
|||
Icons.audio_file_outlined, |
|||
color: Colors.grey, |
|||
size: 32.w, |
|||
), |
|||
5.horizontalSpace, |
|||
Expanded( |
|||
child: Text( |
|||
_controller.meetingData.value.title, |
|||
style: TextStyle( |
|||
fontSize: 16.sp, |
|||
color: Colors.black87, |
|||
), |
|||
), |
|||
), |
|||
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], |
|||
), |
|||
), |
|||
) |
|||
], |
|||
), |
|||
), |
|||
Padding( |
|||
padding: EdgeInsets.symmetric(vertical: 10.w), |
|||
child: Column( |
|||
children: [ |
|||
_box([ |
|||
_shareItem(Icons.link, '分享链接', isBorder: false), |
|||
]), |
|||
_box([ |
|||
_shareItem(Icons.copy, '复制转写'), |
|||
_shareItem(Icons.copy, '复制总结', isBorder: false), |
|||
]), |
|||
_box([ |
|||
_shareItem( |
|||
Icons.multitrack_audio, |
|||
'导出音频', |
|||
onTap: shareAllTranslatAudio, |
|||
), |
|||
_shareItem(Icons.message, '导出转写'), |
|||
_shareItem(Icons.article, '导出总结'), |
|||
_shareItem(Icons.lan, '导出思维导图', isBorder: false), |
|||
]), |
|||
], |
|||
), |
|||
), |
|||
], |
|||
), |
|||
); |
|||
} |
|||
|
|||
Widget _box(List<Widget> children) { |
|||
return Container( |
|||
margin: EdgeInsets.only(bottom: 10.w), |
|||
decoration: BoxDecoration( |
|||
color: Colors.white, |
|||
borderRadius: BorderRadius.circular(12.r), |
|||
), |
|||
child: Column( |
|||
children: children, |
|||
), |
|||
); |
|||
} |
|||
|
|||
Widget _shareItem( |
|||
IconData icon, |
|||
String title, { |
|||
bool isBorder = true, |
|||
VoidCallback? onTap, |
|||
}) { |
|||
return InkWell( |
|||
onTap: onTap, |
|||
child: Container( |
|||
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 15.w), |
|||
decoration: BoxDecoration( |
|||
border: isBorder |
|||
? Border( |
|||
bottom: BorderSide( |
|||
color: Colors.grey[300]!, |
|||
), |
|||
) |
|||
: null, |
|||
), |
|||
child: Row( |
|||
children: [ |
|||
Icon( |
|||
icon, |
|||
color: Colors.black87, |
|||
), |
|||
10.horizontalSpace, |
|||
Expanded( |
|||
child: Text( |
|||
title, |
|||
style: TextStyle( |
|||
fontSize: 14.sp, |
|||
color: Colors.black87, |
|||
), |
|||
), |
|||
), |
|||
], |
|||
), |
|||
), |
|||
); |
|||
} |
|||
|
|||
void shareAllTranslatAudio() async { |
|||
if (_controller.meetingData.value.filepath.isEmpty) { |
|||
EasyLoading.showToast('没有可分享的音频文件'); |
|||
return; |
|||
} |
|||
try { |
|||
await Share.shareXFiles( |
|||
[XFile(_controller.meetingData.value.filepath)], |
|||
text: '分享会议音频', |
|||
); |
|||
EasyLoading.showToast('分享完成!'); |
|||
} catch (e) { |
|||
EasyLoading.showToast('分享失败: ${e.toString()}'); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue