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

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