Skip to content

Commit d7f4d80

Browse files
authored
🚸 Use LocallyAvailableBuilder in the grid to provide better user awareness (#614)
1 parent 43e81e6 commit d7f4d80

File tree

3 files changed

+51
-26
lines changed

3 files changed

+51
-26
lines changed

‎CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ that can be found in the LICENSE file. -->
99
1010
## Unreleased
1111

12-
*None.*
12+
- Use `LocallyAvailableBuilder` in the grid to provide better user awareness.
1313

1414
## 9.2.0
1515

‎lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,32 +1659,57 @@ class DefaultAssetPickerBuilderDelegate
16591659
int index,
16601660
AssetEntity asset,
16611661
) {
1662-
final AssetEntityImageProvider imageProvider = AssetEntityImageProvider(
1663-
asset,
1664-
isOriginal: false,
1665-
thumbnailSize: gridThumbnailSize,
1666-
);
1667-
SpecialImageType? type;
1668-
if (imageProvider.imageFileType == ImageFileType.gif) {
1669-
type = SpecialImageType.gif;
1670-
} else if (imageProvider.imageFileType == ImageFileType.heic) {
1671-
type = SpecialImageType.heic;
1672-
}
1673-
return Stack(
1674-
children: <Widget>[
1675-
Positioned.fill(
1676-
child: RepaintBoundary(
1677-
child: AssetEntityGridItemBuilder(
1678-
image: imageProvider,
1679-
failedItemBuilder: failedItemBuilder,
1662+
return LocallyAvailableBuilder(
1663+
asset: asset,
1664+
builder: (context, asset) {
1665+
final imageProvider = AssetEntityImageProvider(
1666+
asset,
1667+
isOriginal: false,
1668+
thumbnailSize: gridThumbnailSize,
1669+
);
1670+
SpecialImageType? type;
1671+
if (imageProvider.imageFileType == ImageFileType.gif) {
1672+
type = SpecialImageType.gif;
1673+
} else if (imageProvider.imageFileType == ImageFileType.heic) {
1674+
type = SpecialImageType.heic;
1675+
}
1676+
return Stack(
1677+
children: <Widget>[
1678+
Positioned.fill(
1679+
child: RepaintBoundary(
1680+
child: AssetEntityGridItemBuilder(
1681+
image: imageProvider,
1682+
failedItemBuilder: failedItemBuilder,
1683+
),
1684+
),
16801685
),
1686+
if (type == SpecialImageType.gif) // 如果为GIF则显示标识
1687+
gifIndicator(context, asset),
1688+
if (asset.type == AssetType.video) // 如果为视频则显示标识
1689+
videoIndicator(context, asset),
1690+
],
1691+
);
1692+
},
1693+
progressBuilder: (context, state, progress) => Row(
1694+
mainAxisAlignment: MainAxisAlignment.center,
1695+
children: [
1696+
Icon(
1697+
state == PMRequestState.failed
1698+
? Icons.cloud_off
1699+
: Icons.cloud_download_outlined,
1700+
color: context.iconTheme.color?.withOpacity(.4),
1701+
size: 24.0,
16811702
),
1682-
),
1683-
if (type == SpecialImageType.gif) // 如果为GIF则显示标识
1684-
gifIndicator(context, asset),
1685-
if (asset.type == AssetType.video) // 如果为视频则显示标识
1686-
videoIndicator(context, asset),
1687-
],
1703+
if (state != PMRequestState.success && state != PMRequestState.failed)
1704+
ScaleText(
1705+
' ${((progress ?? 0) * 100).toInt()}%',
1706+
style: TextStyle(
1707+
color: context.textTheme.bodyMedium?.color?.withOpacity(.4),
1708+
fontSize: 12.0,
1709+
),
1710+
),
1711+
],
1712+
),
16881713
);
16891714
}
16901715

‎pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies:
2222
flutter:
2323
sdk: flutter
2424

25-
wechat_picker_library: ^1.0.0
25+
wechat_picker_library: ^1.0.2
2626

2727
extended_image: ^8.2.0
2828
photo_manager: ^3.0.0

0 commit comments

Comments
 (0)