import 'package:flutter/material.dart';
import 'package:flutterappfuyou/code/base/YSBase.dart';
import 'package:flutterappfuyou/code/base/YSTools.dart';
import 'package:flutterappfuyou/code/version3/view/YSInstitutionListItemView.dart';
import 'package:flutterappfuyou/code/version3/view/YSSearchView.dart';
import 'package:flutter_webview_pro/webview_flutter.dart';

import '../base/YSNetWorking.dart';

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

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

class _YSInstitutionState extends State<YSInstitution> with SingleTickerProviderStateMixin{
  List _dataArray = [];
  @override
  void initState() {
    Future.delayed(Duration(seconds: 0)).then((value) {
      _getInstitutionData();
    });
    super.initState();
  }
  _getInstitutionData() async{
    Map dict = await ysRequestHttpNoLoading(context, requestType.post, 'transfer/coupon/getRecommendedHospitals', {'idcard':User().idCard});
    if(dict!=null){
      _dataArray = dict['data']??[];
      setState(() {});
    }
  }
  @override
  Widget build(BuildContext context) {
    return YSBase(
      ystitle: '机构列表',
      ysBgColor: Color(0xFFF1F1F1),
      yschild: Container(
        height: ysHeight(context)-ysTOP(context)-100,
        child: ListView.separated(itemBuilder: (context,index){
          Map item = _dataArray[index];
          return YSInstitutionListItemView(item: item,);
        },
        separatorBuilder: (context,index){
          return Container(height: 15,);
        },
        itemCount: _dataArray.length,padding: EdgeInsets.only(left: 15,right: 15,bottom: 15,top: 15),),
      )
      ,
    );
  }
}
