YSMineLiveDataView.dart 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:flutterappfuyou/code/base/YSNetWorking.dart';
  4. import '../../base/YSTools.dart';
  5. import '../../live/YSLiveAnchor.dart';
  6. class YSMineLiveDataView extends StatefulWidget {
  7. final f;
  8. const YSMineLiveDataView({Key key, this.f}) : super(key: key);
  9. @override
  10. _YSMineLiveDataViewState createState() => _YSMineLiveDataViewState();
  11. }
  12. GlobalKey<_YSMineLiveDataViewState> liveDataKey = GlobalKey();
  13. class _YSMineLiveDataViewState extends State<YSMineLiveDataView> {
  14. List _dataArray = [];
  15. refresh(){
  16. refreshKey.currentState.refresh();
  17. }
  18. @override
  19. Widget build(BuildContext context) {
  20. return YSRefreshLoad(
  21. key: refreshKey,
  22. postData: (value) {
  23. _dataArray = value;
  24. setState(() {});
  25. },
  26. url: 'train/live2/list',
  27. request: {'user_id':User().userId},
  28. dataWidget: SingleChildScrollView(
  29. child: GridView.builder(gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
  30. childAspectRatio: 170/230,
  31. crossAxisCount: 2,
  32. crossAxisSpacing: 10,
  33. mainAxisSpacing: 10
  34. ), itemBuilder: (context,index){
  35. Map item = _dataArray[index];
  36. return GestureDetector(
  37. onTap: (){
  38. Navigator.of(context).push(
  39. CupertinoPageRoute(builder: (context){
  40. return YSLiveAnchor(liveId: item['id'],isSelect: false,);
  41. })
  42. ).then((value) {
  43. if(value!=null){
  44. refreshKey.currentState.refresh();
  45. }
  46. });
  47. },
  48. behavior: HitTestBehavior.opaque,
  49. child: ClipRRect(
  50. borderRadius: BorderRadius.all(Radius.circular(5)),
  51. child: Container(
  52. color: Colors.white,
  53. child: LayoutBuilder(
  54. builder: (context,conSize){
  55. return Stack(
  56. children: [
  57. Container(
  58. child: Column(
  59. children: [
  60. Image.network(item['cover'],width: conSize.maxWidth,height: conSize.maxHeight*0.6,fit: BoxFit.cover,),
  61. Container(
  62. height: conSize.maxHeight*0.15,
  63. width: conSize.maxWidth,
  64. padding: EdgeInsets.only(left: 8,right: 8,top: 5,bottom: 5),
  65. child: Text('${item['title']}',style: TextStyle(fontSize: 12,color: Color(0xFF333333)),maxLines: 2,overflow: TextOverflow.ellipsis,),
  66. ),
  67. Container(
  68. height: conSize.maxHeight*0.1,
  69. padding: EdgeInsets.only(left: 8,right: 8),
  70. alignment: Alignment.centerLeft,
  71. child: RichText(
  72. text: TextSpan(
  73. style: TextStyle(fontSize: 9,color: Color(0xFFE26085)),
  74. children: [
  75. WidgetSpan(
  76. child: Image.asset('lib/images/直播时间.png',height: 15,width: 15,)
  77. ),
  78. TextSpan(
  79. text: ' ${item['expect_start']}'
  80. )
  81. ]
  82. ),
  83. ),
  84. ),
  85. Container(
  86. margin: EdgeInsets.only(left: 8,right: 8),
  87. height: conSize.maxHeight*0.15,
  88. decoration: BoxDecoration(
  89. border: Border(top: BorderSide(color: Color(0xFFE8E8E8),width: 0.5))
  90. ),
  91. child: Row(
  92. children: [
  93. Container(
  94. width: conSize.maxWidth-56,
  95. child: RichText(
  96. text: TextSpan(
  97. style: TextStyle(fontSize: 10,color: Color(0xFF333333)),
  98. children: [
  99. TextSpan(
  100. text: '状态:'
  101. ),
  102. TextSpan(
  103. text: '${item['status_string']}',
  104. style: TextStyle(color: Color(item['status']=='created'?0xFF01B10D:0xFF333333)),
  105. )
  106. ]
  107. ),
  108. ),
  109. ),
  110. if(item['status']=='created')GestureDetector(
  111. onTap: (){
  112. ysShowBottomAlertView(context, YSTipsAlertView(
  113. tipsStr: '是否删除此直播?',
  114. valueSetter: (value) async{
  115. Map dict = await ysRequestHttp(context, requestType.delete, 'train/live2/delete', {'live_id':item['id']});
  116. if(dict!=null){
  117. refreshKey.currentState.refresh();
  118. }
  119. },
  120. ));
  121. },
  122. behavior: HitTestBehavior.opaque,
  123. child: Container(
  124. width: 40,
  125. height: 15,
  126. decoration: BoxDecoration(
  127. border: Border.all(color: Color(0xFFB4B4B4),width: 0.5),
  128. borderRadius: BorderRadius.all(Radius.circular(3))
  129. ),
  130. alignment: Alignment.center,
  131. child: Text('删除',style: TextStyle(fontSize: 8,color: Color(0xFFA0A0A0)),),
  132. ),
  133. )
  134. ],
  135. ),
  136. )
  137. ],
  138. ),
  139. )
  140. ],
  141. );
  142. },
  143. ),
  144. ),
  145. ),
  146. );
  147. },itemCount: _dataArray.length,padding: EdgeInsets.only(top: 10,bottom: 10,left: 5,right: 5),shrinkWrap: true,physics: NeverScrollableScrollPhysics(),),
  148. ),
  149. );
  150. }
  151. }