YSQuestion.dart 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutterappfuyou/code/base/YSNetWorking.dart';
  4. import 'package:flutterappfuyou/code/base/YSTools.dart';
  5. import 'package:shared_preferences/shared_preferences.dart';
  6. import 'base/YSBase.dart';
  7. import 'YSQuestionDetail.dart';
  8. class YSQuestion extends StatefulWidget {
  9. @override
  10. _YSQuestionState createState() => _YSQuestionState();
  11. }
  12. class _YSQuestionState extends State<YSQuestion> {
  13. int _selected = 0;
  14. PageController _page = PageController();
  15. ScrollController _scrollPage1 = ScrollController();
  16. ScrollController _scrollPage2 = ScrollController();
  17. int _index = 1;
  18. String searchStr = '';
  19. List _dataArray = [];
  20. List _policyArray = [];
  21. int _policyIndex = 1;
  22. @override
  23. void initState() {
  24. Future.delayed(Duration(seconds: 0)).then((value){
  25. this._refreshData();
  26. _scrollPage1.addListener(() {
  27. if(_scrollPage1.position.pixels == _scrollPage1.position.maxScrollExtent){
  28. this._loadMoreData();
  29. }
  30. });
  31. _scrollPage2.addListener(() {
  32. if(_scrollPage2.position.pixels == _scrollPage2.position.maxScrollExtent){
  33. this._loadMorePolicyData();
  34. }
  35. });
  36. });
  37. super.initState();
  38. }
  39. @override
  40. Widget build(BuildContext context) {
  41. return YSBase(
  42. ystitle: '问题大厅',
  43. ysright: PopupMenuButton<String>(
  44. padding: EdgeInsets.all(0),
  45. icon: Icon(Icons.more_horiz,color: Colors.white,),
  46. onSelected: (value){
  47. Navigator.of(context).push(
  48. CupertinoPageRoute(
  49. builder: (context){
  50. if(value == '我的提问'){
  51. return YSSift(type: 1,);
  52. }else{
  53. return YSSift(type: 2,);
  54. }
  55. }
  56. )
  57. );
  58. },
  59. itemBuilder: (context) {
  60. return <PopupMenuEntry<String>>[
  61. PopupMenuItem<String>(
  62. value: '我的提问',
  63. child: Text('我的提问',style: TextStyle(fontSize: 14,color: Color(0xFF292929)),),
  64. ),
  65. PopupMenuItem<String>(
  66. value: '我的收藏',
  67. child: Text('我的收藏',style: TextStyle(fontSize: 14,color: Color(0xFF292929)),),
  68. ),
  69. ];
  70. },
  71. ),
  72. yschild: SingleChildScrollView(
  73. child: Column(
  74. children: [
  75. Container(
  76. height: 50,
  77. decoration: BoxDecoration(
  78. color: Colors.white,
  79. borderRadius: BorderRadius.only(topRight: Radius.circular(20),topLeft: Radius.circular(20)),
  80. ),
  81. padding: EdgeInsets.only(left: 20,right: 20,top: 10,bottom: 10),
  82. child: CupertinoTextField(
  83. placeholder: '搜索',
  84. textAlign: TextAlign.center,
  85. style: TextStyle(fontSize: 14,color: Color(0xFF808080),decoration: TextDecoration.none),
  86. placeholderStyle: TextStyle(fontSize: 14,color: Color(0xFF808080),decoration: TextDecoration.none),
  87. decoration: BoxDecoration(
  88. borderRadius: BorderRadius.all(Radius.circular(15)),
  89. color: Color(0xFFF5F3F0)
  90. ),
  91. textInputAction: TextInputAction.search,
  92. onSubmitted: (value){
  93. if(value!=null){
  94. searchStr = value;
  95. _selected==0?_refreshData():_refreshPolicyData();
  96. }
  97. },
  98. ),
  99. ),
  100. Container(
  101. height: 25,
  102. color: Colors.white,
  103. padding: EdgeInsets.only(left: 10,right: 10),
  104. child: Column(
  105. crossAxisAlignment: CrossAxisAlignment.start,
  106. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  107. children: [
  108. Row(
  109. children: [
  110. GestureDetector(
  111. onTap: (){
  112. _refreshData();
  113. _selected = 0;
  114. _page.jumpToPage(0);
  115. },
  116. child: Container(
  117. margin: EdgeInsets.only(left: 5,right: 5),
  118. child: Text(' 问专家',style: TextStyle(color: Color(0xFF7F3344),fontSize: 13,decoration: TextDecoration.none,fontWeight: FontWeight.w600),),
  119. ),
  120. ),
  121. GestureDetector(
  122. onTap: (){
  123. _refreshPolicyData();
  124. _selected = 1;
  125. _page.jumpToPage(1);
  126. },
  127. child: Text(' 问政策',style: TextStyle(color: Color(0xFF7F3344),fontSize: 13,decoration: TextDecoration.none,fontWeight: FontWeight.w600),),
  128. ),
  129. ],
  130. ),
  131. Container(height: 2,width: 30,color: Color(0xFF7F3344),margin: EdgeInsets.only(left: _selected==0?15:60),),
  132. ],
  133. ),
  134. ),
  135. Container(
  136. height: MediaQuery.of(context).size.height-150,
  137. child: PageView(
  138. controller: _page,
  139. onPageChanged: (index){
  140. index==0?_refreshData():_refreshPolicyData();
  141. _selected = index;
  142. },
  143. children: [
  144. Container(
  145. height: MediaQuery.of(context).size.height-150,
  146. child: RefreshIndicator(
  147. onRefresh: _refreshData,
  148. color: Color(0xFFDB5278),
  149. child: ListView.separated(
  150. controller: _scrollPage1,
  151. physics: AlwaysScrollableScrollPhysics(),
  152. itemBuilder: (context,index){
  153. return GestureDetector(
  154. onTap: (){
  155. Navigator.of(context).push(
  156. CupertinoPageRoute(
  157. builder: (context){
  158. return YSQuestionDetail(questionId: _dataArray[index]['id'],isPolicy: _dataArray[index]['type']=='policy',);
  159. }
  160. )
  161. );
  162. },
  163. child: Container(
  164. margin: EdgeInsets.only(left: 5,right: 5),
  165. padding: EdgeInsets.all(15),
  166. height: 160,
  167. decoration: BoxDecoration(
  168. color: Colors.white,
  169. borderRadius: BorderRadius.all(Radius.circular(6))
  170. ),
  171. child: Column(
  172. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  173. children: [
  174. Row(
  175. children: [
  176. Container(
  177. height: 35,
  178. width: 35,
  179. decoration: BoxDecoration(
  180. color: Color(0xFFF5F3F0),
  181. borderRadius: BorderRadius.all(Radius.circular(17.5)),
  182. image: DecorationImage(image: NetworkImage('${_dataArray[index]['doctor_avatar']}'),fit: BoxFit.fill)
  183. ),
  184. ),
  185. Container(
  186. margin: EdgeInsets.only(left: 10),
  187. width: MediaQuery.of(context).size.width-85,
  188. child: Text('${_dataArray[index]['doctor_name']}医生 解答了该问题',style: TextStyle(fontSize: 14,color: Color(0xFF666666)),overflow: TextOverflow.ellipsis,),
  189. )
  190. ],
  191. ),
  192. Container(
  193. width: MediaQuery.of(context).size.width-40,
  194. child: Text('问:${_dataArray[index]['question_body']}',style: TextStyle(fontSize: 14,color: Color(0xFF292929)),overflow: TextOverflow.ellipsis,),
  195. ),
  196. Container(
  197. width: MediaQuery.of(context).size.width-40,
  198. child: _dataArray[index]['answer_type']=='voice'?Row(
  199. children: [
  200. Text('医生解答:',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,),
  201. Container(
  202. height: 26,
  203. width: 59,
  204. decoration: BoxDecoration(
  205. color: Color(0xFFF5F3F0),
  206. borderRadius: BorderRadius.all(Radius.circular(4))
  207. ),
  208. alignment: Alignment.center,
  209. child: Stack(
  210. children: [
  211. Row(
  212. children: [
  213. Container(
  214. child: Image.asset('lib/images/voice2.png'),
  215. height: 15,
  216. width: 15,
  217. margin: EdgeInsets.only(left: 10,right: 5),
  218. ),
  219. Text('4',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,),
  220. ],
  221. )
  222. ],
  223. ),
  224. )
  225. ],
  226. ):Text('医生解答:${(_dataArray[index]['answer_body'])??''}',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,),
  227. ),
  228. Container(
  229. width: MediaQuery.of(context).size.width,
  230. height: 1.5,
  231. child: Image.asset('lib/images/line.png'),
  232. ),
  233. Row(
  234. children: [
  235. Container(
  236. width: MediaQuery.of(context).size.width-85,
  237. child: Text('${_dataArray[index]['question_time']}',style: TextStyle(fontSize: 12,color: Color(0xFF808080)),overflow: TextOverflow.ellipsis,),
  238. ),
  239. GestureDetector(
  240. child: Image(height: 15,width: 15,image: AssetImage(_dataArray[index]['is_favorite']==false?'lib/images/uncollection.png':'lib/images/collection.png'),),
  241. onTap: (){
  242. _postCollectionData(index,false);
  243. },
  244. )
  245. ],
  246. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  247. )
  248. ],
  249. ),
  250. ),
  251. );
  252. },
  253. separatorBuilder: (context,index){
  254. return Divider(height: 5,thickness: 5,color: Color(0xFFF5F3F0),);
  255. },
  256. itemCount: _dataArray.length,
  257. padding: EdgeInsets.only(top: 5,bottom: 5),
  258. ),
  259. ),
  260. ),
  261. Container(
  262. height: MediaQuery.of(context).size.height-150,
  263. child: RefreshIndicator(
  264. onRefresh: _refreshPolicyData,
  265. child: ListView.separated(
  266. controller: _scrollPage2,
  267. itemBuilder: (context,index){
  268. return GestureDetector(
  269. onTap: (){
  270. Navigator.of(context).push(
  271. CupertinoPageRoute(
  272. builder: (context){
  273. return YSQuestionDetail(questionId: _policyArray[index]['id'],isPolicy: _policyArray[index]['type']=='policy',);
  274. }
  275. )
  276. );
  277. },
  278. child: Container(
  279. margin: EdgeInsets.only(left: 5,right: 5),
  280. padding: EdgeInsets.all(15),
  281. height: 160,
  282. decoration: BoxDecoration(
  283. color: Colors.white,
  284. borderRadius: BorderRadius.all(Radius.circular(6))
  285. ),
  286. child: Column(
  287. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  288. children: [
  289. Row(
  290. children: [
  291. Container(
  292. height: 35,
  293. width: 35,
  294. decoration: BoxDecoration(
  295. color: Color(0xFFF5F3F0),
  296. borderRadius: BorderRadius.all(Radius.circular(17.5)),
  297. image: DecorationImage(image: NetworkImage('${_policyArray[index]['doctor_avatar']}'),fit: BoxFit.fill)
  298. ),
  299. ),
  300. Container(
  301. margin: EdgeInsets.only(left: 10),
  302. width: MediaQuery.of(context).size.width-85,
  303. child: Text('${_policyArray[index]['doctor_name']}医生 解答了该问题',style: TextStyle(fontSize: 14,color: Color(0xFF666666)),overflow: TextOverflow.ellipsis,),
  304. )
  305. ],
  306. ),
  307. Container(
  308. width: MediaQuery.of(context).size.width-40,
  309. child: Text('问:${_policyArray[index]['question_body']}',style: TextStyle(fontSize: 14,color: Color(0xFF292929)),overflow: TextOverflow.ellipsis,),
  310. ),
  311. Container(
  312. width: MediaQuery.of(context).size.width-40,
  313. child: _policyArray[index]['answer_type']=='voice'?Row(
  314. children: [
  315. Text('医生解答:',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,),
  316. Container(
  317. height: 26,
  318. width: 59,
  319. decoration: BoxDecoration(
  320. color: Color(0xFFF5F3F0),
  321. borderRadius: BorderRadius.all(Radius.circular(4))
  322. ),
  323. alignment: Alignment.center,
  324. child: Stack(
  325. children: [
  326. Row(
  327. children: [
  328. Container(
  329. child: Image.asset('lib/images/voice2.png'),
  330. height: 15,
  331. width: 15,
  332. margin: EdgeInsets.only(left: 10,right: 5),
  333. ),
  334. Text('4',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,),
  335. ],
  336. )
  337. ],
  338. ),
  339. )
  340. ],
  341. ):Text('医生解答:${(_policyArray[index]['answer_body'])??''}',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,),
  342. ),
  343. Container(
  344. width: MediaQuery.of(context).size.width,
  345. height: 1.5,
  346. child: Image.asset('lib/images/line.png'),
  347. ),
  348. Row(
  349. children: [
  350. Container(
  351. width: MediaQuery.of(context).size.width-85,
  352. child: Text('${_policyArray[index]['created_at']}',style: TextStyle(fontSize: 12,color: Color(0xFF808080)),overflow: TextOverflow.ellipsis,),
  353. ),
  354. // GestureDetector(
  355. // child: Image(height: 15,width: 15,image: AssetImage(_policyArray[index]['is_favorite']==true?'lib/images/collection.png':'lib/images/uncollection.png'),),
  356. // onTap: (){
  357. // _postCollectionData(index,true);
  358. // },
  359. // )
  360. ],
  361. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  362. )
  363. ],
  364. ),
  365. ),
  366. );
  367. },
  368. separatorBuilder: (context,index){
  369. return Divider(height: 5,thickness: 5,color: Color(0xFFF5F3F0),);
  370. },
  371. itemCount: _policyArray.length,
  372. padding: EdgeInsets.only(top: 5,bottom: 5),
  373. physics: AlwaysScrollableScrollPhysics(),
  374. ),
  375. ),
  376. )
  377. ],
  378. ),
  379. ),
  380. ],
  381. ),
  382. ),
  383. );
  384. }
  385. Future<void> _refreshData() async{
  386. SharedPreferences prefer = await SharedPreferences.getInstance();
  387. Map request = Map();
  388. _index = 1;
  389. request['page'] = _index;
  390. request['category_id'] = prefer.getInt('chapters')+1;
  391. request['title'] = searchStr;
  392. Map dict = await ysRequestHttpNoLoading(context, requestType.post, 'question/openQuestion', request);
  393. if(dict!=null){
  394. setState(() {
  395. _dataArray = dict['data']['datas'];
  396. });
  397. }
  398. }
  399. Future<void> _loadMoreData() async{
  400. SharedPreferences prefer = await SharedPreferences.getInstance();
  401. Map request = Map();
  402. _index++;
  403. request['page'] = _index;
  404. request['category_id'] = prefer.getInt('chapters')+1;
  405. request['title'] = searchStr;
  406. Map dict = await ysRequestHttp(context, requestType.post, 'question/openQuestion', request);
  407. if(dict!=null){
  408. setState(() {
  409. _dataArray.addAll(dict['data']['datas']);
  410. });
  411. }
  412. }
  413. Future<void> _refreshPolicyData() async{
  414. Map request = Map();
  415. _policyIndex = 1;
  416. request['page'] = _policyIndex;
  417. request['title'] = searchStr;
  418. Map dict = await ysRequestHttpNoLoading(context, requestType.get, 'policy/list', request);
  419. if(dict!=null){
  420. setState(() {
  421. _policyArray = dict['data'];
  422. });
  423. }
  424. }
  425. Future<void> _loadMorePolicyData() async{
  426. Map request = Map();
  427. _policyIndex++;
  428. request['page'] = _policyIndex;
  429. request['title'] = searchStr;
  430. Map dict = await ysRequestHttp(context, requestType.get, 'policy/list', request);
  431. if(dict!=null){
  432. setState(() {
  433. _policyArray.addAll(dict['data']);
  434. });
  435. }
  436. }
  437. _postCollectionData(int index,bool isPolicy) async{
  438. Map dict = await ysRequestHttpNoLoading(context, requestType.post, 'question/favorite', {'question_id':isPolicy==true?_policyArray[index]['id']:_dataArray[index]['id']});
  439. if(dict!=null){
  440. setState(() {
  441. isPolicy==true?_policyArray[index]['is_favorite'] = dict['data']['is_favorite']:_dataArray[index]['is_favorite'] = dict['data']['is_favorite'];
  442. });
  443. }
  444. }
  445. }
  446. class YSSift extends StatefulWidget {
  447. final int type;
  448. const YSSift({Key key, this.type}) : super(key: key);
  449. @override
  450. _YSSiftState createState() => _YSSiftState();
  451. }
  452. class _YSSiftState extends State<YSSift> {
  453. String searchStr = '';
  454. int _index = 1;
  455. List _dataArray = [];
  456. ScrollController _scroll = ScrollController();
  457. @override
  458. void initState() {
  459. Future.delayed(Duration(seconds: 0)).then((value){
  460. this._refreshData();
  461. _scroll.addListener(() {
  462. if(_scroll.position.pixels == _scroll.position.maxScrollExtent){
  463. this._loadMoreData();
  464. }
  465. });
  466. });
  467. super.initState();
  468. }
  469. @override
  470. Widget build(BuildContext context) {
  471. return YSBase(
  472. ystitle: widget.type==1?'我的提问':'收藏列表',
  473. yschild: SingleChildScrollView(
  474. child: Column(
  475. children: [
  476. widget.type==1?Container(
  477. height: 50,
  478. decoration: BoxDecoration(
  479. color: Colors.white,
  480. borderRadius: BorderRadius.only(topRight: Radius.circular(20),topLeft: Radius.circular(20)),
  481. ),
  482. padding: EdgeInsets.only(left: 20,right: 20,top: 10,bottom: 10),
  483. child: CupertinoTextField(
  484. placeholder: '搜索',
  485. textAlign: TextAlign.center,
  486. style: TextStyle(fontSize: 14,color: Color(0xFF808080),decoration: TextDecoration.none),
  487. placeholderStyle: TextStyle(fontSize: 14,color: Color(0xFF808080),decoration: TextDecoration.none),
  488. decoration: BoxDecoration(
  489. borderRadius: BorderRadius.all(Radius.circular(15)),
  490. color: Color(0xFFF5F3F0)
  491. ),
  492. textInputAction: TextInputAction.search,
  493. onSubmitted: (value){
  494. if(value!=null){
  495. searchStr = value;
  496. _refreshData();
  497. }
  498. },
  499. ),
  500. ):Container(),
  501. Container(
  502. height: widget.type==1?MediaQuery.of(context).size.height-150:MediaQuery.of(context).size.height-75,
  503. child: _dataArray.length==0?Container(
  504. alignment: Alignment.center,
  505. child: Image.asset('lib/images/none.png',height: 200,width: 200,),
  506. ):ListView.separated(
  507. itemBuilder: (context,index){
  508. return GestureDetector(
  509. onTap: (){
  510. Navigator.of(context).push(
  511. CupertinoPageRoute(
  512. builder: (context){
  513. return YSQuestionDetail(questionId: _dataArray[index]['id'],isPolicy: _dataArray[index]['type']=='policy',);
  514. }
  515. )
  516. );
  517. },
  518. child: Container(
  519. margin: EdgeInsets.only(left: 5,right: 5),
  520. padding: EdgeInsets.all(15),
  521. height: 160,
  522. decoration: BoxDecoration(
  523. color: Colors.white,
  524. borderRadius: BorderRadius.all(Radius.circular(6))
  525. ),
  526. child: Column(
  527. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  528. children: [
  529. Row(
  530. children: [
  531. Container(
  532. height: 35,
  533. width: 35,
  534. decoration: BoxDecoration(
  535. color: Color(0xFFF5F3F0),
  536. borderRadius: BorderRadius.all(Radius.circular(17.5)),
  537. image: DecorationImage(image: NetworkImage('${_dataArray[index]['doctor_avatar']}'),fit: BoxFit.fill)
  538. ),
  539. ),
  540. Container(
  541. margin: EdgeInsets.only(left: 10),
  542. width: MediaQuery.of(context).size.width-85,
  543. child: Text('${_dataArray[index]['doctor_name']}医生 解答了该问题',style: TextStyle(fontSize: 14,color: Color(0xFF666666)),overflow: TextOverflow.ellipsis,),
  544. )
  545. ],
  546. ),
  547. Container(
  548. width: MediaQuery.of(context).size.width-40,
  549. child: Text('问:${_dataArray[index]['question_title']}',style: TextStyle(fontSize: 14,color: Color(0xFF292929)),overflow: TextOverflow.ellipsis,),
  550. ),
  551. Container(
  552. width: MediaQuery.of(context).size.width-40,
  553. child: _dataArray[index]['answer_type']=='voice'?Row(
  554. children: [
  555. Text('医生解答:',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,),
  556. Container(
  557. height: 26,
  558. width: 59,
  559. decoration: BoxDecoration(
  560. color: Color(0xFFF5F3F0),
  561. borderRadius: BorderRadius.all(Radius.circular(4))
  562. ),
  563. alignment: Alignment.center,
  564. child: Stack(
  565. children: [
  566. Row(
  567. children: [
  568. Container(
  569. child: Image.asset('lib/images/voice2.png'),
  570. height: 15,
  571. width: 15,
  572. margin: EdgeInsets.only(left: 10,right: 5),
  573. ),
  574. Text('4',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,),
  575. ],
  576. )
  577. ],
  578. ),
  579. )
  580. ],
  581. ):Text('医生解答:${(_dataArray[index]['answer_body'])??''}',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,),
  582. ),
  583. Container(
  584. width: MediaQuery.of(context).size.width,
  585. height: 1.5,
  586. child: Image.asset('lib/images/line.png'),
  587. ),
  588. Row(
  589. children: [
  590. Container(
  591. width: MediaQuery.of(context).size.width-85,
  592. child: Text('${_dataArray[index]['question_time']??_dataArray[index]['created_at']??''}',style: TextStyle(fontSize: 12,color: Color(0xFF808080)),overflow: TextOverflow.ellipsis,),
  593. ),
  594. GestureDetector(
  595. child: Image(height: 15,width: 15,image: AssetImage(_dataArray[index]['is_favorite']==false?'lib/images/uncollection.png':'lib/images/collection.png'),),
  596. onTap: (){
  597. _postCollectionData(index,false);
  598. },
  599. )
  600. ],
  601. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  602. )
  603. ],
  604. ),
  605. ),
  606. );
  607. },
  608. separatorBuilder: (context,index){
  609. return Divider(height: 5,thickness: 5,color: Color(0xFFF5F3F0),);
  610. },
  611. itemCount: _dataArray.length,
  612. padding: EdgeInsets.only(top: 5,bottom: 5),
  613. ),
  614. )
  615. ],
  616. ),
  617. ),
  618. );
  619. }
  620. Future<void> _refreshData() async{
  621. Map request = Map();
  622. _index = 1;
  623. request['page'] = _index;
  624. if(widget.type==1){
  625. request['title'] = searchStr;
  626. }
  627. Map dict = await ysRequestHttpNoLoading(context, widget.type==1?requestType.post:requestType.get, widget.type==1?'question/selfQuestion':'question/favoriteList', request);
  628. if(dict!=null){
  629. setState(() {
  630. _dataArray = dict['data']['datas']??[];
  631. });
  632. }
  633. }
  634. Future<void> _loadMoreData() async{
  635. Map request = Map();
  636. _index++;
  637. request['page'] = _index;
  638. if(widget.type==1){
  639. request['title'] = searchStr;
  640. }
  641. Map dict = await ysRequestHttpNoLoading(context, widget.type==1?requestType.post:requestType.get, widget.type==1?'question/selfQuestion':'question/favoriteList', request);
  642. if(dict!=null){
  643. setState(() {
  644. _dataArray.addAll(dict['data']['datas']??[]);
  645. });
  646. }
  647. }
  648. _postCollectionData(int index,bool isPolicy) async{
  649. Map dict = await ysRequestHttpNoLoading(context, requestType.post, 'question/favorite', {'question_id':_dataArray[index]['id']});
  650. if(dict!=null){
  651. setState(() {
  652. _dataArray[index]['is_favorite'] = dict['data']['is_favorite'];
  653. });
  654. }
  655. }
  656. }