1
- import 'package:clippy_flutter/clippy_flutter.dart' ;
2
- import 'package:flutter/material.dart' ;
3
-
4
1
import 'package:azlistview/azlistview.dart' ;
2
+ import 'package:clippy_flutter/diagonal.dart' ;
3
+ import 'package:flutter/material.dart' ;
5
4
import 'package:flutter_app/generated/i18n.dart' ;
6
5
7
6
import '../../page_index.dart' ;
@@ -45,50 +44,41 @@ class _ContactListPageState extends State<ContactListPage> {
45
44
if (snapshot.data.length > 0 ) {
46
45
return AzListView (
47
46
data: snapshot.data,
48
- itemBuilder: (context, model) =>
49
- _buildListItem (model),
50
- header: AzListViewHeader (
51
- height: 220 ,
52
- builder: (context) => Diagonal (
53
- axis: Axis .horizontal,
54
- position: DiagonalPosition .BOTTOM_LEFT ,
55
- clipHeight: 50.0 ,
56
- child: ContactListHeader (
57
- name: "SCL" , phone: "18601952581" ),
58
- ),
59
- ),
60
- isUseRealIndex: true ,
61
- itemHeight: _itemHeight,
62
- indexBarBuilder: (BuildContext context,
63
- List <String > tags,
64
- IndexBarTouchCallback onTouch) {
65
- return Container (
66
- margin: EdgeInsets .symmetric (
67
- vertical: 16.0 , horizontal: 8.0 ),
68
- decoration: BoxDecoration (
69
- color: Colors .grey[50 ],
70
- borderRadius: BorderRadius .circular (20.0 ),
71
- border: Border .all (
72
- color: Colors .grey[300 ], width: .5 )),
73
- child: ClipRRect (
74
- borderRadius: BorderRadius .circular (20.0 ),
75
- child: IndexBar (
76
- data: tags,
77
- itemHeight: 20 ,
78
- onTouch: (details) =>
79
- onTouch (details))));
47
+ itemBuilder: (context, index) {
48
+ if (index == 0 ) {
49
+ return Container (
50
+ height: 220 ,
51
+ child: Diagonal (
52
+ axis: Axis .horizontal,
53
+ position: DiagonalPosition .BOTTOM_LEFT ,
54
+ clipHeight: 50.0 ,
55
+ child: ContactListHeader (
56
+ name: "SCL" , phone: "18601952581" )));
57
+ }
58
+ return _buildListItem (snapshot.data[index]);
80
59
},
81
- indexHintBuilder: (_, String hint) => Container (
82
- alignment: Alignment .center,
83
- width: 60.0 ,
84
- height: 60.0 ,
85
- decoration: BoxDecoration (
86
- color: Colors .blue[700 ].withAlpha (200 ),
87
- shape: BoxShape .circle),
88
- child: Text (hint,
89
- style: TextStyle (
90
- color: Colors .white, fontSize: 30.0 )),
91
- ));
60
+ physics: BouncingScrollPhysics (),
61
+ itemCount: snapshot.data.length,
62
+ // indexBarData: ['↑', ...kIndexBarData],
63
+ indexBarData:
64
+ SuspensionUtil .getTagIndexList (snapshot.data),
65
+ indexBarOptions: IndexBarOptions (
66
+ needRebuild: true ,
67
+ ignoreDragCancel: true ,
68
+ downTextStyle:
69
+ TextStyle (fontSize: 12 , color: Colors .white),
70
+ downItemDecoration: BoxDecoration (
71
+ shape: BoxShape .circle, color: Colors .green),
72
+ indexHintWidth: 120 / 2 ,
73
+ indexHintHeight: 100 / 2 ,
74
+ indexHintDecoration: BoxDecoration (
75
+ image: DecorationImage (
76
+ image: AssetImage (
77
+ 'images/ic_index_bar_bubble_gray.png' ),
78
+ fit: BoxFit .contain)),
79
+ indexHintAlignment: Alignment .centerRight,
80
+ indexHintChildAlignment: Alignment (- 0.25 , 0.0 ),
81
+ indexHintOffset: Offset (- 20 , 0 )));
92
82
}
93
83
return EmptyPage (
94
84
text: '暂无数据' , imageAsset: 'images/empty.jpeg' );
@@ -102,62 +92,58 @@ class _ContactListPageState extends State<ContactListPage> {
102
92
103
93
Widget _buildListItem (ContactBean model) {
104
94
return Container (
105
- padding: const EdgeInsets .only (left: 16.0 , right: 34.0 ),
106
- height: _itemHeight.toDouble (),
107
- child: Container (
108
- decoration: BoxDecoration (
109
- border: (model.isShowSuspension)
110
- ? Border (
111
- top: Divider .createBorderSide (context,
112
- color: Colors .grey, width: 0.6 ),
113
- )
114
- : null ),
115
- child: Row (
116
- children: < Widget > [
117
- Opacity (
118
- opacity: model.isShowSuspension ? 1 : 0 ,
119
- child: SizedBox (
120
- width: 28.0 ,
121
- child: Text (model.firstLetter, style: TextStyles .textDark14),
122
- )),
123
- Expanded (
124
- child: ListTile (
125
- leading: Hero (
126
- tag: '${model .fullName }' ,
127
- child: model? .picture? .medium == ""
128
- ? CircleAvatar (child: Text (model? .fullName[0 ]))
129
- : CircleAvatar (
130
- backgroundImage:
131
- NetworkImage (model? .picture? .medium),
132
- ),
133
- ),
134
- title: Text (model.fullName),
135
- subtitle: Text (model.email),
136
- onTap: () => pushNewPage (
137
- context,
138
- ContactPage (
139
- name: model.fullName,
140
- phone: model.phone,
141
- avatar: model? .picture? .large,
142
- email: model? .email,
143
- cell: model? .cell,
144
- address:
145
- "${model ?.location ?.street ?.number } ${model ?.location ?.street ?.name }" ,
146
- area:
147
- "${model ?.location ?.city }, ${model ?.location ?.state }" ,
148
- birthday: model? .dob? .date))),
149
- )
150
- ],
151
- ),
152
- ),
153
- );
95
+ padding: const EdgeInsets .only (left: 16.0 , right: 34.0 ),
96
+ height: _itemHeight.toDouble (),
97
+ child: Container (
98
+ decoration: BoxDecoration (
99
+ border: (model.isShowSuspension)
100
+ ? Border (
101
+ top: Divider .createBorderSide (context,
102
+ color: Colors .grey, width: 0.6 ))
103
+ : null ),
104
+ child: Row (children: < Widget > [
105
+ Opacity (
106
+ opacity: model.isShowSuspension ? 1 : 0 ,
107
+ child: SizedBox (
108
+ width: 28.0 ,
109
+ child: Text (model.firstLetter,
110
+ style: TextStyles .textDark14))),
111
+ Expanded (
112
+ child: ListTile (
113
+ leading: Hero (
114
+ tag: '${model .fullName }' ,
115
+ child: model? .picture? .medium == ""
116
+ ? CircleAvatar (child: Text (model? .fullName[0 ]))
117
+ : CircleAvatar (
118
+ backgroundImage:
119
+ NetworkImage (model? .picture? .medium))),
120
+ title: Text (model.fullName),
121
+ subtitle: Text (model.email),
122
+ onTap: () => pushNewPage (
123
+ context,
124
+ ContactPage (
125
+ name: model.fullName,
126
+ phone: model.phone,
127
+ avatar: model? .picture? .large,
128
+ email: model? .email,
129
+ cell: model? .cell,
130
+ address:
131
+ "${model ?.location ?.street ?.number } ${model ?.location ?.street ?.name }" ,
132
+ area:
133
+ "${model ?.location ?.city }, ${model ?.location ?.state }" ,
134
+ birthday: model? .dob? .date))))
135
+ ])));
154
136
}
155
137
156
138
Future <List <ContactBean >> fetchData () async {
157
139
List <ContactBean > _contacts = await ApiService .getRandomUser ();
158
140
159
141
/// 根据A-Z排序
160
142
SuspensionUtil .sortListBySuspensionTag (_contacts);
143
+
144
+ SuspensionUtil .setShowSuspensionStatus (_contacts);
145
+
146
+ _contacts.insert (0 , ContactBean (fullName: "header" , firstLetter: "↑" ));
161
147
return _contacts;
162
148
}
163
149
}
0 commit comments