2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 02:05:29 +00:00

Display overlay screen for blocking operations (#186)

* Catch state error in homepage widget

* Add flutter_overlay_loader lib

- Displays an overlay screen to indicate blocking operation

* Wrap blocking widget transitions in a loading overlay

- Prevents user from doing other things while loading
- Shows the user that something is happening

* Linting fixes

* Show overlay when uploading attachment file

* Show overlay when downloading file also

* Show overlay when loading or submitting API forms

- Major improvements to usability "feel"

* UI improvements for stock item test results widget

* Fix API_FORM bug

- onSuccess function was not being called
This commit is contained in:
Oliver
2022-07-20 09:05:21 +10:00
committed by GitHub
parent 277193ecb0
commit 01dd046dd1
20 changed files with 150 additions and 183 deletions

View File

@ -6,6 +6,7 @@ import "package:font_awesome_flutter/font_awesome_flutter.dart";
import "package:inventree/app_colors.dart";
import "package:inventree/inventree/model.dart";
import "package:inventree/widget/fields.dart";
import "package:inventree/widget/progress.dart";
import "package:inventree/widget/snacks.dart";
import "package:inventree/widget/refreshable_state.dart";
import "package:inventree/l10.dart";
@ -51,8 +52,8 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
icon: FaIcon(FontAwesomeIcons.plusCircle),
onPressed: () async {
FilePickerDialog.pickFile(
onPicked: (File file) {
upload(file);
onPicked: (File file) async {
await upload(context, file);
}
);
},
@ -63,9 +64,11 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
return actions;
}
Future<void> upload(File file) async {
Future<void> upload(BuildContext context, File file) async {
showLoadingOverlay(context);
final bool result = await widget.attachment.uploadAttachment(file, widget.referenceId);
hideLoadingOverlay();
if (result) {
showSnackIcon(L10().uploadSuccess, success: true);
@ -121,7 +124,9 @@ class _AttachmentWidgetState extends RefreshableState<AttachmentWidget> {
subtitle: Text(attachment.comment),
leading: FaIcon(attachment.icon, color: COLOR_CLICK),
onTap: () async {
showLoadingOverlay(context);
await attachment.downloadAttachment();
hideLoadingOverlay();
},
));
}