mirror of
https://github.com/inventree/inventree-app.git
synced 2026-07-22 20:23:26 +00:00
Img upload (#858)
* Refactor existing code for image upload * re-encode cropped image to jpg * Fix UX * prevent crop from blocking UI * change default action
This commit is contained in:
@@ -10,6 +10,7 @@ import "package:one_context/one_context.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
import "package:inventree/app_colors.dart";
|
||||
import "package:inventree/widget/fields.dart";
|
||||
import "package:inventree/widget/image_upload.dart";
|
||||
import "package:inventree/widget/progress.dart";
|
||||
import "package:inventree/widget/snacks.dart";
|
||||
import "package:inventree/widget/refreshable_state.dart";
|
||||
@@ -80,14 +81,23 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
|
||||
Future<void> upload(BuildContext context, File? file) async {
|
||||
if (file == null) return;
|
||||
|
||||
final File? processed = await preProcessImage(file);
|
||||
|
||||
if (processed == null) {
|
||||
// User cancelled the upload
|
||||
return;
|
||||
}
|
||||
|
||||
showLoadingOverlay();
|
||||
|
||||
final bool result = await InvenTreeAttachment().uploadAttachment(
|
||||
file,
|
||||
processed,
|
||||
widget.modelType,
|
||||
widget.modelId,
|
||||
);
|
||||
|
||||
await cleanupProcessedImage(file, processed);
|
||||
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (result) {
|
||||
|
||||
Reference in New Issue
Block a user