mirror of
https://github.com/inventree/inventree-app.git
synced 2025-07-30 09:11:34 +00:00
Snack bars for barcode actions
This commit is contained in:
@@ -24,8 +24,18 @@ void showSnackIcon(String text, {IconData icon, Function onAction, bool success,
|
||||
if (success == true) {
|
||||
backgroundColor = Colors.lightGreen;
|
||||
|
||||
// Select an icon if we do not have an action
|
||||
if (icon == null && onAction == null) {
|
||||
icon = FontAwesomeIcons.checkCircle;
|
||||
}
|
||||
|
||||
} else if (success == false) {
|
||||
backgroundColor = Colors.deepOrange;
|
||||
|
||||
if (icon == null && onAction == null) {
|
||||
icon = FontAwesomeIcons.exclamationCircle;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SnackBarAction action;
|
||||
|
@@ -245,6 +245,26 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
}
|
||||
|
||||
|
||||
void _unassignBarcode(BuildContext context) async {
|
||||
|
||||
final bool result = await item.update(context, values: {'uid': ''});
|
||||
|
||||
if (result) {
|
||||
showSnackIcon(
|
||||
I18N.of(context).stockItemUpdateSuccess,
|
||||
success: true
|
||||
);
|
||||
} else {
|
||||
showSnackIcon(
|
||||
I18N.of(context).stockItemUpdateFailure,
|
||||
success: false,
|
||||
);
|
||||
}
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
||||
void _transferStock(BuildContext context, InvenTreeStockLocation location) async {
|
||||
Navigator.of(context).pop();
|
||||
|
||||
@@ -568,7 +588,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
if (item.uid.isEmpty) {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(I18N.of(context).assignBarcode),
|
||||
title: Text(I18N.of(context).barcodeAssign),
|
||||
leading: FaIcon(FontAwesomeIcons.barcode),
|
||||
trailing: FaIcon(FontAwesomeIcons.qrcode),
|
||||
onTap: () {
|
||||
@@ -581,6 +601,16 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
}
|
||||
)
|
||||
);
|
||||
} else {
|
||||
tiles.add(
|
||||
ListTile(
|
||||
title: Text(I18N.of(context).barcodeUnassign),
|
||||
leading: FaIcon(FontAwesomeIcons.barcode),
|
||||
onTap: () {
|
||||
_unassignBarcode(context);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return tiles;
|
||||
|
Reference in New Issue
Block a user