mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-12 18:25:26 +00:00
snack bar now uses OneContext()
This commit is contained in:
@ -91,7 +91,6 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
||||
final bool result = await part.update(context, values: values);
|
||||
|
||||
showSnackIcon(
|
||||
refreshableKey,
|
||||
result ? "Part edited" : "Part editing failed",
|
||||
success: result
|
||||
);
|
||||
|
@ -11,26 +11,44 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:one_context/one_context.dart';
|
||||
|
||||
void showSnackIcon(GlobalKey<ScaffoldState> key, String text, {IconData icon, bool success}) {
|
||||
void showSnackIcon(String text, {IconData icon, Function onTap, bool success}) {
|
||||
|
||||
// Hide the current snackbar
|
||||
key.currentState.hideCurrentSnackBar();
|
||||
OneContext().hideCurrentSnackBar();
|
||||
|
||||
Color backgroundColor;
|
||||
|
||||
// Make some selections based on the "success" value
|
||||
if (success == true) {
|
||||
backgroundColor = Colors.lightGreen;
|
||||
|
||||
// Unspecified icon?
|
||||
if (icon == null) {
|
||||
icon = FontAwesomeIcons.checkCircle;
|
||||
}
|
||||
|
||||
} else if (success == false) {
|
||||
backgroundColor = Colors.deepOrange;
|
||||
|
||||
if (icon == null) {
|
||||
icon = FontAwesomeIcons.timesCircle;
|
||||
}
|
||||
|
||||
// If icon not specified, use the success status
|
||||
if (icon == null) {
|
||||
icon = (success == false) ? FontAwesomeIcons.timesCircle : FontAwesomeIcons.checkCircle;
|
||||
}
|
||||
|
||||
key.currentState.showSnackBar(
|
||||
SnackBar(
|
||||
content: Row(
|
||||
OneContext().showSnackBar(builder: (context) => SnackBar(
|
||||
content: GestureDetector(
|
||||
child: Row(
|
||||
children: [
|
||||
Text(text),
|
||||
Spacer(),
|
||||
FaIcon(icon)
|
||||
]
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
onTap: onTap,
|
||||
),
|
||||
backgroundColor: backgroundColor,
|
||||
));
|
||||
|
||||
}
|
@ -148,7 +148,6 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
|
||||
void _stockUpdateMessage(bool result) {
|
||||
|
||||
showSnackIcon(
|
||||
refreshableKey,
|
||||
result ? "Stock item updated" : "Stock item updated failed",
|
||||
success: result
|
||||
);
|
||||
|
@ -56,7 +56,6 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
||||
);
|
||||
|
||||
showSnackIcon(
|
||||
refreshableKey,
|
||||
success ? "Test result uploaded" : "Could not upload test result",
|
||||
success: success
|
||||
);
|
||||
|
Reference in New Issue
Block a user