mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
minor fix [skip ci]
This commit is contained in:
+21
-13
@@ -75,10 +75,12 @@ class Quote extends SelectableOption {
|
||||
late FiatCurrency _fiatCurrency;
|
||||
late CryptoCurrency _cryptoCurrency;
|
||||
|
||||
|
||||
bool get isSelected => _isSelected;
|
||||
|
||||
bool get isBestRate => _isBestRate;
|
||||
|
||||
FiatCurrency get fiatCurrency => _fiatCurrency;
|
||||
|
||||
CryptoCurrency get cryptoCurrency => _cryptoCurrency;
|
||||
|
||||
@override
|
||||
@@ -96,15 +98,16 @@ class Quote extends SelectableOption {
|
||||
List<String> get badges => recommendations.map((e) => e.title).toList();
|
||||
|
||||
@override
|
||||
String get topLeftSubTitle =>
|
||||
this.rate > 0 ? '1 ${cryptoCurrency.toString()} = ${formatWithCommas(rate.toStringAsFixed(2))} ${fiatCurrency.toString()}' : '';
|
||||
String get topLeftSubTitle => this.rate > 0
|
||||
? '1 ${cryptoCurrency.toString()} = ${formatWithCommas(rate.toStringAsFixed(2))} ${fiatCurrency.toString()}'
|
||||
: '';
|
||||
|
||||
@override
|
||||
String get bottomLeftSubTitle {
|
||||
if (limits != null) {
|
||||
final min = limits!.min;
|
||||
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 '';
|
||||
}
|
||||
@@ -123,9 +126,13 @@ class Quote extends SelectableOption {
|
||||
String get formatedFee => '$feeAmount ${isBuyAction ? fiatCurrency : cryptoCurrency}';
|
||||
|
||||
set setIsSelected(bool isSelected) => _isSelected = isSelected;
|
||||
|
||||
set setIsBestRate(bool isBestRate) => _isBestRate = isBestRate;
|
||||
|
||||
set setFiatCurrency(FiatCurrency fiatCurrency) => _fiatCurrency = fiatCurrency;
|
||||
|
||||
set setCryptoCurrency(CryptoCurrency cryptoCurrency) => _cryptoCurrency = cryptoCurrency;
|
||||
|
||||
set setLimits(Limits limits) => this.limits = limits;
|
||||
|
||||
factory Quote.fromOnramperJson(Map<String, dynamic> json, bool isBuyAction,
|
||||
@@ -185,7 +192,7 @@ class Quote extends SelectableOption {
|
||||
customPaymentMethodType: customPaymentMethodType,
|
||||
quoteId: json['quoteId'] as String? ?? '',
|
||||
recommendations: enumRecommendations,
|
||||
provider: ProvidersHelper.getProviderByType(ProviderType.onramper)!,
|
||||
provider: ProvidersHelper.getProviderByType(ProviderType.onramper),
|
||||
isBuyAction: isBuyAction,
|
||||
limits: Limits(min: minLimit, max: maxLimit),
|
||||
);
|
||||
@@ -220,7 +227,7 @@ class Quote extends SelectableOption {
|
||||
paymentType: paymentType,
|
||||
recommendations: [],
|
||||
quoteId: json['signature'] as String? ?? '',
|
||||
provider: ProvidersHelper.getProviderByType(ProviderType.moonpay)!,
|
||||
provider: ProvidersHelper.getProviderByType(ProviderType.moonpay),
|
||||
isBuyAction: isBuyAction,
|
||||
limits: Limits(min: minLimit, max: maxLimit),
|
||||
);
|
||||
@@ -245,7 +252,7 @@ class Quote extends SelectableOption {
|
||||
payout: _toDouble(json['payout']) ?? 0.0,
|
||||
paymentType: paymentType,
|
||||
recommendations: [ProviderRecommendation.lowKyc],
|
||||
provider: ProvidersHelper.getProviderByType(ProviderType.dfx)!,
|
||||
provider: ProvidersHelper.getProviderByType(ProviderType.dfx),
|
||||
isBuyAction: isBuyAction,
|
||||
limits: Limits(min: minVolume, max: maxVolume),
|
||||
);
|
||||
@@ -267,7 +274,7 @@ class Quote extends SelectableOption {
|
||||
payout: _toDouble(json['cryptoAmount']) ?? 0.0,
|
||||
paymentType: paymentType,
|
||||
recommendations: [],
|
||||
provider: ProvidersHelper.getProviderByType(ProviderType.robinhood)!,
|
||||
provider: ProvidersHelper.getProviderByType(ProviderType.robinhood),
|
||||
isBuyAction: isBuyAction,
|
||||
limits: Limits(min: 0.0, max: double.infinity),
|
||||
);
|
||||
@@ -283,7 +290,7 @@ class Quote extends SelectableOption {
|
||||
payout: quotes['payout'] as double? ?? 0.0,
|
||||
paymentType: paymentType,
|
||||
recommendations: [],
|
||||
provider: ProvidersHelper.getProviderByType(ProviderType.meld)!,
|
||||
provider: ProvidersHelper.getProviderByType(ProviderType.meld),
|
||||
isBuyAction: isBuyAction,
|
||||
limits: Limits(min: 0.0, max: double.infinity),
|
||||
);
|
||||
@@ -292,7 +299,7 @@ class Quote extends SelectableOption {
|
||||
factory Quote.fromKryptonimJson(
|
||||
Map<String, dynamic> json, bool isBuyAction, PaymentType paymentType) {
|
||||
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 minLimit = _toDouble(limits['min_amount']) ?? 0.0;
|
||||
final maxLimit = _toDouble(limits['max_amount']) ?? double.infinity;
|
||||
@@ -300,14 +307,14 @@ class Quote extends SelectableOption {
|
||||
final amount = _toDouble(json['amount']) ?? 0.0;
|
||||
final calculatedRate = amount / convertedAmount;
|
||||
return Quote(
|
||||
rate: calculatedRate,
|
||||
rate: calculatedRate,
|
||||
feeAmount: _toDouble(fees['totalFee']) ?? 0.0,
|
||||
networkFee: _toDouble(fees['network_fee']) ?? 0.0,
|
||||
transactionFee: _toDouble(fees['operation_fee']) ?? 0.0,
|
||||
payout: _toDouble(json['amount']) ?? 0.0,
|
||||
paymentType: paymentType,
|
||||
recommendations: [],
|
||||
provider: ProvidersHelper.getProviderByType(ProviderType.kriptonim)!,
|
||||
provider: ProvidersHelper.getProviderByType(ProviderType.kriptonim),
|
||||
isBuyAction: isBuyAction,
|
||||
limits: Limits(min: minLimit, max: maxLimit));
|
||||
}
|
||||
@@ -324,5 +331,6 @@ class Quote extends SelectableOption {
|
||||
}
|
||||
|
||||
@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}]';
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@ String calculateFiatAmount({double? price, String? cryptoAmount}) {
|
||||
return result > 0.01 ? formatted : '< 0.01';
|
||||
}
|
||||
|
||||
String formatWithCommas(String number) {
|
||||
if (number.isEmpty) return number;
|
||||
String formatWithCommas(String? number) {
|
||||
if (number?.isEmpty ?? true) return '';
|
||||
|
||||
final parts = number.split('.');
|
||||
final parts = number!.split('.');
|
||||
final integerPart = parts[0];
|
||||
final decimalPart = parts.length > 1 ? parts[1] : '';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user