
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/ui/widget/plone_back_button.dart';
import 'package:project_telephony/utils/headers.dart';
import 'package:tab_indicator_styler/tab_indicator_styler.dart';

import 'calling_idle_list.dart';

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

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

class _ContentRefusePageState extends State<ContentRefusePage>
    with AutomaticKeepAliveClientMixin, SingleTickerProviderStateMixin {
  late TabController _tabController;
  final EasyRefreshController _callingRefreshController =
      EasyRefreshController();
  final EasyRefreshController _wasCalledRefreshController =
      EasyRefreshController();

  @override
  void initState() {
    _tabController = TabController(length: 2, initialIndex: 0, vsync: this);
    super.initState();
  }

  @override
  void dispose() {
    _tabController.dispose();
    _callingRefreshController.dispose();
    _wasCalledRefreshController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return Scaffold(
        appBar: AppBar(
          elevation: 0,
          title: Text(
            '选择短信内容',
            style: Theme.of(context).textTheme.headline6,
          ),
          leading: const CloudBackButton(isSpecial: true),
          backgroundColor: kForeGroundColor,
        ),
        backgroundColor: Colors.white,
        body: Column(
          children: [
            Container(
              width:double.infinity,
              height: 88.w,
              margin: EdgeInsets.symmetric(horizontal: 66.w),
              padding: EdgeInsets.all(8.w),
              decoration:BoxDecoration(color: const Color(0xFFF9F9F9),borderRadius: BorderRadius.all(Radius.circular(44.w))),
              child: TabBar(

                  // indicator: Decoration(),
                  controller: _tabController,
                labelColor:const Color(0xFF1890FF),
                unselectedLabelColor:const Color(0xFF999999),
                  unselectedLabelStyle:const TextStyle(fontWeight:FontWeight.bold),
                  labelStyle:const TextStyle(fontWeight:FontWeight.bold),
                  onTap: (num) {
                    if(num==0){
                      _callingRefreshController.callRefresh();
                    }else{
                      _wasCalledRefreshController.callRefresh();
                    }
                    //
                  },
                  indicator: RectangularIndicator(
                    color: Colors.white,
                    bottomLeftRadius: 44.w,
                    bottomRightRadius: 44.w,
                    topLeftRadius: 44.w,
                    topRightRadius: 44.w,
                    // paintingStyle: PaintingStyle.fill,
                  ),
                  // indicatorSize: TabBarIndicatorSize.label,
                  // isScrollable: true,
                  tabs: const [
                    // _tab(0, "被叫接听"),_tab(1, "主叫接听"),
                    Tab(text: "被叫拒接/未接",),Tab(text: "主叫拒接/未接",)
                  ]),


            ),
            Expanded(
                child: TabBarView(controller: _tabController, children: [
              // _getBox(),
              CallingIdleList(
                // contant: const [],
                refreshController: _callingRefreshController,
                isIdle: false,
              ),
              CallingIdleList(
                // contant: const [],
                refreshController: _wasCalledRefreshController, isIdle: true,
              )
            ]))
          ],
        ));
  }

  _getBox() {
    return Container(
      color: Colors.red,
      width: 200.w,
      height: 200.w,
    );
  }

  _tab(int int, String string) {
    return Text(
      string,
      style: TextStyle(
          fontSize: BaseStyle.fontSize28, color:const Color(0xFF1890FF) ),
    );
  }

  @override
  bool get wantKeepAlive => true;
}
