feat(ios):照片loading

This commit is contained in:
2025-10-29 18:13:33 +08:00
parent 0cc51689be
commit 5bb3ebd853
12 changed files with 1561 additions and 7 deletions

View File

@@ -35,6 +35,7 @@ class UploadOss {
required String signature,
required String ossDirectory,
required String ossHost,
bool? isShowLoading,
}) async {
// 生成oss的路径和文件名我这里目前设置的是moment/20201229/test.mp4
String pathName = "$rootDir/${getDate()}/app-${getRandom(12)}.$fileType";
@@ -54,10 +55,12 @@ class UploadOss {
filename: "${getRandom(12)}.$fileType",
),
});
await EasyLoading.show(
// status: 'loading...',
maskType: EasyLoadingMaskType.black,
);
if (isShowLoading == true) {
await EasyLoading.show(
// status: 'loading...',
maskType: EasyLoadingMaskType.black,
);
}
Dio dio = Dio();
dio.options.responseType = ResponseType.plain;
// dio.options.method = 'put';

View File

@@ -270,6 +270,7 @@ class _UploadImagesState extends State<UploadImages> {
Future<void> chooseCamera({
required BuildContext context,
int? max,
bool? isShowLoading,
}) async {
//
showCupertinoModalPopup(
@@ -291,7 +292,7 @@ class _UploadImagesState extends State<UploadImages> {
CupertinoActionSheetAction(
child: const Text('相册'),
onPressed: () {
openGallery();
openGallery(isShowLoading: isShowLoading);
Get.back();
},
),
@@ -324,7 +325,7 @@ class _UploadImagesState extends State<UploadImages> {
}
}
openGallery() async {
openGallery({bool? isShowLoading}) async {
int number = (widget.max ?? 9) - imagesList.length;
// List<Media>? images =
// await ImagesPicker.pick(count: number, pickType: PickType.image);
@@ -336,6 +337,7 @@ class _UploadImagesState extends State<UploadImages> {
for (var element in images) {
String path = await saveNetworkImgGallery(
element.path,
isShowLoading: isShowLoading,
);
list.add(path);
}
@@ -364,7 +366,8 @@ class _UploadImagesState extends State<UploadImages> {
}
// 保存网络图片
Future<String> saveNetworkImgGallery(String path) async {
Future<String> saveNetworkImgGallery(String path,
{bool? isShowLoading}) async {
String string = await UploadOss.upload(
path,
fileType: "jpg",
@@ -374,6 +377,7 @@ class _UploadImagesState extends State<UploadImages> {
policy: widget.policy,
callback: widget.callback,
signature: widget.signature,
isShowLoading: isShowLoading,
);
return string;
}

View File

@@ -22,6 +22,7 @@ class UploadImagesTool {
int? max,
bool? isVideo,
Widget? isAddOtherWidget,
bool? isShowLoading,
}) async {
await chooseCamera(
context: context,
@@ -34,6 +35,7 @@ class UploadImagesTool {
signature: signature ?? '',
isVideo: isVideo,
isAddOtherWidget: isAddOtherWidget,
isShowLoading: isShowLoading,
chooseImages: (list) => chooseImagesTap?.call(list),
);
}
@@ -95,6 +97,7 @@ class UploadImagesTool {
Function? chooseImages,
bool? isVideo,
Widget? isAddOtherWidget,
bool? isShowLoading,
}) async {
//
showCupertinoModalPopup(
@@ -201,6 +204,7 @@ class UploadImagesTool {
policy: policy ?? '',
callback: callback ?? '',
signature: signature ?? '',
isShowLoading: isShowLoading,
chooseImages: (list) =>
chooseImages?.call(list),
);
@@ -258,6 +262,7 @@ class UploadImagesTool {
String? ossHost,
int? max,
bool? isVideo,
bool? isShowLoading,
}) async {
if (isVideo == true) {
XFile? video = await ImagePicker().pickVideo(source: ImageSource.gallery);
@@ -285,6 +290,7 @@ class UploadImagesTool {
policy: policy ?? '',
callback: callback ?? '',
signature: signature ?? '',
isShowLoading: isShowLoading,
);
list.add(path);
}
@@ -327,6 +333,7 @@ class UploadImagesTool {
String? signature,
String? ossDirectory,
String? ossHost,
bool? isShowLoading,
}) async {
String string = await UploadOss.upload(
path,
@@ -337,6 +344,7 @@ class UploadImagesTool {
policy: policy ?? '',
callback: callback ?? '',
signature: signature ?? '',
isShowLoading: isShowLoading,
);
return string;
}