Skip to content
This repository has been archived by the owner on Sep 23, 2021. It is now read-only.

Fix picking unlimited amount of media items #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/src/provider/config_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ class PhotoPickerProvider extends InheritedWidget {

static AssetProvider assetProviderOf(BuildContext context) =>
of(context).assetProvider;

String getSureText(selectedCount) => options.maxSelected == null
? provider.getSureText(options, selectedCount)
: provider.getSureTextWithMax(options, selectedCount);
}
17 changes: 17 additions & 0 deletions lib/src/provider/i18n_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ abstract class I18nProvider {

String getSureText(Options options, int currentCount);

String getSureTextWithMax(Options options, int currentCount);

String getPreviewText(Options options, SelectedProvider selectedProvider);

String getSelectedOptionsText(Options options);
Expand Down Expand Up @@ -48,6 +50,11 @@ class CNProvider extends I18nProvider {

@override
String getSureText(Options options, int currentCount) {
return "确定($currentCount)";
}

@override
String getSureTextWithMax(Options options, int currentCount) {
return "确定($currentCount/${options.maxSelected})";
}

Expand Down Expand Up @@ -98,6 +105,11 @@ class ENProvider extends I18nProvider {

@override
String getSureText(Options options, int currentCount) {
return "Save ($currentCount)";
}

@override
String getSureTextWithMax(Options options, int currentCount) {
return "Save ($currentCount/${options.maxSelected})";
}

Expand Down Expand Up @@ -140,6 +152,11 @@ class DEProvider extends I18nProvider {

@override
String getSureText(Options options, int currentCount) {
return "Speichern ($currentCount)";
}

@override
String getSureTextWithMax(Options options, int currentCount) {
return "Speichern ($currentCount/${options.maxSelected})";
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/ui/page/photo_main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class _PhotoMainPageState extends State<PhotoMainPage>
FlatButton(
splashColor: Colors.transparent,
child: Text(
i18nProvider.getSureText(options, selectedCount),
PhotoPickerProvider.of(context).getSureText(selectedCount),
style: selectedCount == 0
? textStyle.copyWith(color: options.disableColor)
: textStyle,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/ui/page/photo_preview_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class _PhotoPreviewPageState extends State<PhotoPreviewPage> {
splashColor: Colors.transparent,
onPressed: selectedList.length == 0 ? null : sure,
child: Text(
config.provider.getSureText(options, selectedList.length),
config.getSureText(selectedList.length),
style: selectedList.length == 0
? textStyle.copyWith(color: options.disableColor)
: textStyle,
Expand Down