Hibok
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

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