Hibok
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

275 linhas
9.6 KiB

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