|
|
@@ -0,0 +1,155 @@
|
|
|
+import 'package:electronic_assistant/resource/assets.gen.dart';
|
|
|
+import 'package:electronic_assistant/resource/string.gen.dart';
|
|
|
+import 'package:electronic_assistant/utils/expand.dart';
|
|
|
+import 'package:flutter/cupertino.dart';
|
|
|
+import 'package:flutter/material.dart';
|
|
|
+import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
+import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
|
+import 'package:get/get.dart';
|
|
|
+
|
|
|
+import '../resource/colors.gen.dart';
|
|
|
+
|
|
|
+typedef TalkShareCallback = void Function(
|
|
|
+ ShareTalkType shareType, ShareTo shareTo, String dialogTag);
|
|
|
+
|
|
|
+void showTalkShareDialog(String title, TalkShareCallback callback) {
|
|
|
+ const String tag = 'showTalkShareDialog';
|
|
|
+
|
|
|
+ Rx<ShareTalkType> shareType = ShareTalkType.summary.obs;
|
|
|
+
|
|
|
+ SmartDialog.show(
|
|
|
+ tag: tag,
|
|
|
+ maskColor: Colors.black54,
|
|
|
+ alignment: const Alignment(0.0, 0.94),
|
|
|
+ builder: (_) => Container(
|
|
|
+ width: 336.w,
|
|
|
+ padding: EdgeInsets.all(16.w),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: ColorName.white,
|
|
|
+ borderRadius: BorderRadius.circular(12),
|
|
|
+ ),
|
|
|
+ child: IntrinsicHeight(
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Assets.images.iconTalkTxt
|
|
|
+ .image(width: 28.w, height: 32.w),
|
|
|
+ SizedBox(width: 6.w),
|
|
|
+ Expanded(
|
|
|
+ child: Text(title,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 14.sp,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ color: ColorName.primaryTextColor))),
|
|
|
+ SizedBox(width: 18.w),
|
|
|
+ GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ SmartDialog.dismiss(tag: tag);
|
|
|
+ },
|
|
|
+ child: Assets.images.iconTalkShareClose
|
|
|
+ .image(width: 28.w, height: 28.w),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ SizedBox(height: 12.h),
|
|
|
+ Divider(color: '#F6F6F6'.toColor(), height: 1.h),
|
|
|
+ SizedBox(height: 20.h),
|
|
|
+ Obx(() {
|
|
|
+ return Row(
|
|
|
+ children: [
|
|
|
+ Expanded(
|
|
|
+ child: _buildShareTypeItem(
|
|
|
+ StringName.talkTabSummary.tr,
|
|
|
+ Assets.images.iconTalkShareSummary.provider(),
|
|
|
+ shareType.value == ShareTalkType.summary, () {
|
|
|
+ shareType.value = ShareTalkType.summary;
|
|
|
+ })),
|
|
|
+ SizedBox(width: 12.w),
|
|
|
+ Expanded(
|
|
|
+ child: _buildShareTypeItem(
|
|
|
+ StringName.talkTabOriginal.tr,
|
|
|
+ Assets.images.iconTalkShareOriginal.provider(),
|
|
|
+ shareType.value == ShareTalkType.original, () {
|
|
|
+ shareType.value = ShareTalkType.original;
|
|
|
+ })),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }),
|
|
|
+ SizedBox(height: 16.h),
|
|
|
+ Text(
|
|
|
+ '发送至',
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 14.sp, color: ColorName.secondaryTextColor),
|
|
|
+ ),
|
|
|
+ SizedBox(height: 8.h),
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ _buildShareItem(StringName.dialogSendFriend.tr,
|
|
|
+ Assets.images.iconWx.provider(), () {
|
|
|
+ callback(shareType.value, ShareTo.wechat, tag);
|
|
|
+ }),
|
|
|
+ _buildShareItem(StringName.dialogSendFriend.tr,
|
|
|
+ Assets.images.iconQq.provider(), () {
|
|
|
+ callback(shareType.value, ShareTo.qq, tag);
|
|
|
+ }),
|
|
|
+ ],
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ));
|
|
|
+}
|
|
|
+
|
|
|
+Widget _buildShareTypeItem(String title, ImageProvider imageProvider,
|
|
|
+ bool isCheck, void Function() onTap) {
|
|
|
+ return GestureDetector(
|
|
|
+ onTap: onTap,
|
|
|
+ child: Container(
|
|
|
+ padding: EdgeInsets.only(top: 14.h, bottom: 12.h),
|
|
|
+ decoration: isCheck
|
|
|
+ ? BoxDecoration(
|
|
|
+ color: '#E7E9F6'.toColor(),
|
|
|
+ border: Border.all(color: ColorName.colorPrimary, width: 2),
|
|
|
+ borderRadius: BorderRadius.circular(8),
|
|
|
+ )
|
|
|
+ : BoxDecoration(
|
|
|
+ color: '#F6F5F8'.toColor(),
|
|
|
+ borderRadius: BorderRadius.circular(8),
|
|
|
+ ),
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ Image(image: imageProvider, width: 24.w, height: 24.w),
|
|
|
+ SizedBox(width: 4.h),
|
|
|
+ Text(title,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 14.sp, color: ColorName.primaryTextColor)),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+Widget _buildShareItem(
|
|
|
+ String itemName, ImageProvider imageProvider, void Function() onTap) {
|
|
|
+ return Container(
|
|
|
+ margin: EdgeInsets.symmetric(horizontal: 10.w),
|
|
|
+ child: GestureDetector(
|
|
|
+ onTap: onTap,
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ Image(image: imageProvider, width: 40.w, height: 40.w),
|
|
|
+ SizedBox(height: 6.h),
|
|
|
+ Text(itemName,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 14.sp, color: ColorName.secondaryTextColor)),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+}
|
|
|
+
|
|
|
+enum ShareTalkType { summary, original }
|
|
|
+
|
|
|
+enum ShareTo { wechat, qq }
|