mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-01 00:28:18 +08:00
opt image crop
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -149,7 +149,7 @@ abstract class CommonRichTextPubPageState<T extends CommonRichTextPubPage>
|
|||||||
|
|
||||||
Future<void> onCropImage(int index) async {
|
Future<void> onCropImage(int index) async {
|
||||||
late final colorScheme = ColorScheme.of(context);
|
late final colorScheme = ColorScheme.of(context);
|
||||||
CroppedFile? croppedFile = await ImageCropper().cropImage(
|
CroppedFile? croppedFile = await ImageCropper.platform.cropImage(
|
||||||
sourcePath: pathList[index],
|
sourcePath: pathList[index],
|
||||||
uiSettings: [
|
uiSettings: [
|
||||||
AndroidUiSettings(
|
AndroidUiSettings(
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'package:PiliPlus/models_new/fav/fav_folder/list.dart';
|
|||||||
import 'package:PiliPlus/utils/extension.dart';
|
import 'package:PiliPlus/utils/extension.dart';
|
||||||
import 'package:PiliPlus/utils/fav_utils.dart';
|
import 'package:PiliPlus/utils/fav_utils.dart';
|
||||||
import 'package:PiliPlus/utils/image_utils.dart';
|
import 'package:PiliPlus/utils/image_utils.dart';
|
||||||
|
import 'package:PiliPlus/utils/utils.dart';
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
import 'package:easy_debounce/easy_throttle.dart';
|
import 'package:easy_debounce/easy_throttle.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -115,7 +116,9 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
|||||||
imageQuality: 100,
|
imageQuality: 100,
|
||||||
);
|
);
|
||||||
if (pickedFile != null && mounted) {
|
if (pickedFile != null && mounted) {
|
||||||
CroppedFile? croppedFile = await ImageCropper().cropImage(
|
String imgPath = pickedFile.path;
|
||||||
|
if (Utils.isMobile) {
|
||||||
|
CroppedFile? croppedFile = await ImageCropper.platform.cropImage(
|
||||||
sourcePath: pickedFile.path,
|
sourcePath: pickedFile.path,
|
||||||
uiSettings: [
|
uiSettings: [
|
||||||
AndroidUiSettings(
|
AndroidUiSettings(
|
||||||
@@ -138,8 +141,11 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
if (croppedFile != null) {
|
if (croppedFile != null) {
|
||||||
|
imgPath = croppedFile.path;
|
||||||
|
}
|
||||||
|
}
|
||||||
MsgHttp.uploadImage(
|
MsgHttp.uploadImage(
|
||||||
path: croppedFile.path,
|
path: imgPath,
|
||||||
bucket: 'medialist',
|
bucket: 'medialist',
|
||||||
dir: 'cover',
|
dir: 'cover',
|
||||||
).then((res) {
|
).then((res) {
|
||||||
@@ -153,7 +159,6 @@ class _CreateFavPageState extends State<CreateFavPage> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
SmartDialog.showToast(e.toString());
|
SmartDialog.showToast(e.toString());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -488,7 +488,9 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
|||||||
SmartDialog.showToast('不能选GIF');
|
SmartDialog.showToast('不能选GIF');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CroppedFile? croppedFile = await ImageCropper().cropImage(
|
String? imagePath;
|
||||||
|
if (Utils.isMobile) {
|
||||||
|
CroppedFile? croppedFile = await ImageCropper.platform.cropImage(
|
||||||
sourcePath: pickedFile.path,
|
sourcePath: pickedFile.path,
|
||||||
uiSettings: [
|
uiSettings: [
|
||||||
AndroidUiSettings(
|
AndroidUiSettings(
|
||||||
@@ -513,6 +515,12 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
if (croppedFile != null) {
|
if (croppedFile != null) {
|
||||||
|
imagePath = croppedFile.path;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
imagePath = pickedFile.path;
|
||||||
|
}
|
||||||
|
if (imagePath != null) {
|
||||||
Request()
|
Request()
|
||||||
.post(
|
.post(
|
||||||
'/x/member/web/face/update',
|
'/x/member/web/face/update',
|
||||||
@@ -522,7 +530,7 @@ class _EditProfilePageState extends State<EditProfilePage> {
|
|||||||
data: FormData.fromMap({
|
data: FormData.fromMap({
|
||||||
'dopost': 'save',
|
'dopost': 'save',
|
||||||
'DisplayRank': 10000,
|
'DisplayRank': 10000,
|
||||||
'face': await MultipartFile.fromFile(croppedFile.path),
|
'face': await MultipartFile.fromFile(imagePath),
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.then((res) {
|
.then((res) {
|
||||||
|
|||||||
Reference in New Issue
Block a user