import 'package:flutter/material.dart';
import 'package:flutterappfuyou/code/base/YSBase.dart';

import '../../base/YSTools.dart';
import 'YSCommunityListItemView.dart';

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

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

class _YSCouponCommunityState extends State<YSCouponCommunity> {
  List _dataArray2= [];
  @override
  Widget build(BuildContext context) {
    return YSBase(
      ystitle: '社区体检券',
      yschild: NotificationListener<CustomerNotification>(
        onNotification: (value){
          refreshKey3.currentState.refresh();
          return true;
        },
        child: Container(
          height: ysHeight(context),
          width: ysWidth(context),
          child: YSRefreshLoad(
            key: refreshKey3,
            request: {'idcard':User().idCard},
            url: 'transfer/coupon/getCommunityVouchers',
            postData: (value){
              _dataArray2 = value;
              setState(() {});
            },
            dataWidget: SingleChildScrollView(
              child: ListView.separated(
                itemBuilder: (context,index){
                  Map item = _dataArray2[index];
                  return YSCommunityListItemView(item: item);
                },
                separatorBuilder: (context,index){
                  return Container(height: 10,);
                },
                itemCount: _dataArray2.length,
                padding: EdgeInsets.only(top: 15,bottom: 15),
                shrinkWrap: true,
                physics: NeverScrollableScrollPhysics(),
              ),
            ),
          ),
        ),
      ),
    );
  }
}
