From bf5bfc3d71b36e4c6bd163a371f87743eb049b6a Mon Sep 17 00:00:00 2001 From: dethe <76167420+detherminal@users.noreply.github.com> Date: Wed, 12 Mar 2025 23:51:29 +0300 Subject: [PATCH] fix: use trocador provider icons --- .../exchange/response_objects/estimate.dart | 2 + .../sub_widgets/exchange_provider_option.dart | 38 ++++++++++++++++++- .../response_objects/trocador_quote.dart | 3 ++ .../exchange/trocador/trocador_exchange.dart | 2 + 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/lib/models/exchange/response_objects/estimate.dart b/lib/models/exchange/response_objects/estimate.dart index 233959277..6f4173ade 100644 --- a/lib/models/exchange/response_objects/estimate.dart +++ b/lib/models/exchange/response_objects/estimate.dart @@ -19,6 +19,7 @@ class Estimate { final String? warningMessage; final String? rateId; final String exchangeProvider; + final String? exchangeProviderLogo; final String? kycRating; Estimate({ @@ -28,6 +29,7 @@ class Estimate { this.warningMessage, this.rateId, required this.exchangeProvider, + this.exchangeProviderLogo, this.kycRating, }); diff --git a/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart b/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart index ea91dc60f..5b11876e8 100644 --- a/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart +++ b/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart @@ -314,7 +314,43 @@ class _ProviderOptionState extends ConsumerState<_ProviderOption> { child: SizedBox( width: isDesktop ? 32 : 24, height: isDesktop ? 32 : 24, - child: SvgPicture.asset( + child: widget.estimate?.exchangeProviderLogo != null && + widget + .estimate! + .exchangeProviderLogo! + .isNotEmpty + ? ClipRRect( + borderRadius: BorderRadius.circular(5), + child: Image.network( + widget.estimate!.exchangeProviderLogo!, + loadingBuilder: ( + context, + child, + loadingProgress, + ) { + if (loadingProgress == null) { + return child; + } else { + return const Center( + child: + CircularProgressIndicator(), + ); + } + }, + errorBuilder: (context, error, stackTrace) { + return SvgPicture.asset( + Assets.exchange.getIconFor( + exchangeName: widget.exchange.name, + ), + width: isDesktop ? 32 : 24, + height: isDesktop ? 32 : 24, + ); + }, + width: isDesktop ? 32 : 24, + height: isDesktop ? 32 : 24, + ), + ) + : SvgPicture.asset( Assets.exchange.getIconFor( exchangeName: widget.exchange.name, ), diff --git a/lib/services/exchange/trocador/response_objects/trocador_quote.dart b/lib/services/exchange/trocador/response_objects/trocador_quote.dart index cb478a25e..74c55a477 100644 --- a/lib/services/exchange/trocador/response_objects/trocador_quote.dart +++ b/lib/services/exchange/trocador/response_objects/trocador_quote.dart @@ -12,6 +12,7 @@ import 'package:decimal/decimal.dart'; class TrocadorQuote { final String provider; + final String? providerLogo; final String kycRating; final int insurance; final bool fixed; @@ -21,6 +22,7 @@ class TrocadorQuote { TrocadorQuote({ required this.provider, + this.providerLogo, required this.kycRating, required this.insurance, required this.fixed, @@ -32,6 +34,7 @@ class TrocadorQuote { factory TrocadorQuote.fromMap(Map map) { return TrocadorQuote( provider: map['provider'] as String, + providerLogo: map['provider_logo'] as String?, kycRating: map['kycrating'] as String, insurance: map['insurance'] as int, // wtf trocador? diff --git a/lib/services/exchange/trocador/trocador_exchange.dart b/lib/services/exchange/trocador/trocador_exchange.dart index 701bca7cb..cf02cc206 100644 --- a/lib/services/exchange/trocador/trocador_exchange.dart +++ b/lib/services/exchange/trocador/trocador_exchange.dart @@ -236,6 +236,7 @@ class TrocadorExchange extends Exchange { fixedRate: quote.fixed, reversed: reversed, exchangeProvider: quote.provider, + exchangeProviderLogo: quote.providerLogo, rateId: response.value!.tradeId, kycRating: quote.kycRating, ), @@ -256,6 +257,7 @@ class TrocadorExchange extends Exchange { fixedRate: quote.fixed, reversed: reversed, exchangeProvider: quote.provider, + exchangeProviderLogo: quote.providerLogo, rateId: response.value!.tradeId, kycRating: quote.kycRating, ),