YSWikiListView.dart 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutterappfuyou/code/base/YSTools.dart';
  4. import 'package:flutterappfuyou/code/version2/YSUrlPage.dart';
  5. import '../../base/YSNetWorking.dart';
  6. class YSWikiListView extends StatefulWidget {
  7. final Map wikiItem;
  8. final VoidCallback callback;
  9. const YSWikiListView({Key key, this.wikiItem, this.callback}) : super(key: key);
  10. @override
  11. _YSWikiListViewState createState() => _YSWikiListViewState();
  12. }
  13. class _YSWikiListViewState extends State<YSWikiListView> {
  14. @override
  15. Widget build(BuildContext context) {
  16. return GestureDetector(
  17. onTap: (){
  18. Navigator.of(context,rootNavigator: true).push(
  19. CupertinoPageRoute(builder: (context){
  20. return YSUrlPage(url: widget.wikiItem['preview_url'],title: widget.wikiItem['title'],wiki: widget.wikiItem,isCollection: widget.wikiItem['is_favorite']??false,);
  21. })
  22. ).then((value) {
  23. if(widget.callback!=null){
  24. widget.callback();
  25. }
  26. });
  27. },
  28. behavior: HitTestBehavior.opaque,
  29. child: Container(
  30. child: widget.wikiItem['covers'].length==1?Container(
  31. height: 90,
  32. child: Row(
  33. children: [
  34. Container(
  35. height: 70,
  36. width: 100,
  37. decoration: BoxDecoration(
  38. color: Color(0xFFF7CCC8),
  39. image: DecorationImage(
  40. fit: BoxFit.cover,
  41. image: NetworkImage('${widget.wikiItem['covers'][0]}')
  42. )
  43. ),
  44. ),
  45. Container(
  46. margin: EdgeInsets.only(left: 10),
  47. // height: 60,
  48. width: MediaQuery.of(context).size.width-140,
  49. child: Column(
  50. crossAxisAlignment: CrossAxisAlignment.start,
  51. mainAxisSize: MainAxisSize.min,
  52. children: [
  53. Text('${widget.wikiItem['title']}',style: TextStyle(color: Color(0xFF0F0F0F),fontSize: 14,decoration: TextDecoration.none,fontWeight: FontWeight.w600),
  54. maxLines: 1,overflow: TextOverflow.ellipsis,textAlign: TextAlign.left,),
  55. Container(
  56. margin: EdgeInsets.only(top: 5,bottom: 10),
  57. child: Text('${widget.wikiItem['contributor']}',style: TextStyle(color: Color(0xFF0F0F0F),fontSize: 11,
  58. decoration: TextDecoration.none,fontWeight: FontWeight.normal),maxLines: 2,overflow: TextOverflow.ellipsis,),
  59. ),
  60. Row(
  61. children: [
  62. Container(
  63. width: MediaQuery.of(context).size.width-240,
  64. child: Text('${widget.wikiItem['created_at']}',style: TextStyle(color: Color(0xFF0F0F0F),fontSize: 11,
  65. decoration: TextDecoration.none,fontWeight: FontWeight.normal),maxLines: 2,overflow: TextOverflow.ellipsis,),
  66. ),
  67. Container(
  68. alignment: Alignment.center,
  69. child: Row(
  70. children: [
  71. Icon(Icons.remove_red_eye_outlined,size: 10,color: Colors.grey,),
  72. Container(
  73. padding: EdgeInsets.only(left: 1),
  74. width: 40,
  75. child: Text('${widget.wikiItem['views']}',style: TextStyle(color: Colors.grey,fontSize: 11,
  76. decoration: TextDecoration.none,fontWeight: FontWeight.normal),maxLines: 1,overflow: TextOverflow.ellipsis,),
  77. )
  78. ],
  79. ),
  80. ),
  81. Container(
  82. alignment: Alignment.center,
  83. child: GestureDetector(
  84. onTap: () async{
  85. Map dict = await ysRequestHttpNoLoading(context, requestType.put, 'wike/like', {'wike_id':widget.wikiItem['id']});
  86. if(dict!=null){
  87. widget.wikiItem['is_like'] = dict['data']['is_like'];
  88. widget.wikiItem['count_like'] = dict['data']['count_like'];
  89. setState(() {});
  90. }
  91. },
  92. child: Row(
  93. children: [
  94. Icon(Icons.favorite,size: 10,color: widget.wikiItem['is_like']==true?Colors.pinkAccent:Colors.grey,),
  95. Container(
  96. width: 40,
  97. padding: EdgeInsets.only(left: 1),
  98. child: Text('${widget.wikiItem['count_like']}',style: TextStyle(color: Colors.grey,fontSize: 11,
  99. decoration: TextDecoration.none,fontWeight: FontWeight.normal),maxLines: 1,overflow: TextOverflow.ellipsis,),
  100. )
  101. ],
  102. ),
  103. ),
  104. ),
  105. ],
  106. )
  107. ],
  108. ),
  109. )
  110. ],
  111. ),
  112. ):Container(
  113. height: 145,
  114. padding: EdgeInsets.only(top: 5,bottom: 5),
  115. child: Column(
  116. crossAxisAlignment: CrossAxisAlignment.start,
  117. children: [
  118. Text('${widget.wikiItem['title']}',style: TextStyle(color: Color(0xFF0F0F0F),fontSize: 14,decoration: TextDecoration.none,fontWeight: FontWeight.w600),
  119. maxLines: 1,overflow: TextOverflow.ellipsis,textAlign: TextAlign.left,),
  120. Container(
  121. margin: EdgeInsets.only(top: 5,bottom: 5),
  122. child: Text('${widget.wikiItem['introduction']}',style: TextStyle(color: Color(0xFF0F0F0F),fontSize: 11,
  123. decoration: TextDecoration.none,fontWeight: FontWeight.normal),maxLines: 2,overflow: TextOverflow.ellipsis,),
  124. ),
  125. Row(
  126. children: [
  127. for(int i = 0;i<widget.wikiItem['covers'].length;i++)Container(
  128. height: 70,
  129. margin: EdgeInsets.only(right: 10),
  130. width: (MediaQuery.of(context).size.width-50)/3,
  131. decoration: BoxDecoration(
  132. color: Color(0xFFF7CCC8),
  133. image: DecorationImage(
  134. fit: BoxFit.fill,
  135. image: NetworkImage('${widget.wikiItem['covers'][i]}')
  136. )
  137. ),
  138. )
  139. ]
  140. )
  141. ],
  142. ),
  143. ),
  144. ),
  145. );
  146. }
  147. }