Skip to content

Commit b800fca

Browse files
authored
🚀 Adapt the image provider file type getter (#638)
1 parent 6228379 commit b800fca

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

CHANGELOG.md

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

12-
*None.*
12+
### Improvements
13+
14+
- Adapt the file type getter from the image provider to get a precise file type in grid.
15+
- Adds the identifier for grid item's semantics.
16+
- Improves preview page back button.
1317

1418
## 9.3.1
1519

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,10 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
414414
gradient: LinearGradient(
415415
begin: AlignmentDirectional.bottomCenter,
416416
end: AlignmentDirectional.topCenter,
417-
colors: <Color>[theme.dividerColor, Colors.transparent],
417+
colors: <Color>[
418+
theme.canvasColor.withAlpha(128),
419+
Colors.transparent,
420+
],
418421
),
419422
),
420423
child: Container(
@@ -428,11 +431,9 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
428431
child: ScaleText(
429432
textDelegate.gifIndicator,
430433
style: TextStyle(
431-
color: isAppleOS(context)
432-
? theme.textTheme.bodyMedium?.color
433-
: theme.primaryColor,
434-
fontSize: 13,
435-
fontWeight: FontWeight.w500,
434+
color: theme.textTheme.bodyMedium?.color,
435+
fontSize: 12,
436+
fontWeight: FontWeight.bold,
436437
),
437438
semanticsLabel: semanticsTextDelegate.gifIndicator,
438439
strutStyle: const StrutStyle(forceStrutHeight: true, height: 1),
@@ -1503,6 +1504,7 @@ class DefaultAssetPickerBuilderDelegate
15031504
enabled: !isBanned,
15041505
excludeSemantics: true,
15051506
focusable: !isSwitchingPath,
1507+
identifier: asset.id,
15061508
label: '${semanticsTextDelegate.semanticTypeLabel(asset.type)}'
15071509
'${semanticIndex(index)}, '
15081510
'${asset.createDateTime.toString().replaceAll('.000', '')}',
@@ -1718,12 +1720,6 @@ class DefaultAssetPickerBuilderDelegate
17181720
isOriginal: false,
17191721
thumbnailSize: gridThumbnailSize,
17201722
);
1721-
SpecialImageType? type;
1722-
if (imageProvider.imageFileType == ImageFileType.gif) {
1723-
type = SpecialImageType.gif;
1724-
} else if (imageProvider.imageFileType == ImageFileType.heic) {
1725-
type = SpecialImageType.heic;
1726-
}
17271723
return Stack(
17281724
fit: StackFit.expand,
17291725
children: <Widget>[
@@ -1733,8 +1729,16 @@ class DefaultAssetPickerBuilderDelegate
17331729
failedItemBuilder: failedItemBuilder,
17341730
),
17351731
),
1736-
if (type == SpecialImageType.gif) // 如果为GIF则显示标识
1737-
gifIndicator(context, asset),
1732+
FutureBuilder(
1733+
future: imageProvider.imageFileType,
1734+
builder: (context, snapshot) {
1735+
if (snapshot.data case final type?
1736+
when type == ImageFileType.gif) {
1737+
return gifIndicator(context, asset);
1738+
}
1739+
return const SizedBox.shrink();
1740+
},
1741+
),
17381742
if (asset.type == AssetType.video) // 如果为视频则显示标识
17391743
videoIndicator(context, asset),
17401744
if (asset.isLivePhoto) buildLivePhotoIndicator(context, asset),

lib/src/delegates/asset_picker_viewer_builder_delegate.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -734,10 +734,10 @@ class DefaultAssetPickerViewerBuilderDelegate
734734
onPressed: () {
735735
Navigator.maybeOf(context)?.maybePop();
736736
},
737-
tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
737+
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
738738
icon: Icon(
739-
Icons.close,
740-
semanticLabel: MaterialLocalizations.of(context).closeButtonTooltip,
739+
Icons.arrow_back_ios_new,
740+
semanticLabel: MaterialLocalizations.of(context).backButtonTooltip,
741741
),
742742
),
743743
),

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ dependencies:
2525
wechat_picker_library: ^1.0.5
2626

2727
extended_image: ^8.3.0
28-
photo_manager: ^3.4.0
29-
photo_manager_image_provider: ^2.1.2
28+
photo_manager: ^3.5.0
29+
photo_manager_image_provider: ^2.2.0
3030
provider: ^6.0.5
3131
video_player: ^2.7.0
3232
visibility_detector: ^0.4.0

0 commit comments

Comments
 (0)