quotation rate display

This commit is contained in:
Stephan D
2025-12-12 13:45:58 +01:00
parent d64d7dab58
commit 00045c1e65
35 changed files with 530 additions and 199 deletions

View File

@@ -1,22 +1,64 @@
String currencyCodeToSymbol(String currencyCode) {
import 'package:flutter/material.dart';
import 'package:pshared/models/asset.dart';
import 'package:pshared/models/currency.dart';
String currencyCodeToSymbol(Currency currencyCode) {
switch (currencyCode) {
case 'USD':
case Currency.usd:
return '\$';
case 'PLN':
return '';
case 'EUR':
return '';
case 'GBP':
return '£';
case 'HUF':
return 'Ft';
case 'RUB':
case Currency.usdt:
return '';
case Currency.usdc:
return '\$';
case Currency.rub:
return '';
default:
return currencyCode;
case Currency.eur:
return '';
}
}
String currencyToString(String currencyCode, double amount) {
return '${currencyCodeToSymbol(currencyCode)}\u00A0${amount.toStringAsFixed(2)}';
String amountToString(double amount) {
return amount.toStringAsFixed(2);
}
String currencyToString(Currency currencyCode, double amount) {
return '${currencyCodeToSymbol(currencyCode)}\u00A0${amountToString(amount)}';
}
String assetToString(Asset asset) {
return currencyToString(asset.currency, asset.amount);
}
Currency currencyStringToCode(String currencyCode) {
switch (currencyCode) {
case 'USD':
return Currency.usd;
case 'USDT':
return Currency.usdt;
case 'USDC':
return Currency.usdc;
case 'RUB':
return Currency.rub;
case 'EUR':
return Currency.eur;
default:
throw ArgumentError('Unknown currency code: $currencyCode');
}
}
IconData iconForCurrencyType(Currency currencyCode) {
switch (currencyCode) {
case Currency.usd:
return Icons.currency_exchange;
case Currency.eur:
return Icons.currency_exchange;
case Currency.rub:
return Icons.currency_ruble;
case Currency.usdt:
return Icons.currency_exchange;
case Currency.usdc:
return Icons.money;
}
}