2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-05-02 07:26:50 +00:00

Disable some more natty dialogs

This commit is contained in:
Oliver Walters 2021-02-04 23:56:06 +11:00
parent 1ee54a00de
commit e77b9539f9
2 changed files with 24 additions and 9 deletions

View File

@ -65,21 +65,26 @@ class BarcodeHandler {
);
}
Future<void> processBarcode(BuildContext context, QRViewController _controller, String barcode) {
Future<void> processBarcode(BuildContext context, QRViewController _controller, String barcode, {String url = "barcode/", bool show_dialog = false}) {
this._context = context;
this._controller = _controller;
print("Scanned barcode data: ${barcode}");
showProgressDialog(context, "Scanning", "Sending barcode data to server");
if (show_dialog) {
showProgressDialog(context, "Scanning", "Sending barcode data to server");
}
// Send barcode request to server
InvenTreeAPI().post(
"barcode/",
url,
body: {
"barcode": barcode
}
).then((var response) {
hideProgressDialog(context);
if (show_dialog) {
hideProgressDialog(context);
}
if (response.statusCode != 200) {
showErrorDialog(
@ -112,7 +117,11 @@ class BarcodeHandler {
}).timeout(
Duration(seconds: 5)
).catchError((error) {
hideProgressDialog(context);
if (show_dialog) {
hideProgressDialog(context);
}
showErrorDialog(
context,
"Error",

View File

@ -149,7 +149,7 @@ class InvenTreeModel {
}
// POST data to update the model
Future<bool> update(BuildContext context, {Map<String, String> values}) async {
Future<bool> update(BuildContext context, {Map<String, String> values, bool show_dialog = false}) async {
var addr = path.join(URL, pk.toString());
@ -157,13 +157,17 @@ class InvenTreeModel {
addr += "/";
}
showProgressDialog(context, "Updating ${NAME}", "Sending data to server");
if (show_dialog) {
showProgressDialog(context, "Updating ${NAME}", "Sending data to server");
}
var response = await api.patch(addr, body: values)
.timeout(Duration(seconds: 10))
.catchError((e) {
hideProgressDialog(context);
if (show_dialog) {
hideProgressDialog(context);
}
if (e is TimeoutException) {
showErrorDialog(context, "Timeout", "No response from server");
@ -176,7 +180,9 @@ class InvenTreeModel {
if (response == null) return false;
hideProgressDialog(context);
if (show_dialog) {
hideProgressDialog(context);
}
if (response.statusCode != 200) {
print("Error updating ${NAME}: Status code ${response.statusCode}");