YSQuestionListView.dart 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutterappfuyou/code/base/YSNetWorking.dart';
  4. import '../../YSQuestionDetail.dart';
  5. class YSQuestionListView extends StatefulWidget {
  6. final Map questionItem;
  7. const YSQuestionListView({Key key, this.questionItem}) : super(key: key);
  8. @override
  9. _YSQuestionListViewState createState() => _YSQuestionListViewState();
  10. }
  11. class _YSQuestionListViewState extends State<YSQuestionListView> {
  12. @override
  13. Widget build(BuildContext context) {
  14. return GestureDetector(
  15. onTap: (){
  16. Navigator.of(context).push(
  17. CupertinoPageRoute(
  18. builder: (context){
  19. return YSQuestionDetail(questionId: widget.questionItem['id'],isPolicy: false,);
  20. }
  21. )
  22. );
  23. },
  24. child: Container(
  25. margin: EdgeInsets.only(left: 5,right: 5),
  26. padding: EdgeInsets.all(15),
  27. height: 160,
  28. decoration: BoxDecoration(
  29. color: Colors.white,
  30. borderRadius: BorderRadius.all(Radius.circular(6))
  31. ),
  32. child: Column(
  33. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  34. children: [
  35. Row(
  36. children: [
  37. Container(
  38. height: 35,
  39. width: 35,
  40. decoration: BoxDecoration(
  41. color: Color(0xFFF5F3F0),
  42. borderRadius: BorderRadius.all(Radius.circular(17.5)),
  43. image: DecorationImage(image: NetworkImage('${widget.questionItem['doctor_avatar']}'),fit: BoxFit.fill)
  44. ),
  45. ),
  46. Container(
  47. margin: EdgeInsets.only(left: 10),
  48. width: MediaQuery.of(context).size.width-85,
  49. child: Text('${widget.questionItem['doctor_name']}医生 解答了该问题',style: TextStyle(fontSize: 14,color: Color(0xFF666666)),overflow: TextOverflow.ellipsis,),
  50. )
  51. ],
  52. ),
  53. Container(
  54. width: MediaQuery.of(context).size.width-40,
  55. child: Text('问:${widget.questionItem['question_title']}',style: TextStyle(fontSize: 14,color: Color(0xFF292929)),overflow: TextOverflow.ellipsis,),
  56. ),
  57. Container(
  58. width: MediaQuery.of(context).size.width-40,
  59. child: widget.questionItem['answer_type']=='voice'?Row(
  60. children: [
  61. Text('医生解答:',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,),
  62. Container(
  63. height: 26,
  64. width: 59,
  65. decoration: BoxDecoration(
  66. color: Color(0xFFF5F3F0),
  67. borderRadius: BorderRadius.all(Radius.circular(4))
  68. ),
  69. alignment: Alignment.center,
  70. child: Stack(
  71. children: [
  72. Row(
  73. children: [
  74. Container(
  75. child: Image.asset('lib/images/voice2.png'),
  76. height: 15,
  77. width: 15,
  78. margin: EdgeInsets.only(left: 10,right: 5),
  79. ),
  80. Text('4',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,),
  81. ],
  82. )
  83. ],
  84. ),
  85. )
  86. ],
  87. ):Text('医生解答:${(widget.questionItem['answer_body'])??''}',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,),
  88. ),
  89. Container(
  90. width: MediaQuery.of(context).size.width,
  91. height: 1.5,
  92. child: Image.asset('lib/images/line.png'),
  93. ),
  94. Row(
  95. children: [
  96. Container(
  97. width: MediaQuery.of(context).size.width-85,
  98. child: Text('${widget.questionItem['question_time']}',style: TextStyle(fontSize: 12,color: Color(0xFF808080)),overflow: TextOverflow.ellipsis,),
  99. ),
  100. GestureDetector(
  101. child: Image(height: 15,width: 15,image: AssetImage(widget.questionItem['is_favorite']==false?'lib/images/uncollection.png':'lib/images/collection.png'),),
  102. onTap: () async{
  103. _postCollectionData();
  104. },
  105. )
  106. ],
  107. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  108. )
  109. ],
  110. ),
  111. ),
  112. );
  113. }
  114. _postCollectionData() async{
  115. Map dict = await ysRequestHttpNoLoading(context, requestType.post, 'question/favorite', {'question_id':widget.questionItem['id']});
  116. if(dict!=null){
  117. widget.questionItem['is_favorite'] = dict['data']['is_favorite'];
  118. setState(() {});
  119. }
  120. }
  121. }