| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- 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 fileName, String dialogTag);
- void showTalkShareDialog(String? title, TalkShareCallback callback) {
- const String tag = 'showTalkShareDialog';
- Rx<ShareTalkType> shareType = ShareTalkType.summary.obs;
- String getFileName() {
- return '${shareType.value == ShareTalkType.summary ? '[谈话总结]' : '[谈话原文]'} $title.txt';
- }
- 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: Obx(() {
- return Text(getFileName(),
- 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),
- GetPlatform.isIOS
- ? GestureDetector(
- onTap: () {
- callback(shareType.value, ShareTo.ios,
- getFileName(), tag);
- },
- child: Container(
- margin: EdgeInsets.only(top: 8.h),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(8),
- gradient: LinearGradient(
- colors: [
- '#6177F2'.toColor(),
- '#8B9DFF'.toColor()
- ],
- begin: Alignment.centerLeft,
- end: Alignment.centerRight,
- stops: const [0, 1.0],
- ),
- ),
- // width: 240.w,
- height: 48.w,
- child: Center(
- child: Text(
- "分享",
- style: TextStyle(
- fontSize: 16.sp, color: ColorName.white),
- ),
- ),
- ),
- )
- : Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- 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,
- getFileName(), tag);
- }),
- _buildShareItem(StringName.dialogSendFriend.tr,
- Assets.images.iconQq.provider(), () {
- callback(shareType.value, ShareTo.qq,
- getFileName(), 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, ios }
|