mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Fix dialog context poppin' issues for stock actions
This commit is contained in:
parent
de9226aab6
commit
d03e1db4c3
@ -141,24 +141,30 @@ Future<void> showTimeoutError(BuildContext context) async {
|
|||||||
await showServerError(I18N.of(context).timeout, I18N.of(context).noResponse);
|
await showServerError(I18N.of(context).timeout, I18N.of(context).noResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showFormDialog(String title, {GlobalKey<FormState> key, List<Widget> fields, List<Widget> actions, Function callback}) {
|
void showFormDialog(String title, {String acceptText, String cancelText, GlobalKey<FormState> key, List<Widget> fields, List<Widget> actions, Function callback}) {
|
||||||
|
|
||||||
BuildContext dialogContext;
|
BuildContext dialogContext;
|
||||||
|
|
||||||
|
if (acceptText == null) {
|
||||||
|
acceptText = I18N.of(OneContext().context).save;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cancelText == null) {
|
||||||
|
cancelText = I18N.of(OneContext().context).cancel;
|
||||||
|
}
|
||||||
|
|
||||||
// Undefined actions = OK + Cancel
|
// Undefined actions = OK + Cancel
|
||||||
if (actions == null) {
|
if (actions == null) {
|
||||||
actions = <Widget>[
|
actions = <Widget>[
|
||||||
FlatButton(
|
FlatButton(
|
||||||
child: Text(I18N.of(OneContext().context).cancel),
|
child: Text(cancelText),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
|
|
||||||
print("cancel and close the dialog");
|
|
||||||
// Close the form
|
// Close the form
|
||||||
Navigator.pop(dialogContext);
|
Navigator.pop(dialogContext);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
FlatButton(
|
FlatButton(
|
||||||
child: Text(I18N.of(OneContext().context).save),
|
child: Text(acceptText),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (key.currentState.validate()) {
|
if (key.currentState.validate()) {
|
||||||
key.currentState.save();
|
key.currentState.save();
|
||||||
|
@ -101,8 +101,6 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
|
|
||||||
void _addStock() async {
|
void _addStock() async {
|
||||||
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
|
|
||||||
double quantity = double.parse(_quantityController.text);
|
double quantity = double.parse(_quantityController.text);
|
||||||
_quantityController.clear();
|
_quantityController.clear();
|
||||||
|
|
||||||
@ -121,14 +119,9 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
|
|
||||||
showFormDialog( I18N.of(context).addStock,
|
showFormDialog( I18N.of(context).addStock,
|
||||||
key: _addStockKey,
|
key: _addStockKey,
|
||||||
actions: <Widget>[
|
callback: () {
|
||||||
FlatButton(
|
_addStock();
|
||||||
child: Text(I18N.of(context).add),
|
},
|
||||||
onPressed: () {
|
|
||||||
if (_addStockKey.currentState.validate()) _addStock();
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
fields: <Widget> [
|
fields: <Widget> [
|
||||||
Text("Current stock: ${item.quantity}"),
|
Text("Current stock: ${item.quantity}"),
|
||||||
QuantityField(
|
QuantityField(
|
||||||
@ -154,7 +147,6 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _removeStock() async {
|
void _removeStock() async {
|
||||||
Navigator.of(context).pop();
|
|
||||||
|
|
||||||
double quantity = double.parse(_quantityController.text);
|
double quantity = double.parse(_quantityController.text);
|
||||||
_quantityController.clear();
|
_quantityController.clear();
|
||||||
@ -174,14 +166,9 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
|
|
||||||
showFormDialog(I18N.of(context).removeStock,
|
showFormDialog(I18N.of(context).removeStock,
|
||||||
key: _removeStockKey,
|
key: _removeStockKey,
|
||||||
actions: <Widget>[
|
callback: () {
|
||||||
FlatButton(
|
_removeStock();
|
||||||
child: Text(I18N.of(context).remove),
|
},
|
||||||
onPressed: () {
|
|
||||||
if (_removeStockKey.currentState.validate()) _removeStock();
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
fields: <Widget>[
|
fields: <Widget>[
|
||||||
Text("Current stock: ${item.quantity}"),
|
Text("Current stock: ${item.quantity}"),
|
||||||
QuantityField(
|
QuantityField(
|
||||||
@ -201,8 +188,6 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
|
|
||||||
void _countStock() async {
|
void _countStock() async {
|
||||||
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
|
|
||||||
double quantity = double.parse(_quantityController.text);
|
double quantity = double.parse(_quantityController.text);
|
||||||
_quantityController.clear();
|
_quantityController.clear();
|
||||||
|
|
||||||
@ -220,14 +205,10 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
|||||||
|
|
||||||
showFormDialog(I18N.of(context).countStock,
|
showFormDialog(I18N.of(context).countStock,
|
||||||
key: _countStockKey,
|
key: _countStockKey,
|
||||||
actions: <Widget> [
|
callback: () {
|
||||||
FlatButton(
|
_countStock();
|
||||||
child: Text(I18N.of(context).count),
|
},
|
||||||
onPressed: () {
|
acceptText: I18N.of(context).count,
|
||||||
if (_countStockKey.currentState.validate()) _countStock();
|
|
||||||
},
|
|
||||||
)
|
|
||||||
],
|
|
||||||
fields: <Widget> [
|
fields: <Widget> [
|
||||||
QuantityField(
|
QuantityField(
|
||||||
label: I18N.of(context).countStock,
|
label: I18N.of(context).countStock,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user