123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/material.dart';
- import 'package:flutterappfuyou/code/base/YSNetWorking.dart';
- import '../../base/YSTools.dart';
- import '../../live/YSLiveAnchor.dart';
- class YSMineLiveDataView extends StatefulWidget {
- final f;
- const YSMineLiveDataView({Key key, this.f}) : super(key: key);
- @override
- _YSMineLiveDataViewState createState() => _YSMineLiveDataViewState();
- }
- GlobalKey<_YSMineLiveDataViewState> liveDataKey = GlobalKey();
- class _YSMineLiveDataViewState extends State<YSMineLiveDataView> {
- List _dataArray = [];
- refresh(){
- refreshKey.currentState.refresh();
- }
- @override
- Widget build(BuildContext context) {
- return YSRefreshLoad(
- key: refreshKey,
- postData: (value) {
- _dataArray = value;
- setState(() {});
- },
- url: 'train/live2/list',
- request: {'user_id':User().userId},
- dataWidget: SingleChildScrollView(
- child: GridView.builder(gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
- childAspectRatio: 170/230,
- crossAxisCount: 2,
- crossAxisSpacing: 10,
- mainAxisSpacing: 10
- ), itemBuilder: (context,index){
- Map item = _dataArray[index];
- return GestureDetector(
- onTap: (){
- Navigator.of(context).push(
- CupertinoPageRoute(builder: (context){
- return YSLiveAnchor(liveId: item['id'],isSelect: false,);
- })
- ).then((value) {
- if(value!=null){
- refreshKey.currentState.refresh();
- }
- });
- },
- behavior: HitTestBehavior.opaque,
- child: ClipRRect(
- borderRadius: BorderRadius.all(Radius.circular(5)),
- child: Container(
- color: Colors.white,
- child: LayoutBuilder(
- builder: (context,conSize){
- return Stack(
- children: [
- Container(
- child: Column(
- children: [
- Image.network(item['cover'],width: conSize.maxWidth,height: conSize.maxHeight*0.6,fit: BoxFit.cover,),
- Container(
- height: conSize.maxHeight*0.15,
- width: conSize.maxWidth,
- padding: EdgeInsets.only(left: 8,right: 8,top: 5,bottom: 5),
- child: Text('${item['title']}',style: TextStyle(fontSize: 12,color: Color(0xFF333333)),maxLines: 2,overflow: TextOverflow.ellipsis,),
- ),
- Container(
- height: conSize.maxHeight*0.1,
- padding: EdgeInsets.only(left: 8,right: 8),
- alignment: Alignment.centerLeft,
- child: RichText(
- text: TextSpan(
- style: TextStyle(fontSize: 9,color: Color(0xFFE26085)),
- children: [
- WidgetSpan(
- child: Image.asset('lib/images/直播时间.png',height: 15,width: 15,)
- ),
- TextSpan(
- text: ' ${item['expect_start']}'
- )
- ]
- ),
- ),
- ),
- Container(
- margin: EdgeInsets.only(left: 8,right: 8),
- height: conSize.maxHeight*0.15,
- decoration: BoxDecoration(
- border: Border(top: BorderSide(color: Color(0xFFE8E8E8),width: 0.5))
- ),
- child: Row(
- children: [
- Container(
- width: conSize.maxWidth-56,
- child: RichText(
- text: TextSpan(
- style: TextStyle(fontSize: 10,color: Color(0xFF333333)),
- children: [
- TextSpan(
- text: '状态:'
- ),
- TextSpan(
- text: '${item['status_string']}',
- style: TextStyle(color: Color(item['status']=='created'?0xFF01B10D:0xFF333333)),
- )
- ]
- ),
- ),
- ),
- if(item['status']=='created')GestureDetector(
- onTap: (){
- ysShowBottomAlertView(context, YSTipsAlertView(
- tipsStr: '是否删除此直播?',
- valueSetter: (value) async{
- Map dict = await ysRequestHttp(context, requestType.delete, 'train/live2/delete', {'live_id':item['id']});
- if(dict!=null){
- refreshKey.currentState.refresh();
- }
- },
- ));
- },
- behavior: HitTestBehavior.opaque,
- child: Container(
- width: 40,
- height: 15,
- decoration: BoxDecoration(
- border: Border.all(color: Color(0xFFB4B4B4),width: 0.5),
- borderRadius: BorderRadius.all(Radius.circular(3))
- ),
- alignment: Alignment.center,
- child: Text('删除',style: TextStyle(fontSize: 8,color: Color(0xFFA0A0A0)),),
- ),
- )
- ],
- ),
- )
- ],
- ),
- )
- ],
- );
- },
- ),
- ),
- ),
- );
- },itemCount: _dataArray.length,padding: EdgeInsets.only(top: 10,bottom: 10,left: 5,right: 5),shrinkWrap: true,physics: NeverScrollableScrollPhysics(),),
- ),
- );
- }
- }
|