mirror of
https://github.com/HendrikRauh/inventree-app.git
synced 2026-01-13 11:36:24 +00:00
snack bar now uses OneContext()
This commit is contained in:
parent
33483eb9e1
commit
8ae4d2b584
5 changed files with 72 additions and 23 deletions
|
|
@ -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
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue