red warnings not on 0 for exchange

This commit is contained in:
Marco 2022-10-15 20:47:59 -06:00
parent 3dd27d9b53
commit dd00e76623
2 changed files with 16 additions and 10 deletions

View file

@ -92,7 +92,9 @@ class ExchangeFormState extends ChangeNotifier {
String get warning { String get warning {
if (reversed) { if (reversed) {
if (toTicker != null && toAmount != null) { if (toTicker != null && toAmount != null) {
if (minAmount != null && toAmount! < minAmount!) { if (minAmount != null &&
toAmount! < minAmount! &&
toAmount! > Decimal.zero) {
return "Minimum amount ${minAmount!.toString()} ${toTicker!.toUpperCase()}"; return "Minimum amount ${minAmount!.toString()} ${toTicker!.toUpperCase()}";
} else if (maxAmount != null && toAmount! > maxAmount!) { } else if (maxAmount != null && toAmount! > maxAmount!) {
return "Maximum amount ${maxAmount!.toString()} ${toTicker!.toUpperCase()}"; return "Maximum amount ${maxAmount!.toString()} ${toTicker!.toUpperCase()}";
@ -100,7 +102,9 @@ class ExchangeFormState extends ChangeNotifier {
} }
} else { } else {
if (fromTicker != null && fromAmount != null) { if (fromTicker != null && fromAmount != null) {
if (minAmount != null && fromAmount! < minAmount!) { if (minAmount != null &&
fromAmount! < minAmount! &&
fromAmount! > Decimal.zero) {
return "Minimum amount ${minAmount!.toString()} ${fromTicker!.toUpperCase()}"; return "Minimum amount ${minAmount!.toString()} ${fromTicker!.toUpperCase()}";
} else if (maxAmount != null && fromAmount! > maxAmount!) { } else if (maxAmount != null && fromAmount! > maxAmount!) {
return "Maximum amount ${maxAmount!.toString()} ${fromTicker!.toUpperCase()}"; return "Maximum amount ${maxAmount!.toString()} ${fromTicker!.toUpperCase()}";

View file

@ -572,14 +572,16 @@ class _ExchangeFormState extends ConsumerState<ExchangeForm> {
if (mounted) { if (mounted) {
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
unawaited( if (!(fromTicker == "-" || toTicker == "-")) {
showFloatingFlushBar( unawaited(
type: FlushBarType.warning, showFloatingFlushBar(
message: type: FlushBarType.warning,
"Estimated rate trade pair \"$fromTicker-$toTicker\" unavailable. Reverting to last estimated rate pair.", message:
context: context, "Estimated rate trade pair \"$fromTicker-$toTicker\" unavailable. Reverting to last estimated rate pair.",
), context: context,
); ),
);
}
break; break;
case ExchangeRateType.fixed: case ExchangeRateType.fixed:
if (!(toTicker == "-" || fromTicker == "-")) { if (!(toTicker == "-" || fromTicker == "-")) {