mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-12 18:25:26 +00:00
API error messages now use snackIcon
- Press "details" for further error information - Is nice
This commit is contained in:
@ -13,7 +13,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
import 'package:one_context/one_context.dart';
|
||||
|
||||
void showSnackIcon(String text, {IconData icon, Function onTap, bool success}) {
|
||||
void showSnackIcon(String text, {IconData icon, Function onAction, bool success, String actionText}) {
|
||||
|
||||
OneContext().hideCurrentSnackBar();
|
||||
|
||||
@ -23,32 +23,35 @@ void showSnackIcon(String text, {IconData icon, Function onTap, bool success}) {
|
||||
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;
|
||||
}
|
||||
SnackBarAction action;
|
||||
|
||||
if (onAction != null && actionText != null) {
|
||||
action = SnackBarAction(
|
||||
label: actionText,
|
||||
onPressed: onAction,
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> childs = [
|
||||
Text(text),
|
||||
Spacer(),
|
||||
];
|
||||
|
||||
if (icon != null) {
|
||||
childs.add(FaIcon(icon));
|
||||
}
|
||||
|
||||
OneContext().showSnackBar(builder: (context) => SnackBar(
|
||||
content: GestureDetector(
|
||||
child: Row(
|
||||
children: [
|
||||
Text(text),
|
||||
Spacer(),
|
||||
FaIcon(icon)
|
||||
],
|
||||
),
|
||||
onTap: onTap,
|
||||
content: Row(
|
||||
children: childs
|
||||
),
|
||||
backgroundColor: backgroundColor,
|
||||
));
|
||||
action: action
|
||||
)
|
||||
);
|
||||
|
||||
}
|
Reference in New Issue
Block a user