minor fix [skip ci]

This commit is contained in:
OmarHatem
2025-07-31 20:39:26 +03:00
parent 7468fed91b
commit c67a0f2346
2 changed files with 24 additions and 16 deletions
+21 -13
View File
@@ -75,10 +75,12 @@ class Quote extends SelectableOption {
late FiatCurrency _fiatCurrency; late FiatCurrency _fiatCurrency;
late CryptoCurrency _cryptoCurrency; late CryptoCurrency _cryptoCurrency;
bool get isSelected => _isSelected; bool get isSelected => _isSelected;
bool get isBestRate => _isBestRate; bool get isBestRate => _isBestRate;
FiatCurrency get fiatCurrency => _fiatCurrency; FiatCurrency get fiatCurrency => _fiatCurrency;
CryptoCurrency get cryptoCurrency => _cryptoCurrency; CryptoCurrency get cryptoCurrency => _cryptoCurrency;
@override @override
@@ -96,15 +98,16 @@ class Quote extends SelectableOption {
List<String> get badges => recommendations.map((e) => e.title).toList(); List<String> get badges => recommendations.map((e) => e.title).toList();
@override @override
String get topLeftSubTitle => String get topLeftSubTitle => this.rate > 0
this.rate > 0 ? '1 ${cryptoCurrency.toString()} = ${formatWithCommas(rate.toStringAsFixed(2))} ${fiatCurrency.toString()}' : ''; ? '1 ${cryptoCurrency.toString()} = ${formatWithCommas(rate.toStringAsFixed(2))} ${fiatCurrency.toString()}'
: '';
@override @override
String get bottomLeftSubTitle { String get bottomLeftSubTitle {
if (limits != null) { if (limits != null) {
final min = limits!.min; final min = limits!.min;
final max = limits!.max; final max = limits!.max;
return 'min: ${min} ${fiatCurrency.toString()} | max: ${max == double.infinity ? '' : '${max} ${fiatCurrency.toString()}'}'; return 'min: ${formatWithCommas(min?.toString())} ${fiatCurrency.toString()} | max: ${max == double.infinity ? '' : '${formatWithCommas(max?.toString())} ${fiatCurrency.toString()}'}';
} }
return ''; return '';
} }
@@ -123,9 +126,13 @@ class Quote extends SelectableOption {
String get formatedFee => '$feeAmount ${isBuyAction ? fiatCurrency : cryptoCurrency}'; String get formatedFee => '$feeAmount ${isBuyAction ? fiatCurrency : cryptoCurrency}';
set setIsSelected(bool isSelected) => _isSelected = isSelected; set setIsSelected(bool isSelected) => _isSelected = isSelected;
set setIsBestRate(bool isBestRate) => _isBestRate = isBestRate; set setIsBestRate(bool isBestRate) => _isBestRate = isBestRate;
set setFiatCurrency(FiatCurrency fiatCurrency) => _fiatCurrency = fiatCurrency; set setFiatCurrency(FiatCurrency fiatCurrency) => _fiatCurrency = fiatCurrency;
set setCryptoCurrency(CryptoCurrency cryptoCurrency) => _cryptoCurrency = cryptoCurrency; set setCryptoCurrency(CryptoCurrency cryptoCurrency) => _cryptoCurrency = cryptoCurrency;
set setLimits(Limits limits) => this.limits = limits; set setLimits(Limits limits) => this.limits = limits;
factory Quote.fromOnramperJson(Map<String, dynamic> json, bool isBuyAction, factory Quote.fromOnramperJson(Map<String, dynamic> json, bool isBuyAction,
@@ -185,7 +192,7 @@ class Quote extends SelectableOption {
customPaymentMethodType: customPaymentMethodType, customPaymentMethodType: customPaymentMethodType,
quoteId: json['quoteId'] as String? ?? '', quoteId: json['quoteId'] as String? ?? '',
recommendations: enumRecommendations, recommendations: enumRecommendations,
provider: ProvidersHelper.getProviderByType(ProviderType.onramper)!, provider: ProvidersHelper.getProviderByType(ProviderType.onramper),
isBuyAction: isBuyAction, isBuyAction: isBuyAction,
limits: Limits(min: minLimit, max: maxLimit), limits: Limits(min: minLimit, max: maxLimit),
); );
@@ -220,7 +227,7 @@ class Quote extends SelectableOption {
paymentType: paymentType, paymentType: paymentType,
recommendations: [], recommendations: [],
quoteId: json['signature'] as String? ?? '', quoteId: json['signature'] as String? ?? '',
provider: ProvidersHelper.getProviderByType(ProviderType.moonpay)!, provider: ProvidersHelper.getProviderByType(ProviderType.moonpay),
isBuyAction: isBuyAction, isBuyAction: isBuyAction,
limits: Limits(min: minLimit, max: maxLimit), limits: Limits(min: minLimit, max: maxLimit),
); );
@@ -245,7 +252,7 @@ class Quote extends SelectableOption {
payout: _toDouble(json['payout']) ?? 0.0, payout: _toDouble(json['payout']) ?? 0.0,
paymentType: paymentType, paymentType: paymentType,
recommendations: [ProviderRecommendation.lowKyc], recommendations: [ProviderRecommendation.lowKyc],
provider: ProvidersHelper.getProviderByType(ProviderType.dfx)!, provider: ProvidersHelper.getProviderByType(ProviderType.dfx),
isBuyAction: isBuyAction, isBuyAction: isBuyAction,
limits: Limits(min: minVolume, max: maxVolume), limits: Limits(min: minVolume, max: maxVolume),
); );
@@ -267,7 +274,7 @@ class Quote extends SelectableOption {
payout: _toDouble(json['cryptoAmount']) ?? 0.0, payout: _toDouble(json['cryptoAmount']) ?? 0.0,
paymentType: paymentType, paymentType: paymentType,
recommendations: [], recommendations: [],
provider: ProvidersHelper.getProviderByType(ProviderType.robinhood)!, provider: ProvidersHelper.getProviderByType(ProviderType.robinhood),
isBuyAction: isBuyAction, isBuyAction: isBuyAction,
limits: Limits(min: 0.0, max: double.infinity), limits: Limits(min: 0.0, max: double.infinity),
); );
@@ -283,7 +290,7 @@ class Quote extends SelectableOption {
payout: quotes['payout'] as double? ?? 0.0, payout: quotes['payout'] as double? ?? 0.0,
paymentType: paymentType, paymentType: paymentType,
recommendations: [], recommendations: [],
provider: ProvidersHelper.getProviderByType(ProviderType.meld)!, provider: ProvidersHelper.getProviderByType(ProviderType.meld),
isBuyAction: isBuyAction, isBuyAction: isBuyAction,
limits: Limits(min: 0.0, max: double.infinity), limits: Limits(min: 0.0, max: double.infinity),
); );
@@ -292,7 +299,7 @@ class Quote extends SelectableOption {
factory Quote.fromKryptonimJson( factory Quote.fromKryptonimJson(
Map<String, dynamic> json, bool isBuyAction, PaymentType paymentType) { Map<String, dynamic> json, bool isBuyAction, PaymentType paymentType) {
final fees = json['fees'] as Map<String, dynamic>; final fees = json['fees'] as Map<String, dynamic>;
final rate = _toDouble(json['rate']) ?? 0.0; // final rate = _toDouble(json['rate']) ?? 0.0;
final limits = json['limits'] as Map<String, dynamic>; final limits = json['limits'] as Map<String, dynamic>;
final minLimit = _toDouble(limits['min_amount']) ?? 0.0; final minLimit = _toDouble(limits['min_amount']) ?? 0.0;
final maxLimit = _toDouble(limits['max_amount']) ?? double.infinity; final maxLimit = _toDouble(limits['max_amount']) ?? double.infinity;
@@ -300,14 +307,14 @@ class Quote extends SelectableOption {
final amount = _toDouble(json['amount']) ?? 0.0; final amount = _toDouble(json['amount']) ?? 0.0;
final calculatedRate = amount / convertedAmount; final calculatedRate = amount / convertedAmount;
return Quote( return Quote(
rate: calculatedRate, rate: calculatedRate,
feeAmount: _toDouble(fees['totalFee']) ?? 0.0, feeAmount: _toDouble(fees['totalFee']) ?? 0.0,
networkFee: _toDouble(fees['network_fee']) ?? 0.0, networkFee: _toDouble(fees['network_fee']) ?? 0.0,
transactionFee: _toDouble(fees['operation_fee']) ?? 0.0, transactionFee: _toDouble(fees['operation_fee']) ?? 0.0,
payout: _toDouble(json['amount']) ?? 0.0, payout: _toDouble(json['amount']) ?? 0.0,
paymentType: paymentType, paymentType: paymentType,
recommendations: [], recommendations: [],
provider: ProvidersHelper.getProviderByType(ProviderType.kriptonim)!, provider: ProvidersHelper.getProviderByType(ProviderType.kriptonim),
isBuyAction: isBuyAction, isBuyAction: isBuyAction,
limits: Limits(min: minLimit, max: maxLimit)); limits: Limits(min: minLimit, max: maxLimit));
} }
@@ -324,5 +331,6 @@ class Quote extends SelectableOption {
} }
@override @override
String toString() => 'Quote: rate: $rate, feeAmount: $feeAmount, networkFee: $networkFee, transactionFee: $transactionFee, payout: $payout, paymentType: $paymentType, provider: $provider, quoteId: $quoteId, recommendations: $recommendations, isBuyAction: $isBuyAction, rampId: $rampId, rampName: $rampName, rampIconPath: $rampIconPath, [limits: min: ${limits?.min}, max: ${limits?.max}]'; String toString() =>
'Quote: rate: $rate, feeAmount: $feeAmount, networkFee: $networkFee, transactionFee: $transactionFee, payout: $payout, paymentType: $paymentType, provider: $provider, quoteId: $quoteId, recommendations: $recommendations, isBuyAction: $isBuyAction, rampId: $rampId, rampName: $rampName, rampIconPath: $rampIconPath, [limits: min: ${limits?.min}, max: ${limits?.max}]';
} }
+3 -3
View File
@@ -29,10 +29,10 @@ String calculateFiatAmount({double? price, String? cryptoAmount}) {
return result > 0.01 ? formatted : '< 0.01'; return result > 0.01 ? formatted : '< 0.01';
} }
String formatWithCommas(String number) { String formatWithCommas(String? number) {
if (number.isEmpty) return number; if (number?.isEmpty ?? true) return '';
final parts = number.split('.'); final parts = number!.split('.');
final integerPart = parts[0]; final integerPart = parts[0];
final decimalPart = parts.length > 1 ? parts[1] : ''; final decimalPart = parts.length > 1 ? parts[1] : '';