feat(picker): 统一安卓相册名称本地化
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_common/upload_image/ossUtil.dart';
|
||||
import 'package:flutter_common/utils/asset_picker_localization.dart';
|
||||
import 'package:flutter_image_compress/flutter_image_compress.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
@@ -34,22 +35,6 @@ class _ImageCompressionTarget {
|
||||
}
|
||||
|
||||
class UploadImagesTool {
|
||||
static String _assetPathNameBuilder(AssetPathEntity path) {
|
||||
final locale =
|
||||
Get.locale ?? WidgetsBinding.instance.platformDispatcher.locale;
|
||||
if (locale.languageCode.toLowerCase() != 'zh') {
|
||||
return path.name;
|
||||
}
|
||||
|
||||
const systemPathNameMap = {
|
||||
'Recent': '最近项目',
|
||||
'Camera': '相机',
|
||||
'Screenshots': '截屏',
|
||||
'Downloads': '下载',
|
||||
};
|
||||
return systemPathNameMap[path.name] ?? path.name;
|
||||
}
|
||||
|
||||
static uploadImagesTool({
|
||||
String? oSSAccessKeyId,
|
||||
String? policy,
|
||||
@@ -312,7 +297,8 @@ class UploadImagesTool {
|
||||
pickerConfig: AssetPickerConfig(
|
||||
maxAssets: 1,
|
||||
requestType: RequestType.video,
|
||||
pathNameBuilder: _assetPathNameBuilder,
|
||||
pathNameBuilder: (AssetPathEntity path) =>
|
||||
AssetPickerLocalization.pathName(Get.context!, path),
|
||||
),
|
||||
);
|
||||
final File? video = await result?.first.file;
|
||||
@@ -335,7 +321,8 @@ class UploadImagesTool {
|
||||
Get.context!,
|
||||
pickerConfig: AssetPickerConfig(
|
||||
maxAssets: max ?? 50,
|
||||
pathNameBuilder: _assetPathNameBuilder,
|
||||
pathNameBuilder: (AssetPathEntity path) =>
|
||||
AssetPickerLocalization.pathName(Get.context!, path),
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user