From 8374691d8cb3bdc929631451bd9b68de0918776c Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 18 Apr 2020 22:53:02 +1000 Subject: [PATCH] Add some //TODO items --- lib/widget/dialogs.dart | 6 ++++++ lib/widget/refreshable_state.dart | 10 +++++++--- lib/widget/stock_detail.dart | 16 ++++++++++++---- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/lib/widget/dialogs.dart b/lib/widget/dialogs.dart index d6e0cf0e..57de3a63 100644 --- a/lib/widget/dialogs.dart +++ b/lib/widget/dialogs.dart @@ -3,6 +3,12 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; +void showMessage(BuildContext context, String message) { + Scaffold.of(context).showSnackBar(SnackBar( + content: Text(message), + )); +} + void showErrorDialog(BuildContext context, String title, String description) { showDialog( context: context, diff --git a/lib/widget/refreshable_state.dart b/lib/widget/refreshable_state.dart index a85fbc3b..eb34d25e 100644 --- a/lib/widget/refreshable_state.dart +++ b/lib/widget/refreshable_state.dart @@ -68,9 +68,13 @@ abstract class RefreshableState extends State { appBar: getAppBar(context), drawer: getDrawer(context), floatingActionButton: getFab(context), - body: RefreshIndicator( - onRefresh: refresh, - child: getBody(context) + body: Builder( + builder: (BuildContext context) { + return RefreshIndicator( + onRefresh: refresh, + child: getBody(context) + ); + } ), bottomNavigationBar: getBottomNavBar(context), ); diff --git a/lib/widget/stock_detail.dart b/lib/widget/stock_detail.dart index 853318f0..38f85367 100644 --- a/lib/widget/stock_detail.dart +++ b/lib/widget/stock_detail.dart @@ -97,6 +97,8 @@ class _StockItemDisplayState extends RefreshableState { // TODO - Handle error cases refresh(); + + // TODO - Display a snackbar here indicating the action was successful (or otherwise) } void _addStockDialog() async { @@ -141,6 +143,8 @@ class _StockItemDisplayState extends RefreshableState { // TODO - Handle error cases refresh(); + + // TODO - Display a snackbar here indicating the action was successful (or otherwise) } void _removeStockDialog() { @@ -187,6 +191,8 @@ class _StockItemDisplayState extends RefreshableState { // TODO - Handle error cases, timeout, etc refresh(); + + // TODO - Display a snackbar here indicating the action was successful (or otherwise) } void _countStockDialog() async { @@ -218,7 +224,7 @@ class _StockItemDisplayState extends RefreshableState { } - void _transferStock(int location) async { + void _transferStock(BuildContext context, InvenTreeStockLocation location) async { Navigator.of(context).pop(); double quantity = double.parse(_quantityController.text); @@ -227,11 +233,13 @@ class _StockItemDisplayState extends RefreshableState { _quantityController.clear(); _notesController.clear(); - var response = await item.transferStock(quantity, location, notes: notes); + var response = await item.transferStock(quantity, location.pk, notes: notes); - // TODO - Error handling + // TODO - Error handling (potentially return false?) refresh(); + // TODO - Display a snackbar here indicating the action was successful (or otherwise) + } void _transferStockDialog() async { @@ -293,7 +301,7 @@ class _StockItemDisplayState extends RefreshableState { _selectedController.text = selectedLocation.pathstring; }, onSaved: (value) { - _transferStock(selectedLocation.pk); + _transferStock(context, selectedLocation); }, itemBuilder: (context, suggestion) { var location = suggestion as InvenTreeStockLocation;