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.
 
 
 
 
 
 

218 rivejä
7.7 KiB

  1. import 'package:chat/data/UserData.dart';
  2. import 'package:chat/data/constants.dart';
  3. import 'package:chat/data/translate_hk_data_mgr.dart';
  4. import 'package:chat/generated/i18n.dart';
  5. import 'package:chat/utils/MessageMgr.dart';
  6. import 'package:chat/utils/count_down_button.dart';
  7. import 'package:chat/utils/msgHandler.dart';
  8. import 'package:chat/utils/screen.dart';
  9. import 'package:flutter/material.dart';
  10. ///翻译管家-结束后评论弹窗
  11. class TranslateOrderPushPage extends StatefulWidget {
  12. bool isUser;
  13. String orderId;
  14. int scenes;
  15. String desc;
  16. Function userStartChat;
  17. int createTime;
  18. String userName;
  19. TranslateOrderPushPage(this.isUser,
  20. {this.orderId,
  21. this.scenes,
  22. this.desc,
  23. this.userStartChat,
  24. this.createTime,
  25. this.userName});
  26. @override
  27. State<StatefulWidget> createState() {
  28. return TranslateOrderPushPageState();
  29. }
  30. }
  31. class TranslateOrderPushPageState extends State<TranslateOrderPushPage> {
  32. @override
  33. void initState() {
  34. // TODO: implement initState
  35. super.initState();
  36. MessageMgr().on(MessageMgr.TRANSLATE_HK_CANCEL_ORDER, cancelOrder);
  37. }
  38. cancelOrder(args){
  39. Navigator.pop(context);
  40. }
  41. @override
  42. void dispose() {
  43. // TODO: implement dispose
  44. super.dispose();
  45. MessageMgr().off(MessageMgr.TRANSLATE_HK_CANCEL_ORDER, cancelOrder);
  46. }
  47. @override
  48. void didChangeDependencies() {
  49. // TODO: implement didChangeDependencies
  50. super.didChangeDependencies();
  51. }
  52. String withZero(int num){
  53. return num<10?'0$num':'$num';
  54. }
  55. @override
  56. Widget build(BuildContext context) {
  57. // TODO: implement build
  58. var scenesList = [
  59. I18n.of(context).translation_scenes_1,
  60. I18n.of(context).translation_scenes_2,
  61. I18n.of(context).translation_scenes_3,
  62. I18n.of(context).translation_scenes_4,
  63. ];
  64. DateTime date = UserData().isTranslateUser?DateTime.now():DateTime.fromMillisecondsSinceEpoch(TranslateHKMgr().startWaitTime);
  65. String time = '${withZero(date.hour)}:${withZero(date.minute)}';
  66. int second = (DateTime.now().millisecondsSinceEpoch-TranslateHKMgr().startWaitTime)~/1000;
  67. String userWaitStr ;
  68. if( second>60){
  69. userWaitStr = (second~/60).toString()+I18n.of(context).minute;
  70. }else{
  71. userWaitStr = second.toString()+I18n.of(context).second;
  72. }
  73. String translateStr= I18n.of(context).translation_butler_push_order_time.replaceAll('/s1', time)+'5${I18n.of(context).minute}';
  74. String userStr= I18n.of(context).translation_butler_push_order_time2.replaceAll('/s1', time)+userWaitStr;
  75. return UnconstrainedBox(
  76. alignment: Alignment.topCenter,
  77. child: InkWell(
  78. onTap: () {},
  79. child: Container(
  80. alignment: Alignment.topCenter,
  81. // height: 180,
  82. width: Screen.width - 20,
  83. margin: EdgeInsets.all(10),
  84. child: Card(
  85. elevation: 2, // 阴影
  86. shape: RoundedRectangleBorder(
  87. borderRadius: BorderRadius.circular(10),
  88. // side: BorderSide(color: Colors.green,width: 25),
  89. ),
  90. child: Container(
  91. // color: Colors.yellow,
  92. width: double.maxFinite,
  93. padding: EdgeInsets.all(16),
  94. child: Column(
  95. crossAxisAlignment: CrossAxisAlignment.start,
  96. children: <Widget>[
  97. Padding(
  98. padding: EdgeInsets.only(bottom: 15),
  99. child: Text(
  100. I18n.of(context).translation_butler_dialog_title,
  101. textScaleFactor: 1.0,
  102. textAlign: TextAlign.left,
  103. style: TextStyle(
  104. fontWeight: FontWeight.w500,
  105. color: AppColors.NewAppbarTextColor,
  106. fontSize: 17),
  107. ),
  108. ),
  109. Text(
  110. I18n.of(context).translation_butler_dialog_order.replaceAll(
  111. '/s1', widget.isUser ? I18n.of(context).you : widget.userName),
  112. textScaleFactor: 1.0,
  113. textAlign: TextAlign.left,
  114. style: TextStyle(
  115. color: AppColors.NewAppbarTextColor, fontSize: 14),
  116. ),
  117. SizedBox(
  118. height: 10,
  119. ),
  120. Text(
  121. widget.isUser?userStr: translateStr,
  122. textScaleFactor: 1.0,
  123. textAlign: TextAlign.left,
  124. style: TextStyle(color: Color(0xFF797979), fontSize: 11),
  125. ),
  126. widget.isUser
  127. ? Container()
  128. : Text(
  129. '${I18n.of(context).translation_butler_scenes2}:${scenesList[widget.scenes]}',
  130. textScaleFactor: 1.0,
  131. textAlign: TextAlign.left,
  132. style:
  133. TextStyle(color: Color(0xFF797979), fontSize: 11),
  134. ),
  135. widget.isUser
  136. ? Container()
  137. : Text(
  138. '${I18n.of(context).translation_more_desc}:${widget.desc}',
  139. textScaleFactor: 1.0,
  140. textAlign: TextAlign.left,
  141. style:
  142. TextStyle(color: Color(0xFF797979), fontSize: 11),
  143. ),
  144. //
  145. Container(
  146. margin: EdgeInsets.only(
  147. left: 30, right: 30, top: 20, bottom: 10),
  148. child: widget.isUser
  149. ? Container(
  150. margin: EdgeInsets.only(top: 10),
  151. height: 36,
  152. alignment: Alignment.center,
  153. child: RaisedButton(
  154. color: Color(0xff3875E9),
  155. shape: RoundedRectangleBorder(
  156. borderRadius:
  157. BorderRadius.all(Radius.circular(10))),
  158. child: Padding(
  159. padding: EdgeInsets.only(left: 10, right: 10),
  160. child: Text(
  161. I18n.of(context)
  162. .translation_butler_dialog_start_chat,
  163. textScaleFactor: 1.0,
  164. style: TextStyle(
  165. color: Colors.white,
  166. fontSize: 15,
  167. fontWeight: FontWeight.w500),
  168. ),
  169. ),
  170. onPressed: () {
  171. Navigator.of(context).pop();
  172. widget.userStartChat();
  173. }),
  174. )
  175. : CountDownButton(
  176. I18n.of(context)
  177. .translation_butler_dialog_start_service,
  178. () {
  179. ///倒计时结束自动关闭
  180. Navigator.of(context).pop();
  181. },
  182. onPress: () {
  183. ///发送确认接单
  184. MsgHandler.sendReceiveOrder();
  185. Navigator.of(context).pop();
  186. },
  187. countDownTime: 60,
  188. ),
  189. )
  190. ],
  191. ),
  192. ),
  193. ),
  194. ),
  195. ),
  196. );
  197. }
  198. }