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,38 +0,0 @@
import 'package:flutter/material.dart';
import 'package:pweb/models/currency.dart';
String currencyCodeToSymbol(Currency currencyCode) {
switch (currencyCode) {
case Currency.usd:
return '\$';
case Currency.eur:
return '';
case Currency.rub:
return '';
case Currency.usdt:
return 'USDT';
case Currency.usdc:
return 'USDC';
}
}
String currencyToString(Currency currencyCode, double amount) {
return '${amount.toStringAsFixed(2)} ${currencyCodeToSymbol(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;
}
}

View File

@@ -1,16 +1,17 @@
import 'package:flutter/material.dart';
import 'package:pshared/models/payment/methods/type.dart';
import 'package:pshared/models/payment/type.dart';
import 'package:pweb/models/wallet.dart';
import 'package:pweb/pages/payment_methods/icon.dart';
import 'package:pweb/generated/i18n/app_localizations.dart';
class PaymentMethodDropdown extends StatefulWidget {
final List<PaymentMethod> methods;
final ValueChanged<PaymentMethod> onChanged;
final PaymentMethod? initialValue;
final List<Wallet> methods;
final ValueChanged<Wallet> onChanged;
final Wallet? initialValue;
const PaymentMethodDropdown({
super.key,
@@ -24,7 +25,7 @@ class PaymentMethodDropdown extends StatefulWidget {
}
class _PaymentMethodDropdownState extends State<PaymentMethodDropdown> {
late PaymentMethod _selectedMethod;
late Wallet _selectedMethod;
@override
void initState() {
@@ -34,7 +35,7 @@ class _PaymentMethodDropdownState extends State<PaymentMethodDropdown> {
@override
Widget build(BuildContext context) {
return DropdownButtonFormField<PaymentMethod>(
return DropdownButtonFormField<Wallet>(
dropdownColor: Theme.of(context).colorScheme.onSecondary,
initialValue: _selectedMethod,
decoration: InputDecoration(
@@ -42,13 +43,13 @@ class _PaymentMethodDropdownState extends State<PaymentMethodDropdown> {
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
),
items: widget.methods.map((method) {
return DropdownMenuItem<PaymentMethod>(
return DropdownMenuItem<Wallet>(
value: method,
child: Row(
children: [
Icon(iconForPaymentType(method.type), size: 20),
Icon(iconForPaymentType(PaymentType.managedWallet), size: 20),
const SizedBox(width: 8),
Text('${method.name}' + (method.description == null ? '' : ' (${method.description!})')),
Text(method.name),
],
),
);