Agrega PRIVACY.md, actualiza AGENTS.md
This commit is contained in:
76
lib/utils/currency_utils.dart
Normal file
76
lib/utils/currency_utils.dart
Normal file
@@ -0,0 +1,76 @@
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class CurrencyInfo {
|
||||
final String code;
|
||||
final String name;
|
||||
final String symbol;
|
||||
|
||||
const CurrencyInfo({
|
||||
required this.code,
|
||||
required this.name,
|
||||
required this.symbol,
|
||||
});
|
||||
}
|
||||
|
||||
class CurrencyUtils {
|
||||
static const List<CurrencyInfo> allCurrencies = [
|
||||
CurrencyInfo(code: 'USD', name: 'US Dollar', symbol: r'$'),
|
||||
CurrencyInfo(code: 'EUR', name: 'Euro', symbol: '€'),
|
||||
CurrencyInfo(code: 'GBP', name: 'British Pound', symbol: '£'),
|
||||
CurrencyInfo(code: 'JPY', name: 'Japanese Yen', symbol: '¥'),
|
||||
CurrencyInfo(code: 'MXN', name: 'Mexican Peso', symbol: r'MX$'),
|
||||
CurrencyInfo(code: 'COP', name: 'Colombian Peso', symbol: r'$'),
|
||||
CurrencyInfo(code: 'ARS', name: 'Argentine Peso', symbol: r'$'),
|
||||
CurrencyInfo(code: 'PEN', name: 'Peruvian Sol', symbol: 'S/'),
|
||||
CurrencyInfo(code: 'CLP', name: 'Chilean Peso', symbol: r'$'),
|
||||
CurrencyInfo(code: 'BRL', name: 'Brazilian Real', symbol: r'R$'),
|
||||
CurrencyInfo(code: 'CAD', name: 'Canadian Dollar', symbol: r'CA$'),
|
||||
CurrencyInfo(code: 'AUD', name: 'Australian Dollar', symbol: r'A$'),
|
||||
CurrencyInfo(code: 'CHF', name: 'Swiss Franc', symbol: 'CHF'),
|
||||
CurrencyInfo(code: 'CNY', name: 'Chinese Yuan', symbol: '¥'),
|
||||
CurrencyInfo(code: 'INR', name: 'Indian Rupee', symbol: '₹'),
|
||||
CurrencyInfo(code: 'KRW', name: 'South Korean Won', symbol: '₩'),
|
||||
CurrencyInfo(code: 'SEK', name: 'Swedish Krona', symbol: 'kr'),
|
||||
CurrencyInfo(code: 'NOK', name: 'Norwegian Krone', symbol: 'kr'),
|
||||
CurrencyInfo(code: 'NZD', name: 'New Zealand Dollar', symbol: r'NZ$'),
|
||||
CurrencyInfo(code: 'UYU', name: 'Uruguayan Peso', symbol: r'$U'),
|
||||
CurrencyInfo(code: 'PYG', name: 'Paraguayan Guarani', symbol: '₲'),
|
||||
CurrencyInfo(code: 'BOB', name: 'Bolivian Boliviano', symbol: 'Bs'),
|
||||
CurrencyInfo(code: 'CRC', name: 'Costa Rican Colón', symbol: '₡'),
|
||||
CurrencyInfo(code: 'DOP', name: 'Dominican Peso', symbol: r'RD$'),
|
||||
CurrencyInfo(code: 'GTQ', name: 'Guatemalan Quetzal', symbol: 'Q'),
|
||||
CurrencyInfo(code: 'HNL', name: 'Honduran Lempira', symbol: 'L'),
|
||||
CurrencyInfo(code: 'NIO', name: 'Nicaraguan Córdoba', symbol: r'C$'),
|
||||
CurrencyInfo(code: 'PAB', name: 'Panamanian Balboa', symbol: 'B/.'),
|
||||
CurrencyInfo(code: 'VES', name: 'Venezuelan Bolívar', symbol: 'Bs.S'),
|
||||
CurrencyInfo(code: 'SGD', name: 'Singapore Dollar', symbol: r'S$'),
|
||||
CurrencyInfo(code: 'HKD', name: 'Hong Kong Dollar', symbol: r'HK$'),
|
||||
CurrencyInfo(code: 'TRY', name: 'Turkish Lira', symbol: '₺'),
|
||||
CurrencyInfo(code: 'TWD', name: 'Taiwan Dollar', symbol: r'NT$'),
|
||||
CurrencyInfo(code: 'THB', name: 'Thai Baht', symbol: '฿'),
|
||||
CurrencyInfo(code: 'ZAR', name: 'South African Rand', symbol: 'R'),
|
||||
CurrencyInfo(code: 'ILS', name: 'Israeli Shekel', symbol: '₪'),
|
||||
CurrencyInfo(code: 'DKK', name: 'Danish Krone', symbol: 'kr'),
|
||||
CurrencyInfo(code: 'PLN', name: 'Polish Zloty', symbol: 'zł'),
|
||||
];
|
||||
|
||||
static const _zeroDecimal = {'JPY', 'KRW', 'CLP', 'PYG', 'COP'};
|
||||
|
||||
static String getSymbol(String code) {
|
||||
final idx = allCurrencies.indexWhere((c) => c.code == code);
|
||||
return idx >= 0 ? allCurrencies[idx].symbol : r'$';
|
||||
}
|
||||
|
||||
static String getDisplayName(String code) {
|
||||
final idx = allCurrencies.indexWhere((c) => c.code == code);
|
||||
return idx >= 0 ? '${allCurrencies[idx].code} - ${allCurrencies[idx].name}' : code;
|
||||
}
|
||||
|
||||
static String formatPrice(double amount, String code) {
|
||||
final symbol = getSymbol(code);
|
||||
final fmt = _zeroDecimal.contains(code)
|
||||
? NumberFormat('#,##0')
|
||||
: NumberFormat('#,##0.00');
|
||||
return '$symbol${fmt.format(amount)}';
|
||||
}
|
||||
}
|
||||
29
lib/utils/transitions.dart
Normal file
29
lib/utils/transitions.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SmoothPageTransitionBuilder extends PageTransitionsBuilder {
|
||||
const SmoothPageTransitionBuilder();
|
||||
|
||||
@override
|
||||
Widget buildTransitions<T>(
|
||||
PageRoute<T> route,
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
Widget child,
|
||||
) {
|
||||
const begin = Offset(0.0, 0.04);
|
||||
const end = Offset.zero;
|
||||
const curve = Curves.easeInOutCubic;
|
||||
final tween = Tween(begin: begin, end: end).chain(
|
||||
CurveTween(curve: curve),
|
||||
);
|
||||
final fadeTween = Tween<double>(begin: 0.0, end: 1.0);
|
||||
return SlideTransition(
|
||||
position: animation.drive(tween),
|
||||
child: FadeTransition(
|
||||
opacity: animation.drive(fadeTween),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user