import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutterappfuyou/code/YSUserInfo.dart';
import 'package:flutterappfuyou/code/base/YSBase.dart';
import 'package:flutterappfuyou/code/base/YSTools.dart';
import 'package:flutterappfuyou/code/version2/YSMineLiveAdd.dart';
import 'package:flutterappfuyou/code/version2/view/YSMineLiveDataView.dart';

class YSMineLive extends StatefulWidget {
  const YSMineLive({Key key}) : super(key: key);

  @override
  _YSMineLiveState createState() => _YSMineLiveState();
}

class _YSMineLiveState extends State<YSMineLive> with SingleTickerProviderStateMixin{
  List _titleArray = [
    {'title':'全部'},
    {'title':'预告'},
    {'title':'直播中'},
    {'title':'已结束'}
  ];
  TabController _tabController;
  @override
  void initState() {
    _tabController = TabController(
      vsync: this,
      length: _titleArray.length
    );
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return YSBase(
      ystitle: '直播',
      yschild: Container(
        padding: EdgeInsets.only(top: 20),
        child: DefaultTabController(
          length: _titleArray.length,
          child: Column(
            children: [
              Container(
                height: 80,
                decoration: BoxDecoration(
                  border: Border(bottom: BorderSide(color: Color(0xFFE26085),width: 0.1))
                ),
                padding: EdgeInsets.only(left: 20,right: 20),
                child: Row(
                  children: [
                    Container(
                      height: 50,
                      width: 50,
                      decoration: BoxDecoration(
                        image: DecorationImage(image: NetworkImage(User().avatar),fit: BoxFit.cover),
                        color: Color(0xFFE26085),
                        borderRadius: BorderRadius.all(Radius.circular(50))
                      ),
                    ),
                    Container(
                      height: 80,
                      width: ysWidth(context)-170,
                      padding: EdgeInsets.only(left: 10,right: 10),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.center,
                        mainAxisSize: MainAxisSize.min,
                        children: [
                          Text(User().name,style: TextStyle(fontSize: 16,color: Color(0xFF222222),fontWeight: FontWeight.normal),),
                          Container(
                            padding: EdgeInsets.only(top: 3),
                            child: Text('主讲老师',style: TextStyle(fontSize: 12,color: Color(0xFFB4B4B4)),),
                          )
                        ],
                      ),
                    ),
                    GestureDetector(
                      onTap: (){
                        Navigator.of(context).push(
                          CupertinoPageRoute(builder: (context){
                            return YSMineLiveAdd();
                          })
                        ).then((value) {
                          liveDataKey.currentState.refresh();
                        });
                      },
                      child: Container(
                        width: 80,
                        height: 30,
                        decoration: BoxDecoration(
                          color: Color(0xFFE26085),
                          borderRadius: BorderRadius.all(Radius.circular(2))
                        ),
                        alignment: Alignment.center,
                        child: Text('我要直播',style: TextStyle(fontSize: 12,color: Colors.white),),
                      ),
                    )
                  ],
                ),
              ),
              Container(
                height: ysHeight(context)-ysTOP(context)-150,
                width: ysWidth(context),
                color: Color(0xFFF0F0F1),
                child: YSMineLiveDataView(f: {'title':'全部'},key: liveDataKey,),
              )
              // Container(
              //   width: ysWidth(context),
              //   height: 50,
              //   child: TabBar(
              //     controller: _tabController,
              //     isScrollable: true,
              //     indicatorColor: Color(0xFFFA4444),
              //     labelColor: Color(0xFFFA4444),
              //     indicatorWeight: 2,
              //     indicatorSize: TabBarIndicatorSize.label,
              //     labelStyle: TextStyle(fontSize: 15),
              //     unselectedLabelColor: Color(0xFF5D6978),
              //     tabs: _titleArray.map((f) {
              //       return Tab(text: '${f['title']}');
              //     }).toList(),
              //   )
              //   ,
              // ),
              // Container(
              //   height: ysHeight(context)-ysTOP(context)-200,
              //   width: ysWidth(context),
              //   color: Color(0xFFF0F0F1),
              //   child: TabBarView(
              //     controller: _tabController,
              //     children: _titleArray.map((f) {
              //       return YSMineLiveDataView(f: f,);
              //     }).toList(),
              //   ),
              // )
            ],
          ),
        ),
      ),
    );
  }
}


