Hibok
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

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