Commit 40d88265e06ffed07bb9c88b94f72697dc9f61ff

Authored by wdn127929
1 parent 7b7c9b6c

联系人搜索部分

@@ -11,14 +11,14 @@ if (flutterRoot == null) { @@ -11,14 +11,14 @@ if (flutterRoot == null) {
11 throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 11 throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 } 12 }
13 13
14 -def flutterVersionCode = "260" 14 +def flutterVersionCode = "261"
15 if (flutterVersionCode == null) { 15 if (flutterVersionCode == null) {
16 - flutterVersionCode = '260' 16 + flutterVersionCode = '261'
17 } 17 }
18 18
19 -def flutterVersionName = "2.6.0" 19 +def flutterVersionName = "2.6.1"
20 if (flutterVersionName == null) { 20 if (flutterVersionName == null) {
21 - flutterVersionName = '2.6.0' 21 + flutterVersionName = '2.6.1'
22 } 22 }
23 23
24 apply plugin: 'com.android.application' 24 apply plugin: 'com.android.application'
@@ -472,7 +472,7 @@ @@ -472,7 +472,7 @@
472 CODE_SIGN_IDENTITY = "iPhone Developer"; 472 CODE_SIGN_IDENTITY = "iPhone Developer";
473 "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 473 "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
474 CODE_SIGN_STYLE = Automatic; 474 CODE_SIGN_STYLE = Automatic;
475 - CURRENT_PROJECT_VERSION = 250; 475 + CURRENT_PROJECT_VERSION = 251;
476 DEVELOPMENT_TEAM = 8J59HM8B82; 476 DEVELOPMENT_TEAM = 8J59HM8B82;
477 ENABLE_BITCODE = NO; 477 ENABLE_BITCODE = NO;
478 FLUTTER_BUILD_MODE = release; 478 FLUTTER_BUILD_MODE = release;
@@ -616,7 +616,7 @@ @@ -616,7 +616,7 @@
616 CODE_SIGN_ENTITLEMENTS = "Runner/一键订Debug.entitlements"; 616 CODE_SIGN_ENTITLEMENTS = "Runner/一键订Debug.entitlements";
617 CODE_SIGN_IDENTITY = "iPhone Developer"; 617 CODE_SIGN_IDENTITY = "iPhone Developer";
618 CODE_SIGN_STYLE = Automatic; 618 CODE_SIGN_STYLE = Automatic;
619 - CURRENT_PROJECT_VERSION = 250; 619 + CURRENT_PROJECT_VERSION = 251;
620 DEVELOPMENT_TEAM = 8J59HM8B82; 620 DEVELOPMENT_TEAM = 8J59HM8B82;
621 ENABLE_BITCODE = NO; 621 ENABLE_BITCODE = NO;
622 FLUTTER_BUILD_MODE = release; 622 FLUTTER_BUILD_MODE = release;
@@ -651,7 +651,7 @@ @@ -651,7 +651,7 @@
651 CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; 651 CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
652 CODE_SIGN_IDENTITY = "iPhone Developer"; 652 CODE_SIGN_IDENTITY = "iPhone Developer";
653 CODE_SIGN_STYLE = Automatic; 653 CODE_SIGN_STYLE = Automatic;
654 - CURRENT_PROJECT_VERSION = 250; 654 + CURRENT_PROJECT_VERSION = 251;
655 DEVELOPMENT_TEAM = 8J59HM8B82; 655 DEVELOPMENT_TEAM = 8J59HM8B82;
656 ENABLE_BITCODE = NO; 656 ENABLE_BITCODE = NO;
657 FLUTTER_BUILD_MODE = release; 657 FLUTTER_BUILD_MODE = release;
@@ -2,10 +2,8 @@ import 'package:json_annotation/json_annotation.dart'; @@ -2,10 +2,8 @@ import 'package:json_annotation/json_annotation.dart';
2 2
3 part 'user_history_entity.g.dart'; 3 part 'user_history_entity.g.dart';
4 4
5 -  
6 @JsonSerializable() 5 @JsonSerializable()
7 class UserHistoryEntity extends Object { 6 class UserHistoryEntity extends Object {
8 -  
9 @JsonKey(name: 'id') 7 @JsonKey(name: 'id')
10 String id; 8 String id;
11 9
@@ -24,12 +22,19 @@ class UserHistoryEntity extends Object { @@ -24,12 +22,19 @@ class UserHistoryEntity extends Object {
24 @JsonKey(name: 'cusdem') 22 @JsonKey(name: 'cusdem')
25 String cusdem; 23 String cusdem;
26 24
27 - UserHistoryEntity(this.id,this.sid,this.rname,this.sex,this.phone,this.cusdem,); 25 + String pinyin;
28 26
29 - factory UserHistoryEntity.fromJson(Map<String, dynamic> srcJson) => _$UserHistoryEntityFromJson(srcJson); 27 + UserHistoryEntity(
  28 + this.id,
  29 + this.sid,
  30 + this.rname,
  31 + this.sex,
  32 + this.phone,
  33 + this.cusdem,
  34 + );
30 35
31 - Map<String, dynamic> toJson() => _$UserHistoryEntityToJson(this); 36 + factory UserHistoryEntity.fromJson(Map<String, dynamic> srcJson) =>
  37 + _$UserHistoryEntityFromJson(srcJson);
32 38
  39 + Map<String, dynamic> toJson() => _$UserHistoryEntityToJson(this);
33 } 40 }
34 -  
35 -  
@@ -61,7 +61,7 @@ class _IfNeedCreateStoreItemState extends State<IfNeedCreateStoreItem> { @@ -61,7 +61,7 @@ class _IfNeedCreateStoreItemState extends State<IfNeedCreateStoreItem> {
61 fontSize: ScreenUtil().setWidth(30), 61 fontSize: ScreenUtil().setWidth(30),
62 color: MyColours.color_333333)), 62 color: MyColours.color_333333)),
63 VEmptyView(10), 63 VEmptyView(10),
64 - Text('店长', 64 + Text('${widget.model.roleName}',
65 maxLines: 1, 65 maxLines: 1,
66 overflow: TextOverflow.ellipsis, 66 overflow: TextOverflow.ellipsis,
67 style: TextStyle( 67 style: TextStyle(
@@ -61,13 +61,13 @@ class _ContantLeftPageState extends State<ContantLeftPage> { @@ -61,13 +61,13 @@ class _ContantLeftPageState extends State<ContantLeftPage> {
61 ); 61 );
62 } else { 62 } else {
63 return ListView.builder( 63 return ListView.builder(
64 - itemCount: model.userHistorys.length, 64 + itemCount: model.userHistorysShow.length,
65 itemBuilder: (BuildContext context, int index) { 65 itemBuilder: (BuildContext context, int index) {
66 return InkWell( 66 return InkWell(
67 onTap: () { 67 onTap: () {
68 - if (model.userHistorys[index].phone != null &&  
69 - model.userHistorys[index].phone != '') {  
70 - DialogUtil.goPhone(model.userHistorys[index].phone); 68 + if (model.userHistorysShow[index].phone != null &&
  69 + model.userHistorysShow[index].phone != '') {
  70 + DialogUtil.goPhone(model.userHistorysShow[index].phone);
71 } 71 }
72 }, 72 },
73 child: Column( 73 child: Column(
@@ -101,19 +101,19 @@ class _ContantLeftPageState extends State<ContantLeftPage> { @@ -101,19 +101,19 @@ class _ContantLeftPageState extends State<ContantLeftPage> {
101 crossAxisAlignment: CrossAxisAlignment.start, 101 crossAxisAlignment: CrossAxisAlignment.start,
102 children: [ 102 children: [
103 Text( 103 Text(
104 - model.userHistorys[index].rname == null ||  
105 - model.userHistorys[index].rname == '' 104 + model.userHistorysShow[index].rname == null ||
  105 + model.userHistorysShow[index].rname == ''
106 ? '' 106 ? ''
107 - : model.userHistorys[index].rname, 107 + : model.userHistorysShow[index].rname,
108 style: TextStyle( 108 style: TextStyle(
109 color: MyColours.color_333333, 109 color: MyColours.color_333333,
110 fontSize: ScreenUtil().setSp(32))), 110 fontSize: ScreenUtil().setSp(32))),
111 VEmptyView(10), 111 VEmptyView(10),
112 Text( 112 Text(
113 - model.userHistorys[index].phone == null ||  
114 - model.userHistorys[index].phone == '' 113 + model.userHistorysShow[index].phone == null ||
  114 + model.userHistorysShow[index].phone == ''
115 ? '' 115 ? ''
116 - : model.userHistorys[index].phone, 116 + : model.userHistorysShow[index].phone,
117 style: TextStyle( 117 style: TextStyle(
118 color: MyColours.color_999999, 118 color: MyColours.color_999999,
119 fontSize: ScreenUtil().setSp(30))) 119 fontSize: ScreenUtil().setSp(30)))
1 import 'package:flutter/material.dart'; 1 import 'package:flutter/material.dart';
2 -import 'package:flutter/services.dart';  
3 2
4 import 'package:contacts_service/contacts_service.dart'; 3 import 'package:contacts_service/contacts_service.dart';
5 import 'package:flutter_screenutil/screenutil.dart'; 4 import 'package:flutter_screenutil/screenutil.dart';
6 -import 'package:intl/intl.dart'; 5 +
7 import 'package:one_key/pages/my/contant_left_page.dart'; 6 import 'package:one_key/pages/my/contant_left_page.dart';
8 import 'package:one_key/pages/my/contant_right_page.dart'; 7 import 'package:one_key/pages/my/contant_right_page.dart';
9 import 'package:one_key/provider/contant_show_model.dart'; 8 import 'package:one_key/provider/contant_show_model.dart';
10 import 'package:one_key/res/colors.dart'; 9 import 'package:one_key/res/colors.dart';
11 -import 'package:one_key/utils/dialog_util.dart';  
12 import 'package:one_key/utils/event_bus.dart'; 10 import 'package:one_key/utils/event_bus.dart';
13 -import 'package:one_key/utils/misc.dart';  
14 -import 'package:one_key/widgets/MyDivider.dart'; 11 +import 'package:one_key/utils/utils.dart';
  12 +
15 import 'package:one_key/widgets/custom_tab_indicator.dart'; 13 import 'package:one_key/widgets/custom_tab_indicator.dart';
16 import 'package:one_key/widgets/system_app_bar.dart'; 14 import 'package:one_key/widgets/system_app_bar.dart';
17 -import 'package:one_key/widgets/v_empty_view.dart';  
18 -import 'package:permission_handler/permission_handler.dart'; 15 +
19 import 'package:provider/provider.dart'; 16 import 'package:provider/provider.dart';
20 17
21 class ContactListPage extends StatefulWidget { 18 class ContactListPage extends StatefulWidget {
@@ -28,7 +25,8 @@ class _ContactListPageState extends State<ContactListPage> @@ -28,7 +25,8 @@ class _ContactListPageState extends State<ContactListPage>
28 List<Contact> _contacts; 25 List<Contact> _contacts;
29 List _tabBarTitle; 26 List _tabBarTitle;
30 TabController tabController; 27 TabController tabController;
31 - 28 + TextEditingController controller = TextEditingController();
  29 + ContantShowModel contantShowModel;
32 @override 30 @override
33 void initState() { 31 void initState() {
34 _tabBarTitle = ['预订联系人', '手机联系人']; 32 _tabBarTitle = ['预订联系人', '手机联系人'];
@@ -38,6 +36,7 @@ class _ContactListPageState extends State<ContactListPage> @@ -38,6 +36,7 @@ class _ContactListPageState extends State<ContactListPage>
38 36
39 @override 37 @override
40 Widget build(BuildContext context) { 38 Widget build(BuildContext context) {
  39 + contantShowModel = Provider.of<ContantShowModel>(context, listen: true);
41 return Scaffold( 40 return Scaffold(
42 backgroundColor: MyColours.color_ffffff, 41 backgroundColor: MyColours.color_ffffff,
43 appBar: SystemAppBar( 42 appBar: SystemAppBar(
@@ -52,6 +51,75 @@ class _ContactListPageState extends State<ContactListPage> @@ -52,6 +51,75 @@ class _ContactListPageState extends State<ContactListPage>
52 child: Column( 51 child: Column(
53 children: <Widget>[ 52 children: <Widget>[
54 Container( 53 Container(
  54 + // color: Colors.red,
  55 + padding: EdgeInsets.symmetric(
  56 + horizontal: ScreenUtil().setWidth(40),
  57 + vertical: ScreenUtil().setWidth(10)),
  58 + height: ScreenUtil().setWidth(45 * 2),
  59 + // alignment: Alignment.center,
  60 + child: Container(
  61 + alignment: Alignment.center,
  62 + padding: EdgeInsets.symmetric(
  63 + horizontal: ScreenUtil().setWidth(20 * 2),
  64 + vertical: ScreenUtil().setWidth(14)),
  65 + decoration: BoxDecoration(
  66 + color: MyColours.color_F0F0F0,
  67 + borderRadius: BorderRadius.circular(
  68 + ScreenUtil().setWidth(24 * 2))),
  69 + child: TextField(
  70 + controller: controller,
  71 + // focusNode: _focusNode,
  72 + // autofocus: true,
  73 +
  74 + style: TextStyle(
  75 + color: MyColours.color_333333,
  76 + fontSize: ScreenUtil().setSp(30),
  77 + textBaseline: TextBaseline.alphabetic),
  78 + textAlignVertical: TextAlignVertical.center,
  79 + decoration: InputDecoration(
  80 + hintText: "搜索联系人",
  81 + hintStyle: TextStyle(
  82 + color: MyColours.color_999999,
  83 + fontSize: ScreenUtil().setSp(30),
  84 + ),
  85 + isCollapsed:
  86 + true, //重点,相当于高度包裹的意思,必须设置为true,不然有默认奇妙的最小高度
  87 + border: InputBorder.none,
  88 + //左边图标设置
  89 + icon: Image.asset(
  90 + Utils.getImgPath('search'),
  91 + width: ScreenUtil().setWidth(30),
  92 + ),
  93 + //右边图标设置
  94 + suffixIcon: GestureDetector(
  95 + child: Container(
  96 + height: ScreenUtil().setWidth(30),
  97 + width: ScreenUtil().setWidth(30),
  98 + alignment: Alignment.centerRight,
  99 + child: Image.asset(
  100 + Utils.getImgPath('clear'),
  101 + width: ScreenUtil().setWidth(30),
  102 + ),
  103 + ),
  104 + onTap: () {
  105 + WidgetsBinding.instance.addPostFrameCallback(
  106 + ((_) => controller.clear()));
  107 + },
  108 + )),
  109 + keyboardType: TextInputType.text,
  110 + textInputAction: TextInputAction.search,
  111 + onChanged: (value) {
  112 + setState(() {});
  113 + // _searchSellerLocation();
  114 + contantShowModel.searchData(value);
  115 + },
  116 + onEditingComplete: () {
  117 + // _searchSellerLocation();
  118 + // _focusNode.unfocus();
  119 + },
  120 + ),
  121 + )),
  122 + Container(
55 padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(10)), 123 padding: EdgeInsets.only(bottom: ScreenUtil().setWidth(10)),
56 margin: EdgeInsets.symmetric( 124 margin: EdgeInsets.symmetric(
57 horizontal: ScreenUtil().setWidth(30)), 125 horizontal: ScreenUtil().setWidth(30)),
@@ -83,10 +151,8 @@ class _ContactListPageState extends State<ContactListPage> @@ -83,10 +151,8 @@ class _ContactListPageState extends State<ContactListPage>
83 controller: tabController, 151 controller: tabController,
84 // physics: NeverScrollableScrollPhysics(), 152 // physics: NeverScrollableScrollPhysics(),
85 children: <Widget>[ 153 children: <Widget>[
86 - ChangeNotifierProvider<ContantShowModel>(  
87 - create: (_) => ContantShowModel(),  
88 - child: ContantLeftPage()),  
89 - ContantRightPage() 154 + ContantLeftPage(),
  155 + ContantRightPage(),
90 ], 156 ],
91 )), 157 )),
92 ], 158 ],
@@ -3,7 +3,10 @@ import 'dart:io'; @@ -3,7 +3,10 @@ import 'dart:io';
3 import 'package:flutter/material.dart'; 3 import 'package:flutter/material.dart';
4 4
5 import 'package:flutter_screenutil/flutter_screenutil.dart'; 5 import 'package:flutter_screenutil/flutter_screenutil.dart';
  6 +import 'package:lpinyin/lpinyin.dart';
6 import 'package:one_key/constant/state.dart'; 7 import 'package:one_key/constant/state.dart';
  8 +import 'package:one_key/models/user_history_entity.dart';
  9 +import 'package:one_key/provider/contant_show_model.dart';
7 10
8 import 'package:one_key/res/colors.dart'; 11 import 'package:one_key/res/colors.dart';
9 import 'package:one_key/utils/dialog_util.dart'; 12 import 'package:one_key/utils/dialog_util.dart';
@@ -14,6 +17,7 @@ import 'package:one_key/widgets/page_exception.dart'; @@ -14,6 +17,7 @@ import 'package:one_key/widgets/page_exception.dart';
14 import 'package:one_key/widgets/v_empty_view.dart'; 17 import 'package:one_key/widgets/v_empty_view.dart';
15 import 'package:contacts_service/contacts_service.dart'; 18 import 'package:contacts_service/contacts_service.dart';
16 import 'package:permission_handler/permission_handler.dart'; 19 import 'package:permission_handler/permission_handler.dart';
  20 +import 'package:provider/provider.dart';
17 21
18 class ContantRightPage extends StatefulWidget { 22 class ContantRightPage extends StatefulWidget {
19 ContantRightPage({Key key}) : super(key: key); 23 ContantRightPage({Key key}) : super(key: key);
@@ -23,15 +27,18 @@ class ContantRightPage extends StatefulWidget { @@ -23,15 +27,18 @@ class ContantRightPage extends StatefulWidget {
23 } 27 }
24 28
25 class _ContantRightPageState extends State<ContantRightPage> { 29 class _ContantRightPageState extends State<ContantRightPage> {
26 - PageState _pageState = PageState.Loading; 30 + // PageState _pageState = PageState.Loading;
27 List<Contact> _contacts; 31 List<Contact> _contacts;
28 bool isNeed = false; 32 bool isNeed = false;
29 bool goSetting = false; 33 bool goSetting = false;
30 bool userNo = false; 34 bool userNo = false;
  35 + ContantShowModel contantShowModel;
31 @override 36 @override
32 void initState() { 37 void initState() {
33 super.initState(); 38 super.initState();
34 - _openAddressBook(); 39 + WidgetsBinding.instance.addPostFrameCallback((_) {
  40 + _openAddressBook();
  41 + });
35 } 42 }
36 43
37 // Future<void> _askPermissions() async { 44 // Future<void> _askPermissions() async {
@@ -49,7 +56,7 @@ class _ContantRightPageState extends State<ContantRightPage> { @@ -49,7 +56,7 @@ class _ContantRightPageState extends State<ContantRightPage> {
49 print('never'); 56 print('never');
50 userNo = true; 57 userNo = true;
51 setState(() { 58 setState(() {
52 - _pageState = PageState.NoPermission; 59 + contantShowModel.pageStateRight = PageState.NoPermission;
53 }); 60 });
54 // DialogUtil.openAlertDialog( 61 // DialogUtil.openAlertDialog(
55 // context, '未获得通讯录权限', "请在手机的权限管理里,将通讯录权限开启", '去设置', 340.0, 62 // context, '未获得通讯录权限', "请在手机的权限管理里,将通讯录权限开启", '去设置', 340.0,
@@ -65,7 +72,7 @@ class _ContantRightPageState extends State<ContantRightPage> { @@ -65,7 +72,7 @@ class _ContantRightPageState extends State<ContantRightPage> {
65 refreshContacts(); 72 refreshContacts();
66 } else { 73 } else {
67 setState(() { 74 setState(() {
68 - _pageState = PageState.NoPermission; 75 + contantShowModel.pageStateRight = PageState.NoPermission;
69 }); 76 });
70 //拒绝通讯录权限 , 苹果拒绝权限后,不再提示权限框,进入此处 77 //拒绝通讯录权限 , 苹果拒绝权限后,不再提示权限框,进入此处
71 // DialogUtil.openAlertDialog( 78 // DialogUtil.openAlertDialog(
@@ -113,7 +120,7 @@ class _ContantRightPageState extends State<ContantRightPage> { @@ -113,7 +120,7 @@ class _ContantRightPageState extends State<ContantRightPage> {
113 120
114 Future<void> refreshContacts() async { 121 Future<void> refreshContacts() async {
115 // Load without thumbnails initially. 122 // Load without thumbnails initially.
116 - var contacts = (await ContactsService.getContacts( 123 + List<Contact> contacts = (await ContactsService.getContacts(
117 withThumbnails: false, iOSLocalizedLabels: false)) 124 withThumbnails: false, iOSLocalizedLabels: false))
118 .toList(); 125 .toList();
119 // var contacts = (await ContactsService.getContactsForPhone("8554964652")) 126 // var contacts = (await ContactsService.getContactsForPhone("8554964652"))
@@ -121,9 +128,22 @@ class _ContantRightPageState extends State<ContantRightPage> { @@ -121,9 +128,22 @@ class _ContantRightPageState extends State<ContantRightPage> {
121 setState(() { 128 setState(() {
122 _contacts = contacts; 129 _contacts = contacts;
123 if (_contacts.length > 0) { 130 if (_contacts.length > 0) {
124 - _pageState = PageState.Success; 131 + for (int i = 0; i < _contacts.length; i++) {
  132 + UserHistoryEntity item = UserHistoryEntity(
  133 + '',
  134 + '',
  135 + _contacts[i].displayName,
  136 + '',
  137 + _contacts[i].phones.first.value,
  138 + '');
  139 + item.pinyin =
  140 + item.pinyin = PinyinHelper.getPinyin(_contacts[i].displayName);
  141 + contantShowModel.contacts.add(item);
  142 + }
  143 + contantShowModel.contactsShow = contantShowModel.contacts;
  144 + contantShowModel.pageStateRight = PageState.Success;
125 } else { 145 } else {
126 - _pageState = PageState.Empty; 146 + contantShowModel.pageStateRight = PageState.Empty;
127 } 147 }
128 }); 148 });
129 149
@@ -200,30 +220,32 @@ class _ContantRightPageState extends State<ContantRightPage> { @@ -200,30 +220,32 @@ class _ContantRightPageState extends State<ContantRightPage> {
200 220
201 @override 221 @override
202 Widget build(BuildContext context) { 222 Widget build(BuildContext context) {
203 - return _pageState != PageState.Success  
204 - ? ExceptionPage(  
205 - pageState: _pageState,  
206 - callback: () async {  
207 - if (await checkContactPermission()) {  
208 - _openAddressBook();  
209 - } else {  
210 - goSetting = true;  
211 - openSetting();  
212 - }  
213 - },  
214 - emptyMsg: "暂时没有联系人哦",  
215 - emptyImg: "empty_search",  
216 - showMsg: "加载中,请稍后...",  
217 - )  
218 - : ListView.builder(  
219 - itemCount: _contacts?.length ?? 0, 223 + contantShowModel = Provider.of<ContantShowModel>(context, listen: true);
  224 + return Consumer<ContantShowModel>(builder: (context, model, _) {
  225 + if (model.pageStateRight != PageState.Success) {
  226 + return ExceptionPage(
  227 + pageState: model.pageStateRight,
  228 + callback: () async {
  229 + if (await checkContactPermission()) {
  230 + _openAddressBook();
  231 + } else {
  232 + goSetting = true;
  233 + openSetting();
  234 + }
  235 + },
  236 + emptyMsg: "暂时没有联系人哦",
  237 + emptyImg: "empty_search",
  238 + showMsg: "加载中,请稍后...",
  239 + );
  240 + } else {
  241 + return ListView.builder(
  242 + itemCount: contantShowModel.contactsShow?.length ?? 0,
220 itemBuilder: (BuildContext context, int index) { 243 itemBuilder: (BuildContext context, int index) {
221 - Contact c = _contacts?.elementAt(index); 244 + UserHistoryEntity c = contantShowModel.contactsShow[index];
222 return InkWell( 245 return InkWell(
223 onTap: () { 246 onTap: () {
224 - if (c.phones.first.value != null &&  
225 - c.phones.first.value != '') {  
226 - DialogUtil.goPhone(c.phones.first.value); 247 + if (c.phone != null && c.phone != '') {
  248 + DialogUtil.goPhone(c.phone);
227 } 249 }
228 }, 250 },
229 child: Column( 251 child: Column(
@@ -257,18 +279,17 @@ class _ContantRightPageState extends State<ContantRightPage> { @@ -257,18 +279,17 @@ class _ContantRightPageState extends State<ContantRightPage> {
257 crossAxisAlignment: CrossAxisAlignment.start, 279 crossAxisAlignment: CrossAxisAlignment.start,
258 children: [ 280 children: [
259 Text( 281 Text(
260 - c.displayName == null || c.displayName == '' 282 + c.rname == null || c.rname == ''
261 ? '' 283 ? ''
262 - : c.displayName, 284 + : c.rname,
263 style: TextStyle( 285 style: TextStyle(
264 color: MyColours.color_333333, 286 color: MyColours.color_333333,
265 fontSize: ScreenUtil().setSp(32))), 287 fontSize: ScreenUtil().setSp(32))),
266 VEmptyView(10), 288 VEmptyView(10),
267 Text( 289 Text(
268 - c.phones.first.value == null ||  
269 - c.phones.first.value == '' 290 + c.phone == null || c.phone == ''
270 ? '' 291 ? ''
271 - : c.phones.first.value, 292 + : c.phone,
272 style: TextStyle( 293 style: TextStyle(
273 color: MyColours.color_999999, 294 color: MyColours.color_999999,
274 fontSize: ScreenUtil().setSp(30))) 295 fontSize: ScreenUtil().setSp(30)))
@@ -277,5 +298,7 @@ class _ContantRightPageState extends State<ContantRightPage> { @@ -277,5 +298,7 @@ class _ContantRightPageState extends State<ContantRightPage> {
277 ) 298 )
278 ])); 299 ]));
279 }); 300 });
  301 + }
  302 + });
280 } 303 }
281 } 304 }
  1 +import 'package:contacts_service/contacts_service.dart';
1 import 'package:flutter/material.dart'; 2 import 'package:flutter/material.dart';
2 import 'package:one_key/constant/constant.dart'; 3 import 'package:one_key/constant/constant.dart';
3 import 'package:one_key/constant/error.dart'; 4 import 'package:one_key/constant/error.dart';
@@ -6,12 +7,15 @@ import 'package:one_key/models/user_history_entity.dart'; @@ -6,12 +7,15 @@ import 'package:one_key/models/user_history_entity.dart';
6 import 'package:one_key/net/base_resp.dart'; 7 import 'package:one_key/net/base_resp.dart';
7 import 'package:one_key/net/dio_util.dart'; 8 import 'package:one_key/net/dio_util.dart';
8 import 'package:one_key/net/http_url.dart'; 9 import 'package:one_key/net/http_url.dart';
  10 +import 'package:lpinyin/lpinyin.dart';
9 11
10 class ContantShowModel extends ChangeNotifier { 12 class ContantShowModel extends ChangeNotifier {
11 PageState pageStateLeft = PageState.Loading; 13 PageState pageStateLeft = PageState.Loading;
12 - List<UserHistoryEntity> userHistorys = []; //历史录入  
13 -  
14 - 14 + PageState pageStateRight = PageState.Loading;
  15 + List<UserHistoryEntity> userHistorys = []; //历史录入(总)
  16 + List<UserHistoryEntity> contacts = []; //手机通讯录(总)
  17 + List<UserHistoryEntity> userHistorysShow = []; //历史录入展示
  18 + List<UserHistoryEntity> contactsShow = []; //手机通讯录展示
15 19
16 //获取历史录入 20 //获取历史录入
17 getUserHistorys(BuildContext context, Map<String, String> params) async { 21 getUserHistorys(BuildContext context, Map<String, String> params) async {
@@ -42,9 +46,44 @@ class ContantShowModel extends ChangeNotifier { @@ -42,9 +46,44 @@ class ContantShowModel extends ChangeNotifier {
42 if (userHistorys.length == 0) { 46 if (userHistorys.length == 0) {
43 pageStateLeft = PageState.Empty; 47 pageStateLeft = PageState.Empty;
44 } else { 48 } else {
  49 + for (int i = 0; i < userHistorys.length; i++) {
  50 + UserHistoryEntity item = userHistorys[i];
  51 + item.pinyin = PinyinHelper.getPinyin(item.rname);
  52 + userHistorys[i] = item;
  53 + }
  54 + userHistorysShow = userHistorys;
45 pageStateLeft = PageState.Success; 55 pageStateLeft = PageState.Success;
46 } 56 }
47 notifyListeners(); 57 notifyListeners();
48 } 58 }
49 } 59 }
  60 +
  61 + searchData(String key) {
  62 + userHistorysShow = [];
  63 + contactsShow = [];
  64 + // for (int i = 0; i < userHistorys.length; i++) {
  65 +
  66 + // String name = userHistorys[i].rname;
  67 + // String pinyin = userHistorys[i].pinyin;
  68 + // String phone = userHistorys[i].phone;
  69 + // if (name.contains(key) || pinyin.contains(key) || phone.contains(key)) {
  70 + // userHistorysShow.add(userHistorys[i]);
  71 + // }
  72 + // }
  73 + for (int i = 0; i < contacts.length; i++) {
  74 + String name = contacts[i].rname;
  75 + String pinyin = contacts[i].pinyin;
  76 + String phone = contacts[i].phone;
  77 + if (name.contains(key) || pinyin.contains(key) || phone.contains(key)) {
  78 + contactsShow.add(contacts[i]);
  79 + }
  80 + }
  81 + if (userHistorysShow.length == 0) {
  82 + pageStateLeft = PageState.Empty;
  83 + }
  84 + if (contactsShow.length == 0) {
  85 + pageStateRight = PageState.Empty;
  86 + }
  87 + notifyListeners();
  88 + }
50 } 89 }
@@ -47,6 +47,7 @@ import 'package:one_key/pages/webview/webview_page.dart'; @@ -47,6 +47,7 @@ import 'package:one_key/pages/webview/webview_page.dart';
47 import 'package:one_key/provider/base_info_provider.dart'; 47 import 'package:one_key/provider/base_info_provider.dart';
48 import 'package:one_key/provider/book_set_time_model.dart'; 48 import 'package:one_key/provider/book_set_time_model.dart';
49 import 'package:one_key/provider/choose_table_model.dart'; 49 import 'package:one_key/provider/choose_table_model.dart';
  50 +import 'package:one_key/provider/contant_show_model.dart';
50 import 'package:one_key/provider/create_store_model.dart'; 51 import 'package:one_key/provider/create_store_model.dart';
51 import 'package:one_key/provider/my_model.dart'; 52 import 'package:one_key/provider/my_model.dart';
52 import 'package:one_key/provider/notebook_detail_change_model.dart'; 53 import 'package:one_key/provider/notebook_detail_change_model.dart';
@@ -437,13 +438,14 @@ var myIntegralPageHandler = new Handler( @@ -437,13 +438,14 @@ var myIntegralPageHandler = new Handler(
437 return ChangeNotifierProvider<MyModel>( 438 return ChangeNotifierProvider<MyModel>(
438 create: (_) => MyModel(), child: MyIntegralPage(sunModel: sunModel)); 439 create: (_) => MyModel(), child: MyIntegralPage(sunModel: sunModel));
439 }); 440 });
  441 +
440 ///我的联系人 442 ///我的联系人
441 var myContantPageHandler = new Handler( 443 var myContantPageHandler = new Handler(
442 handlerFunc: (BuildContext context, Map<String, List<Object>> params) { 444 handlerFunc: (BuildContext context, Map<String, List<Object>> params) {
443 // IntegralSunModel sunModel = IntegralSunModel.fromJson(json 445 // IntegralSunModel sunModel = IntegralSunModel.fromJson(json
444 - // .decode(FluroConvertUtils.fluroCnParamsDecode(params["sunModel"].first))); 446 + // .decode(FluroConvertUtils.fluroCnParamsDecode(params["sunModel"].first)));
445 // String urlStr = FluroConvertUtils.fluroCnParamsDecode(params["urlStr"].first); 447 // String urlStr = FluroConvertUtils.fluroCnParamsDecode(params["urlStr"].first);
446 448
447 - return ContactListPage(); 449 + return ChangeNotifierProvider<ContantShowModel>(
  450 + create: (_) => ContantShowModel(), child: ContactListPage());
448 }); 451 });
449 -  
@@ -555,6 +555,13 @@ packages: @@ -555,6 +555,13 @@ packages:
555 url: "https://pub.flutter-io.cn" 555 url: "https://pub.flutter-io.cn"
556 source: hosted 556 source: hosted
557 version: "1.0.1" 557 version: "1.0.1"
  558 + lpinyin:
  559 + dependency: "direct main"
  560 + description:
  561 + name: lpinyin
  562 + url: "https://pub.flutter-io.cn"
  563 + source: hosted
  564 + version: "2.0.3"
558 matcher: 565 matcher:
559 dependency: transitive 566 dependency: transitive
560 description: 567 description:
@@ -116,7 +116,8 @@ dependencies: @@ -116,7 +116,8 @@ dependencies:
116 dotted_border: ^1.0.7 116 dotted_border: ^1.0.7
117 scroll_to_index: ^2.0.0 117 scroll_to_index: ^2.0.0
118 118
119 - #通讯录 119 + #汉字转拼音
  120 + lpinyin: ^2.0.3
120 121
121 122
122 123