53 lines
2.2 KiB
Dart
53 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
import 'package:sxchnge_wallet/sxchnge_wallet.dart';
|
|
|
|
import '../generated/i18n/app_localizations.dart';
|
|
|
|
String money(BuildContext context, CurrencyAccount account, int amount) =>
|
|
NumberFormat.currency(
|
|
locale: Localizations.localeOf(context).toLanguageTag(),
|
|
name: account.currency,
|
|
symbol: '${account.currency} ',
|
|
decimalDigits: account.precision,
|
|
).format(amount / account.scale);
|
|
String kindText(AppLocalizations l, TransferKind kind) => switch (kind) {
|
|
TransferKind.topUp => l.wTopUp,
|
|
TransferKind.exchange => l.wExchange,
|
|
TransferKind.payout => l.wPayout,
|
|
};
|
|
IconData kindIcon(TransferKind kind) => switch (kind) {
|
|
TransferKind.topUp => Icons.add_rounded,
|
|
TransferKind.exchange => Icons.swap_horiz_rounded,
|
|
TransferKind.payout => Icons.north_east_rounded,
|
|
};
|
|
String statusText(AppLocalizations l, OperationStatus s) => switch (s) {
|
|
OperationStatus.pending => l.wPending,
|
|
OperationStatus.completed => l.wCompleted,
|
|
OperationStatus.failed => l.wFailed,
|
|
};
|
|
String fundsText(AppLocalizations l, WalletOperation o) =>
|
|
switch ((o.status, o.quote.request.kind)) {
|
|
(OperationStatus.pending, TransferKind.topUp) => l.wPendingTopUp,
|
|
(OperationStatus.pending, TransferKind.exchange) => l.wPendingExchange,
|
|
(OperationStatus.pending, TransferKind.payout) => l.wPendingPayout,
|
|
(OperationStatus.completed, TransferKind.topUp) => l.wCompleteTopUp,
|
|
(OperationStatus.completed, TransferKind.exchange) => l.wCompleteExchange,
|
|
(OperationStatus.completed, TransferKind.payout) => l.wCompletePayout,
|
|
(OperationStatus.failed, TransferKind.topUp) => l.wFailedTopUp,
|
|
_ => l.wFailedOutgoing,
|
|
};
|
|
String walletError(AppLocalizations l, WalletError e) => switch (e) {
|
|
WalletError.invalidAmount => l.wInvalidAmount,
|
|
WalletError.insufficientFunds => l.wInsufficient,
|
|
WalletError.limitExceeded => l.wLimitError,
|
|
WalletError.expiredQuote => l.wExpired,
|
|
WalletError.invalidRecipient => l.wRecipientError,
|
|
WalletError.unsupported => l.wUnsupported,
|
|
WalletError.notFound => l.wNotFound,
|
|
WalletError.uncertain => l.wUncertain,
|
|
_ => l.wUnavailable,
|
|
};
|