Add ach payment amount on buy page (#282)

wownero
Godwin Asuquo 2 years ago committed by GitHub
parent dd47a82a0d
commit d14150f4b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,9 +4,11 @@ class BuyAmount {
BuyAmount({ BuyAmount({
@required this.sourceAmount, @required this.sourceAmount,
@required this.destAmount, @required this.destAmount,
this.achSourceAmount,
this.minAmount = 0}); this.minAmount = 0});
final double sourceAmount; final double sourceAmount;
final double destAmount; final double destAmount;
final double achSourceAmount;
final int minAmount; final int minAmount;
} }

@ -107,8 +107,9 @@ class WyreBuyProvider extends BuyProvider {
final responseJSON = json.decode(response.body) as Map<String, dynamic>; final responseJSON = json.decode(response.body) as Map<String, dynamic>;
final sourceAmount = responseJSON['sourceAmount'] as double; final sourceAmount = responseJSON['sourceAmount'] as double;
final destAmount = responseJSON['destAmount'] 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 @override

@ -177,12 +177,14 @@ class PreOrderPage extends BasePage {
builder: (context, AsyncSnapshot<BuyAmount> snapshot) { builder: (context, AsyncSnapshot<BuyAmount> snapshot) {
double sourceAmount; double sourceAmount;
double destAmount; double destAmount;
double achAmount;
int minAmount; int minAmount;
if (snapshot.hasData) { if (snapshot.hasData) {
sourceAmount = snapshot.data.sourceAmount; sourceAmount = snapshot.data.sourceAmount;
destAmount = snapshot.data.destAmount; destAmount = snapshot.data.destAmount;
minAmount = snapshot.data.minAmount; minAmount = snapshot.data.minAmount;
achAmount = snapshot.data.achSourceAmount;
} else { } else {
sourceAmount = 0.0; sourceAmount = 0.0;
destAmount = 0.0; destAmount = 0.0;
@ -201,6 +203,7 @@ class PreOrderPage extends BasePage {
sourceCurrency: buyViewModel.fiatCurrency, sourceCurrency: buyViewModel.fiatCurrency,
destAmount: destAmount, destAmount: destAmount,
destCurrency: buyViewModel.cryptoCurrency, destCurrency: buyViewModel.cryptoCurrency,
achSourceAmount: achAmount,
onTap: ((buyViewModel.doubleAmount != 0.0) onTap: ((buyViewModel.doubleAmount != 0.0)
&& (snapshot.hasData)) ? () => && (snapshot.hasData)) ? () =>
onSelectBuyProvider( onSelectBuyProvider(

@ -3,6 +3,7 @@ import 'package:cake_wallet/buy/get_buy_provider_icon.dart';
import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/crypto_currency.dart';
import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/entities/fiat_currency.dart';
import 'package:cake_wallet/palette.dart'; import 'package:cake_wallet/palette.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
class BuyListItem extends StatelessWidget { class BuyListItem extends StatelessWidget {
@ -13,6 +14,7 @@ class BuyListItem extends StatelessWidget {
@required this.sourceCurrency, @required this.sourceCurrency,
@required this.destAmount, @required this.destAmount,
@required this.destCurrency, @required this.destCurrency,
@required this.achSourceAmount,
@required this.onTap @required this.onTap
}); });
@ -22,6 +24,7 @@ class BuyListItem extends StatelessWidget {
final FiatCurrency sourceCurrency; final FiatCurrency sourceCurrency;
final double destAmount; final double destAmount;
final CryptoCurrency destCurrency; final CryptoCurrency destCurrency;
final double achSourceAmount;
final void Function() onTap; final void Function() onTap;
@override @override
@ -47,70 +50,100 @@ class BuyListItem extends StatelessWidget {
return GestureDetector( return GestureDetector(
onTap: () => onTap?.call(), onTap: () => onTap?.call(),
child: Container( child: Container(
height: 102,
padding: EdgeInsets.only( padding: EdgeInsets.only(
left: 20, left: 20,
//top: 33, top: 28,
bottom: 28,
right: 20 right: 20
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(25)), borderRadius: BorderRadius.all(Radius.circular(25)),
color: backgroundColor color: backgroundColor
), ),
child: Stack( child: Column(
children: [ children: [
Positioned( Row(
top: 33, mainAxisAlignment: MainAxisAlignment.spaceBetween,
left: 0, mainAxisSize: MainAxisSize.max,
right: 0, crossAxisAlignment: CrossAxisAlignment.center,
child: Row( children: [
mainAxisAlignment: MainAxisAlignment.spaceBetween, Row(
mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min,
children: [ children: [
Row( if (providerIcon != null)
mainAxisAlignment: MainAxisAlignment.start, Padding(
mainAxisSize: MainAxisSize.min,
children: [
if (providerIcon != null) Padding(
padding: EdgeInsets.only(right: 10), padding: EdgeInsets.only(right: 10),
child: providerIcon child: providerIcon),
), Text(
Text( provider.description.title,
provider.description.title, style: TextStyle(
style: TextStyle( color: secondaryTextColor,
color: secondaryTextColor, fontSize: 20,
fontSize: 20, fontWeight: FontWeight.bold),
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(
Text( '${destAmount?.toString()} ${destCurrency.title}',
'${destAmount?.toString()} ${destCurrency.title}', style: TextStyle(
style: TextStyle( color: secondaryTextColor,
color: secondaryTextColor, fontSize: 20,
fontSize: 20, fontWeight: FontWeight.bold),
fontWeight: FontWeight.bold
), ),
), Row(
], children: [
) Icon(
), CupertinoIcons.creditcard,
Positioned( size: 12,
top: 65, color: primaryTextColor,
right: 0, ),
child: Text( SizedBox(width: 5),
'${sourceAmount?.toString()} ${sourceCurrency.title}', Text(
style: TextStyle( '${sourceAmount?.toString()} ${sourceCurrency.title}',
color: primaryTextColor, style: TextStyle(
fontSize: 16, color: primaryTextColor,
fontWeight: FontWeight.bold fontSize: 16,
fontWeight: FontWeight.bold),
),
],
),
],
), ),
), ],
) ),
], ],
) ),
) )
); );
} }

@ -103,7 +103,7 @@ abstract class BuyViewModelBase with Store {
print(e.toString()); print(e.toString());
} }
if (isMoonPayEnabled) { if (isMoonPayEnabled ?? false) {
_providerList.add(MoonPayBuyProvider(wallet: wallet)); _providerList.add(MoonPayBuyProvider(wallet: wallet));
} }

Loading…
Cancel
Save