Skip to content

Commit 7432375

Browse files
authored
🐛 Unify indicators usage (#344)
* ⚡️ Unify indicators usage * ⬆️ Use latest `photo_manager` * 🔖 7.3.3
1 parent 039724e commit 7432375

File tree

4 files changed

+30
-75
lines changed

4 files changed

+30
-75
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ that can be found in the LICENSE file. -->
44

55
# Changelog
66

7+
## 7.3.3
8+
9+
### Fixes
10+
11+
- Unify indicators usage to avoid accidentally indicator switching. (#344)
12+
713
## 7.3.2
814

915
### Improvements

example/lib/customs/pickers/directory_file_asset_picker.dart

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -765,31 +765,6 @@ class FileAssetPickerBuilder
765765
return RepaintBoundary(child: Image.file(asset, fit: BoxFit.cover));
766766
}
767767

768-
@override
769-
Widget loadingIndicator(BuildContext context) {
770-
return Center(
771-
child: Selector<FileAssetPickerProvider, bool>(
772-
selector: (_, FileAssetPickerProvider p) => p.isAssetsEmpty,
773-
builder: (_, bool isAssetsEmpty, __) {
774-
if (isAssetsEmpty) {
775-
return Text(textDelegate.emptyList);
776-
} else {
777-
return Center(
778-
child: SizedBox.fromSize(
779-
size: Size.square(Screens.width / gridCount / 3),
780-
child: CircularProgressIndicator(
781-
valueColor: AlwaysStoppedAnimation<Color>(
782-
theme.iconTheme.color ?? Colors.grey,
783-
),
784-
),
785-
),
786-
);
787-
}
788-
},
789-
),
790-
);
791-
}
792-
793768
@override
794769
Widget pathEntityListBackdrop(BuildContext context) {
795770
return ValueListenableBuilder<bool>(

lib/src/delegates/asset_picker_builder_delegate.dart

Lines changed: 22 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -414,29 +414,30 @@ abstract class AssetPickerBuilderDelegate<Asset, Path> {
414414
);
415415
}
416416

417+
/// Indicator when no assets were found from the current path.
418+
/// 当前目录下无资源的显示
419+
Widget emptyIndicator(BuildContext context) {
420+
return ScaleText(
421+
textDelegate.emptyList,
422+
maxScaleFactor: 1.5,
423+
semanticsLabel: semanticsTextDelegate.emptyList,
424+
);
425+
}
426+
417427
/// Loading indicator.
418428
/// 加载指示器
419429
Widget loadingIndicator(BuildContext context) {
420-
return Center(
421-
child: Selector<AssetPickerProvider<Asset, Path>, bool>(
422-
selector: (_, AssetPickerProvider<Asset, Path> p) => p.isAssetsEmpty,
423-
builder: (BuildContext c, bool isAssetsEmpty, Widget? w) {
424-
if (loadingIndicatorBuilder != null) {
425-
return loadingIndicatorBuilder!(c, isAssetsEmpty);
426-
}
427-
if (isAssetsEmpty) {
428-
return ScaleText(
429-
textDelegate.emptyList,
430-
maxScaleFactor: 1.5,
431-
semanticsLabel: semanticsTextDelegate.emptyList,
432-
);
433-
}
434-
return w!;
435-
},
436-
child: PlatformProgressIndicator(
437-
color: theme.iconTheme.color,
438-
size: context.mediaQuery.size.width / gridCount / 3,
439-
),
430+
return Selector<AssetPickerProvider<Asset, Path>, bool>(
431+
selector: (_, AssetPickerProvider<Asset, Path> p) => p.isAssetsEmpty,
432+
builder: (BuildContext context, bool isAssetsEmpty, Widget? w) {
433+
if (loadingIndicatorBuilder != null) {
434+
return loadingIndicatorBuilder!(context, isAssetsEmpty);
435+
}
436+
return Center(child: isAssetsEmpty ? emptyIndicator(context) : w);
437+
},
438+
child: PlatformProgressIndicator(
439+
color: theme.iconTheme.color,
440+
size: context.mediaQuery.size.width / gridCount / 3,
440441
),
441442
);
442443
}
@@ -1039,8 +1040,7 @@ class DefaultAssetPickerBuilderDelegate
10391040
specialItem = null;
10401041
}
10411042
if (totalCount == 0 && specialItem == null) {
1042-
return loadingIndicatorBuilder?.call(context, true) ??
1043-
Center(child: emptyIndicator(context));
1043+
return loadingIndicator(context);
10441044
}
10451045
// Then we use the [totalCount] to calculate placeholders we need.
10461046
final int placeholderCount;
@@ -1525,32 +1525,6 @@ class DefaultAssetPickerBuilderDelegate
15251525
);
15261526
}
15271527

1528-
Widget emptyIndicator(BuildContext context) {
1529-
return ScaleText(
1530-
textDelegate.emptyList,
1531-
maxScaleFactor: 1.5,
1532-
semanticsLabel: semanticsTextDelegate.emptyList,
1533-
);
1534-
}
1535-
1536-
@override
1537-
Widget loadingIndicator(BuildContext context) {
1538-
return Center(
1539-
child: Selector<DefaultAssetPickerProvider, bool>(
1540-
selector: (_, DefaultAssetPickerProvider p) => p.isAssetsEmpty,
1541-
builder: (BuildContext context, bool isAssetsEmpty, __) {
1542-
if (isAssetsEmpty) {
1543-
return emptyIndicator(context);
1544-
}
1545-
return PlatformProgressIndicator(
1546-
color: theme.iconTheme.color,
1547-
size: context.mediaQuery.size.width / gridCount / 3,
1548-
);
1549-
},
1550-
),
1551-
);
1552-
}
1553-
15541528
/// While the picker is switching path, this will displayed.
15551529
/// If the user tapped on it, it'll collapse the list widget.
15561530
///

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: wechat_assets_picker
22
description: An audio/video/image picker in pure Dart which is the same with WeChat, support multi picking.
3-
version: 7.3.2
3+
version: 7.3.3
44
homepage: https://github.com/fluttercandies/flutter_wechat_assets_picker
55

66
environment:
@@ -12,7 +12,7 @@ dependencies:
1212
sdk: flutter
1313

1414
extended_image: ^6.2.0
15-
photo_manager: ^2.1.0+1
15+
photo_manager: ^2.1.4
1616
provider: ^6.0.2
1717
video_player: ^2.4.0
1818

0 commit comments

Comments
 (0)