|
- import 'package:chat/data/UserData.dart';
- import 'package:chat/data/constants.dart';
- import 'package:chat/data/translate_hk_data_mgr.dart';
- import 'package:chat/generated/i18n.dart';
- import 'package:chat/utils/MessageMgr.dart';
- import 'package:chat/utils/count_down_button.dart';
- import 'package:chat/utils/msgHandler.dart';
- import 'package:chat/utils/screen.dart';
- import 'package:flutter/material.dart';
-
- ///翻译管家-结束后评论弹窗
- class TranslateOrderPushPage extends StatefulWidget {
- bool isUser;
- String orderId;
- int scenes;
-
- String desc;
- Function userStartChat;
- int createTime;
- String userName;
-
- TranslateOrderPushPage(this.isUser,
- {this.orderId,
- this.scenes,
- this.desc,
- this.userStartChat,
- this.createTime,
- this.userName});
-
- @override
- State<StatefulWidget> createState() {
- return TranslateOrderPushPageState();
- }
- }
-
- class TranslateOrderPushPageState extends State<TranslateOrderPushPage> {
- @override
- void initState() {
- // TODO: implement initState
- super.initState();
- MessageMgr().on(MessageMgr.TRANSLATE_HK_CANCEL_ORDER, cancelOrder);
- }
-
-
-
- cancelOrder(args){
- Navigator.pop(context);
- }
-
- @override
- void dispose() {
- // TODO: implement dispose
- super.dispose();
- MessageMgr().off(MessageMgr.TRANSLATE_HK_CANCEL_ORDER, cancelOrder);
- }
-
- @override
- void didChangeDependencies() {
- // TODO: implement didChangeDependencies
- super.didChangeDependencies();
- }
-
- String withZero(int num){
- return num<10?'0$num':'$num';
- }
-
- @override
- Widget build(BuildContext context) {
- // TODO: implement build
- var scenesList = [
- I18n.of(context).translation_scenes_1,
- I18n.of(context).translation_scenes_2,
- I18n.of(context).translation_scenes_3,
- I18n.of(context).translation_scenes_4,
- ];
-
- DateTime date = UserData().isTranslateUser?DateTime.now():DateTime.fromMillisecondsSinceEpoch(TranslateHKMgr().startWaitTime);
- String time = '${withZero(date.hour)}:${withZero(date.minute)}';
-
- int second = (DateTime.now().millisecondsSinceEpoch-TranslateHKMgr().startWaitTime)~/1000;
- String userWaitStr ;
- if( second>60){
- userWaitStr = (second~/60).toString()+I18n.of(context).minute;
- }else{
- userWaitStr = second.toString()+I18n.of(context).second;
- }
-
- String translateStr= I18n.of(context).translation_butler_push_order_time.replaceAll('/s1', time)+'5${I18n.of(context).minute}';
- String userStr= I18n.of(context).translation_butler_push_order_time2.replaceAll('/s1', time)+userWaitStr;
-
- return UnconstrainedBox(
- alignment: Alignment.topCenter,
- child: InkWell(
- onTap: () {},
- child: Container(
- alignment: Alignment.topCenter,
-
- // height: 180,
- width: Screen.width - 20,
- margin: EdgeInsets.all(10),
- child: Card(
- elevation: 2, // 阴影
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(10),
- // side: BorderSide(color: Colors.green,width: 25),
- ),
- child: Container(
- // color: Colors.yellow,
- width: double.maxFinite,
- padding: EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Padding(
- padding: EdgeInsets.only(bottom: 15),
- child: Text(
- I18n.of(context).translation_butler_dialog_title,
- textScaleFactor: 1.0,
- textAlign: TextAlign.left,
- style: TextStyle(
- fontWeight: FontWeight.w500,
- color: AppColors.NewAppbarTextColor,
- fontSize: 17),
- ),
- ),
- Text(
- I18n.of(context).translation_butler_dialog_order.replaceAll(
- '/s1', widget.isUser ? I18n.of(context).you : widget.userName),
- textScaleFactor: 1.0,
- textAlign: TextAlign.left,
- style: TextStyle(
- color: AppColors.NewAppbarTextColor, fontSize: 14),
- ),
- SizedBox(
- height: 10,
- ),
- Text(
- widget.isUser?userStr: translateStr,
- textScaleFactor: 1.0,
- textAlign: TextAlign.left,
- style: TextStyle(color: Color(0xFF797979), fontSize: 11),
- ),
-
- widget.isUser
- ? Container()
- : Text(
- '${I18n.of(context).translation_butler_scenes2}:${scenesList[widget.scenes]}',
- textScaleFactor: 1.0,
- textAlign: TextAlign.left,
- style:
- TextStyle(color: Color(0xFF797979), fontSize: 11),
- ),
-
- widget.isUser
- ? Container()
- : Text(
- '${I18n.of(context).translation_more_desc}:${widget.desc}',
- textScaleFactor: 1.0,
- textAlign: TextAlign.left,
- style:
- TextStyle(color: Color(0xFF797979), fontSize: 11),
- ),
- //
- Container(
- margin: EdgeInsets.only(
- left: 30, right: 30, top: 20, bottom: 10),
- child: widget.isUser
- ? Container(
- margin: EdgeInsets.only(top: 10),
- height: 36,
- alignment: Alignment.center,
- child: RaisedButton(
- color: Color(0xff3875E9),
- shape: RoundedRectangleBorder(
- borderRadius:
- BorderRadius.all(Radius.circular(10))),
- child: Padding(
- padding: EdgeInsets.only(left: 10, right: 10),
- child: Text(
- I18n.of(context)
- .translation_butler_dialog_start_chat,
- textScaleFactor: 1.0,
- style: TextStyle(
- color: Colors.white,
- fontSize: 15,
- fontWeight: FontWeight.w500),
- ),
- ),
- onPressed: () {
- Navigator.of(context).pop();
- widget.userStartChat();
- }),
- )
- : CountDownButton(
- I18n.of(context)
- .translation_butler_dialog_start_service,
- () {
- ///倒计时结束自动关闭
- Navigator.of(context).pop();
- },
- onPress: () {
- ///发送确认接单
- MsgHandler.sendReceiveOrder();
- Navigator.of(context).pop();
- },
- countDownTime: 60,
- ),
- )
- ],
- ),
- ),
- ),
- ),
- ),
- );
- }
- }
|