mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
* Add action for scanning a stock location into another location * Adds barcode scan handler for new functionality * Handle scanning of stock location * Cleanup * Refactor existing barcode scanning functions - Will require extensive testing and validation * Add entry to release notes * Delete dead code * Improved ordering based on stock quantity * Bug fix for 'adjustStock' function * Improve error responses for barcode scanning * Improve error responses for barcode scanning * Remove old debug statements * Add some extra explanatory texts * Icon change * Fixes for unit tests * Adds extra functionality for user profile manager * Refactor barcode code - do not rely on BuildContext * Adds initial unit testing for barcode scanning - Work on mocking barcode data - Add hooks for testing snackBar and audio files * Linting fixes * More barcode unit tests * Cleanup unit tests for barcode * Remove unused import * Handle HTTPException in API * Improvements for API unit testing * Unit testing for scanning item into location * Add unit test for scanning in items from a location context * Unit test for scanning location into parent location * Improve feedback for barcode scanning events
75 lines
1.7 KiB
Dart
75 lines
1.7 KiB
Dart
import "package:flutter/material.dart";
|
|
import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
|
import "package:one_context/one_context.dart";
|
|
|
|
import "package:inventree/helpers.dart";
|
|
import "package:inventree/l10.dart";
|
|
|
|
/*
|
|
* Display a configurable 'snackbar' at the bottom of the screen
|
|
*/
|
|
void showSnackIcon(String text, {IconData? icon, Function()? onAction, bool? success, String? actionText}) {
|
|
|
|
debug("showSnackIcon: '${text}'");
|
|
|
|
// Escape quickly if we do not have context
|
|
if (!OneContext.hasContext) {
|
|
// Debug message for unit testing
|
|
return;
|
|
}
|
|
|
|
BuildContext? context = OneContext().context;
|
|
|
|
if (context != null) {
|
|
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
|
}
|
|
|
|
Color backgroundColor = Colors.deepOrange;
|
|
|
|
// Make some selections based on the "success" value
|
|
if (success != null && 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 != null && success == false) {
|
|
backgroundColor = Colors.deepOrange;
|
|
|
|
if (icon == null && onAction == null) {
|
|
icon = FontAwesomeIcons.exclamationCircle;
|
|
}
|
|
}
|
|
|
|
String _action = actionText ?? L10().details;
|
|
|
|
SnackBarAction? action;
|
|
|
|
if (onAction != null) {
|
|
action = SnackBarAction(
|
|
label: _action,
|
|
onPressed: onAction,
|
|
);
|
|
}
|
|
|
|
List<Widget> childs = [
|
|
Text(text),
|
|
Spacer(),
|
|
];
|
|
|
|
if (icon != null) {
|
|
childs.add(FaIcon(icon));
|
|
}
|
|
|
|
OneContext().showSnackBar(builder: (context) => SnackBar(
|
|
content: Row(
|
|
children: childs
|
|
),
|
|
backgroundColor: backgroundColor,
|
|
action: action
|
|
)
|
|
);
|
|
|
|
} |