YSMineQuestionnaire.dart 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutterappfuyou/code/base/YSBase.dart';
  3. import 'package:flutterappfuyou/code/base/YSNetWorking.dart';
  4. import 'package:flutterappfuyou/code/version2/YSMineQuestionnaireDetail.dart';
  5. class YSMineQuestionnaire extends StatefulWidget {
  6. const YSMineQuestionnaire({Key key}) : super(key: key);
  7. @override
  8. _YSMineQuestionnaireState createState() => _YSMineQuestionnaireState();
  9. }
  10. class _YSMineQuestionnaireState extends State<YSMineQuestionnaire> {
  11. List _dataArray = [];
  12. @override
  13. void initState() {
  14. Future.delayed(Duration(seconds: 0)).then((value) {
  15. _refreshData();
  16. });
  17. super.initState();
  18. }
  19. @override
  20. Widget build(BuildContext context) {
  21. return YSBase(
  22. ystitle: '调查问卷',
  23. yschild: Container(
  24. height: MediaQuery.of(context).size.height,
  25. width: MediaQuery.of(context).size.width,
  26. child: _dataArray.length==0?Container(
  27. alignment: Alignment.center,
  28. child: Image.asset('lib/images/none.png',height: 200,width: 200,),
  29. ):ListView.separated(
  30. itemBuilder: (context,index){
  31. Map item = _dataArray[index];
  32. String statusStr = item['status']=='load'?'未开始':item['status']=='progress'?'进行中':item['status']=='end'?'已结束':'已停止';
  33. return GestureDetector(
  34. onTap: (){
  35. Navigator.of(context).push(
  36. CupertinoPageRoute(builder: (context){
  37. return YSMineQuestionnaireDetail(questionId: item['id']);
  38. })
  39. );
  40. },
  41. behavior: HitTestBehavior.opaque,
  42. child: Container(
  43. padding: EdgeInsets.all(15),
  44. child: LayoutBuilder(
  45. builder: (context,conSize){
  46. return Column(
  47. crossAxisAlignment: CrossAxisAlignment.start,
  48. children: [
  49. Container(
  50. padding: EdgeInsets.only(bottom: 10),
  51. child: Row(
  52. children: [
  53. Container(
  54. width: conSize.maxWidth-80,
  55. padding: EdgeInsets.only(right: 10),
  56. child: Text(item['title']??'',style: TextStyle(fontSize: 14,color: Color(0xFF606266)),),
  57. ),
  58. Container(
  59. width: 80,
  60. child: Text(statusStr,style: TextStyle(fontSize: 10,color: Color(0xFFD0021B)),),
  61. alignment: Alignment.centerRight,
  62. )
  63. ],
  64. ),
  65. ),
  66. Text('开始时间:${item['time_start']??''} 截止时间:${item['time_end']??''}',style: TextStyle(fontSize: 8,color: Color(0xFF989898)),),
  67. ],
  68. );
  69. },
  70. ),
  71. ),
  72. );
  73. },
  74. separatorBuilder: (context,index){
  75. return Container(height: 5,color: Color(0xFFF5F3F0),);
  76. },
  77. itemCount: _dataArray.length,
  78. padding: EdgeInsets.only(top: 10),
  79. ),
  80. ),
  81. );
  82. }
  83. _refreshData() async{
  84. Map dict = await ysRequestHttp(context, requestType.get, 'naire/list',{});
  85. if(dict!=null){
  86. _dataArray = dict['data']??[];
  87. setState(() {});
  88. }
  89. }
  90. }