diff --git a/lib/inventree/stock.dart b/lib/inventree/stock.dart index a0aec8b4..45606a2d 100644 --- a/lib/inventree/stock.dart +++ b/lib/inventree/stock.dart @@ -473,6 +473,7 @@ class InvenTreeStockItem extends InvenTreeModel { return response.isValid(); } + // TODO: Refactor this once the server supports API metadata for this action Future countStock(BuildContext context, double q, {String? notes}) async { final bool result = await adjustStock(context, "/stock/count/", q, notes: notes); @@ -480,6 +481,7 @@ class InvenTreeStockItem extends InvenTreeModel { return result; } + // TODO: Refactor this once the server supports API metadata for this action Future addStock(BuildContext context, double q, {String? notes}) async { final bool result = await adjustStock(context, "/stock/add/", q, notes: notes); @@ -487,6 +489,7 @@ class InvenTreeStockItem extends InvenTreeModel { return result; } + // TODO: Refactor this once the server supports API metadata for this action Future removeStock(BuildContext context, double q, {String? notes}) async { final bool result = await adjustStock(context, "/stock/remove/", q, notes: notes); @@ -494,6 +497,7 @@ class InvenTreeStockItem extends InvenTreeModel { return result; } + // TODO: Refactor this once the server supports API metadata for this action Future transferStock(int location, {double? quantity, String? notes}) async { if ((quantity == null) || (quantity < 0) || (quantity > this.quantity)) { quantity = this.quantity; diff --git a/lib/widget/back.dart b/lib/widget/back.dart new file mode 100644 index 00000000..587a69b3 --- /dev/null +++ b/lib/widget/back.dart @@ -0,0 +1,27 @@ +/* + * A custom implementation of a "Back" button for display in the app drawer + * + * Long-pressing on this will return the user to the home screen + */ + +import "package:flutter/cupertino.dart"; +import "package:flutter/material.dart"; + +Widget backButton(BuildContext context) { + + return GestureDetector( + onLongPress: () { + while (Navigator.of(context).canPop()) { + Navigator.of(context).pop(); + } + }, + child: IconButton( + icon: BackButtonIcon(), + onPressed: () { + if (Navigator.of(context).canPop()) { + Navigator.of(context).pop(); + } + }, + ), + ); +} \ No newline at end of file diff --git a/lib/widget/refreshable_state.dart b/lib/widget/refreshable_state.dart index fb1e3559..0b8cd2b8 100644 --- a/lib/widget/refreshable_state.dart +++ b/lib/widget/refreshable_state.dart @@ -1,3 +1,4 @@ +import 'package:inventree/widget/back.dart'; import "package:inventree/widget/drawer.dart"; import "package:flutter/cupertino.dart"; import "package:flutter/material.dart"; @@ -66,6 +67,7 @@ abstract class RefreshableState extends State { return AppBar( title: Text(getAppBarTitle(context)), actions: getAppBarActions(context), + leading: backButton(context), ); }