Hibok
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

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