Skip to content

Commit

Permalink
🚀 Adapt the image provider file type getter (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexV525 authored Oct 8, 2024
1 parent 6228379 commit b800fca
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ that can be found in the LICENSE file. -->
## Unreleased

*None.*
### Improvements

- Adapt the file type getter from the image provider to get a precise file type in grid.
- Adds the identifier for grid item's semantics.
- Improves preview page back button.

## 9.3.1

Expand Down
32 changes: 18 additions & 14 deletions lib/src/delegates/asset_picker_builder_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,10 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
gradient: LinearGradient(
begin: AlignmentDirectional.bottomCenter,
end: AlignmentDirectional.topCenter,
colors: <Color>[theme.dividerColor, Colors.transparent],
colors: <Color>[
theme.canvasColor.withAlpha(128),
Colors.transparent,
],
),
),
child: Container(
Expand All @@ -428,11 +431,9 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
child: ScaleText(
textDelegate.gifIndicator,
style: TextStyle(
color: isAppleOS(context)
? theme.textTheme.bodyMedium?.color
: theme.primaryColor,
fontSize: 13,
fontWeight: FontWeight.w500,
color: theme.textTheme.bodyMedium?.color,
fontSize: 12,
fontWeight: FontWeight.bold,
),
semanticsLabel: semanticsTextDelegate.gifIndicator,
strutStyle: const StrutStyle(forceStrutHeight: true, height: 1),
Expand Down Expand Up @@ -1503,6 +1504,7 @@ class DefaultAssetPickerBuilderDelegate
enabled: !isBanned,
excludeSemantics: true,
focusable: !isSwitchingPath,
identifier: asset.id,
label: '${semanticsTextDelegate.semanticTypeLabel(asset.type)}'
'${semanticIndex(index)}, '
'${asset.createDateTime.toString().replaceAll('.000', '')}',
Expand Down Expand Up @@ -1718,12 +1720,6 @@ class DefaultAssetPickerBuilderDelegate
isOriginal: false,
thumbnailSize: gridThumbnailSize,
);
SpecialImageType? type;
if (imageProvider.imageFileType == ImageFileType.gif) {
type = SpecialImageType.gif;
} else if (imageProvider.imageFileType == ImageFileType.heic) {
type = SpecialImageType.heic;
}
return Stack(
fit: StackFit.expand,
children: <Widget>[
Expand All @@ -1733,8 +1729,16 @@ class DefaultAssetPickerBuilderDelegate
failedItemBuilder: failedItemBuilder,
),
),
if (type == SpecialImageType.gif) // 如果为GIF则显示标识
gifIndicator(context, asset),
FutureBuilder(
future: imageProvider.imageFileType,
builder: (context, snapshot) {
if (snapshot.data case final type?
when type == ImageFileType.gif) {
return gifIndicator(context, asset);
}
return const SizedBox.shrink();
},
),
if (asset.type == AssetType.video) // 如果为视频则显示标识
videoIndicator(context, asset),
if (asset.isLivePhoto) buildLivePhotoIndicator(context, asset),
Expand Down
6 changes: 3 additions & 3 deletions lib/src/delegates/asset_picker_viewer_builder_delegate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,10 @@ class DefaultAssetPickerViewerBuilderDelegate
onPressed: () {
Navigator.maybeOf(context)?.maybePop();
},
tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
icon: Icon(
Icons.close,
semanticLabel: MaterialLocalizations.of(context).closeButtonTooltip,
Icons.arrow_back_ios_new,
semanticLabel: MaterialLocalizations.of(context).backButtonTooltip,
),
),
),
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ dependencies:
wechat_picker_library: ^1.0.5

extended_image: ^8.3.0
photo_manager: ^3.4.0
photo_manager_image_provider: ^2.1.2
photo_manager: ^3.5.0
photo_manager_image_provider: ^2.2.0
provider: ^6.0.5
video_player: ^2.7.0
visibility_detector: ^0.4.0
Expand Down

0 comments on commit b800fca

Please sign in to comment.