[mob] Use custom assetPickerTextDelegate to use en as default (#1844)

## Description

## Tests
Tested locally
This commit is contained in:
Neeraj Gupta 2024-05-24 18:24:48 +05:30 committed by GitHub
commit 3c8d29bcdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -167,7 +167,13 @@ class AddPhotosPhotoWidget extends StatelessWidget {
Future<void> _onPickFromDeviceClicked(BuildContext context) async {
try {
final List<AssetEntity>? result = await AssetPicker.pickAssets(context);
final assetPickerTextDelegate = await _getAssetPickerTextDelegate();
final List<AssetEntity>? result = await AssetPicker.pickAssets(
context,
pickerConfig: AssetPickerConfig(
textDelegate: assetPickerTextDelegate,
),
);
if (result != null && result.isNotEmpty) {
final ca = CollectionActions(
CollectionsService.instance,
@ -204,6 +210,39 @@ class AddPhotosPhotoWidget extends StatelessWidget {
}
}
}
// _getAssetPickerTextDelegate returns the text delegate for the asset picker
// This custom method is required to enforce English as the default fallback
// instead of Chinese.
Future<AssetPickerTextDelegate> _getAssetPickerTextDelegate() async {
final Locale locale = await getLocale();
switch (locale.languageCode.toLowerCase()) {
case "en":
return const EnglishAssetPickerTextDelegate();
case "he":
return const HebrewAssetPickerTextDelegate();
case "de":
return const GermanAssetPickerTextDelegate();
case "ru":
return const RussianAssetPickerTextDelegate();
case "ja":
return const JapaneseAssetPickerTextDelegate();
case "ar":
return const ArabicAssetPickerTextDelegate();
case "fr":
return const FrenchAssetPickerTextDelegate();
case "vi":
return const VietnameseAssetPickerTextDelegate();
case "tr":
return const TurkishAssetPickerTextDelegate();
case "ko":
return const KoreanAssetPickerTextDelegate();
case "zh":
return const AssetPickerTextDelegate();
default:
return const EnglishAssetPickerTextDelegate();
}
}
}
class DelayedGallery extends StatefulWidget {