part of user_coupon;


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

  @override
  State<UserCouponPage> createState() => _UserCouponPageState();
}

class _UserCouponPageState extends State<UserCouponPage> {
  @override
  Widget build(BuildContext context) {
    return GetBuilder<UserCouponController>(
      init: UserCouponController(),
      builder:(controller) => Scaffold(
        appBar: AppBar(
          centerTitle: true,
          title: const Text('优惠券'),
        ),
        body: CustomPullScrollView(
          controller: controller.refreshController,
          onRefresh: controller.onRefresh,
          onLoading: controller.onLoading,
          child: controller.coupons.isEmpty?Container(
            padding: EdgeInsets.only(top: 110.w),
            alignment: Alignment.center,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                SizedBox(height: 152.w, width: 195.w,
                  child: Image.asset( 'assets/images/none.png',),),
                SizedBox(height: 13.w,),
              ],
            ),
          ):ListView.builder(
              itemBuilder: (BuildContext context, int index){
                return BuildItem(model: controller.coupons[index],);
                // if (index == controller.coupons.length){
                //   return GestureDetector(
                //     onTap: (){
                //       // controller.getOverCoupons();
                //     },
                //     child: Container(
                //       alignment: Alignment.center,
                //       height: 40.w,
                //       // color: Colors.cyan,
                //       child: Text('过期优惠券'),
                //     ),
                //   );
                // }
                // else {
                //   return BuildItem(model: controller.coupons[index],);
                // }
              },
              // itemCount: controller.coupons.length +1,
            itemCount: controller.coupons.length,
          ),
        ),
      ),
    );
  }
}
