contant_page.dart 3.7 KB
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'package:contacts_service/contacts_service.dart';
import 'package:flutter_screenutil/screenutil.dart';
import 'package:intl/intl.dart';
import 'package:one_key/pages/my/contant_left_page.dart';
import 'package:one_key/pages/my/contant_right_page.dart';
import 'package:one_key/provider/contant_show_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/utils/dialog_util.dart';
import 'package:one_key/utils/event_bus.dart';
import 'package:one_key/utils/misc.dart';
import 'package:one_key/widgets/MyDivider.dart';
import 'package:one_key/widgets/custom_tab_indicator.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';

class ContactListPage extends StatefulWidget {
  @override
  _ContactListPageState createState() => _ContactListPageState();
}

class _ContactListPageState extends State<ContactListPage>
    with TickerProviderStateMixin {
  List<Contact> _contacts;
  List _tabBarTitle;
  TabController tabController;

  @override
  void initState() {
    _tabBarTitle = ['预订联系人', '手机联系人'];
    super.initState();
    tabController = TabController(length: 2, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: MyColours.color_ffffff,
        appBar: SystemAppBar(
          '联系人',
          onTap: () {
            EventBus().emit('changeStatusColor');
            Navigator.of(context).pop();
          },
        ),
        body: WillPopScope(
            child: SafeArea(
                child: Column(
              children: <Widget>[
                Container(
                  padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(10)),
                  margin: EdgeInsets.symmetric(
                      horizontal: ScreenUtil().setWidth(30)),
                  child: TabBar(
                      controller: tabController,
                      indicator: CustomTabIndicator(
                        radius: 0,
                      ),
                      indicatorColor: MyColours.color_199095,
                      indicatorSize: TabBarIndicatorSize.tab,
                      // indicatorPadding: EdgeInsets.symmetric(
                      //     horizontal: ScreenUtil().setWidth(12)),
                      labelColor: MyColours.color_199095,
                      labelStyle: TextStyle(
                          fontSize: ScreenUtil().setSp(32),
                          fontWeight: FontWeight.bold),
                      labelPadding: EdgeInsets.zero,
                      unselectedLabelStyle:
                          TextStyle(fontWeight: FontWeight.normal),
                      unselectedLabelColor: MyColours.color_999999,
                      tabs: _tabBarTitle.map((value) {
                        return Tab(
                          child: Text(value),
                        );
                      }).toList()),
                ),
                Expanded(
                    child: TabBarView(
                  controller: tabController,
                  // physics: NeverScrollableScrollPhysics(),
                  children: <Widget>[
                    ChangeNotifierProvider<ContantShowModel>(
                        create: (_) => ContantShowModel(),
                        child: ContantLeftPage()),
                    ContantRightPage()
                  ],
                )),
              ],
            )),
            onWillPop: () async {
              EventBus().emit('changeStatusColor');
              return true;
            }));
  }
}