mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: pick images
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -112,50 +112,54 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
||||
}
|
||||
|
||||
void _pickImg() async {
|
||||
XFile? pickedFile = await _imagePicker.pickImage(
|
||||
source: ImageSource.gallery,
|
||||
imageQuality: 100,
|
||||
);
|
||||
if (pickedFile != null && mounted) {
|
||||
CroppedFile? croppedFile = await ImageCropper().cropImage(
|
||||
sourcePath: pickedFile.path,
|
||||
uiSettings: [
|
||||
AndroidUiSettings(
|
||||
toolbarTitle: '裁剪',
|
||||
toolbarColor: Theme.of(context).colorScheme.primary,
|
||||
toolbarWidgetColor: Colors.white,
|
||||
aspectRatioPresets: [
|
||||
CropAspectRatioPreset.ratio16x9,
|
||||
],
|
||||
lockAspectRatio: true,
|
||||
hideBottomControls: true,
|
||||
initAspectRatio: CropAspectRatioPreset.ratio16x9,
|
||||
),
|
||||
IOSUiSettings(
|
||||
title: '裁剪',
|
||||
aspectRatioPresets: [
|
||||
CropAspectRatioPreset.ratio16x9,
|
||||
],
|
||||
aspectRatioLockEnabled: true,
|
||||
resetAspectRatioEnabled: false,
|
||||
aspectRatioPickerButtonHidden: true,
|
||||
),
|
||||
],
|
||||
try {
|
||||
XFile? pickedFile = await _imagePicker.pickImage(
|
||||
source: ImageSource.gallery,
|
||||
imageQuality: 100,
|
||||
);
|
||||
if (croppedFile != null) {
|
||||
MsgHttp.uploadImage(
|
||||
path: croppedFile.path,
|
||||
bucket: 'medialist',
|
||||
dir: 'cover',
|
||||
).then((data) {
|
||||
if (data['status']) {
|
||||
_cover = data['data']['location'];
|
||||
setState(() {});
|
||||
} else {
|
||||
SmartDialog.showToast(data['msg']);
|
||||
}
|
||||
});
|
||||
if (pickedFile != null && mounted) {
|
||||
CroppedFile? croppedFile = await ImageCropper().cropImage(
|
||||
sourcePath: pickedFile.path,
|
||||
uiSettings: [
|
||||
AndroidUiSettings(
|
||||
toolbarTitle: '裁剪',
|
||||
toolbarColor: Theme.of(context).colorScheme.primary,
|
||||
toolbarWidgetColor: Colors.white,
|
||||
aspectRatioPresets: [
|
||||
CropAspectRatioPreset.ratio16x9,
|
||||
],
|
||||
lockAspectRatio: true,
|
||||
hideBottomControls: true,
|
||||
initAspectRatio: CropAspectRatioPreset.ratio16x9,
|
||||
),
|
||||
IOSUiSettings(
|
||||
title: '裁剪',
|
||||
aspectRatioPresets: [
|
||||
CropAspectRatioPreset.ratio16x9,
|
||||
],
|
||||
aspectRatioLockEnabled: true,
|
||||
resetAspectRatioEnabled: false,
|
||||
aspectRatioPickerButtonHidden: true,
|
||||
),
|
||||
],
|
||||
);
|
||||
if (croppedFile != null) {
|
||||
MsgHttp.uploadImage(
|
||||
path: croppedFile.path,
|
||||
bucket: 'medialist',
|
||||
dir: 'cover',
|
||||
).then((data) {
|
||||
if (data['status']) {
|
||||
_cover = data['data']['location'];
|
||||
setState(() {});
|
||||
} else {
|
||||
SmartDialog.showToast(data['msg']);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -361,27 +361,31 @@ class _ReplyPageState extends State<ReplyPage>
|
||||
EasyThrottle.throttle(
|
||||
'imagePicker', const Duration(milliseconds: 500),
|
||||
() async {
|
||||
List<XFile> pickedFiles =
|
||||
await _imagePicker.pickMultiImage(
|
||||
limit: _limit,
|
||||
imageQuality: 100,
|
||||
);
|
||||
if (pickedFiles.isNotEmpty) {
|
||||
for (int i = 0; i < pickedFiles.length; i++) {
|
||||
if (_pathList.length == _limit) {
|
||||
SmartDialog.showToast('最多选择$_limit张图片');
|
||||
if (i != 0) {
|
||||
_pathStream.add(_pathList);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
_pathList.add(pickedFiles[i].path);
|
||||
if (i == pickedFiles.length - 1) {
|
||||
SmartDialog.dismiss();
|
||||
_pathStream.add(_pathList);
|
||||
try {
|
||||
List<XFile> pickedFiles =
|
||||
await _imagePicker.pickMultiImage(
|
||||
limit: _limit,
|
||||
imageQuality: 100,
|
||||
);
|
||||
if (pickedFiles.isNotEmpty) {
|
||||
for (int i = 0; i < pickedFiles.length; i++) {
|
||||
if (_pathList.length == _limit) {
|
||||
SmartDialog.showToast('最多选择$_limit张图片');
|
||||
if (i != 0) {
|
||||
_pathStream.add(_pathList);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
_pathList.add(pickedFiles[i].path);
|
||||
if (i == pickedFiles.length - 1) {
|
||||
SmartDialog.dismiss();
|
||||
_pathStream.add(_pathList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
SmartDialog.showToast(e.toString());
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user