import 'package:flutter/material.dart';

import 'package:pshared/models/asset.dart';
import 'package:pshared/models/currency.dart';


String currencyCodeToSymbol(Currency currencyCode) {
  switch (currencyCode) {
    case Currency.usd:
      return '\$';
    case Currency.usdt:
      return '₮';
    case Currency.usdc:
      return '\$';
    case Currency.rub:
      return '₽';
    case Currency.eur:
      return '€';
  }
}

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');
  }
}

String currencyCodeToString(Currency currencyCode) {
  switch (currencyCode) {
    case Currency.usd:
      return 'USD';
    case Currency.usdt:
      return 'USDT';
    case Currency.usdc:
      return 'USDC';
    case Currency.rub:
      return 'RUB';
    case Currency.eur:
      return 'EUR';
  }
}

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;
  }
}