Hibok
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

298 rindas
10 KiB

  1. import 'package:chat/data/constants.dart';
  2. import 'package:chat/data/translate_hk_data_mgr.dart';
  3. import 'package:chat/generated/i18n.dart';
  4. import 'package:chat/r.dart';
  5. import 'package:chat/utils/HttpUtil.dart';
  6. import 'package:chat/utils/screen.dart';
  7. import 'package:flutter/material.dart';
  8. ///翻译管家-结束后评论弹窗
  9. class TravelEvaluationPage extends StatefulWidget {
  10. @override
  11. State<StatefulWidget> createState() {
  12. return TravelEvaluationPageState();
  13. }
  14. }
  15. class EvaluationBean {
  16. int id;
  17. String name;
  18. bool isSelect = false;
  19. EvaluationBean(this.id, this.name);
  20. }
  21. class TravelEvaluationPageState extends State<TravelEvaluationPage> {
  22. bool isGood = true;
  23. List<EvaluationBean> posList;
  24. List<EvaluationBean> negList;
  25. @override
  26. void initState() {
  27. super.initState();
  28. }
  29. @override
  30. void didChangeDependencies() {
  31. super.didChangeDependencies();
  32. posList = [
  33. EvaluationBean(6, I18n.of(context).translation_pos_1),
  34. EvaluationBean(7, I18n.of(context).translation_pos_2),
  35. EvaluationBean(8, I18n.of(context).translation_pos_3),
  36. EvaluationBean(9, I18n.of(context).translation_pos_4),
  37. EvaluationBean(10, I18n.of(context).translation_pos_5),
  38. ];
  39. negList = [
  40. EvaluationBean(1, I18n.of(context).translation_neg1),
  41. EvaluationBean(2, I18n.of(context).translation_neg2),
  42. EvaluationBean(3, I18n.of(context).translation_neg3),
  43. EvaluationBean(4, I18n.of(context).translation_neg4),
  44. EvaluationBean(5, I18n.of(context).translation_neg5),
  45. ];
  46. }
  47. ///评价接口
  48. evaluationAPI(){
  49. List<EvaluationBean> list= isGood ? posList : negList;
  50. String value='';
  51. for(int k=0;k<list.length;k++){
  52. EvaluationBean item = posList[k];
  53. if(item.isSelect){
  54. if(value==''){
  55. value= '${item.id}';
  56. }else{
  57. value = value+'|${item.id}';
  58. }
  59. }
  60. }
  61. HttpUtil().evaluationTransalteHK(TranslateHKMgr().orderId,value,isGood,(){
  62. Navigator.of(context).pop();
  63. });
  64. }
  65. @override
  66. Widget build(BuildContext context) {
  67. List<Widget> evaluationWidget = getItem(isGood ? posList : negList);
  68. return UnconstrainedBox(child: Container(
  69. alignment: Alignment.center,
  70. width: Screen.width - 20,
  71. margin: EdgeInsets.all(10),
  72. child: Card(
  73. elevation: 2, // 阴影
  74. shape: RoundedRectangleBorder(
  75. borderRadius: BorderRadius.circular(10),
  76. // side: BorderSide(color: Colors.green,width: 25),
  77. ),
  78. child: Container(
  79. // color: Colors.yellow,
  80. width: double.maxFinite,
  81. padding: EdgeInsets.all(16),
  82. child: Stack(children: <Widget>[
  83. Column(
  84. crossAxisAlignment: CrossAxisAlignment.center,
  85. children: <Widget>[
  86. Padding(
  87. padding: EdgeInsets.only(bottom: 15,top: 25),
  88. child: Text(
  89. I18n.of(context).translation_butler_dialog_tips,
  90. textScaleFactor: 1.0,
  91. textAlign: TextAlign.left,
  92. style: TextStyle(
  93. fontWeight: FontWeight.w500,
  94. color: AppColors.NewAppbarTextColor,
  95. fontSize: 17),
  96. ),
  97. ),
  98. ///满意 - 不满意
  99. Row(
  100. mainAxisAlignment: MainAxisAlignment.spaceAround,
  101. children: <Widget>[
  102. InkWell(
  103. onTap: () {
  104. setState(() {
  105. isGood = !isGood;
  106. });
  107. },
  108. child: Column(
  109. children: <Widget>[
  110. Stack(
  111. children: <Widget>[
  112. Image.asset(
  113. isGood
  114. ? R.assetsImagesImgTranslationYesP
  115. : R.assetsImagesImgTranslationYes,
  116. width: 82,
  117. height: 82,
  118. ),
  119. isGood
  120. ? Positioned.fill(
  121. child: Container(
  122. margin: EdgeInsets.only(
  123. top: 10, right: 10),
  124. alignment: Alignment.topRight,
  125. child: Image.asset(
  126. R.assetsImagesImgTranslationTick,
  127. width: 20,
  128. height: 20,
  129. ),
  130. ))
  131. : Container()
  132. ],
  133. ),
  134. SizedBox(
  135. height: 4,
  136. ),
  137. Text(
  138. I18n.of(context).translation_butler_dialog_yes,
  139. textScaleFactor: 1.0,
  140. style: TextStyle(
  141. color:
  142. Color(isGood ? 0xff000000 : 0xffB0B0B0),
  143. fontSize: 18),
  144. )
  145. ],
  146. ),
  147. ),
  148. Container(
  149. height: 60,
  150. width: 1,
  151. color: Color(0xffDDDDDD),
  152. ),
  153. InkWell(
  154. onTap: () {
  155. setState(() {
  156. isGood = !isGood;
  157. });
  158. },
  159. child: Column(
  160. children: <Widget>[
  161. Stack(
  162. children: <Widget>[
  163. Image.asset(
  164. isGood
  165. ? R.assetsImagesImgTranslationNo
  166. : R.assetsImagesImgTranslationNoP,
  167. width: 82,
  168. height: 82),
  169. isGood
  170. ? Container()
  171. : Positioned.fill(
  172. child: Container(
  173. margin: EdgeInsets.only(
  174. top: 10, right: 10),
  175. alignment: Alignment.topRight,
  176. child: Image.asset(
  177. R.assetsImagesImgTranslationTick,
  178. width: 20,
  179. height: 20),
  180. ))
  181. ],
  182. ),
  183. SizedBox(
  184. height: 4,
  185. ),
  186. Text(
  187. I18n.of(context).translation_butler_dialog_no,
  188. textScaleFactor: 1.0,
  189. style: TextStyle(
  190. color:
  191. Color(isGood ? 0xffB0B0B0 : 0xff000000),
  192. fontSize: 18),
  193. )
  194. ],
  195. ),
  196. )
  197. ],
  198. ),
  199. SizedBox(height: 10,),
  200. ///评价
  201. Wrap(
  202. alignment: WrapAlignment.center,
  203. children: evaluationWidget,
  204. ),
  205. Container(
  206. margin: EdgeInsets.only( top: 30),
  207. height: 36,
  208. child: RaisedButton(
  209. color: Color(0xff3875E9),
  210. shape: RoundedRectangleBorder(
  211. borderRadius: BorderRadius.all(Radius.circular(10))),
  212. child: Padding(padding: EdgeInsets.only(left: 10,right: 10),child: Text(
  213. I18n.of(context).translation_butler_dialog_submit ,
  214. textScaleFactor: 1.0,
  215. style: TextStyle(color: Colors.white, fontSize: 15,fontWeight: FontWeight.w500),
  216. ),),
  217. onPressed:evaluationAPI ),
  218. )
  219. ],
  220. ),
  221. Positioned.fill(child:Container(
  222. alignment: Alignment.topRight,
  223. padding: EdgeInsets.only(
  224. bottom: 10, right: 14, top: 10, left: 14),
  225. child: InkWell(onTap: (){Navigator.pop(context);},child:Icon(
  226. IconData(
  227. 0xe679,
  228. fontFamily: 'iconfont',
  229. ),
  230. size: 19,
  231. color: Colors.black //const Color(0xFF939393),
  232. ) ,)))
  233. ],),
  234. ),
  235. ),
  236. ),);
  237. }
  238. getItem(List<EvaluationBean> posList) {
  239. List<Widget> evaluationWidget = [];
  240. for (int k = 0; k < posList.length; k++) {
  241. EvaluationBean item = posList[k];
  242. evaluationWidget.add(InkWell(
  243. onTap: () {
  244. print('点击$k');
  245. item.isSelect = !item.isSelect;
  246. posList[k] = item;
  247. setState(() {});
  248. },
  249. child: Container(
  250. margin: EdgeInsets.only(left: 10, top: 10),
  251. child: Padding(
  252. padding: EdgeInsets.only(left: 7, right: 7, top: 3, bottom: 3),
  253. child: fixedText(item.name,
  254. color: Color(item.isSelect ? 0xff3875E9 : 0xff868686)),
  255. ),
  256. decoration: BoxDecoration(
  257. border: Border.all(
  258. color: Color(item.isSelect ? 0xff3875E9 : 0xff868686),
  259. width: 1.0),
  260. borderRadius: BorderRadius.all(Radius.circular(6))),
  261. ),
  262. ));
  263. }
  264. return evaluationWidget;
  265. }
  266. }