Browse Source

修改分享

weicu
tanlongsheng 1 year ago
parent
commit
ed3d3b1ade
  1. 2
      lib/modules/meeting/controllers/mind_map_controller.dart
  2. 164
      lib/modules/meeting/views/bottomSheet/second_level_bottom_sheet.dart
  3. 45
      lib/modules/meeting/views/bottomSheet/share_bottom_sheet.dart

2
lib/modules/meeting/controllers/mind_map_controller.dart

@ -170,7 +170,7 @@ class MindMapController extends GetxController {
final String base64Str = dataUrl.split(',').last; final String base64Str = dataUrl.split(',').last;
final Uint8List bytes = base64.decode(base64Str); final Uint8List bytes = base64.decode(base64Str);
final String fileName = final String fileName =
'${_meetingDetailsController.meetingData.value.title} mindmap.png'; '${_meetingDetailsController.meetingData.value.title}_mindmap.png';
final tempDir = await getTemporaryDirectory(); final tempDir = await getTemporaryDirectory();
final File file = File('${tempDir.path}/$fileName'); final File file = File('${tempDir.path}/$fileName');
await file.writeAsBytes(bytes); await file.writeAsBytes(bytes);

164
lib/modules/meeting/views/bottomSheet/second_level_bottom_sheet.dart

@ -0,0 +1,164 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
class SecondLevelBottomSheet extends StatefulWidget {
final String title;
final String subtitle;
final Function(int index) onTap;
final List children;
const SecondLevelBottomSheet(
this.title, this.subtitle, this.onTap, this.children,
{super.key});
@override
State<SecondLevelBottomSheet> createState() => _SecondLevelBottomSheetState();
}
class _SecondLevelBottomSheetState extends State<SecondLevelBottomSheet> {
int _selectedIndex = 0;
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 12.w),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
padding: EdgeInsets.symmetric(vertical: 10.w),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
widget.title,
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],
),
Padding(
padding: EdgeInsetsGeometry.only(
top: 20.w,
bottom: 10.w,
left: 12.w,
),
child: Text(
widget.subtitle,
style: TextStyle(
fontSize: 14.sp,
color: Colors.grey[600],
),
),
),
Container(
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12.r),
),
child: Column(
children: List.generate(widget.children.length, (int index) {
Map item = widget.children[index];
return InkWell(
onTap: () {
setState(() {
_selectedIndex = index;
});
},
child: Container(
padding:
EdgeInsets.symmetric(horizontal: 12.w, vertical: 14.w),
decoration: BoxDecoration(
border: item['isBorder']
? Border(
bottom: BorderSide(
width: 0.5,
color: Colors.grey[300]!,
),
)
: null,
),
child: Row(
children: [
Icon(
item['icon'],
color: Colors.black87,
),
10.horizontalSpace,
Expanded(
child: Text(
item['title'],
style: TextStyle(
fontSize: 14.sp,
color: Colors.black87,
),
),
),
if (_selectedIndex == index)
const Icon(
Icons.check,
color: Colors.black87,
),
],
),
),
);
}),
),
),
Padding(
padding: EdgeInsets.symmetric(vertical: 20.w),
child: GestureDetector(
onTap: () {
Get.back();
widget.onTap(_selectedIndex);
},
child: Container(
height: 48.w,
alignment: Alignment.center,
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(12.r),
),
child: Text(
'导出',
style: TextStyle(
fontSize: 16.sp,
color: Colors.white,
),
),
),
),
),
],
),
);
}
}

45
lib/modules/meeting/views/bottomSheet/share_bottom_sheet.dart

@ -14,6 +14,7 @@ import 'package:webview_flutter/webview_flutter.dart';
import '../../../../core/utils/synchrodata.dart'; import '../../../../core/utils/synchrodata.dart';
import '../../controllers/meeting_details_controller.dart'; import '../../controllers/meeting_details_controller.dart';
import '../../controllers/mind_map_controller.dart'; import '../../controllers/mind_map_controller.dart';
import 'second_level_bottom_sheet.dart';
class ShareBottomSheet extends StatefulWidget { class ShareBottomSheet extends StatefulWidget {
const ShareBottomSheet({super.key}); const ShareBottomSheet({super.key});
@ -141,7 +142,7 @@ class _ShareBottomSheetState extends State<ShareBottomSheet> {
Get.back(); Get.back();
final tempDir = await getTemporaryDirectory(); final tempDir = await getTemporaryDirectory();
final file = File( final file = File(
'${tempDir.path}/${_controller.meetingData.value.title} speaker.txt'); '${tempDir.path}/${_controller.meetingData.value.title}_speaker.txt');
String allText = _getAllText(); String allText = _getAllText();
await file.writeAsString(allText); await file.writeAsString(allText);
_share(file.path, '分享会议转写'); _share(file.path, '分享会议转写');
@ -151,12 +152,42 @@ class _ShareBottomSheetState extends State<ShareBottomSheet> {
onTap: _controller.meetingDetails.value.tasktype >= 3 onTap: _controller.meetingDetails.value.tasktype >= 3
? () async { ? () async {
Get.back(); Get.back();
final tempDir = await getTemporaryDirectory(); Get.bottomSheet(
final file = File( SecondLevelBottomSheet(
'${tempDir.path}/${_controller.meetingData.value.title} summary.txt'); '导出总结',
await file.writeAsString( '导出为',
_controller.meetingDetails.value.summary); (int index) async {
_share(file.path, '分享会议总结'); if (index == 0) {
final tempDir =
await getTemporaryDirectory();
final file = File(
'${tempDir.path}/${_controller.meetingData.value.title}_summary.txt');
await file.writeAsString(_controller
.meetingDetails.value.summary);
_share(file.path, '分享会议总结');
} else {}
},
const [
{
'icon': Icons.text_snippet,
'title': 'TXT',
'isBorder': true,
},
{
'icon': Icons.picture_as_pdf,
'title': 'PDF',
'isBorder': false,
},
],
),
isScrollControlled: true,
backgroundColor: Colors.grey[100],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(12.r),
),
),
);
} }
: null), : null),
_shareItem( _shareItem(

Loading…
Cancel
Save