Тема и общие виджеты (AssetIcon, ServiceMark, HelpTip, глоссарий), верхняя панель TopNav и вкладки Аналитики вместо NavSidebar, иконки PWA. Экраны: портфели, создание брокерского счёта, ручное событие, правка инструмента, Обзор карточками по скоупам и таблица активов, пересчёт метрик с опросом /metrics/status. design-system.md обновлён.
35 lines
1.2 KiB
Dart
35 lines
1.2 KiB
Dart
import 'package:decimal/decimal.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
/// Currency symbols for the instruments we expect to see. Falls back to the
|
|
/// ISO code itself (e.g. 'USDT') when we don't have a nicer glyph.
|
|
const _currencySymbols = {'RUB': '₽', 'USD': '\$', 'EUR': '€'};
|
|
|
|
/// Formats a decimal-string amount (as the API sends it, to avoid double
|
|
/// rounding errors) with `intl`'s ru_RU rules and a currency symbol.
|
|
class MoneyText extends StatelessWidget {
|
|
const MoneyText(this.amount, {required this.currency, super.key, this.style});
|
|
|
|
/// The amount as a string, e.g. `'1234.5'` — never a [double].
|
|
final String amount;
|
|
final String currency;
|
|
final TextStyle? style;
|
|
|
|
static String format(String amount, String currency) {
|
|
final value = Decimal.parse(amount).toDouble();
|
|
final symbol = _currencySymbols[currency] ?? currency;
|
|
final formatter = NumberFormat.currency(
|
|
locale: 'ru_RU',
|
|
symbol: symbol,
|
|
decimalDigits: 2,
|
|
);
|
|
return formatter.format(value);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Text(format(amount, currency), style: style);
|
|
}
|
|
}
|