|
@@ -11,7 +11,6 @@ import 'package:provider/provider.dart';
|
11
|
11
|
import 'photo_main_page.dart';
|
12
|
12
|
import 'photo_preview_page.dart';
|
13
|
13
|
|
14
|
|
-
|
15
|
14
|
class PhotoListPage extends StatefulWidget {
|
16
|
15
|
final ValueChanged<List<AssetEntity>> onSelected;
|
17
|
16
|
final ListOptions options;
|
|
@@ -28,7 +27,8 @@ class PhotoListPage extends StatefulWidget {
|
28
|
27
|
|
29
|
28
|
class _PhotoListPageState extends State<PhotoListPage>
|
30
|
29
|
with SelectedProvider, GalleryListProvider, WidgetsBindingObserver {
|
31
|
|
- PhotoProvider get config => Provider.of<PhotoProvider>(context, listen: false);
|
|
30
|
+ PhotoProvider get config =>
|
|
31
|
+ Provider.of<PhotoProvider>(context, listen: false);
|
32
|
32
|
ListOptions get options => widget.options;
|
33
|
33
|
I18nProvider get i18nProvider => config.provider;
|
34
|
34
|
AssetProvider get assetProvider => config.assetProvider;
|
|
@@ -42,7 +42,7 @@ class _PhotoListPageState extends State<PhotoListPage>
|
42
|
42
|
bool isPushed = false;
|
43
|
43
|
|
44
|
44
|
// Throttle _changeThrottle;
|
45
|
|
-
|
|
45
|
+
|
46
|
46
|
@override
|
47
|
47
|
void initState() {
|
48
|
48
|
super.initState();
|
|
@@ -91,13 +91,16 @@ class _PhotoListPageState extends State<PhotoListPage>
|
91
|
91
|
List<AssetPathEntity> pathList;
|
92
|
92
|
switch (options.pickType) {
|
93
|
93
|
case PickType.onlyImage:
|
94
|
|
- pathList = await PhotoManager.getAssetPathList(type: RequestType.image, onlyAll: true);
|
|
94
|
+ pathList = await PhotoManager.getAssetPathList(
|
|
95
|
+ type: RequestType.image, onlyAll: true);
|
95
|
96
|
break;
|
96
|
97
|
case PickType.onlyVideo:
|
97
|
|
- pathList = await PhotoManager.getAssetPathList(type: RequestType.video, onlyAll: true);
|
|
98
|
+ pathList = await PhotoManager.getAssetPathList(
|
|
99
|
+ type: RequestType.video, onlyAll: true);
|
98
|
100
|
break;
|
99
|
101
|
default:
|
100
|
|
- pathList = await PhotoManager.getAssetPathList(type: RequestType.image | RequestType.video, onlyAll: true);
|
|
102
|
+ pathList = await PhotoManager.getAssetPathList(
|
|
103
|
+ type: RequestType.image | RequestType.video, onlyAll: true);
|
101
|
104
|
}
|
102
|
105
|
|
103
|
106
|
return _onRefreshAssetPathList(pathList);
|
|
@@ -149,7 +152,8 @@ class _PhotoListPageState extends State<PhotoListPage>
|
149
|
152
|
SnackBar(
|
150
|
153
|
content: Text(
|
151
|
154
|
msg,
|
152
|
|
- style: options.theme.textStyle.copyWith(color: options.theme.onPrimaryColor),
|
|
155
|
+ style: options.theme.textStyle
|
|
156
|
+ .copyWith(color: options.theme.onPrimaryColor),
|
153
|
157
|
),
|
154
|
158
|
duration: Duration(milliseconds: 1500),
|
155
|
159
|
backgroundColor: options.theme.primaryColor.withOpacity(0.7),
|
|
@@ -189,21 +193,24 @@ class _PhotoListPageState extends State<PhotoListPage>
|
189
|
193
|
}
|
190
|
194
|
|
191
|
195
|
var data = list[index];
|
192
|
|
- return RepaintBoundary(
|
193
|
|
- child: GestureDetector(
|
194
|
|
- onTap: () => _onItemClick(data, index),
|
195
|
|
- child: Stack(
|
196
|
|
- children: <Widget>[
|
197
|
|
- ImageItem(
|
198
|
|
- entity: data,
|
199
|
|
- themeColor: options.theme.primaryColor,
|
200
|
|
- size: options.thumbSize,
|
201
|
|
- loadingDelegate: options.loadingDelegate,
|
202
|
|
- badgeDelegate: options.badgeDelegate,
|
203
|
|
- ),
|
204
|
|
- _buildMask(containsEntity(data)),
|
205
|
|
- _buildSelected(data),
|
206
|
|
- ],
|
|
196
|
+ return Padding(
|
|
197
|
+ padding: EdgeInsets.only(left: index != 0 ? options.padding : 0),
|
|
198
|
+ child: RepaintBoundary(
|
|
199
|
+ child: GestureDetector(
|
|
200
|
+ onTap: () => _onItemClick(data, index),
|
|
201
|
+ child: Stack(
|
|
202
|
+ children: <Widget>[
|
|
203
|
+ ImageItem(
|
|
204
|
+ entity: data,
|
|
205
|
+ themeColor: options.theme.primaryColor,
|
|
206
|
+ size: options.thumbSize,
|
|
207
|
+ loadingDelegate: options.loadingDelegate,
|
|
208
|
+ badgeDelegate: options.badgeDelegate,
|
|
209
|
+ ),
|
|
210
|
+ _buildMask(containsEntity(data)),
|
|
211
|
+ _buildSelected(data),
|
|
212
|
+ ],
|
|
213
|
+ ),
|
207
|
214
|
),
|
208
|
215
|
),
|
209
|
216
|
);
|
|
@@ -247,7 +254,9 @@ class _PhotoListPageState extends State<PhotoListPage>
|
247
|
254
|
Widget _buildText(AssetEntity entity) {
|
248
|
255
|
var isSelected = containsEntity(entity);
|
249
|
256
|
Widget child;
|
250
|
|
- BoxDecoration decoration = BoxDecoration(borderRadius: BorderRadius.circular(1.0),);
|
|
257
|
+ BoxDecoration decoration = BoxDecoration(
|
|
258
|
+ borderRadius: BorderRadius.circular(1.0),
|
|
259
|
+ );
|
251
|
260
|
if (isSelected) {
|
252
|
261
|
child = Text(
|
253
|
262
|
(indexOfSelected(entity) + 1).toString(),
|
|
@@ -259,9 +268,11 @@ class _PhotoListPageState extends State<PhotoListPage>
|
259
|
268
|
);
|
260
|
269
|
decoration = decoration.copyWith(color: options.theme.primaryColor);
|
261
|
270
|
} else {
|
262
|
|
- decoration = decoration.copyWith(border: Border.all(
|
263
|
|
- color: options.theme.onPrimaryColor.withAlpha(200),
|
264
|
|
- ),);
|
|
271
|
+ decoration = decoration.copyWith(
|
|
272
|
+ border: Border.all(
|
|
273
|
+ color: options.theme.onPrimaryColor.withAlpha(200),
|
|
274
|
+ ),
|
|
275
|
+ );
|
265
|
276
|
}
|
266
|
277
|
return Padding(
|
267
|
278
|
padding: const EdgeInsets.all(8.0),
|
|
@@ -341,4 +352,4 @@ class _PhotoListPageState extends State<PhotoListPage>
|
341
|
352
|
),
|
342
|
353
|
);
|
343
|
354
|
}
|
344
|
|
-}
|
|
355
|
+}
|