diff --git a/lib/buy/buy_amount.dart b/lib/buy/buy_amount.dart index 3cf3543d..1a1b3ae2 100644 --- a/lib/buy/buy_amount.dart +++ b/lib/buy/buy_amount.dart @@ -4,9 +4,11 @@ class BuyAmount { BuyAmount({ @required this.sourceAmount, @required this.destAmount, + this.achSourceAmount, this.minAmount = 0}); final double sourceAmount; final double destAmount; + final double achSourceAmount; final int minAmount; } \ No newline at end of file diff --git a/lib/buy/wyre/wyre_buy_provider.dart b/lib/buy/wyre/wyre_buy_provider.dart index 21117363..aac8c3db 100644 --- a/lib/buy/wyre/wyre_buy_provider.dart +++ b/lib/buy/wyre/wyre_buy_provider.dart @@ -107,8 +107,9 @@ class WyreBuyProvider extends BuyProvider { final responseJSON = json.decode(response.body) as Map; final sourceAmount = responseJSON['sourceAmount'] as double; final destAmount = responseJSON['destAmount'] as double; + final achAmount = responseJSON['sourceAmountWithoutFees'] as double; - return BuyAmount(sourceAmount: sourceAmount, destAmount: destAmount); + return BuyAmount(sourceAmount: sourceAmount, destAmount: destAmount, achSourceAmount: achAmount); } @override diff --git a/lib/src/screens/buy/pre_order_page.dart b/lib/src/screens/buy/pre_order_page.dart index f6b327e1..3f403bf8 100644 --- a/lib/src/screens/buy/pre_order_page.dart +++ b/lib/src/screens/buy/pre_order_page.dart @@ -177,12 +177,14 @@ class PreOrderPage extends BasePage { builder: (context, AsyncSnapshot snapshot) { double sourceAmount; double destAmount; + double achAmount; int minAmount; if (snapshot.hasData) { sourceAmount = snapshot.data.sourceAmount; destAmount = snapshot.data.destAmount; minAmount = snapshot.data.minAmount; + achAmount = snapshot.data.achSourceAmount; } else { sourceAmount = 0.0; destAmount = 0.0; @@ -201,6 +203,7 @@ class PreOrderPage extends BasePage { sourceCurrency: buyViewModel.fiatCurrency, destAmount: destAmount, destCurrency: buyViewModel.cryptoCurrency, + achSourceAmount: achAmount, onTap: ((buyViewModel.doubleAmount != 0.0) && (snapshot.hasData)) ? () => onSelectBuyProvider( diff --git a/lib/src/screens/buy/widgets/buy_list_item.dart b/lib/src/screens/buy/widgets/buy_list_item.dart index 3d6f19d2..97cbb646 100644 --- a/lib/src/screens/buy/widgets/buy_list_item.dart +++ b/lib/src/screens/buy/widgets/buy_list_item.dart @@ -3,6 +3,7 @@ import 'package:cake_wallet/buy/get_buy_provider_icon.dart'; import 'package:cw_core/crypto_currency.dart'; import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/palette.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; class BuyListItem extends StatelessWidget { @@ -13,6 +14,7 @@ class BuyListItem extends StatelessWidget { @required this.sourceCurrency, @required this.destAmount, @required this.destCurrency, + @required this.achSourceAmount, @required this.onTap }); @@ -22,6 +24,7 @@ class BuyListItem extends StatelessWidget { final FiatCurrency sourceCurrency; final double destAmount; final CryptoCurrency destCurrency; + final double achSourceAmount; final void Function() onTap; @override @@ -47,70 +50,100 @@ class BuyListItem extends StatelessWidget { return GestureDetector( onTap: () => onTap?.call(), child: Container( - height: 102, padding: EdgeInsets.only( left: 20, - //top: 33, + top: 28, + bottom: 28, right: 20 ), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(25)), color: backgroundColor ), - child: Stack( + child: Column( children: [ - Positioned( - top: 33, - left: 0, - right: 0, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - if (providerIcon != null) Padding( + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + if (providerIcon != null) + Padding( padding: EdgeInsets.only(right: 10), - child: providerIcon - ), - Text( - provider.description.title, - style: TextStyle( - color: secondaryTextColor, - fontSize: 20, - fontWeight: FontWeight.bold + child: providerIcon), + Text( + provider.description.title, + style: TextStyle( + color: secondaryTextColor, + fontSize: 20, + fontWeight: FontWeight.bold), + ) + ], + ), + Column( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + if(achSourceAmount != null)...[ + Text( + '${destAmount?.toString()} ${destCurrency.title}', + style: TextStyle( + color: secondaryTextColor, + fontSize: 20, + fontWeight: FontWeight.bold), + ), + Row( + children: [ + Icon( + Icons.account_balance_outlined, + size: 12, + color: primaryTextColor, + ), + SizedBox(width: 5), + Text( + '${achSourceAmount?.toString()} ${sourceCurrency.title}', + style: TextStyle( + color: primaryTextColor, + fontSize: 16, + fontWeight: FontWeight.bold), ), - ) + ], + ), + SizedBox(height: 10), ], - ), - Text( - '${destAmount?.toString()} ${destCurrency.title}', - style: TextStyle( - color: secondaryTextColor, - fontSize: 20, - fontWeight: FontWeight.bold + Text( + '${destAmount?.toString()} ${destCurrency.title}', + style: TextStyle( + color: secondaryTextColor, + fontSize: 20, + fontWeight: FontWeight.bold), ), - ), - ], - ) - ), - Positioned( - top: 65, - right: 0, - child: Text( - '${sourceAmount?.toString()} ${sourceCurrency.title}', - style: TextStyle( - color: primaryTextColor, - fontSize: 16, - fontWeight: FontWeight.bold + Row( + children: [ + Icon( + CupertinoIcons.creditcard, + size: 12, + color: primaryTextColor, + ), + SizedBox(width: 5), + Text( + '${sourceAmount?.toString()} ${sourceCurrency.title}', + style: TextStyle( + color: primaryTextColor, + fontSize: 16, + fontWeight: FontWeight.bold), + ), + ], + ), + ], ), - ), - ) + ], + ), ], - ) + ), ) ); } diff --git a/lib/view_model/buy/buy_view_model.dart b/lib/view_model/buy/buy_view_model.dart index 7d8fe5f9..b7b74d7f 100644 --- a/lib/view_model/buy/buy_view_model.dart +++ b/lib/view_model/buy/buy_view_model.dart @@ -103,7 +103,7 @@ abstract class BuyViewModelBase with Store { print(e.toString()); } - if (isMoonPayEnabled) { + if (isMoonPayEnabled ?? false) { _providerList.add(MoonPayBuyProvider(wallet: wallet)); }