@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
3
3
import 'package:flutter_app/bean/contact.dart' ;
4
4
import 'package:flutter_app/contact/page/contact_page.dart' ;
5
5
import 'package:flutter_app/contact/ui/contact_list_header.dart' ;
6
- import 'package:flutter_app/contact/ ui/suspension_tag.dart' ;
6
+ import 'package:flutter_app/ui/suspension_tag.dart' ;
7
7
import 'package:flutter_app/global/config.dart' ;
8
8
import 'package:flutter_app/service/api_service.dart' ;
9
9
import 'package:flutter_app/utils/loading_util.dart' ;
@@ -21,7 +21,7 @@ class _ContactListPageState extends State<ContactListPage> {
21
21
List <Contact > _contacts = [];
22
22
23
23
int _suspensionHeight = 40 ;
24
- int _itemHeight = 60 ;
24
+ int _itemHeight = 70 ;
25
25
26
26
int _themeColorIndex;
27
27
@@ -35,65 +35,59 @@ class _ContactListPageState extends State<ContactListPage> {
35
35
@override
36
36
Widget build (BuildContext context) {
37
37
return Scaffold (
38
- appBar: AppBar (
39
- title: Text ("通讯录" ),
40
- elevation: 0.0 ,
41
- backgroundColor: themeColors[_themeColorIndex],
42
- centerTitle: true ,
43
- ),
44
- body: _contacts.isNotEmpty
45
- ? AzListView (
46
- data: _contacts,
47
- itemBuilder: (context, model) => _buildListItem (model),
48
- header: AzListViewHeader (
49
- height: 220 ,
50
- builder: (context) => Diagonal (
51
- axis: Axis .horizontal,
52
- position: DiagonalPosition .BOTTOM_LEFT ,
53
- clipHeight: 50.0 ,
54
- child:
55
- ContactListHeader (name: "SCL" , phone: "18601952581" ),
56
- ),
57
- ),
58
- isUseRealIndex: true ,
59
- itemHeight: _itemHeight,
60
- suspensionHeight: _suspensionHeight,
61
- indexBarBuilder: (BuildContext context, List <String > tags,
62
- IndexBarTouchCallback onTouch) {
63
- return Container (
64
- margin: EdgeInsets .symmetric (vertical: 16.0 , horizontal: 8.0 ),
65
- decoration: BoxDecoration (
66
- color: Colors .grey[50 ],
67
- borderRadius: BorderRadius .circular (20.0 ),
68
- border: Border .all (color: Colors .grey[300 ], width: .5 )),
69
- child: ClipRRect (
70
- borderRadius: BorderRadius .circular (20.0 ),
71
- child: IndexBar (
72
- data: tags,
73
- itemHeight: 20 ,
74
- onTouch: (details) {
75
- onTouch (details);
76
- },
77
- ),
78
- ),
79
- );
80
- },
81
- indexHintBuilder: (context, hint) {
82
- return Container (
83
- alignment: Alignment .center,
84
- width: 60.0 ,
85
- height: 60.0 ,
86
- decoration: BoxDecoration (
87
- color: Colors .blue[700 ].withAlpha (200 ),
88
- shape: BoxShape .circle,
89
- ),
90
- child: Text (hint,
91
- style: TextStyle (color: Colors .white, fontSize: 30.0 )),
92
- );
93
- },
94
- )
95
- : getLoadingWidget (),
96
- );
38
+ appBar: AppBar (
39
+ title: Text ("通讯录" ),
40
+ elevation: 0.0 ,
41
+ backgroundColor: themeColors[_themeColorIndex]),
42
+ body: _contacts.isNotEmpty
43
+ ? AzListView (
44
+ data: _contacts,
45
+ itemBuilder: (context, model) => _buildListItem (model),
46
+ header: AzListViewHeader (
47
+ height: 220 ,
48
+ builder: (context) => Diagonal (
49
+ axis: Axis .horizontal,
50
+ position: DiagonalPosition .BOTTOM_LEFT ,
51
+ clipHeight: 50.0 ,
52
+ child: ContactListHeader (
53
+ name: "SCL" , phone: "18601952581" ),
54
+ ),
55
+ ),
56
+ isUseRealIndex: true ,
57
+ itemHeight: _itemHeight,
58
+ suspensionHeight: _suspensionHeight,
59
+ indexBarBuilder: (BuildContext context, List <String > tags,
60
+ IndexBarTouchCallback onTouch) {
61
+ return Container (
62
+ margin:
63
+ EdgeInsets .symmetric (vertical: 16.0 , horizontal: 8.0 ),
64
+ decoration: BoxDecoration (
65
+ color: Colors .grey[50 ],
66
+ borderRadius: BorderRadius .circular (20.0 ),
67
+ border:
68
+ Border .all (color: Colors .grey[300 ], width: .5 )),
69
+ child: ClipRRect (
70
+ borderRadius: BorderRadius .circular (20.0 ),
71
+ child: IndexBar (
72
+ data: tags,
73
+ itemHeight: 20 ,
74
+ onTouch: (details) {
75
+ onTouch (details);
76
+ })));
77
+ },
78
+ indexHintBuilder: (context, hint) {
79
+ return Container (
80
+ alignment: Alignment .center,
81
+ width: 60.0 ,
82
+ height: 60.0 ,
83
+ decoration: BoxDecoration (
84
+ color: Colors .blue[700 ].withAlpha (200 ),
85
+ shape: BoxShape .circle),
86
+ child: Text (hint,
87
+ style: TextStyle (color: Colors .white, fontSize: 30.0 )),
88
+ );
89
+ })
90
+ : getLoadingWidget ());
97
91
}
98
92
99
93
void getContacts () async {
@@ -107,7 +101,7 @@ class _ContactListPageState extends State<ContactListPage> {
107
101
if (contacts == null || contacts.isEmpty) return ;
108
102
for (int i = 0 , length = contacts.length; i < length; i++ ) {
109
103
String pinyin = PinyinHelper .getPinyinE (contacts[i].fullName);
110
- String tag = pinyin. substring ( 0 , 1 ) .toUpperCase ();
104
+ String tag = pinyin[ 0 ] .toUpperCase ();
111
105
if (RegExp ("[A-Z]" ).hasMatch (tag)) {
112
106
contacts[i].tagIndex = tag;
113
107
} else {
@@ -125,6 +119,7 @@ class _ContactListPageState extends State<ContactListPage> {
125
119
offstage: model.isShowSuspension != true ,
126
120
child: SuspensionTag (susTag: susTag, susHeight: _suspensionHeight)),
127
121
SizedBox (
122
+ height: _itemHeight.toDouble (),
128
123
child: ListTile (
129
124
leading: model? .picture? .medium == ""
130
125
? CircleAvatar (child: Text (model? .fullName[0 ]))
0 commit comments