Browse Source

添加分享链接

weicu
tanlongsheng 1 year ago
parent
commit
9ee7fde0b0
  1. 54
      lib/modules/meeting/views/share_bottom_sheet.dart

54
lib/modules/meeting/views/share_bottom_sheet.dart

@ -72,16 +72,42 @@ class _ShareBottomSheetState extends State<ShareBottomSheet> {
child: Column( child: Column(
children: [ children: [
_box([ _box([
_shareItem(Icons.link, '分享链接', isBorder: false, onTap: () { _shareItem(
final GetStorage storage = GetStorage(); Icons.link,
String token = storage.read("logintoken") ?? ''; '分享链接',
String userId = ''; isBorder: false,
Map? userInfo = storage.read("user_info"); onTap: () async {
if (userInfo != null) { Get.back();
userId = userInfo['user']['uid']; final GetStorage storage = GetStorage();
} String token = storage.read("logintoken") ?? '';
String id = '${userId}_${_controller.meetingData.value.id}'; String userId = '';
}), Map? userInfo = storage.read("user_info");
if (userInfo != null) {
userId = userInfo['user']['uid'];
}
String id =
'${userId}_${_controller.meetingData.value.id}';
final thumbnail = await getAssetThumbnailFile(
'assets/images/headphone_dark.png',
'share_thumb.png',
);
final result = await SharePlus.instance.share(ShareParams(
title: _controller.meetingData.value.title,
subject:
'DeepSound WEB,由DeepSound.Ai提供支持-实时记录会议纪要,多语言翻译。',
uri: Uri.parse(
'http://web.ideapsound.com/share/$id/$token',
),
previewThumbnail: thumbnail,
));
if (result.status == ShareResultStatus.success) {
EasyLoading.showToast('分享完成!');
}
},
),
]), ]),
_box([ _box([
_shareItem(Icons.copy, '复制转写', onTap: () { _shareItem(Icons.copy, '复制转写', onTap: () {
@ -223,4 +249,12 @@ class _ShareBottomSheetState extends State<ShareBottomSheet> {
} }
return text; return text;
} }
Future<XFile> getAssetThumbnailFile(String assetPath, String fileName) async {
final byteData = await rootBundle.load(assetPath);
final tempDir = await getTemporaryDirectory();
final file = File('${tempDir.path}/$fileName');
await file.writeAsBytes(byteData.buffer.asUint8List());
return XFile(file.path);
}
} }

Loading…
Cancel
Save