import 'package:chat/data/constants.dart'; import 'package:chat/data/translate_hk_data_mgr.dart'; import 'package:chat/generated/i18n.dart'; import 'package:chat/r.dart'; import 'package:chat/utils/HttpUtil.dart'; import 'package:chat/utils/screen.dart'; import 'package:flutter/material.dart'; ///翻译管家-结束后评论弹窗 class TravelEvaluationPage extends StatefulWidget { @override State createState() { return TravelEvaluationPageState(); } } class EvaluationBean { int id; String name; bool isSelect = false; EvaluationBean(this.id, this.name); } class TravelEvaluationPageState extends State { bool isGood = true; List posList; List negList; @override void initState() { super.initState(); } @override void didChangeDependencies() { super.didChangeDependencies(); posList = [ EvaluationBean(6, I18n.of(context).translation_pos_1), EvaluationBean(7, I18n.of(context).translation_pos_2), EvaluationBean(8, I18n.of(context).translation_pos_3), EvaluationBean(9, I18n.of(context).translation_pos_4), EvaluationBean(10, I18n.of(context).translation_pos_5), ]; negList = [ EvaluationBean(1, I18n.of(context).translation_neg1), EvaluationBean(2, I18n.of(context).translation_neg2), EvaluationBean(3, I18n.of(context).translation_neg3), EvaluationBean(4, I18n.of(context).translation_neg4), EvaluationBean(5, I18n.of(context).translation_neg5), ]; } ///评价接口 evaluationAPI(){ List list= isGood ? posList : negList; String value=''; for(int k=0;k evaluationWidget = getItem(isGood ? posList : negList); return UnconstrainedBox(child: Container( alignment: Alignment.center, width: Screen.width - 20, margin: EdgeInsets.all(10), child: Card( elevation: 2, // 阴影 shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), // side: BorderSide(color: Colors.green,width: 25), ), child: Container( // color: Colors.yellow, width: double.maxFinite, padding: EdgeInsets.all(16), child: Stack(children: [ Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding( padding: EdgeInsets.only(bottom: 15,top: 25), child: Text( I18n.of(context).translation_butler_dialog_tips, textScaleFactor: 1.0, textAlign: TextAlign.left, style: TextStyle( fontWeight: FontWeight.w500, color: AppColors.NewAppbarTextColor, fontSize: 17), ), ), ///满意 - 不满意 Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ InkWell( onTap: () { setState(() { isGood = !isGood; }); }, child: Column( children: [ Stack( children: [ Image.asset( isGood ? R.assetsImagesImgTranslationYesP : R.assetsImagesImgTranslationYes, width: 82, height: 82, ), isGood ? Positioned.fill( child: Container( margin: EdgeInsets.only( top: 10, right: 10), alignment: Alignment.topRight, child: Image.asset( R.assetsImagesImgTranslationTick, width: 20, height: 20, ), )) : Container() ], ), SizedBox( height: 4, ), Text( I18n.of(context).translation_butler_dialog_yes, textScaleFactor: 1.0, style: TextStyle( color: Color(isGood ? 0xff000000 : 0xffB0B0B0), fontSize: 18), ) ], ), ), Container( height: 60, width: 1, color: Color(0xffDDDDDD), ), InkWell( onTap: () { setState(() { isGood = !isGood; }); }, child: Column( children: [ Stack( children: [ Image.asset( isGood ? R.assetsImagesImgTranslationNo : R.assetsImagesImgTranslationNoP, width: 82, height: 82), isGood ? Container() : Positioned.fill( child: Container( margin: EdgeInsets.only( top: 10, right: 10), alignment: Alignment.topRight, child: Image.asset( R.assetsImagesImgTranslationTick, width: 20, height: 20), )) ], ), SizedBox( height: 4, ), Text( I18n.of(context).translation_butler_dialog_no, textScaleFactor: 1.0, style: TextStyle( color: Color(isGood ? 0xffB0B0B0 : 0xff000000), fontSize: 18), ) ], ), ) ], ), SizedBox(height: 10,), ///评价 Wrap( alignment: WrapAlignment.center, children: evaluationWidget, ), Container( margin: EdgeInsets.only( top: 30), height: 36, child: RaisedButton( color: Color(0xff3875E9), shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(10))), child: Padding(padding: EdgeInsets.only(left: 10,right: 10),child: Text( I18n.of(context).translation_butler_dialog_submit , textScaleFactor: 1.0, style: TextStyle(color: Colors.white, fontSize: 15,fontWeight: FontWeight.w500), ),), onPressed:evaluationAPI ), ) ], ), Positioned.fill(child:Container( alignment: Alignment.topRight, padding: EdgeInsets.only( bottom: 10, right: 14, top: 10, left: 14), child: InkWell(onTap: (){Navigator.pop(context);},child:Icon( IconData( 0xe679, fontFamily: 'iconfont', ), size: 19, color: Colors.black //const Color(0xFF939393), ) ,))) ],), ), ), ),); } getItem(List posList) { List evaluationWidget = []; for (int k = 0; k < posList.length; k++) { EvaluationBean item = posList[k]; evaluationWidget.add(InkWell( onTap: () { print('点击$k'); item.isSelect = !item.isSelect; posList[k] = item; setState(() {}); }, child: Container( margin: EdgeInsets.only(left: 10, top: 10), child: Padding( padding: EdgeInsets.only(left: 7, right: 7, top: 3, bottom: 3), child: fixedText(item.name, color: Color(item.isSelect ? 0xff3875E9 : 0xff868686)), ), decoration: BoxDecoration( border: Border.all( color: Color(item.isSelect ? 0xff3875E9 : 0xff868686), width: 1.0), borderRadius: BorderRadius.all(Radius.circular(6))), ), )); } return evaluationWidget; } }