Hibok
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

226 řádky
7.1 KiB

  1. import 'package:chat/data/UserData.dart';
  2. import 'package:chat/home/realtimehelper/translation_butler_page.dart';
  3. import 'package:chat/home/realtimehelper/travel_butler_page.dart';
  4. import 'package:chat/models/group_info_model.dart';
  5. import 'package:chat/utils/MessageMgr.dart';
  6. import 'package:chat/utils/msgHandler.dart';
  7. import 'package:chat/utils/screen.dart';
  8. import 'package:flutter/cupertino.dart';
  9. import 'package:flutter/material.dart';
  10. import 'package:oktoast/oktoast.dart';
  11. import '../../data/constants.dart';
  12. import '../../generated/i18n.dart';
  13. import '../../r.dart';
  14. class RealTimeHelperPage extends StatefulWidget {
  15. final GroupInfoModel groupInfoModel;
  16. RealTimeHelperPage({Key key, this.groupInfoModel}) : super(key: key);
  17. @override
  18. State<StatefulWidget> createState() {
  19. return RealTimeHelperPageState();
  20. }
  21. }
  22. class RealTimeHelperPageState extends State<RealTimeHelperPage> {
  23. bool isReceiveOrder = false;
  24. @override
  25. void initState() {
  26. super.initState();
  27. // MessageMgr().on('update_system',refresh);
  28. MessageMgr().on(MessageMgr.TRANSLATE_HK_IS_RECEIVED_ORDER,isReceiveOrderMsg);
  29. }
  30. isReceiveOrderMsg(data){
  31. bool isReceive = data;
  32. isReceiveOrder = isReceive;
  33. setState(() {});
  34. }
  35. @override
  36. void dispose() {
  37. super.dispose();
  38. // MessageMgr().off('update_system',refresh);
  39. MessageMgr().off(MessageMgr.TRANSLATE_HK_IS_RECEIVED_ORDER,isReceiveOrderMsg);
  40. }
  41. @override
  42. Widget build(BuildContext context) {
  43. Widget appBar = AppBar(
  44. backgroundColor: Colors.white,
  45. title: Text(
  46. I18n.of(context).real_time_helper,
  47. textScaleFactor: 1.0,
  48. style: TextStyle(color: AppColors.NewAppbarTextColor),
  49. ),
  50. // leading: CustomUI.buildCustomLeading(context),
  51. centerTitle: false,
  52. );
  53. return UserData().isTranslateUser?Scaffold(
  54. // appBar: appBar,
  55. body: Container(
  56. color: Color(0xffE8EAF0),
  57. child: Stack(
  58. children: <Widget>[
  59. Container(
  60. child: Image.asset(
  61. R.assetsImagesImgRealtimeBg2,
  62. width: MediaQuery.of(context).size.width,
  63. height:250,
  64. fit: BoxFit.cover,
  65. ),
  66. ),
  67. Container(
  68. child: Image.asset(
  69. R.assetsImagesImgRealtimeBg1,
  70. width: MediaQuery.of(context).size.width,
  71. height:MediaQuery.of(context).padding.top+80,
  72. fit: BoxFit.cover,
  73. ),
  74. ),
  75. Container(
  76. child: SafeArea(
  77. child: ListView(
  78. children: <Widget>[
  79. SizedBox(height: 4,),
  80. Container(
  81. alignment: Alignment.center,
  82. child: fixedText(I18n.of(context).translation_butler_title3, color: Colors.white, fontSize: 21),
  83. ),
  84. UnconstrainedBox(child: InkWell(onTap: (){
  85. MsgHandler.translateReceiptOrStopOrder(!isReceiveOrder);
  86. },child: Container(
  87. alignment: Alignment.center,
  88. padding: EdgeInsets.only(left: 11,right: 11,top: 3,bottom: 3),
  89. decoration: BoxDecoration(
  90. border: Border.all(color: isReceiveOrder?Color(0xFFFEE645):Colors.white, width: 1),
  91. borderRadius: BorderRadius.circular(11)),
  92. 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),
  93. ),),),
  94. Container(
  95. padding: EdgeInsets.only(left: 13,top: 20),
  96. child: fixedText(I18n.of(context).real_time_helper, color: Colors.white, fontSize: 22,fontWeight: FontWeight.w700),
  97. ),
  98. helperCard(I18n.of(context).translation_butler,
  99. R.assetsImagesImgTranslationButler, () {
  100. if (UserData().isTranslateUser) {
  101. showToast(I18n.of(context).translation_butler_stop_tips);
  102. } else {
  103. Navigator.of(context).push(
  104. MaterialPageRoute(
  105. builder: (_) => TranslationButlerPage(),
  106. ),
  107. );
  108. }
  109. }, textColor: Color(0xff2685FA)),
  110. helperCard(I18n.of(context).travel_butler,
  111. R.assetsImagesImgTravelButler, () {
  112. Navigator.of(context).push(
  113. MaterialPageRoute(
  114. builder: (_) => TravelButlerPage(),
  115. ),
  116. );
  117. }, textColor: Color(0xffff682d)),
  118. SizedBox(
  119. height: 15,
  120. ),
  121. ],
  122. )),
  123. )
  124. ],
  125. ),
  126. ),
  127. ):Scaffold(
  128. appBar: appBar,
  129. body: SafeArea(
  130. child: Container(
  131. color: Color(0xffE8EAF0),
  132. child: ListView(
  133. children: <Widget>[
  134. helperCard(I18n.of(context).translation_butler,
  135. R.assetsImagesImgTranslationButler, () {
  136. Navigator.of(context).push(
  137. MaterialPageRoute(
  138. builder: (_) => TranslationButlerPage(),
  139. ),
  140. );
  141. },textColor: Color(0xff2685FA)),
  142. helperCard(
  143. I18n.of(context).travel_butler, R.assetsImagesImgTravelButler,
  144. () {
  145. Navigator.of(context).push(
  146. MaterialPageRoute(
  147. builder: (_) => TravelButlerPage(),
  148. ),
  149. );
  150. },textColor: Color(0xffff682d) ),
  151. SizedBox(
  152. height: 15,
  153. ),
  154. ],
  155. ),
  156. ),
  157. ),
  158. );
  159. }
  160. Widget helperCard(String title, String assets, Function callBack,
  161. {Color textColor }) {
  162. return Stack(children: <Widget>[
  163. InkWell(
  164. child: Container(
  165. margin: EdgeInsets.all(10),
  166. child: Card(
  167. elevation: 2, // 阴影
  168. shape: RoundedRectangleBorder(
  169. borderRadius: BorderRadius.circular(10),
  170. // side: BorderSide(color: Colors.green,width: 25),
  171. ),
  172. child: Container(
  173. padding: EdgeInsets.all(10),
  174. child: Column(
  175. children: <Widget>[
  176. Image.asset(
  177. assets,
  178. ),
  179. Padding(
  180. padding: EdgeInsets.only(top: 15, bottom: 15),
  181. child: Text(
  182. title + ' >>',
  183. textScaleFactor: 1.0,
  184. style: TextStyle(color: textColor, fontSize: 20),
  185. ),
  186. )
  187. ],
  188. ),
  189. ),
  190. ),
  191. ),
  192. onTap: callBack,
  193. ),
  194. ],);
  195. }
  196. }