part of user_order;

class UserOrderPage extends StatefulWidget {
  const UserOrderPage({Key? key /*, required this.userInfo*/
      })
      : super(key: key);

  @override
  State<UserOrderPage> createState() => _UserOrderState();
}

List<Tab> tabs = [
  const Tab(
    text: '全部',
  ),
  const Tab(
    text: '待支付',
  ),
  const Tab(
    text: '已取消',
  ),
  const Tab(
    text: '已完成',
  ),
  const Tab(
    text: '已退款',
  ),
];
int tab = 0;

class _UserOrderState extends State<UserOrderPage>
    with SingleTickerProviderStateMixin {
  late TabController _tabController; // 选中的性别
  late TextEditingController searchController = TextEditingController();

  @override
  void initState() {
    _tabController = TabController(length: tabs.length, vsync: this);
    super.initState();

    // 在这里可以使用 localVariable 进行操作
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Container(
          padding: EdgeInsets.only(right: 10.w),
          child: CustomInputSearch(
            controller: searchController,
            readOnly: true,
            hintText: '搜索我的订单',
            onTap: () {
              context.pushNamed(Routes.orderSearch);
            },
          ),
        ),

        titleSpacing: 0,
      ),
      body: _buildBody(),
    );
  }

  Widget _buildBody() {
    return DefaultTabController(
        length: tabs.length,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            ClipRRect(
              borderRadius: const BorderRadius.only(
                  topLeft: Radius.circular(5), topRight: Radius.circular(5)),
              child: Container(
                width: double.infinity,
                color: Colors.white,
                height: 35.w,
                child: TabBar(
                    labelPadding: EdgeInsets.symmetric(horizontal: 15.w),
                    indicatorSize: TabBarIndicatorSize.label,
                    indicatorColor: AppTheme.primary,
                    indicatorWeight: 1.5,
                    labelStyle: TextStyle(
                        color: AppTheme.primary,
                        fontSize: 15.w,
                        height: 1.5,
                        fontWeight: Fonts.boldSemi),
                    unselectedLabelColor: Colours.c9,
                    unselectedLabelStyle: TextStyle(
                        color: Colours.c9, fontSize: 15.w, height: 1.5),
                    isScrollable: true,
                    controller: _tabController,
                    tabs: tabs),
              ),
            ),
            Expanded(
              child: TabBarView(
                  controller: _tabController,
                  children: List.generate(tabs.length, (index) {
                    tab = index;
                    return BuildListPage(
                      tag:
                          tab, /* models:controller.orderList,*/ /*controller: controller,*/ /*,context: context,*/
                    );
                  })),
            )
          ],
        ));
  }
}
