mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
Add a custom "back" button to refreshable state
- Long press to return to the "home" screen
This commit is contained in:
parent
9eaf4a09da
commit
38e4735f77
@ -473,6 +473,7 @@ class InvenTreeStockItem extends InvenTreeModel {
|
|||||||
return response.isValid();
|
return response.isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Refactor this once the server supports API metadata for this action
|
||||||
Future<bool> countStock(BuildContext context, double q, {String? notes}) async {
|
Future<bool> countStock(BuildContext context, double q, {String? notes}) async {
|
||||||
|
|
||||||
final bool result = await adjustStock(context, "/stock/count/", q, notes: notes);
|
final bool result = await adjustStock(context, "/stock/count/", q, notes: notes);
|
||||||
@ -480,6 +481,7 @@ class InvenTreeStockItem extends InvenTreeModel {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Refactor this once the server supports API metadata for this action
|
||||||
Future<bool> addStock(BuildContext context, double q, {String? notes}) async {
|
Future<bool> addStock(BuildContext context, double q, {String? notes}) async {
|
||||||
|
|
||||||
final bool result = await adjustStock(context, "/stock/add/", q, notes: notes);
|
final bool result = await adjustStock(context, "/stock/add/", q, notes: notes);
|
||||||
@ -487,6 +489,7 @@ class InvenTreeStockItem extends InvenTreeModel {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Refactor this once the server supports API metadata for this action
|
||||||
Future<bool> removeStock(BuildContext context, double q, {String? notes}) async {
|
Future<bool> removeStock(BuildContext context, double q, {String? notes}) async {
|
||||||
|
|
||||||
final bool result = await adjustStock(context, "/stock/remove/", q, notes: notes);
|
final bool result = await adjustStock(context, "/stock/remove/", q, notes: notes);
|
||||||
@ -494,6 +497,7 @@ class InvenTreeStockItem extends InvenTreeModel {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Refactor this once the server supports API metadata for this action
|
||||||
Future<bool> transferStock(int location, {double? quantity, String? notes}) async {
|
Future<bool> transferStock(int location, {double? quantity, String? notes}) async {
|
||||||
if ((quantity == null) || (quantity < 0) || (quantity > this.quantity)) {
|
if ((quantity == null) || (quantity < 0) || (quantity > this.quantity)) {
|
||||||
quantity = this.quantity;
|
quantity = this.quantity;
|
||||||
|
27
lib/widget/back.dart
Normal file
27
lib/widget/back.dart
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
import 'package:inventree/widget/back.dart';
|
||||||
import "package:inventree/widget/drawer.dart";
|
import "package:inventree/widget/drawer.dart";
|
||||||
import "package:flutter/cupertino.dart";
|
import "package:flutter/cupertino.dart";
|
||||||
import "package:flutter/material.dart";
|
import "package:flutter/material.dart";
|
||||||
@ -66,6 +67,7 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> {
|
|||||||
return AppBar(
|
return AppBar(
|
||||||
title: Text(getAppBarTitle(context)),
|
title: Text(getAppBarTitle(context)),
|
||||||
actions: getAppBarActions(context),
|
actions: getAppBarActions(context),
|
||||||
|
leading: backButton(context),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user