import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/order/order_history_page.dart';
import 'package:huixiang/view_widget/login_tips_dialog.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/view_widget/my_tab.dart';
import 'package:shared_preferences/shared_preferences.dart';

class OrderPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _OrderPage();
  }
}

class _OrderPage extends State<OrderPage>
    with SingleTickerProviderStateMixin {
  TabController tabcontroller;

  List<String> lables = [
    "全部",
    "待付款",
    "未完成",
    "已完成",
  ];

  @override
  void initState() {
    super.initState();

    if (tabcontroller == null)
      tabcontroller = TabController(length: lables.length, vsync: this, initialIndex: 1);
  }

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 4,
      child: Scaffold(
        appBar: MyAppBar(
          title: "",
          leading: false,
          bottom: TabBar(
            // isScrollable: true, //可滚动
            indicatorColor: Color(0xff39B54A),
            labelColor: Colors.black,
            labelStyle: TextStyle(
              fontSize: 17.sp,
              fontWeight: FontWeight.bold,
            ),
            unselectedLabelStyle: TextStyle(
              fontSize: 16.sp,
              fontWeight: FontWeight.normal,
            ),
            // controller: tabController,
            //未选中文字颜色
            unselectedLabelColor: Color(0xffA29E9E),
            indicatorSize: TabBarIndicatorSize.label,
            //指示器与文字等宽
            tabs: <Widget>[
              MyTab(text: S.of(context).quanbu),
              MyTab(text: S.of(context).daifukuan),
              MyTab(text: S.of(context).weiwancheng),
              MyTab(text: S.of(context).yiwancheng),
            ],
          ),
        ),
        body: TabBarView(
          children: [OrderHistoryList(0),OrderHistoryList(1),OrderHistoryList(2),OrderHistoryList(3), ],
        ),
      ),
    );
  }
}