Skip to content

Commit e16efa8

Browse files
committed
🐛 Fix video judge condition with WeChat Moment mode
1 parent f89795d commit e16efa8

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

lib/src/delegates/asset_picker_viewer_builder_delegate.dart

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,13 @@ class DefaultAssetPickerViewerBuilderDelegate
263263
bool get isWeChatMoment =>
264264
specialPickerType == SpecialPickerType.wechatMoment;
265265

266+
/// Whether there are videos in preview/selected assets.
267+
/// 当前正在预览或已选的资源是否有视频
268+
bool get hasVideo =>
269+
previewAssets.any((AssetEntity e) => e.type == AssetType.video) ||
270+
(selectedAssets?.any((AssetEntity e) => e.type == AssetType.video) ??
271+
false);
272+
266273
@override
267274
void initStateAndTicker(
268275
AssetPickerViewerState<AssetEntity, AssetPathEntity> s,
@@ -595,14 +602,9 @@ class DefaultAssetPickerViewerBuilderDelegate
595602
'Viewer provider must not be null'
596603
'when the special type is not WeChat moment.',
597604
);
598-
// Check whether any videos in selected assets.
599-
final bool _hasVideos = selectedAssets?.any(
600-
(AssetEntity e) => e.type == AssetType.video,
601-
) ??
602-
false;
603605
return MaterialButton(
604606
minWidth: () {
605-
if (isWeChatMoment && _hasVideos) {
607+
if (isWeChatMoment && hasVideo) {
606608
return 48.0;
607609
}
608610
return provider!.isSelectedNotEmpty ? 48.0 : 20.0;
@@ -615,7 +617,7 @@ class DefaultAssetPickerViewerBuilderDelegate
615617
),
616618
child: Text(
617619
() {
618-
if (isWeChatMoment && _hasVideos) {
620+
if (isWeChatMoment && hasVideo) {
619621
return Constants.textDelegate.confirm;
620622
}
621623
if (provider!.isSelectedNotEmpty) {
@@ -633,7 +635,7 @@ class DefaultAssetPickerViewerBuilderDelegate
633635
),
634636
),
635637
onPressed: () {
636-
if (isWeChatMoment && _hasVideos) {
638+
if (isWeChatMoment && hasVideo) {
637639
Navigator.of(context).pop(<AssetEntity>[currentAsset]);
638640
return;
639641
}
@@ -784,7 +786,8 @@ class DefaultAssetPickerViewerBuilderDelegate
784786
),
785787
),
786788
appBar(context),
787-
if (selectedAssets != null) bottomDetailBuilder(context),
789+
if (selectedAssets != null || (isWeChatMoment && hasVideo))
790+
bottomDetailBuilder(context),
788791
],
789792
),
790793
),

0 commit comments

Comments
 (0)