part of pay_coupon;



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

  @override
  State<PayCouponPage> createState() => _PayCouponPageState();
}

class _PayCouponPageState extends State<PayCouponPage> {
  @override
  Widget build(BuildContext context) {
    return GetBuilder<PayCouponController>(
      init: PayCouponController('main'),
      builder: (controller) =>Scaffold(
        appBar: AppBar(
          centerTitle: true,
          title: const Text('选择优惠券'),
        ),
        body: Column(
          children: [
            TabBar(
              labelColor: Colours.c3,
              labelStyle: TextStyle(fontSize: 15.w,height: 1.4,fontWeight: Fonts.medium),
              unselectedLabelColor: Colours.c9,
              unselectedLabelStyle: TextStyle(fontSize: 15.w,height: 1.4),
              indicatorSize: TabBarIndicatorSize.label,
              indicatorColor: AppTheme.primary,
              tabs:controller.tabs,
              physics: const NeverScrollableScrollPhysics(),
              controller: controller.tabController,
            ),
            Expanded(
              child: TabBarView(
                controller: controller.tabController,
                children: List.generate(controller.tabs.length, (index){
                  return CouponPage(tag:'$index');
                })
              ),
            ),
          ],
        ),
      ),
    );
  }
}

class CouponPage extends StatefulWidget {
  final String tag;
  const CouponPage({
    Key? key,
    required this.tag
  }) : super(key: key);

  @override
  State<CouponPage> createState() => _CouponPageState();
}

class _CouponPageState extends State<CouponPage> {
  @override
  Widget build(BuildContext context) {
    return  GetBuilder<PayCouponController>(
      init: PayCouponController(widget.tag),
      builder: (controller) =>CustomPullScrollView(
        controller: controller.refreshController,
        onRefresh: controller.onRefresh,
        onLoading: controller.onLoading,
        child: ListView.builder(
          itemBuilder: (BuildContext context, int index){
            CouponModel model = controller.coupons[index];
            return BuildItem(model:model,);
          },
          itemCount: controller.coupons.length,
        ),
      ),
    );
  }
}





