Hibok
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

774 lignes
26 KiB

  1. import 'dart:async';
  2. import 'package:chat/data/UserData.dart';
  3. import 'package:chat/data/translate_hk_data_mgr.dart';
  4. import 'package:chat/models/group_info_model.dart';
  5. import 'package:chat/models/money_change.dart';
  6. import 'package:chat/utils/MessageMgr.dart';
  7. import 'package:chat/utils/msgHandler.dart';
  8. import 'package:chat/utils/screen.dart';
  9. import 'package:chat/utils/sp_utils.dart';
  10. import 'package:flutter/cupertino.dart';
  11. import 'package:flutter/material.dart';
  12. import 'package:flutter/services.dart';
  13. import 'package:provider/provider.dart';
  14. import '../../data/constants.dart';
  15. import '../../generated/i18n.dart';
  16. import '../../r.dart';
  17. import '../../utils/CustomUI.dart';
  18. import 'package:chat/utils/PopUpMenu.dart' as myPop;
  19. class TranslationButlerPage extends StatefulWidget {
  20. final GroupInfoModel groupInfoModel;
  21. TranslationButlerPage({Key key, this.groupInfoModel}) : super(key: key);
  22. @override
  23. State<StatefulWidget> createState() {
  24. return TranslationButlerPageState();
  25. }
  26. }
  27. class ValueModel{
  28. String name;
  29. var key;
  30. ValueModel(this.name,this.key);
  31. }
  32. class TranslationButlerPageState extends State<TranslationButlerPage> {
  33. int curToLang = 1;
  34. int curSourceLang = UserData().language;
  35. int curScenes = 0;
  36. List<ValueModel> langList; ///语言列表
  37. List<ValueModel> scenesList; ///场景列表
  38. String extraMsg='';
  39. FocusNode focusNode = new FocusNode();
  40. String textLimitTips='';
  41. ScrollController _scrollController = new ScrollController();
  42. int orderStatus = 0; ///订单状态
  43. int secondsPassed = 1;///等待时间计数
  44. int timeStamp; ///订单开始时间戳
  45. Timer waitTimer;///等待时间计时器
  46. int time60=1; ///60秒一圈计数
  47. int waitNum=0;
  48. refreshOrder(args){
  49. orderStatus = TranslateHKMgr().orderStatus;
  50. switch(orderStatus){
  51. case TranslateHKMgr.ORDER_STATUS_EMPTY:
  52. isCreatingOrder=false;
  53. waitTimer?.cancel();
  54. secondsPassed = 0;
  55. SPUtils.save(Constants.TranslationHelper,null);
  56. break;
  57. case TranslateHKMgr.ORDER_STATUS_WAITING:
  58. // secondsPassed = 0;
  59. print('开始倒计时$secondsPassed');
  60. waitNum = TranslateHKMgr().waitNum;
  61. waitTimer = Timer.periodic(Duration(seconds: 1), (Timer t) {
  62. handleTick();
  63. });
  64. break;
  65. }
  66. setState(() {});
  67. }
  68. ///订单没有人接,超时,服务器会发送取消订单通知
  69. canceledOrder(args){
  70. TranslateHKMgr().orderStatus = TranslateHKMgr.ORDER_STATUS_EMPTY;
  71. refreshOrder(null);
  72. }
  73. @override
  74. void initState() {
  75. super.initState();
  76. orderStatus = TranslateHKMgr().orderStatus;
  77. waitNum = TranslateHKMgr().waitNum;
  78. initData();
  79. MessageMgr().on(MessageMgr.TRANSLATE_HK_REFRESH_ORDER, refreshOrder);
  80. MessageMgr().on(MessageMgr.TRANSLATE_HK_CANCEL_ORDER, canceledOrder);
  81. WidgetsBinding.instance.addPostFrameCallback((_) {
  82. // Future.delayed(Duration(seconds: 1), () {
  83. //// CustomUI.buildTranslationHelperOrderDialog(context,true);
  84. // Navigator.of(context).push(
  85. // new MaterialPageRoute(
  86. // builder: (context) {
  87. // return ChatPage(
  88. // key: Key('Chat'),
  89. // friendId: 100029,
  90. // isTranslateButler: true,
  91. // );
  92. // },
  93. // ),
  94. // );
  95. // });
  96. });
  97. }
  98. initData() async {
  99. String time = (await SPUtils.get(Constants.TranslationHelper));
  100. if (time != null) {
  101. print('time:$time');
  102. int second = int.parse(time) ~/ 1000;
  103. if((DateTime.now().millisecondsSinceEpoch ~/ 1000 - second)>1800){ ///超过半小时清除缓存记录
  104. SPUtils.save(Constants.TranslationHelper,null);
  105. return;
  106. }
  107. secondsPassed =
  108. ((DateTime.now().millisecondsSinceEpoch ~/ 1000 - second));
  109. refreshOrder(null);
  110. print('缓存的秒数 $secondsPassed');
  111. } else {
  112. print('time: null');
  113. }
  114. }
  115. bool isCreatingOrder=false;
  116. apply() {
  117. if(isCreatingOrder){
  118. return;
  119. }
  120. isCreatingOrder=true;
  121. TranslateHKMgr().startWaitTime=DateTime.now().millisecondsSinceEpoch;
  122. MsgHandler.sendCreateTranslateOrder(langList[curSourceLang].key,langList[curToLang].key,scenesList[curScenes].key,extraMsg);
  123. extraMsg='';
  124. }
  125. @override
  126. void didChangeDependencies() {
  127. super.didChangeDependencies();
  128. textLimitTips = I18n.of(context).translation_input_limit.replaceAll('/s1', '80');
  129. langList = [
  130. ValueModel(I18n.of(context).english,1),
  131. ValueModel(I18n.of(context).Vietnamese,2),
  132. ValueModel(I18n.of(context).traditional_Chinese,4),
  133. ValueModel(I18n.of(context).Simplified_Chinese,8),
  134. ValueModel(I18n.of(context).Korean,16),
  135. ValueModel(I18n.of(context).Japanese,32),
  136. ];
  137. scenesList = [
  138. ValueModel(I18n.of(context).translation_scenes_1,0),
  139. ValueModel(I18n.of(context).translation_scenes_2,1),
  140. ValueModel(I18n.of(context).translation_scenes_3,2),
  141. ValueModel(I18n.of(context).translation_scenes_4,3),
  142. ];
  143. }
  144. @override
  145. void dispose() {
  146. waitTimer?.cancel();
  147. MessageMgr().off(MessageMgr.TRANSLATE_HK_REFRESH_ORDER, refreshOrder);
  148. MessageMgr().off(MessageMgr.TRANSLATE_HK_CANCEL_ORDER, canceledOrder);
  149. if (orderStatus==TranslateHKMgr.ORDER_STATUS_WAITING && timeStamp != null) {
  150. print('保存时间戳$timeStamp');
  151. SPUtils.save(Constants.TranslationHelper, timeStamp.toString());
  152. }
  153. super.dispose();
  154. }
  155. _langPopMenu(bool isSource) {
  156. var curIndex = isSource ? curSourceLang : curToLang;
  157. return myPop.PopupMenuButton(
  158. child: Container(
  159. height: 37,
  160. width: double.maxFinite,
  161. decoration: BoxDecoration(
  162. color: Color(0xffD3E7FF),
  163. borderRadius: BorderRadius.circular(5)),
  164. child: Row(
  165. mainAxisAlignment: MainAxisAlignment.start,
  166. children: <Widget>[
  167. Expanded(
  168. child: Container(padding: EdgeInsets.only(left: 5),alignment: Alignment.center,child: Text(
  169. langList[curIndex].name,
  170. textAlign: TextAlign.center,
  171. overflow: TextOverflow.ellipsis,
  172. textScaleFactor: 1.0,
  173. style: TextStyle(color: Color(0xff4A5E76), fontSize: 14),
  174. ),)),
  175. Icon(IconData(0xe63b, fontFamily: Constants.IconFontFamily),
  176. size: 30, color: Color(0xff4A5E76))
  177. ],
  178. ),
  179. ),
  180. offset: Offset(0, 100),
  181. onSelected: (int index) {
  182. if (curIndex != index) {
  183. if (isSource) {
  184. curSourceLang = index;
  185. } else {
  186. curToLang = index;
  187. }
  188. print('更换翻译语言');
  189. setState(() {});
  190. }
  191. },
  192. itemBuilder: (BuildContext context) {
  193. return List<myPop.PopupMenuItem<int>>.generate(langList.length,
  194. (int i) {
  195. return myPop.PopupMenuItem(
  196. child: Container(
  197. alignment: Alignment.center,
  198. color: Colors.white,
  199. padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
  200. child: Text(langList[i].name,
  201. textScaleFactor: 1.0,
  202. maxLines: 1,
  203. style: TextStyle(
  204. color: i == curIndex
  205. ? Colors.blueAccent
  206. : Color(AppColors.AppBarColor),
  207. fontSize: 14)),
  208. ),
  209. value: i,
  210. );
  211. });
  212. });
  213. }
  214. _scenesPopMenu() {
  215. var curIndex = curScenes;
  216. return myPop.PopupMenuButton(
  217. child: Container(
  218. height: 40,
  219. width: double.maxFinite,
  220. decoration:BoxDecoration(
  221. borderRadius: BorderRadius.all(Radius.circular(6)),
  222. color: Colors.white,
  223. boxShadow: [
  224. BoxShadow(
  225. color: Color(0x739f9f9f),
  226. offset: Offset(0.2, 0.4),
  227. blurRadius: 1.0,
  228. spreadRadius: 0.6),
  229. // BoxShadow(
  230. // color: Color(0x9900FF00), offset: Offset(1.0, 1.0)),
  231. // BoxShadow(color: Color(0xFF0000FF))
  232. ]),
  233. child: Row(
  234. mainAxisAlignment: MainAxisAlignment.start,
  235. children: <Widget>[
  236. Expanded(
  237. child: Text(
  238. scenesList[curIndex].name,
  239. textAlign: TextAlign.center,
  240. overflow: TextOverflow.ellipsis,
  241. textScaleFactor: 1.0,
  242. style: TextStyle(color: Color(0xff3875E9), fontSize: 14),
  243. )),
  244. Icon(IconData(0xe63b, fontFamily: Constants.IconFontFamily),
  245. size: 30, color: Color(0xff4A5E76))
  246. ],
  247. ),
  248. ),
  249. offset: Offset(0, 100),
  250. onSelected: (int index) {
  251. if (curIndex != index) {
  252. curScenes = index;
  253. print('更换场景');
  254. setState(() {});
  255. }
  256. },
  257. itemBuilder: (BuildContext context) {
  258. return List<myPop.PopupMenuItem<int>>.generate(scenesList.length,
  259. (int i) {
  260. return myPop.PopupMenuItem(
  261. child: Container(
  262. width: Screen.width *0.43,
  263. alignment: Alignment.center,
  264. color: Colors.white,
  265. padding: EdgeInsets.symmetric(vertical: 10, horizontal: 10),
  266. child: Text(scenesList[i].name,
  267. textScaleFactor: 1.0,
  268. maxLines: 1,
  269. style: TextStyle(
  270. color: i == curIndex
  271. ? Colors.blueAccent
  272. : Color(AppColors.AppBarColor),
  273. fontSize: 14)),
  274. ),
  275. value: i,
  276. );
  277. });
  278. });
  279. }
  280. @override
  281. Widget build(BuildContext context) {
  282. Widget appBar = AppBar(
  283. backgroundColor: AppColors.NewAppbarBgColor,
  284. title: Text(
  285. I18n.of(context).translation_butler,
  286. textScaleFactor: 1.0,
  287. style: TextStyle(color: AppColors.NewAppbarTextColor),
  288. ),
  289. // leading: CustomUI.buildCustomLeading(context),
  290. centerTitle: true,
  291. actions: <Widget>[
  292. Container(
  293. child: CustomUI.buildImageLabel(R.assetsImagesCoin,
  294. Provider.of<MoneyChangeProvider>(context).money,
  295. isLeft: true),
  296. decoration: BoxDecoration(borderRadius: BorderRadius.circular(15)),
  297. ),
  298. SizedBox(
  299. width: 10,
  300. )
  301. ],
  302. );
  303. return Scaffold(
  304. appBar: appBar,
  305. body: SafeArea(
  306. child: Container(
  307. color: Color(0xffE8EAF0),
  308. child: orderStatus==TranslateHKMgr.ORDER_STATUS_EMPTY ? createOrderPage() : waitPage(),
  309. ),
  310. ),
  311. );
  312. }
  313. Widget createOrderPage() {
  314. return ListView(
  315. controller: _scrollController,
  316. children: <Widget>[
  317. Padding(
  318. padding: EdgeInsets.only(left: 20, right: 10, top: 15),
  319. child: Row(children: <Widget>[
  320. Expanded(child: Text(
  321. I18n.of(context).translation_butler_tips,
  322. textScaleFactor: 1.0,
  323. style: TextStyle(color: Color(0xffABABAB), fontSize: 13),
  324. )),
  325. InkWell(child: Container( width: 40,height: 40,child: Align(child: Icon(
  326. IconData(0xe681, fontFamily: Constants.IconFontFamily),
  327. color: Color(0xFFFF7E00),
  328. size: 28.0,
  329. ),alignment: Alignment.center,),),onTap: (){
  330. CustomUI.buildTip(context, I18n.of(context).translation_butler, Padding(padding: EdgeInsets.all(10),child: fixedText(I18n.of(context).translation_butler_introduction,fontSize: 14),));
  331. },)
  332. ],),
  333. ) ,
  334. Container(
  335. margin: EdgeInsets.all(10),
  336. child: Card(
  337. elevation: 2, // 阴影
  338. shape: RoundedRectangleBorder(
  339. borderRadius: BorderRadius.circular(10),
  340. // side: BorderSide(color: Colors.green,width: 25),
  341. ),
  342. child: Container(
  343. padding: EdgeInsets.all(10),
  344. child: Column(
  345. crossAxisAlignment: CrossAxisAlignment.start,
  346. children: <Widget>[
  347. Padding(
  348. padding: EdgeInsets.only(bottom: 12),
  349. child: Text(
  350. I18n.of(context).choose_language,
  351. textScaleFactor: 1.0,
  352. textAlign: TextAlign.left,
  353. style: TextStyle(
  354. color: AppColors.NewAppbarTextColor, fontSize: 17),
  355. ),
  356. ),
  357. Row(
  358. children: <Widget>[
  359. SizedBox(width: 15,),
  360. Expanded(
  361. child: _langPopMenu(true),
  362. flex: 5,
  363. ),
  364. Expanded(
  365. child: InkWell(
  366. onTap: () {
  367. var temp = curSourceLang;
  368. curSourceLang = curToLang;
  369. curToLang = temp;
  370. setState(() {});
  371. },
  372. child: Container(
  373. child: Icon(
  374. IconData(
  375. 0xe669,
  376. fontFamily: Constants.IconFontFamily,
  377. ),
  378. size: 24,
  379. color: Color(0xff4A5E76),
  380. ),
  381. padding: EdgeInsets.symmetric(
  382. vertical: 5, horizontal: 5),
  383. ),
  384. ),
  385. flex: 2,
  386. ),
  387. Expanded(
  388. child: _langPopMenu(false),
  389. flex: 5,
  390. ),
  391. SizedBox(width: 15,),
  392. ],
  393. ),
  394. Row(
  395. children: <Widget>[
  396. Expanded(
  397. child: Image.asset(
  398. R.assetsImagesImgTranslationIcon,
  399. width: 195,
  400. height: 175,
  401. ),
  402. flex: 4,
  403. ),
  404. Expanded(
  405. child: Column(
  406. children: <Widget>[
  407. Text(
  408. I18n.of(context).translation_butler_scenes,
  409. textScaleFactor: 1.0,
  410. textAlign: TextAlign.left,
  411. style: TextStyle(
  412. color: AppColors.NewAppbarTextColor,
  413. fontWeight: FontWeight.w700,
  414. fontSize: 15),
  415. ),
  416. SizedBox(height: 10,),
  417. _scenesPopMenu(),
  418. ],
  419. ),
  420. flex: 6,
  421. )
  422. ],
  423. ),
  424. Stack(children: <Widget>[
  425. Container(
  426. alignment: Alignment.topLeft,
  427. height: 110.5,
  428. padding: EdgeInsets.only(bottom: 10),
  429. decoration: BoxDecoration(
  430. color: Color(0xFFE9EEF4),
  431. borderRadius: BorderRadius.all(Radius.circular(10))),
  432. child: TextField(
  433. keyboardAppearance: Brightness.light,
  434. maxLines: 10,
  435. focusNode: focusNode,
  436. textInputAction: TextInputAction.done,
  437. onSubmitted: (input) {
  438. focusNode.unfocus();
  439. },
  440. decoration: new InputDecoration(
  441. hintText: I18n.of(context).translation_more_desc,
  442. hintStyle: TextStyle(fontSize: 14),
  443. border: InputBorder.none,
  444. ),
  445. // maxLines: 1,
  446. inputFormatters: [LengthLimitingTextInputFormatter(80)],
  447. // obscureText: true,
  448. style: TextStyle(textBaseline: TextBaseline.alphabetic),
  449. onChanged: (str) {
  450. if (_scrollController != null) {
  451. ///解决键盘遮挡输入框
  452. _scrollController.position.moveTo(
  453. 200,
  454. duration: Duration(milliseconds: 100),
  455. curve: Curves.easeIn,
  456. );
  457. }
  458. extraMsg = str;
  459. textLimitTips = I18n.of(context).translation_input_limit.replaceAll('/s1', (80-str.length).toString());
  460. setState(() {});
  461. },
  462. ),
  463. ),
  464. Positioned.fill(child: Container(padding: EdgeInsets.only(bottom: 5,right: 5),alignment: Alignment.bottomRight,child: Text(
  465. textLimitTips,
  466. textScaleFactor: 1.0,
  467. style: TextStyle(color: Color(0xFF95A3B2), fontSize: 11),
  468. ),)),
  469. ],),
  470. Padding(padding: EdgeInsets.only(left: 5,right: 5,top: 5,bottom: 8),child: Text(
  471. I18n.of(context).translation_butler_scenes_tips,
  472. textScaleFactor: 1.0,
  473. style: TextStyle(color: Color(0xFFFA7B3D), fontSize: 12),
  474. ),),
  475. ],
  476. ),
  477. ),
  478. ),
  479. ),
  480. Container(
  481. margin: EdgeInsets.only(left: 70, right: 70, top: 50),
  482. height: 47,
  483. child: RaisedButton(
  484. color: Color(0xff3875E9),
  485. shape: RoundedRectangleBorder(
  486. borderRadius: BorderRadius.all(Radius.circular(10))),
  487. child: Text(
  488. I18n.of(context).translation_butler_call + ' (50h)',
  489. textScaleFactor: 1.0,
  490. style: TextStyle(color: Colors.white, fontSize: 19),
  491. ),
  492. onPressed: () {
  493. timeStamp = DateTime.now().millisecondsSinceEpoch;
  494. apply();
  495. }),
  496. ),
  497. Container(
  498. width: double.maxFinite,
  499. alignment: Alignment.center,
  500. padding: EdgeInsets.only(left: 10, right: 10, top: 15,bottom: 20),
  501. child: Text(
  502. I18n.of(context).translation_butler_rules,
  503. textScaleFactor: 1.0,
  504. style: TextStyle(color: Color(0xffABABAB), fontSize: 13),
  505. ),
  506. ),
  507. ],
  508. );
  509. }
  510. Widget waitPage() {
  511. // ~/ 取整操作
  512. int seconds = secondsPassed % 60;
  513. int minutes = secondsPassed ~/ 60;
  514. return ListView(
  515. children: <Widget>[
  516. ///当前排队人数过多。。。
  517. Container(
  518. margin: EdgeInsets.all(10),
  519. child: Card(
  520. elevation: 2, // 阴影
  521. shape: RoundedRectangleBorder(
  522. borderRadius: BorderRadius.circular(10),
  523. // side: BorderSide(color: Colors.green,width: 25),
  524. ),
  525. child: Container(
  526. // width: double.maxFinite,
  527. // color: Colors.blue,
  528. padding: EdgeInsets.fromLTRB(14, 14, 14, 22),
  529. child: Column(
  530. children: <Widget>[
  531. Padding(
  532. padding: EdgeInsets.only(bottom: 20, top: 10),
  533. child: Text(
  534. I18n.of(context).translation_butler_tips2,
  535. textScaleFactor: 1.0,
  536. textAlign: TextAlign.left,
  537. style: TextStyle(color: Color(0xff797979), fontSize: 13),
  538. ),
  539. ),
  540. Container(
  541. width: double.maxFinite,
  542. child: Row(
  543. mainAxisSize: MainAxisSize.max,
  544. mainAxisAlignment: MainAxisAlignment.spaceAround,
  545. children: <Widget>[
  546. Column(
  547. mainAxisAlignment: MainAxisAlignment.center,
  548. children: <Widget>[
  549. fixedText(
  550. I18n.of(context).translation_butler_wait_people,
  551. fontSize: 16,
  552. color: Colors.black),
  553. SizedBox(
  554. height: 10,
  555. ),
  556. RichText(
  557. maxLines: 3,
  558. textAlign: TextAlign.center,
  559. text: TextSpan(children: [
  560. TextSpan(
  561. text: '$waitNum',
  562. style: TextStyle(
  563. color: Color(0xffFF1010),
  564. fontSize: 27)),
  565. TextSpan(
  566. text: ' ' +
  567. I18n.of(context)
  568. .translation_butler_wait_people_unit,
  569. style: TextStyle(
  570. color: Colors.black, fontSize: 17)),
  571. ]))
  572. ],
  573. ),
  574. Container(
  575. width: 1,
  576. height: 65,
  577. color: Color(0xffD8D8D8),
  578. ),
  579. Column(
  580. mainAxisAlignment: MainAxisAlignment.center,
  581. children: <Widget>[
  582. fixedText(
  583. I18n.of(context).translation_butler_wait_time,
  584. fontSize: 16,
  585. color: Colors.black),
  586. SizedBox(
  587. height: 10,
  588. ),
  589. RichText(
  590. maxLines: 3,
  591. textAlign: TextAlign.center,
  592. text: TextSpan(children: [
  593. TextSpan(
  594. text: '${waitNum*5}',
  595. style: TextStyle(
  596. color: Color(0xff3875E9),
  597. fontSize: 27)),
  598. TextSpan(
  599. text: ' ' + I18n.of(context).minute,
  600. style: TextStyle(
  601. color: Colors.black, fontSize: 17)),
  602. ]))
  603. ],
  604. ),
  605. ],
  606. ),
  607. )
  608. ],
  609. ),
  610. ),
  611. ),
  612. ),
  613. Padding(
  614. padding: EdgeInsets.only(left: 20, right: 10, top: 5, bottom: 10),
  615. child: Text(
  616. I18n.of(context).translation_butler_tips3,
  617. textScaleFactor: 1.0,
  618. style: TextStyle(color: Colors.black, fontSize: 18),
  619. ),
  620. ),
  621. Stack(
  622. alignment: Alignment.center,
  623. children: <Widget>[
  624. UnconstrainedBox(
  625. child: Container(
  626. //限制进度条的高度
  627. height: 190.0,
  628. //限制进度条的宽度
  629. width: 190.0,
  630. child: CircularProgressIndicator(
  631. //0~1的浮点数,用来表示进度多少;如果 value 为 null 或空,则显示一个动画,否则显示一个定值
  632. value: time60/60,
  633. strokeWidth: 5,
  634. //背景颜色
  635. backgroundColor: Color(0xffB2B2B2),
  636. //进度颜色
  637. valueColor:
  638. AlwaysStoppedAnimation<Color>(Color(0xff3875E9))),
  639. ),
  640. ),
  641. Column(
  642. children: <Widget>[
  643. Text(
  644. I18n.of(context).translation_butler_already_wait,
  645. textScaleFactor: 1.0,
  646. style: TextStyle(color: Colors.black, fontSize: 19),
  647. ),
  648. SizedBox(
  649. height: 10,
  650. ),
  651. Text(
  652. getFull(minutes) + ' : ' + getFull(seconds),
  653. textScaleFactor: 1.0,
  654. style: TextStyle(color: Color(0xffFF1010), fontSize: 35),
  655. )
  656. ],
  657. )
  658. ],
  659. ),
  660. Container(
  661. margin: EdgeInsets.only(left: 70, right: 70, top: 50),
  662. height: 47,
  663. child: RaisedButton(
  664. color: Color(0xff3875E9),
  665. shape: RoundedRectangleBorder(
  666. borderRadius: BorderRadius.all(Radius.circular(10))),
  667. child: Text(
  668. I18n.of(context).translation_butler_cancel,
  669. textScaleFactor: 1.0,
  670. style: TextStyle(color: Colors.white, fontSize: 19),
  671. ),
  672. onPressed: cancelOrder ),
  673. ),
  674. ],
  675. );
  676. }
  677. void cancelOrder()async {
  678. await SPUtils.save(Constants.TranslationHelper, null);
  679. setState(() {
  680. time60=0;
  681. TranslateHKMgr().orderStatus = TranslateHKMgr.ORDER_STATUS_EMPTY;
  682. refreshOrder(null);
  683. MsgHandler.sendCancelTranslateOrder();
  684. });
  685. }
  686. void handleTick() {
  687. setState(() {
  688. secondsPassed = secondsPassed + 1; //需要更新UI
  689. time60=time60+1;
  690. if(time60==60){
  691. time60=0;
  692. }
  693. });
  694. }
  695. getFull(int sec) {
  696. return sec < 10 ? '0$sec' : '$sec';
  697. }
  698. }