Hibok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1492 rivejä
47 KiB

  1. import 'dart:convert';
  2. import 'dart:io';
  3. import 'dart:math';
  4. import 'dart:typed_data';
  5. import 'package:cached_network_image/cached_network_image.dart';
  6. import 'package:chat/chat/download_item.dart';
  7. import 'package:chat/chat/file_msg_item.dart';
  8. import 'package:chat/chat/gift_msg_item.dart';
  9. import 'package:chat/chat/msg_state_widge.dart';
  10. import 'package:chat/chat/place_item.dart';
  11. import 'package:chat/chat/redbag_widget.dart';
  12. import 'package:chat/chat/upload_item.dart';
  13. import 'package:chat/chat/video_view.dart';
  14. import 'package:chat/data/UserData.dart';
  15. import 'package:chat/data/constants.dart';
  16. import 'package:chat/generated/i18n.dart';
  17. import 'package:chat/models/ChatMsg.dart';
  18. import 'package:chat/models/UserInfo.dart';
  19. import 'package:chat/models/group_info_model.dart';
  20. import 'package:chat/models/keyboard_provider.dart';
  21. import 'package:chat/models/ref_name_provider.dart';
  22. import 'package:chat/proto/chat.pbenum.dart';
  23. import 'package:chat/proto/chat.pbserver.dart';
  24. import 'package:chat/proto/transhousekeeper.pb.dart';
  25. import 'package:chat/utils/CustomUI.dart';
  26. import 'package:chat/utils/HttpUtil.dart';
  27. import 'package:chat/utils/MessageMgr.dart';
  28. import 'package:chat/utils/app_navigator.dart';
  29. import 'package:chat/utils/date_utils.dart';
  30. import 'package:chat/utils/file_cache_mgr.dart';
  31. import 'package:chat/utils/msgHandler.dart';
  32. import 'package:chat/utils/screen.dart';
  33. import 'package:chat/utils/sound_util.dart';
  34. import 'package:chat/utils/upload_util.dart';
  35. import 'package:chat/utils/video_anim.dart';
  36. import 'package:chat/utils/wpop/w_popup_menu.dart';
  37. import 'package:dio/dio.dart';
  38. import 'package:flutter/services.dart';
  39. import 'package:flutter/cupertino.dart';
  40. import 'package:flutter/material.dart';
  41. import 'package:oktoast/oktoast.dart';
  42. import 'package:provider/provider.dart';
  43. import 'package:share_extend/share_extend.dart';
  44. import 'package:url_launcher/url_launcher.dart';
  45. import '../r.dart';
  46. import 'full_img_view.dart';
  47. import 'upload_item.dart';
  48. import 'package:chat/models/money_change.dart';
  49. import 'package:chat/models/voucher_change.dart';
  50. const double ChatRadius = 7.5;
  51. const Color SendMsgBg = Color(0xFFD4F0FF);
  52. const double TextHeight = 1.2;
  53. const double PaddingLeft = 9.5;
  54. const Color ReciveBorderColor = Color(0xFFDCDCDC);
  55. const double FontSize = 15;
  56. class ChatPageItem extends StatefulWidget {
  57. final MsgModel msg;
  58. final UserInfo friendInfo;
  59. final int lastMsgTime;
  60. final Function hideKeyboard;
  61. const ChatPageItem(
  62. {Key key, this.msg, this.lastMsgTime, this.friendInfo, this.hideKeyboard})
  63. : assert(msg != null),
  64. super(key: key);
  65. @override
  66. _ChatPageItemState createState() => _ChatPageItemState();
  67. }
  68. class _ChatPageItemState extends State<ChatPageItem>
  69. with SingleTickerProviderStateMixin {
  70. int curTextType = 0; //文字、译文切换索引
  71. List<String> textList = [];
  72. UserInfo friendInfo;
  73. String curSoundUrl;
  74. CancelToken _cancelToken = CancelToken();
  75. bool isLongPressed = false;
  76. @override
  77. void initState() {
  78. super.initState();
  79. friendInfo = widget.friendInfo;
  80. if (widget.msg.from == UserData().basicInfo.userId &&
  81. widget.msg.state == MsgState.None) {
  82. print('重新发送消息');
  83. MsgHandler.sendChatMsg(widget.msg);
  84. }
  85. textList = widget.msg.getTransTextList();
  86. MessageMgr().on('Update Translate Message', updateTranslateMsg);
  87. MessageMgr().on('Cancel Request', _deleteItem);
  88. MessageMgr().on('Cancel Request', _deleteItem);
  89. }
  90. @override
  91. void dispose() {
  92. MessageMgr().off('Cancel Request', _deleteItem);
  93. MessageMgr().off('Update Translate Message', updateTranslateMsg);
  94. super.dispose();
  95. }
  96. _deleteItem(msg) {
  97. if (msg == widget.msg) {
  98. print(widget.msg.state);
  99. if (widget.msg.state == MsgState.Uploading) {
  100. print('取消上传');
  101. UploadUtil().cancelRequests(_cancelToken);
  102. }
  103. }
  104. }
  105. updateTextList() {
  106. textList.clear();
  107. curTextType = 0;
  108. textList = widget.msg.getTransTextList();
  109. }
  110. updateTranslateMsg(msg) {
  111. if (msg.time == widget.msg.time) {
  112. if (mounted) {
  113. updateTextList();
  114. if (!mounted) {
  115. return;
  116. }
  117. setState(() {
  118. print('更新翻译文字');
  119. });
  120. }
  121. }
  122. }
  123. getTodayTime(msgDate) {
  124. String showTimeStr;
  125. var sendTime = widget.msg.time;
  126. var today = DateTime.now();
  127. //今天
  128. if (msgDate.year == today.year &&
  129. msgDate.month == today.month &&
  130. msgDate.day == today.day) {
  131. showTimeStr =
  132. DateUtils().getFormartData(timeSamp: sendTime, format: 'HH:mm');
  133. } else {
  134. showTimeStr = DateUtils()
  135. .getFormartData(timeSamp: sendTime, format: 'yyyy/MM/dd HH:mm');
  136. }
  137. return showTimeStr;
  138. }
  139. String getMsgTime() {
  140. String showTimeStr;
  141. var sendTime = widget.msg.time;
  142. var msgDate = DateTime.fromMillisecondsSinceEpoch(sendTime);
  143. if (widget.lastMsgTime == null) {
  144. showTimeStr = getTodayTime(msgDate);
  145. } else {
  146. if (sendTime - widget.lastMsgTime > 3 * 60 * 1000) {
  147. showTimeStr = getTodayTime(msgDate);
  148. }
  149. }
  150. return showTimeStr;
  151. }
  152. @override
  153. Widget build(BuildContext context) {
  154. var showTime = getMsgTime();
  155. return Container(
  156. width: Screen.width,
  157. margin: const EdgeInsets.symmetric(vertical: 10.0),
  158. child: Column(
  159. children: <Widget>[
  160. showTime == null
  161. ? SizedBox()
  162. : Container(
  163. decoration: BoxDecoration(
  164. color: Color(0xFF2C2F36).withOpacity(0.25),
  165. borderRadius: BorderRadius.all(Radius.circular(9.5))),
  166. padding:
  167. EdgeInsets.only(left: 7, right: 7, top: 3, bottom: 2),
  168. child: Text(showTime,
  169. textScaleFactor: 1.0,
  170. style: TextStyle(fontSize: 10.0, color: Colors.white)),
  171. ),
  172. SizedBox(height: 10),
  173. _msgWidget()
  174. ],
  175. ),
  176. );
  177. }
  178. _msgWidget() {
  179. if (widget.msg.from == 0) {
  180. return _serverNotifyMsg();
  181. } else {
  182. if (widget.msg.from == UserData().basicInfo.userId) {
  183. return _getSentMessageLayout(context);
  184. } else {
  185. return _getReceivedMessageLayout(context);
  186. }
  187. }
  188. }
  189. _serverNotifyMsg() {
  190. var type = widget.msg.msgType;
  191. if (type == ChatType.RedWalletChatType.value) {
  192. RedWallet wallet = RedWallet.fromBuffer(widget.msg.msgContent);
  193. var msg = '';
  194. if (wallet.state == RedWalletState.Received) {
  195. if (wallet.tuId == friendInfo.userId) {
  196. msg = I18n.of(context).get_money.replaceFirst(
  197. '/s1',
  198. Provider.of<RefNameProvider>(context)
  199. .getRefName(friendInfo.userId, friendInfo.nickName));
  200. } else {
  201. msg = I18n.of(context).you_get_money.replaceFirst(
  202. '/s1',
  203. Provider.of<RefNameProvider>(context)
  204. .getRefName(friendInfo.userId, friendInfo.nickName));
  205. }
  206. } else {
  207. if (wallet.tuId == friendInfo.userId) {
  208. msg = I18n.of(context).your_redMoney_over;
  209. } else {
  210. msg = I18n.of(context).other_redMoney_over;
  211. }
  212. }
  213. return Container(
  214. alignment: Alignment.center,
  215. constraints: BoxConstraints(maxWidth: Screen.width - 120),
  216. child: extendedText(msg, color: Constants.GreyTextColor, fontSize: 12),
  217. );
  218. } else {
  219. ///todo 翻译管家系统通知消息
  220. print('这里应该要有翻译管家');
  221. if (type == ChatType.GroupChatNoticeType.value && widget.msg.channelType ==ChatChannelType.Session.value) {
  222. TransHKChatNotice res = TransHKChatNotice.fromBuffer(widget.msg.msgContent);
  223. if(res.noticeType==TransHKChatNoticeType.StartChat){
  224. ///开始翻译服务
  225. return _buildServiceCard(true, () {});
  226. }else if(res.noticeType==TransHKChatNoticeType.EndChat){
  227. ///翻译服务结束
  228. return _buildServiceCard(false, () {});
  229. }else{
  230. return Container();
  231. }
  232. // return Container();
  233. }
  234. // else{
  235. // if (type == ChatType.GroupChatNoticeType.value) {
  236. // var res = GroupChatNotice.fromBuffer(widget.msg.msgContent);
  237. //
  238. // var groupInfoModel = Provider.of<GroupInfoModel>(context);
  239. // var showStr = MsgHandler.getGroupNoticeMsg(res, groupInfoModel);
  240. // return Container(
  241. // alignment: Alignment.center,
  242. // constraints: BoxConstraints(maxWidth: Screen.width - 120),
  243. // child: Text(
  244. // showStr,
  245. // textScaleFactor: 1.0,
  246. // textAlign: TextAlign.center,
  247. // style: TextStyle(color: Constants.GreyTextColor, fontSize: 12),
  248. // ),
  249. // );
  250. // }
  251. // }
  252. }
  253. return Container();
  254. }
  255. _textGif(List<int> msgContent) {
  256. var msg = utf8.decode(msgContent);
  257. return Container(
  258. constraints: BoxConstraints(maxWidth: Screen.width - 120),
  259. child: extendedText(
  260. msg,
  261. hideKeyboard: widget.hideKeyboard,
  262. fontSize: FontSize,
  263. color: Colors.black,
  264. ),
  265. );
  266. }
  267. _textMsg(List<int> msgContent) {
  268. var msg = utf8.decode(msgContent);
  269. bool isUrl =false;
  270. if(textList[curTextType].contains('http') ){
  271. isUrl =true;
  272. }
  273. Widget text = Container(
  274. constraints: BoxConstraints(maxWidth: Screen.width - 120),
  275. child: extendedText(
  276. msg,
  277. hideKeyboard: widget.hideKeyboard,
  278. fontSize: FontSize,
  279. color: isUrl?Colors.blue:Colors.black,
  280. ),
  281. padding: EdgeInsets.symmetric(horizontal: 9, vertical: 10.5),
  282. decoration: BoxDecoration(
  283. color: isLongPressed ? Colors.grey[300] : SendMsgBg,
  284. border: Border.all(color: Color(0xFFB9CBD7), width: 0.6),
  285. borderRadius: BorderRadius.all(Radius.circular(ChatRadius))),
  286. );
  287. if (widget.msg.refMsgContent != null &&
  288. widget.msg.refMsgContent.length > 0) {
  289. QuoteMsg quoteMsg = QuoteMsg.fromBuffer(widget.msg.refMsgContent);
  290. return Column(
  291. mainAxisSize: MainAxisSize.min,
  292. crossAxisAlignment: CrossAxisAlignment.end,
  293. children: <Widget>[
  294. text,
  295. SizedBox(height: 2),
  296. Container(
  297. constraints: BoxConstraints(maxWidth: Screen.width - 120),
  298. padding: EdgeInsets.symmetric(vertical: 1, horizontal: 3),
  299. child: Text(
  300. quoteMsg.content,
  301. maxLines: 1,
  302. textScaleFactor: 1.0,
  303. overflow: TextOverflow.ellipsis,
  304. style: TextStyle(fontSize: 12),
  305. ),
  306. decoration: BoxDecoration(
  307. color: Colors.grey[300],
  308. borderRadius: BorderRadius.circular(5)),
  309. )
  310. ],
  311. );
  312. } else {
  313. return text;
  314. }
  315. }
  316. _soundMsg() {
  317. double time = widget.msg.extraInfo / 1000;
  318. if (time > 60) {
  319. time = 60.0;
  320. }
  321. bool isPlaying = false;
  322. var soundPath = widget.msg.localFile;
  323. isPlaying = SoundUtils().isPlaying(soundPath);
  324. var soundWidget = GestureDetector(
  325. child: Container(
  326. width: 120,
  327. child: Row(
  328. mainAxisAlignment: MainAxisAlignment.end,
  329. children: <Widget>[
  330. Container(
  331. alignment: Alignment.center,
  332. padding: EdgeInsets.only(bottom: 2),
  333. margin: EdgeInsets.only(right: 10),
  334. width: 25.5,
  335. height: 25.5,
  336. decoration: BoxDecoration(
  337. border:
  338. Border.all(color: const Color(0xFF1B92C7), width: 0.5),
  339. color: const Color(0xFF04A4FE),
  340. shape: BoxShape.circle),
  341. child: Icon(
  342. IconData(isPlaying ? 0xe652 : 0xe653,
  343. fontFamily: Constants.IconFontFamily),
  344. size: isPlaying ? 15 : 18,
  345. color: Colors.white,
  346. ),
  347. ),
  348. isPlaying
  349. ? Stack(
  350. children: <Widget>[
  351. Container(
  352. height: 18,
  353. width: 19,
  354. ),
  355. Positioned(
  356. bottom: 0,
  357. child: VideoAnim(
  358. begin: 18,
  359. start: 0.444,
  360. end: 4.5,
  361. )),
  362. Positioned(
  363. left: 7,
  364. bottom: 0,
  365. child: VideoAnim(
  366. begin: 4.5,
  367. end: 18,
  368. )),
  369. Positioned(
  370. left: 14,
  371. bottom: 0,
  372. child: VideoAnim(
  373. begin: 18,
  374. end: 4.5,
  375. ))
  376. ],
  377. )
  378. : Stack(
  379. children: <Widget>[
  380. Container(
  381. height: 18,
  382. width: 19,
  383. ),
  384. Positioned(
  385. bottom: 0, child: CustomUI.buildAudioContaniner(12)),
  386. Positioned(
  387. left: 7,
  388. bottom: 0,
  389. child: CustomUI.buildAudioContaniner(4.5)),
  390. Positioned(
  391. left: 14,
  392. bottom: 0,
  393. child: CustomUI.buildAudioContaniner(18))
  394. ],
  395. ),
  396. Expanded(child: SizedBox()),
  397. fixedText(time.toStringAsFixed(0),
  398. color: Constants.BlackTextColor, fontSize: 16)
  399. ],
  400. ),
  401. padding: EdgeInsets.symmetric(horizontal: 15, vertical: 12),
  402. decoration: BoxDecoration(
  403. color: SendMsgBg,
  404. border: Border.all(color: Color(0xFFB9CBD7), width: 0.6),
  405. borderRadius: BorderRadius.all(Radius.circular(ChatRadius))),
  406. ),
  407. onTap: () async {
  408. print('播放状态 : $isPlaying');
  409. print('当前文件$soundPath ');
  410. if (isPlaying) {
  411. SoundUtils().pause();
  412. } else {
  413. SoundUtils().play(soundPath, onPlayed: () {
  414. if (mounted) {
  415. setState(() {});
  416. }
  417. }, complete: () {
  418. if (mounted) {
  419. setState(() {});
  420. }
  421. });
  422. }
  423. },
  424. );
  425. return UploadImgItem(
  426. msg: widget.msg,
  427. child: soundWidget,
  428. isShowProgress: false,
  429. );
  430. }
  431. Size _getImgSize() {
  432. double aspectRatio = widget.msg.extraInfo / 100;
  433. var maxWidth = Screen.width * 0.65;
  434. var maxHeight = Screen.height / 4;
  435. var width, height;
  436. if (maxWidth / maxHeight > aspectRatio) {
  437. height = maxHeight;
  438. width = maxHeight * aspectRatio;
  439. } else {
  440. width = maxWidth;
  441. height = maxWidth / aspectRatio;
  442. }
  443. return Size(width, height);
  444. }
  445. _imgMsg(List<int> imgData) {
  446. var imgSize = _getImgSize();
  447. ImageProvider provider = MemoryImage(widget.msg.localFile==null?Uint8List.fromList(imgData):File(widget.msg.localFile).readAsBytesSync());
  448. return GestureDetector(
  449. child: ClipRRect(
  450. child: UploadImgItem(
  451. msg: widget.msg,
  452. cancelToken: _cancelToken,
  453. child: Container(
  454. height: imgSize.height,
  455. width: imgSize.width,
  456. child: Image(
  457. fit: BoxFit.contain,
  458. image: provider,
  459. ),
  460. )),
  461. borderRadius: BorderRadius.circular(5),
  462. ),
  463. onTap: () async {
  464. showFullImg(context, widget.msg);
  465. });
  466. }
  467. _videoMsg(BuildContext context, List<int> thumbnail) {
  468. var imgSize = _getImgSize();
  469. return InkWell(
  470. child: ClipRRect(
  471. child: Stack(
  472. alignment: Alignment.center,
  473. children: <Widget>[
  474. UploadImgItem(
  475. msg: widget.msg,
  476. cancelToken: _cancelToken,
  477. child: Container(
  478. width: imgSize.width,
  479. height: imgSize.height,
  480. child: Image(
  481. fit: BoxFit.contain,
  482. image: MemoryImage(Uint8List.fromList(thumbnail)),
  483. ),
  484. ))
  485. ],
  486. ),
  487. borderRadius: BorderRadius.circular(5),
  488. ),
  489. onTap: () {
  490. showVideoPage(context, widget.msg.localFile);
  491. },
  492. );
  493. }
  494. _msgLayout(BuildContext context, MsgModel msg) {
  495. Widget item;
  496. switch (ChatType.valueOf(msg.msgType)) {
  497. case ChatType.TextChatType:
  498. item = _textMsg(msg.msgContent);
  499. break;
  500. case ChatType.EmoticonType:
  501. item = _textGif(msg.msgContent);
  502. break;
  503. case ChatType.ImageChatType:
  504. item = _imgMsg(msg.msgContent);
  505. break;
  506. case ChatType.ShortVideoChatType:
  507. item = _videoMsg(context, msg.msgContent);
  508. break;
  509. case ChatType.ShortVoiceChatType:
  510. item = _soundMsg();
  511. break;
  512. case ChatType.RedWalletChatType:
  513. item = RedBagItem(
  514. Key(msg.time.toString()), UserData().basicInfo.userId, msg);
  515. break;
  516. case ChatType.PlaceChatType:
  517. item = PlaceItem(isMe: true, placeContent: msg.msgContent);
  518. break;
  519. case ChatType.GiftChatType:
  520. item = GiftMsgItem(msg.msgContent, true);
  521. break;
  522. case ChatType.FileChatType:
  523. item = _fileMsgItem();
  524. break;
  525. default:
  526. }
  527. return wrapItemWithMenu(item);
  528. }
  529. Widget _fileMsgItem() {
  530. return UploadImgItem(
  531. msg: widget.msg,
  532. cancelToken: _cancelToken,
  533. child: Container(
  534. height: 100,
  535. constraints: BoxConstraints(maxWidth: Screen.width - 120),
  536. padding: EdgeInsets.symmetric(horizontal: 9, vertical: 10.5),
  537. decoration: BoxDecoration(
  538. color: isLongPressed ? Colors.grey[300] : SendMsgBg,
  539. borderRadius: BorderRadius.all(Radius.circular(ChatRadius))),
  540. child: FileMsgItem(widget.msg)));
  541. }
  542. Widget _getSentMessageLayout(BuildContext context) {
  543. bool hasHeadImg = true;
  544. if (UserData().basicInfo.headimgurl == null ||
  545. UserData().basicInfo.headimgurl.length == 0) {
  546. hasHeadImg = false;
  547. }
  548. return Row(
  549. crossAxisAlignment: CrossAxisAlignment.start,
  550. mainAxisAlignment: MainAxisAlignment.end,
  551. children: <Widget>[
  552. MsgStateWidget(widget.msg),
  553. SizedBox(width: 3),
  554. _msgLayout(context, widget.msg),
  555. SizedBox(width: 10),
  556. Column(
  557. crossAxisAlignment: CrossAxisAlignment.end,
  558. children: <Widget>[
  559. ClipRRect(
  560. borderRadius: BorderRadius.circular(8),
  561. child: hasHeadImg
  562. ? CachedNetworkImage(
  563. imageUrl: UserData().basicInfo.headimgurl,
  564. placeholder: (context, url) => Image.asset(
  565. Constants.DefaultHeadImgUrl,
  566. width: 40,
  567. height: 40,
  568. ),
  569. width: 40,
  570. height: 40,
  571. )
  572. : SizedBox(
  573. width: 40,
  574. height: 40,
  575. child: Image.asset(R.assetsImagesDefaultNorAvatar))),
  576. ],
  577. )
  578. ]);
  579. }
  580. Widget wrapItemWithMenu(item) {
  581. List<Function> actionsFunc = [];
  582. List<String> actions = [
  583. I18n.of(context).delete,
  584. I18n.of(context).reply,
  585. ];
  586. actionsFunc.add(() {
  587. MessageMgr().emit('Delete Select Message', widget.msg);
  588. });
  589. actionsFunc.add(() {
  590. print('发送引用的消息');
  591. MessageMgr().emit('Reply Select Message', widget.msg);
  592. });
  593. ///转发
  594. if (widget.msg.msgType == ChatType.TextChatType.value||
  595. widget.msg.msgType == ChatType.ImageChatType.value||
  596. widget.msg.msgType == ChatType.ShortVideoChatType.value||
  597. widget.msg.msgType == ChatType.PlaceChatType.value||
  598. widget.msg.msgType == ChatType.EmoticonType.value||
  599. widget.msg.msgType == ChatType.FileChatType.value
  600. ){
  601. actions.add( I18n.of(context).forward);
  602. actionsFunc.add(() {
  603. print('转发消息');
  604. if(widget.msg.msgType == ChatType.FileChatType.value && widget.msg.localFile==null){
  605. showToast('请先下载文件');
  606. return ;
  607. }
  608. AppNavigator.pushForwardPage(context, widget.msg);
  609. });
  610. }
  611. if (widget.msg.msgType == ChatType.FileChatType.value &&widget.msg.localFile!=null) {
  612. //分享文件
  613. actions.add(I18n.of(context).copy_download_url);
  614. actionsFunc.add(() async{
  615. UploadUtil().copyFileUrl(widget.msg, context);
  616. String path = widget.msg.localFile;
  617. String type='file';
  618. if(path.contains('mp4') ||path.contains('mp3')){
  619. type = 'video';
  620. }else if(path.contains('png')||path.contains('jpg')||path.contains('jpeg')||path.contains('JPG')||path.contains('PNG')){
  621. type = 'image';
  622. }
  623. ShareExtend.share(FileCacheMgr.replacePath(path), type);
  624. });
  625. }
  626. if (widget.msg.msgType == ChatType.TextChatType.value) {
  627. actions.insert(0, I18n.of(context).copy);
  628. actionsFunc.insert(0, () {
  629. //复制当前的文字
  630. print('复制文字 ${textList[curTextType]}');
  631. ClipboardData clipboardData =
  632. ClipboardData(text: textList[curTextType]);
  633. Clipboard.setData(clipboardData);
  634. });
  635. }
  636. if (widget.msg.msgType == ChatType.ShortVoiceChatType.value) {
  637. var soundPlayMode =
  638. Provider.of<KeyboardIndexProvider>(context).soundPlayMode;
  639. actions.add(soundPlayMode
  640. ? I18n.of(context).handset_playback
  641. : I18n.of(context).speaker_play);
  642. actionsFunc.add(() {
  643. Provider.of<KeyboardIndexProvider>(context)
  644. .changeSoundPlayMode(!soundPlayMode);
  645. SoundUtils.instance.savePlayModeConfig(soundPlayMode);
  646. });
  647. }
  648. // String date2 = DateTime.fromMillisecondsSinceEpoch(widget.msg.time).toString();
  649. bool isUrl =false;
  650. if(widget.msg.msgType==ChatType.TextChatType.value ){
  651. if( textList[curTextType].contains('http')){
  652. isUrl =true;
  653. }
  654. }
  655. return WPopupMenu(
  656. child: item,
  657. actions: actions,
  658. onTap: ()async{
  659. if(isUrl){
  660. if (await canLaunch(textList[curTextType])) {
  661. launch(textList[curTextType]);
  662. }
  663. }
  664. },
  665. onLongPressStart: () {
  666. isLongPressed = true;
  667. setState(() {});
  668. },
  669. onLongPressEnd: () {
  670. isLongPressed = false;
  671. setState(() {});
  672. },
  673. onValueChanged: (int value) {
  674. print('选择的是$value个菜单');
  675. if (value >= 0 && value < actionsFunc.length) {
  676. actionsFunc[value]();
  677. }
  678. },
  679. );
  680. }
  681. //用户评价人工翻译,差评
  682. rateTranslateResult() async {
  683. return await HttpUtil().rateTranslateResult(widget.msg, () {
  684. if (mounted) {
  685. setState(() {});
  686. }
  687. });
  688. }
  689. _receiveJIF(MsgModel msg) {
  690. var text = utf8.decode(msg.msgContent);
  691. return extendedText(text, hideKeyboard: widget.hideKeyboard);
  692. }
  693. double _getTextWidth(String text) {
  694. var tp = TextPainter(
  695. text: TextSpan(style: TextStyle(fontSize: FontSize), text: text),
  696. textAlign: TextAlign.left,
  697. textDirection: TextDirection.ltr,
  698. textScaleFactor: 1,
  699. );
  700. tp.layout(maxWidth: Screen.width - 140);
  701. RegExp alterStr = RegExp(r'\[([0-9]+)\]');
  702. Iterable<Match> matches = alterStr.allMatches(text);
  703. // print('~~~~~~~~~~~~~~${matches.length}~~~~~~~~~~~~~~~');
  704. double delta = 0;
  705. for (Match m in matches) {
  706. // print('~~~~~~~~~~~~~~${m.group(1)}~~~~~~~~~~~~~~~');
  707. if (int.parse(m.group(1)) > 10) {
  708. delta += 20 + 4 - 25;
  709. } else {
  710. delta += 20 + 4 - 16.8;
  711. }
  712. }
  713. return tp.width + delta;
  714. }
  715. _receiveText(MsgModel msg) {
  716. List<Widget> showMsg = [];
  717. if (textList.length > 0) {
  718. bool isUrl =false;
  719. if(textList[curTextType].contains('http') ){
  720. isUrl =true;
  721. }
  722. showMsg.add(Container(
  723. constraints:
  724. BoxConstraints(maxWidth: Screen.width - 140, minHeight: 24),
  725. alignment: Alignment.centerLeft,
  726. child: extendedText(
  727. textList[curTextType],
  728. color: isUrl?Colors.blue:Constants.BlackTextColor,
  729. hideKeyboard: widget.hideKeyboard,
  730. fontSize: FontSize,
  731. )));
  732. }
  733. var width = _getTextWidth(textList[curTextType]);
  734. var minWidth = width;
  735. if (msg.transTag != 0) {
  736. minWidth = 200;
  737. showMsg.add(Padding(
  738. padding: EdgeInsets.symmetric(vertical: 5),
  739. child: Divider(color: Color(0xFFECECEC), height: 1)));
  740. Widget tranWidget = _transProcessWidget(msg.transTag);
  741. showMsg.add(tranWidget);
  742. }
  743. ///todo
  744. Widget text = Container(
  745. width: width + 20,
  746. constraints:
  747. BoxConstraints(maxWidth: Screen.width - 120, minWidth: minWidth),
  748. padding: EdgeInsets.symmetric(horizontal: 9, vertical: 10.5),
  749. child: Column(
  750. crossAxisAlignment: CrossAxisAlignment.start, children: showMsg),
  751. decoration: BoxDecoration(
  752. border: Border.all(color: ReciveBorderColor, width: 0.5),
  753. color: isLongPressed ? Colors.grey[300] : Colors.white,
  754. borderRadius: BorderRadius.all(Radius.circular(ChatRadius))),
  755. );
  756. if (msg.refMsgContent != null && msg.refMsgContent.length > 0) {
  757. QuoteMsg quoteMsg = QuoteMsg.fromBuffer(msg.refMsgContent);
  758. return Column(
  759. mainAxisSize: MainAxisSize.min,
  760. crossAxisAlignment: CrossAxisAlignment.start,
  761. children: <Widget>[
  762. text,
  763. SizedBox(height: 2),
  764. Container(
  765. constraints: BoxConstraints(maxWidth: Screen.width - 120),
  766. padding: EdgeInsets.symmetric(vertical: 1, horizontal: 3),
  767. child: Text(
  768. quoteMsg.content,
  769. maxLines: 1,
  770. textScaleFactor: 1.0,
  771. overflow: TextOverflow.ellipsis,
  772. style: TextStyle(fontSize: 12),
  773. ),
  774. decoration: BoxDecoration(
  775. color: Colors.grey[300],
  776. borderRadius: BorderRadius.circular(5)),
  777. )
  778. ],
  779. );
  780. } else {
  781. return text;
  782. }
  783. }
  784. _translateItemWidget(int code, String title, Function onTap) {
  785. Color color = onTap == null ? Constants.GreyTextColor : Color(0xFF087FF3);
  786. return InkWell(
  787. onTap: onTap,
  788. splashColor: Colors.red,
  789. child: Container(
  790. width: 80,
  791. child: Row(
  792. children: <Widget>[
  793. Icon(IconData(code, fontFamily: Constants.IconFontFamily),
  794. color: color, size: 20),
  795. SizedBox(width: 5),
  796. Expanded(
  797. child: SizedBox(
  798. child: Text(
  799. title,
  800. style: TextStyle(color: color, fontSize: 10),
  801. textScaleFactor: 1.0,
  802. maxLines: 1,
  803. overflow: TextOverflow.ellipsis,
  804. ),
  805. ))
  806. ],
  807. )));
  808. }
  809. bool isTranslating = false;
  810. _transProcessWidget(int transTag) {
  811. double width = 160;
  812. Widget userTranslateWidget;
  813. Widget machineTranslateWidget;
  814. if (transTag == 1) {
  815. //机器翻译中
  816. userTranslateWidget = _translateItemWidget(0xe670, I18n.of(context).man_retranslate, null);
  817. machineTranslateWidget =
  818. _translateItemWidget(0xe671, I18n.of(context).robotTranslate, null);
  819. } else if (transTag == 2) {
  820. //人工翻译中
  821. userTranslateWidget = _translateItemWidget(0xe670, I18n.of(context).ManTranslate, null);
  822. machineTranslateWidget = _translateItemWidget(0xe671, I18n.of(context).robot_retranslate, () {
  823. setState(() {
  824. curTextType += 1;
  825. curTextType %= textList.length;
  826. });
  827. });
  828. } else if (transTag == 3) {
  829. //机器翻译完成
  830. userTranslateWidget = _translateItemWidget(
  831. 0xe670,
  832. I18n.of(context).man_retranslate,
  833. isTranslating
  834. ? null
  835. : () async {
  836. isTranslating = true;
  837. int money =
  838. Provider.of<MoneyChangeProvider>(context, listen: false)
  839. .money;
  840. int voucher =
  841. Provider.of<VoucherChangeProvider>(context, listen: false)
  842. .voucher;
  843. int needMoney = widget.msg.getNeedMoney();
  844. if (needMoney > voucher + money) {
  845. showToast('翻译券和H币不足');
  846. return;
  847. }
  848. var res = await HttpUtil().getPersonalTranslate(widget.msg);
  849. if (res) {
  850. print('请求人工翻译成功,进行扣费');
  851. setState(() {
  852. widget.msg.transTag = 2;
  853. //优先扣券
  854. if (voucher > 0) {
  855. int costQuan = min(voucher, needMoney);
  856. Provider.of<VoucherChangeProvider>(context,
  857. listen: false)
  858. .subVoucher(costQuan);
  859. }
  860. //不足的话再扣H币
  861. if (needMoney > voucher) {
  862. Provider.of<MoneyChangeProvider>(context, listen: false)
  863. .subMoney(needMoney - voucher);
  864. }
  865. });
  866. }
  867. });
  868. machineTranslateWidget = _translateItemWidget(0xe671, I18n.of(context).robot_retranslate, () {
  869. setState(() {
  870. curTextType += 1;
  871. curTextType %= textList.length;
  872. });
  873. });
  874. } else if (transTag == 4 || transTag == 10) {
  875. //4人工翻译完成,未评论 10人工翻译完成已评论
  876. userTranslateWidget = InkWell(
  877. onTap: () {
  878. setState(() {
  879. curTextType = 0;
  880. });
  881. },
  882. child: Container(
  883. width: width / 2,
  884. child: Row(
  885. children: <Widget>[
  886. InkWell(
  887. child: Icon(
  888. IconData(0xe641, fontFamily: Constants.IconFontFamily),
  889. size: 18,
  890. color:
  891. transTag == 10 ? Colors.grey : Color(0xFF087FF3)),
  892. onTap: transTag == 10
  893. ? null
  894. : () {
  895. CustomUI.showIosDialog(
  896. context, I18n.of(context).bad_ev, () async {
  897. bool isSuccess = await rateTranslateResult();
  898. if (isSuccess) {
  899. Navigator.of(context).pop(true);
  900. showToast(I18n.of(context).success);
  901. } else {
  902. showToast(I18n.of(context).fail);
  903. Navigator.of(context).pop();
  904. }
  905. }, () {
  906. Navigator.of(context).pop();
  907. });
  908. },
  909. ),
  910. SizedBox(width: 5),
  911. Expanded(
  912. child: SizedBox(
  913. child: Text(
  914. I18n.of(context).over,
  915. style: TextStyle(color: Color(0xFF087FF3), fontSize: 10),
  916. textScaleFactor: 1.0,
  917. maxLines: 1,
  918. overflow: TextOverflow.ellipsis,
  919. ),
  920. ))
  921. ],
  922. )));
  923. machineTranslateWidget = _translateItemWidget(0xe675, I18n.of(context).see_original, () {
  924. setState(() {
  925. curTextType = textList.length - 1;
  926. });
  927. });
  928. }
  929. return Container(
  930. height: 26,
  931. alignment: Alignment.center,
  932. child: Row(
  933. children: <Widget>[
  934. userTranslateWidget,
  935. Expanded(
  936. child: SizedBox(child: VerticalDivider(), height: 20, width: 2)),
  937. machineTranslateWidget
  938. ],
  939. ),
  940. );
  941. }
  942. _receiveImg(BuildContext context, List<int> imgData, {String downloadData}) {
  943. ImageProvider provider = MemoryImage(widget.msg.localFile==null?Uint8List.fromList(imgData):File(widget.msg.localFile).readAsBytesSync());
  944. var imgSize = _getImgSize();
  945. return DownloadItem(
  946. isAutoDown: false,
  947. msg: widget.msg,
  948. onFinishTap: (){
  949. showFullImg(context, widget.msg);
  950. },
  951. child: Container(
  952. width: imgSize.width,
  953. height: imgSize.height,
  954. child: ClipRRect(
  955. child: Image(
  956. image: provider ?? AssetImage(R.assetsImagesIcAlbum),
  957. ),
  958. borderRadius: BorderRadius.circular(5),
  959. ),
  960. ),
  961. );
  962. }
  963. _receiveVideo(BuildContext context, List<int> imgData,
  964. {String downloadData}) {
  965. ImageProvider provider = MemoryImage(Uint8List.fromList(imgData));
  966. var imgSize = _getImgSize();
  967. return InkWell(
  968. onTap: () {
  969. if (widget.msg.localFile != null) {
  970. showVideoPage(context, widget.msg.localFile);
  971. }
  972. },
  973. child: DownloadItem(
  974. isAutoDown: false,
  975. msg: widget.msg,
  976. child: Container(
  977. width: imgSize.width,
  978. height: imgSize.height,
  979. child: ClipRRect(
  980. child: Image(
  981. image: provider ?? AssetImage(R.assetsImagesIcAlbum),
  982. ),
  983. borderRadius: BorderRadius.circular(5),
  984. ),
  985. ),
  986. ));
  987. }
  988. showVideoPage(BuildContext context, String filePath) {
  989. widget.hideKeyboard();
  990. Navigator.push(context,
  991. MaterialPageRoute<void>(builder: (BuildContext context) {
  992. return VideoPage(videoPath: filePath);
  993. }));
  994. }
  995. Widget _receiveFileMsgItem() {
  996. return DownloadItem(
  997. isAutoDown: false,
  998. msg: widget.msg,
  999. onComplete: () {
  1000. if (mounted) {
  1001. setState(() {});
  1002. }
  1003. },
  1004. child: Container(
  1005. height: 100,
  1006. constraints: BoxConstraints(maxWidth: Screen.width - 120),
  1007. padding: EdgeInsets.symmetric(horizontal: 9, vertical: 10.5),
  1008. decoration: BoxDecoration(
  1009. color: Colors.white,
  1010. border: Border.all(color: ReciveBorderColor, width: 0.5),
  1011. borderRadius: BorderRadius.all(Radius.circular(ChatRadius))),
  1012. child: FileMsgItem(widget.msg)));
  1013. }
  1014. _receiveSound(BuildContext context, List<int> soundData) {
  1015. print('收到语音消息');
  1016. MsgModel msg = widget.msg;
  1017. var time = widget.msg.extraInfo / 1000;
  1018. if (time > 60) {
  1019. time = 60.0;
  1020. }
  1021. bool isPlaying = false;
  1022. if (curSoundUrl != null) {
  1023. isPlaying = SoundUtils().isPlaying(curSoundUrl);
  1024. }
  1025. var soundWidget = InkWell(
  1026. onTap: () async {
  1027. bool isLocal = true;
  1028. if (msg.localFile != null) {
  1029. isLocal = true;
  1030. curSoundUrl = msg.localFile;
  1031. } else {
  1032. isLocal = false;
  1033. var sessionId = msg.sessionId;
  1034. curSoundUrl = UploadUtil()
  1035. .getFullUrl(msg.extraFile, sessionId, msg.channelType);
  1036. }
  1037. print('当前文件$curSoundUrl 本地?$isLocal');
  1038. if (isPlaying) {
  1039. await SoundUtils().pause();
  1040. } else {
  1041. print('开始播放');
  1042. if (widget.msg.soundListened == 0) {
  1043. widget.msg.updateSoundListened();
  1044. } //设置为已经播放
  1045. await SoundUtils().play(curSoundUrl, isLocal: isLocal, onPlayed: () {
  1046. if (mounted) {
  1047. this.setState(() {});
  1048. }
  1049. }, complete: () {
  1050. if (mounted) {
  1051. this.setState(() {});
  1052. }
  1053. });
  1054. }
  1055. },
  1056. child: Container(
  1057. width: 130,
  1058. child: Row(children: <Widget>[
  1059. Container(
  1060. alignment: Alignment.center,
  1061. padding: EdgeInsets.only(bottom: 2),
  1062. margin: EdgeInsets.only(right: 10),
  1063. width: 25.5,
  1064. height: 25.5,
  1065. decoration: BoxDecoration(
  1066. border:
  1067. Border.all(color: const Color(0xFF1B92C7), width: 0.5),
  1068. color: const Color(0xFF04A4FE),
  1069. shape: BoxShape.circle),
  1070. child: Icon(
  1071. IconData(isPlaying ? 0xe652 : 0xe653,
  1072. fontFamily: Constants.IconFontFamily),
  1073. size: isPlaying ? 15 : 18,
  1074. color: Colors.white,
  1075. ),
  1076. ),
  1077. isPlaying
  1078. ? Stack(
  1079. children: <Widget>[
  1080. Container(
  1081. height: 18,
  1082. width: 19,
  1083. ),
  1084. Positioned(
  1085. bottom: 0,
  1086. child: VideoAnim(
  1087. begin: 18,
  1088. start: 0.444,
  1089. end: 4.5,
  1090. )),
  1091. Positioned(
  1092. left: 7,
  1093. bottom: 0,
  1094. child: VideoAnim(
  1095. begin: 4.5,
  1096. end: 18,
  1097. )),
  1098. Positioned(
  1099. left: 14,
  1100. bottom: 0,
  1101. child: VideoAnim(
  1102. begin: 18,
  1103. end: 4.5,
  1104. ))
  1105. ],
  1106. )
  1107. : Stack(
  1108. children: <Widget>[
  1109. Container(
  1110. height: 18,
  1111. width: 19,
  1112. ),
  1113. Positioned(
  1114. bottom: 0, child: CustomUI.buildAudioContaniner(12)),
  1115. Positioned(
  1116. left: 7,
  1117. bottom: 0,
  1118. child: CustomUI.buildAudioContaniner(4.5)),
  1119. Positioned(
  1120. left: 14,
  1121. bottom: 0,
  1122. child: CustomUI.buildAudioContaniner(18))
  1123. ],
  1124. ),
  1125. Expanded(child: SizedBox()),
  1126. fixedText(time.toStringAsFixed(0),
  1127. color: Constants.BlackTextColor, fontSize: 16)
  1128. ])),
  1129. );
  1130. List<Widget> showMsg = [];
  1131. showMsg.add(DownloadItem(
  1132. msg: widget.msg,
  1133. child: soundWidget,
  1134. isShowProgress: false,
  1135. ));
  1136. double width = 130;
  1137. double minWidth = 0;
  1138. if (textList.length > 0) {
  1139. width = _getTextWidth(textList[curTextType]) + 20;
  1140. width = min(width, Screen.width - 120);
  1141. showMsg.add(Padding(
  1142. padding: EdgeInsets.symmetric(vertical: 5),
  1143. child: Divider(
  1144. height: 1,
  1145. )));
  1146. showMsg.add(Container(
  1147. child: extendedText(
  1148. textList[curTextType],
  1149. color: Constants.BlackTextColor,
  1150. hideKeyboard: widget.hideKeyboard,
  1151. fontSize: FontSize,
  1152. ),
  1153. alignment: Alignment.centerLeft,
  1154. constraints:
  1155. BoxConstraints(maxWidth: Screen.width - 120, minHeight: 22),
  1156. ));
  1157. }
  1158. if (msg.transTag != 0) {
  1159. minWidth = 200;
  1160. showMsg.add(Divider(color: Color(0xFFECECEC), height: 3));
  1161. Widget tranWidget = _transProcessWidget(msg.transTag);
  1162. showMsg.add(tranWidget);
  1163. }
  1164. return Container(
  1165. width: width + 20,
  1166. constraints:
  1167. BoxConstraints(maxWidth: Screen.width - 120, minWidth: minWidth),
  1168. child: Column(
  1169. crossAxisAlignment: CrossAxisAlignment.start, children: showMsg),
  1170. padding: EdgeInsets.symmetric(horizontal: 9, vertical: 10.5),
  1171. decoration: BoxDecoration(
  1172. color: Colors.white,
  1173. border: Border.all(color: ReciveBorderColor, width: 0.5),
  1174. borderRadius: BorderRadius.all(Radius.circular(ChatRadius))),
  1175. );
  1176. }
  1177. void showFullImg(BuildContext context, MsgModel msg) {
  1178. print('显示图片');
  1179. widget.hideKeyboard();
  1180. Navigator.push(context,
  1181. MaterialPageRoute<void>(builder: (BuildContext context) {
  1182. return PhotoPage(msg: msg);
  1183. }));
  1184. }
  1185. _reveiveMsg(BuildContext context) {
  1186. Widget item;
  1187. switch (ChatType.valueOf(widget.msg.msgType)) {
  1188. case ChatType.TextChatType:
  1189. item = _receiveText(widget.msg);
  1190. break;
  1191. case ChatType.EmoticonType:
  1192. item = _receiveJIF(widget.msg);
  1193. break;
  1194. case ChatType.ImageChatType:
  1195. if (widget.msg.extraFile != null) {
  1196. item = _receiveImg(context, widget.msg.msgContent,
  1197. downloadData: widget.msg.extraFile);
  1198. } else {
  1199. item = _receiveImg(context, widget.msg.msgContent);
  1200. }
  1201. break;
  1202. case ChatType.ShortVideoChatType:
  1203. item = _receiveVideo(context, widget.msg.msgContent,
  1204. downloadData: widget.msg.extraFile);
  1205. break;
  1206. case ChatType.ShortVoiceChatType:
  1207. item = _receiveSound(context, widget.msg.msgContent);
  1208. break;
  1209. case ChatType.RedWalletChatType:
  1210. item = RedBagItem(
  1211. Key(widget.msg.time.toString()), friendInfo.userId, widget.msg);
  1212. break;
  1213. case ChatType.PlaceChatType:
  1214. item = PlaceItem(isMe: false, placeContent: widget.msg.msgContent);
  1215. break;
  1216. case ChatType.GiftChatType:
  1217. item = GiftMsgItem(widget.msg.msgContent, false);
  1218. break;
  1219. case ChatType.FileChatType:
  1220. item = _receiveFileMsgItem();
  1221. break;
  1222. default:
  1223. }
  1224. return wrapItemWithMenu(item);
  1225. }
  1226. Widget _getReceivedMessageLayout(BuildContext context) {
  1227. bool hasHeadImg = true;
  1228. if (friendInfo.headimgurl == null || friendInfo.headimgurl.length == 0) {
  1229. hasHeadImg = false;
  1230. }
  1231. bool isShowSoundSate =
  1232. widget.msg.msgType == ChatType.ShortVoiceChatType.value &&
  1233. widget.msg.soundListened == 0;
  1234. return Row(crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
  1235. Container(
  1236. margin: const EdgeInsets.only(right: 8.0),
  1237. child: InkWell(
  1238. child: ClipRRect(
  1239. borderRadius: BorderRadius.circular(8),
  1240. child: hasHeadImg
  1241. ? CachedNetworkImage(
  1242. imageUrl: friendInfo.headimgurl,
  1243. placeholder: (context, url) => Image.asset(
  1244. Constants.DefaultHeadImgUrl,
  1245. width: 40,
  1246. height: 40,
  1247. ),
  1248. width: 40,
  1249. height: 40,
  1250. )
  1251. : SizedBox(
  1252. width: 40,
  1253. height: 40,
  1254. child: Image.asset(R.assetsImagesDefaultNorAvatar))),
  1255. onTap: () {
  1256. AppNavigator.pushProfileInfoPage(context, friendInfo.userId,
  1257. fromWhere: 0);
  1258. },
  1259. )),
  1260. _reveiveMsg(context),
  1261. isShowSoundSate
  1262. ? Container(
  1263. margin: EdgeInsets.only(left: 8),
  1264. width: 40,
  1265. height: 40,
  1266. alignment: Alignment.centerLeft,
  1267. child: CircleAvatar(
  1268. radius: 3.5,
  1269. backgroundColor: Colors.red,
  1270. ))
  1271. : Container()
  1272. ]);
  1273. }
  1274. Widget _buildServiceCard(bool isStart, Function callBack) {
  1275. return Container(
  1276. alignment: Alignment.center,
  1277. margin: EdgeInsets.all(10),
  1278. child: Card(
  1279. elevation: 2,
  1280. // 阴影
  1281. shape: RoundedRectangleBorder(
  1282. borderRadius: BorderRadius.circular(10),
  1283. // side: BorderSide(color: Colors.green,width: 25),
  1284. ),
  1285. child: Padding(
  1286. padding: EdgeInsets.only(left: 10, right: 10, top: 15, bottom: 15),
  1287. child: Row(
  1288. children: <Widget>[
  1289. Column(
  1290. crossAxisAlignment: CrossAxisAlignment.start,
  1291. children: <Widget>[
  1292. Text(
  1293. isStart
  1294. ? I18n.of(context).translation_butler_start_service
  1295. : I18n.of(context).translation_butler_service_end,
  1296. textScaleFactor: 1.0,
  1297. style: TextStyle(
  1298. color: AppColors.NewAppbarTextColor, fontSize: 15),
  1299. ),
  1300. Text(
  1301. isStart
  1302. ? I18n.of(context).translation_butler_start_tips
  1303. : I18n.of(context).translation_butler_evaluation_tips,
  1304. textScaleFactor: 1.0,
  1305. style: TextStyle(
  1306. color: AppColors.NewAppbarTextColor, fontSize: 13),
  1307. )
  1308. ],
  1309. ),
  1310. isStart
  1311. ? Container()
  1312. : Expanded(
  1313. child: Container(
  1314. margin: EdgeInsets.only(left: 15),
  1315. height: 30,
  1316. child: RaisedButton(
  1317. color: Color(0xff3875E9),
  1318. shape: RoundedRectangleBorder(
  1319. borderRadius:
  1320. BorderRadius.all(Radius.circular(10))),
  1321. child: Text(
  1322. I18n.of(context).translation_butler_evaluation,
  1323. textScaleFactor: 1.0,
  1324. style: TextStyle(color: Colors.white, fontSize: 15),
  1325. ),
  1326. onPressed: () {
  1327. CustomUI.buildTranslationEvaluationDialog(context);
  1328. }),
  1329. )),
  1330. ],
  1331. ),
  1332. ),
  1333. ),
  1334. );
  1335. }
  1336. }