Hibok
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

775 行
26 KiB

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