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.
 
 
 
 
 
 

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