mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-27 06:18:50 +01:00
Update list of trocador providers to be fetched from the api (#1379)
* fetch providers from Trocadore api * Update exchange_confirm_page.dart * Update exchange_view_model.dart * update trocador providers page * Revert "Update exchange_view_model.dart" This reverts commit 5722ed768a8a5e21deaaaec37d9436a7e3a2651f. * update exchange view model * pass the TrocadorExchangeProvider as a dependency [skip ci] * add missing localozation [skip ci] * minor fix * address review comments[skip ci] * update states when the provider is enabled * add kyc rating * sort providers by KYC * minor fix * Update exchange_view_model.dart * Update lib/exchange/provider/trocador_exchange_provider.dart Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * backward compatibility for Trocador provider states * minor fix --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
@@ -97,22 +97,39 @@ class ExchangeConfirmPage extends BasePage {
|
||||
],
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
(trade.provider.image?.isNotEmpty ?? false)
|
||||
? ImageUtil.getImageFromPath(
|
||||
imagePath: trade.provider.image, width: 50)
|
||||
: const SizedBox(),
|
||||
if (!trade.provider.horizontalLogo)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Text(trade.provider.title),
|
||||
Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
if (trade.provider == ExchangeProviderDescription.trocador)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: Text(
|
||||
S.of(context).selected_trocador_provider +':${trade.providerName}',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 12.0,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: Theme.of(context).extension<TransactionTradeTheme>()!.detailsTitlesColor),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
(trade.provider.image?.isNotEmpty ?? false)
|
||||
? Image.asset(trade.provider.image, height: 50)
|
||||
: const SizedBox(),
|
||||
if (!trade.provider.horizontalLogo)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Text(trade.provider.title),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:cake_wallet/exchange/provider/trocador_exchange_provider.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/screens/settings/widgets/settings_switcher_cell.dart';
|
||||
import 'package:cake_wallet/view_model/settings/trocador_providers_view_model.dart';
|
||||
@@ -15,23 +15,92 @@ class TrocadorProvidersPage extends BasePage {
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
final availableProviders = TrocadorExchangeProvider.availableProviders;
|
||||
final providerStates = trocadorProvidersViewModel.providerStates;
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 10),
|
||||
child: ListView.builder(
|
||||
itemCount: availableProviders.length,
|
||||
itemBuilder: (_, index) {
|
||||
String provider = availableProviders[index];
|
||||
return Observer(
|
||||
builder: (_) => SettingsSwitcherCell(
|
||||
title: provider,
|
||||
value: providerStates[provider] ?? false,
|
||||
onValueChange: (BuildContext _, bool value) {
|
||||
trocadorProvidersViewModel.toggleProviderState(provider);
|
||||
}));
|
||||
child: Observer(
|
||||
builder: (_) {
|
||||
if (trocadorProvidersViewModel.isLoading) {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
}
|
||||
var providerStates = trocadorProvidersViewModel.providerStates;
|
||||
final providerRatings = trocadorProvidersViewModel.providerRatings;
|
||||
if (providerStates.isEmpty) {
|
||||
return Center(child: Text(S.of(context).no_providers_available));
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: providerStates.length,
|
||||
itemBuilder: (_, index) {
|
||||
final providerName = providerStates.keys.elementAt(index);
|
||||
final providerEnabled = providerStates[providerName] ?? true;
|
||||
return SettingsSwitcherCell(
|
||||
title: providerName,
|
||||
value: providerEnabled,
|
||||
leading: Badge(
|
||||
title: 'KYC \nRATING',
|
||||
subTitle: providerRatings[providerName] ?? 'N/A',
|
||||
textColor: Colors.white,
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
),
|
||||
onValueChange: (BuildContext _, value) =>
|
||||
trocadorProvidersViewModel.toggleProviderState(providerName),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Badge extends StatelessWidget {
|
||||
Badge({required this.textColor, required this.backgroundColor, required this.title, required this.subTitle});
|
||||
|
||||
final String title;
|
||||
final String subTitle;
|
||||
final Color textColor;
|
||||
final Color backgroundColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
child: FittedBox(
|
||||
fit: BoxFit.fitHeight,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.all(Radius.circular(24)), color: backgroundColor),
|
||||
alignment: Alignment.center,
|
||||
child: IntrinsicHeight(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontSize: 7,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
VerticalDivider(
|
||||
color: textColor,
|
||||
thickness: 1,
|
||||
),
|
||||
Text(
|
||||
subTitle,
|
||||
style: TextStyle(
|
||||
color: textColor,
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user