|
- import 'package:chat/data/UserData.dart';
- import 'package:chat/home/realtimehelper/translation_butler_page.dart';
- import 'package:chat/home/realtimehelper/travel_butler_page.dart';
- import 'package:chat/models/group_info_model.dart';
- import 'package:chat/utils/CustomUI.dart';
- import 'package:chat/utils/MessageMgr.dart';
- import 'package:chat/utils/msgHandler.dart';
- import 'package:chat/utils/screen.dart';
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:oktoast/oktoast.dart';
-
- import '../../data/constants.dart';
- import '../../generated/i18n.dart';
- import '../../r.dart';
-
- class RealTimeHelperPage extends StatefulWidget {
- final GroupInfoModel groupInfoModel;
-
- RealTimeHelperPage({Key key, this.groupInfoModel}) : super(key: key);
-
- @override
- State<StatefulWidget> createState() {
- return RealTimeHelperPageState();
- }
- }
-
- class RealTimeHelperPageState extends State<RealTimeHelperPage> {
-
- bool isReceiveOrder = false;
-
-
- @override
- void initState() {
- super.initState();
- // MessageMgr().on('update_system',refresh);
- MessageMgr().on(MessageMgr.TRANSLATE_HK_IS_RECEIVED_ORDER,isReceiveOrderMsg);
-
-
- }
-
-
- isReceiveOrderMsg(data){
- bool isReceive = data;
- isReceiveOrder = isReceive;
- setState(() {});
- }
-
-
-
-
- @override
- void dispose() {
- super.dispose();
- // MessageMgr().off('update_system',refresh);
- MessageMgr().off(MessageMgr.TRANSLATE_HK_IS_RECEIVED_ORDER,isReceiveOrderMsg);
-
- }
-
-
-
-
- @override
- Widget build(BuildContext context) {
- Widget appBar = AppBar(
- backgroundColor: Colors.white,
- title: Text(
- I18n.of(context).real_time_helper,
- textScaleFactor: 1.0,
- style: TextStyle(color: AppColors.NewAppbarTextColor),
- ),
- // leading: CustomUI.buildCustomLeading(context),
- centerTitle: false,
- );
-
-
- return UserData().isTranslateUser?Scaffold(
- // appBar: appBar,
- body: Container(
- color: Color(0xffE8EAF0),
- child: Stack(
- children: <Widget>[
- Container(
- child: Image.asset(
- R.assetsImagesImgRealtimeBg2,
- width: MediaQuery.of(context).size.width,
- height:250,
- fit: BoxFit.cover,
- ),
- ),
- Container(
- child: Image.asset(
- R.assetsImagesImgRealtimeBg1,
- width: MediaQuery.of(context).size.width,
- height:MediaQuery.of(context).padding.top+80,
- fit: BoxFit.cover,
- ),
- ),
- Container(
- child: SafeArea(
- child: ListView(
- children: <Widget>[
- SizedBox(height: 4,),
- Container(
- alignment: Alignment.center,
- child: fixedText(I18n.of(context).translation_butler_title3, color: Colors.white, fontSize: 21),
- ),
- UnconstrainedBox(child: InkWell(onTap: (){
-
- MsgHandler.translateReceiptOrStopOrder(!isReceiveOrder);
-
-
- },child: Container(
- alignment: Alignment.center,
- padding: EdgeInsets.only(left: 11,right: 11,top: 3,bottom: 3),
- decoration: BoxDecoration(
- border: Border.all(color: isReceiveOrder?Color(0xFFFEE645):Colors.white, width: 1),
- borderRadius: BorderRadius.circular(11)),
- child: fixedText(isReceiveOrder?I18n.of(context).translation_butler_start_receive_order:I18n.of(context).translation_butler_stop_receive_order, color: isReceiveOrder?Color(0xFFFEE645):Colors.white, fontSize: 15),
- ),),),
- Container(
- padding: EdgeInsets.only(left: 13,top: 20),
- child: fixedText(I18n.of(context).real_time_helper, color: Colors.white, fontSize: 22,fontWeight: FontWeight.w700),
- ),
- helperCard(I18n.of(context).translation_butler,
- R.assetsImagesImgTranslationButler, () {
- if (UserData().isTranslateUser) {
- showToast(I18n.of(context).translation_butler_stop_tips);
- } else {
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (_) => TranslationButlerPage(),
- ),
- );
- }
- }, textColor: Color(0xff2685FA)),
- helperCard(I18n.of(context).travel_butler,
- R.assetsImagesImgTravelButler, () {
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (_) => TravelButlerPage(),
- ),
- );
- }, textColor: Color(0xffff682d)),
- SizedBox(
- height: 15,
- ),
- ],
- )),
- )
- ],
- ),
- ),
- ):Scaffold(
- appBar: appBar,
- body: SafeArea(
- child: Container(
- color: Color(0xffE8EAF0),
- child: ListView(
- children: <Widget>[
- helperCard(I18n.of(context).translation_butler,
- R.assetsImagesImgTranslationButler, () {
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (_) => TranslationButlerPage(),
- ),
- );
- },textColor: Color(0xff2685FA),tips: I18n.of(context).translation_butler_introduction),
- helperCard(
- I18n.of(context).travel_butler, R.assetsImagesImgTravelButler,
- () {
- Navigator.of(context).push(
- MaterialPageRoute(
- builder: (_) => TravelButlerPage(),
- ),
- );
- },textColor: Color(0xffff682d),tips: I18n.of(context).travel_introduction),
- SizedBox(
- height: 15,
- ),
- ],
- ),
- ),
- ),
- );
- }
-
- Widget helperCard(String title, String assets, Function callBack,
- {Color textColor,String tips}) {
- return Stack(children: <Widget>[
- InkWell(
- child: Container(
- margin: EdgeInsets.all(10),
- child: Card(
- elevation: 2, // 阴影
- shape: RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(10),
- // side: BorderSide(color: Colors.green,width: 25),
- ),
- child: Container(
- padding: EdgeInsets.all(10),
- child: Column(
- children: <Widget>[
- Image.asset(
- assets,
- ),
- Padding(
- padding: EdgeInsets.only(top: 15, bottom: 15),
- child: Text(
- title + ' >>',
- textScaleFactor: 1.0,
- style: TextStyle(color: textColor, fontSize: 20),
- ),
- )
- ],
- ),
- ),
- ),
- ),
- onTap: callBack,
- ),
-
- Positioned(child: InkWell(child: Container( width: 40,height: 40,child: Align(child: Icon(
- IconData(0xe681, fontFamily: Constants.IconFontFamily),
- color: Color(0xFFFF7E00),
- size: 28.0,
- ),alignment: Alignment.center,),),onTap: (){
- CustomUI.buildTip(context, title, Padding(padding: EdgeInsets.all(10),child: fixedText(tips,fontSize: 14),));
- },),right: 21,top: 21,)
-
- ],);
- }
- }
|