Add ach payment amount on buy page (#282)
Godwin Asuquo committed
Mar 7, 2022 at 11:13 UTC
d14150f4b109af0592d43a79b55740f21e9c1f63
5 files changed
+90
-51
lib/buy/buy_amount.dart
+2
@@ -4,9 +4,11 @@ class BuyAmount {
4
BuyAmount({
5
@required this.sourceAmount,
6
@required this.destAmount,
7
+ this.achSourceAmount,
8
this.minAmount = 0});
9
10
final double sourceAmount;
11
final double destAmount;
12
+ final double achSourceAmount;
13
final int minAmount;
14
}
\ No newline at end of file
lib/buy/wyre/wyre_buy_provider.dart
+2
-1
@@ -107,8 +107,9 @@ class WyreBuyProvider extends BuyProvider {
107
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
108
final sourceAmount = responseJSON['sourceAmount'] as double;
109
final destAmount = responseJSON['destAmount'] as double;
110
+ final achAmount = responseJSON['sourceAmountWithoutFees'] as double;
111
111
- return BuyAmount(sourceAmount: sourceAmount, destAmount: destAmount);
112
+ return BuyAmount(sourceAmount: sourceAmount, destAmount: destAmount, achSourceAmount: achAmount);
113
}
114
115
@override
lib/src/screens/buy/pre_order_page.dart
+3
@@ -177,12 +177,14 @@ class PreOrderPage extends BasePage {
177
builder: (context, AsyncSnapshot<BuyAmount> snapshot) {
178
double sourceAmount;
179
double destAmount;
180
+ double achAmount;
181
int minAmount;
182
183
if (snapshot.hasData) {
184
sourceAmount = snapshot.data.sourceAmount;
185
destAmount = snapshot.data.destAmount;
186
minAmount = snapshot.data.minAmount;
187
+ achAmount = snapshot.data.achSourceAmount;
188
} else {
189
sourceAmount = 0.0;
190
destAmount = 0.0;
@@ -201,6 +203,7 @@ class PreOrderPage extends BasePage {
203
sourceCurrency: buyViewModel.fiatCurrency,
204
destAmount: destAmount,
205
destCurrency: buyViewModel.cryptoCurrency,
206
+ achSourceAmount: achAmount,
207
onTap: ((buyViewModel.doubleAmount != 0.0)
208
&& (snapshot.hasData)) ? () =>
209
onSelectBuyProvider(
lib/src/screens/buy/widgets/buy_list_item.dart
+82
-49
@@ -3,6 +3,7 @@ import 'package:cake_wallet/buy/get_buy_provider_icon.dart';
3
import 'package:cw_core/crypto_currency.dart';
4
import 'package:cake_wallet/entities/fiat_currency.dart';
5
import 'package:cake_wallet/palette.dart';
6
+import 'package:flutter/cupertino.dart';
7
import 'package:flutter/material.dart';
8
9
class BuyListItem extends StatelessWidget {
@@ -13,6 +14,7 @@ class BuyListItem extends StatelessWidget {
14
@required this.sourceCurrency,
15
@required this.destAmount,
16
@required this.destCurrency,
17
+ @required this.achSourceAmount,
18
@required this.onTap
19
});
20
@@ -22,6 +24,7 @@ class BuyListItem extends StatelessWidget {
24
final FiatCurrency sourceCurrency;
25
final double destAmount;
26
final CryptoCurrency destCurrency;
27
+ final double achSourceAmount;
28
final void Function() onTap;
29
30
@override
@@ -47,70 +50,100 @@ class BuyListItem extends StatelessWidget {
50
return GestureDetector(
51
onTap: () => onTap?.call(),
52
child: Container(
50
- height: 102,
53
padding: EdgeInsets.only(
54
left: 20,
53
- //top: 33,
55
+ top: 28,
56
+ bottom: 28,
57
right: 20
58
),
59
decoration: BoxDecoration(
60
borderRadius: BorderRadius.all(Radius.circular(25)),
61
color: backgroundColor
62
),
60
- child: Stack(
63
+ child: Column(
64
children: [
62
- Positioned(
63
- top: 33,
64
- left: 0,
65
- right: 0,
66
- child: Row(
67
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
68
- mainAxisSize: MainAxisSize.max,
69
- crossAxisAlignment: CrossAxisAlignment.center,
70
- children: [
71
- Row(
72
- mainAxisAlignment: MainAxisAlignment.start,
73
- mainAxisSize: MainAxisSize.min,
74
- children: [
75
- if (providerIcon != null) Padding(
65
+ Row(
66
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
67
+ mainAxisSize: MainAxisSize.max,
68
+ crossAxisAlignment: CrossAxisAlignment.center,
69
+ children: [
70
+ Row(
71
+ mainAxisAlignment: MainAxisAlignment.start,
72
+ mainAxisSize: MainAxisSize.min,
73
+ children: [
74
+ if (providerIcon != null)
75
+ Padding(
76
padding: EdgeInsets.only(right: 10),
77
- child: providerIcon
78
- ),
79
- Text(
80
- provider.description.title,
81
- style: TextStyle(
82
- color: secondaryTextColor,
83
- fontSize: 20,
84
- fontWeight: FontWeight.bold
77
+ child: providerIcon),
78
+ Text(
79
+ provider.description.title,
80
+ style: TextStyle(
81
+ color: secondaryTextColor,
82
+ fontSize: 20,
83
+ fontWeight: FontWeight.bold),
84
+ )
85
+ ],
86
+ ),
87
+ Column(
88
+ crossAxisAlignment: CrossAxisAlignment.end,
89
+ children: [
90
+ if(achSourceAmount != null)...[
91
+ Text(
92
+ '${destAmount?.toString()} ${destCurrency.title}',
93
+ style: TextStyle(
94
+ color: secondaryTextColor,
95
+ fontSize: 20,
96
+ fontWeight: FontWeight.bold),
97
+ ),
98
+ Row(
99
+ children: [
100
+ Icon(
101
+ Icons.account_balance_outlined,
102
+ size: 12,
103
+ color: primaryTextColor,
104
+ ),
105
+ SizedBox(width: 5),
106
+ Text(
107
+ '${achSourceAmount?.toString()} ${sourceCurrency.title}',
108
+ style: TextStyle(
109
+ color: primaryTextColor,
110
+ fontSize: 16,
111
+ fontWeight: FontWeight.bold),
112
),
86
- )
113
+ ],
114
+ ),
115
+ SizedBox(height: 10),
116
],
88
- ),
89
- Text(
90
- '${destAmount?.toString()} ${destCurrency.title}',
91
- style: TextStyle(
92
- color: secondaryTextColor,
93
- fontSize: 20,
94
- fontWeight: FontWeight.bold
117
+ Text(
118
+ '${destAmount?.toString()} ${destCurrency.title}',
119
+ style: TextStyle(
120
+ color: secondaryTextColor,
121
+ fontSize: 20,
122
+ fontWeight: FontWeight.bold),
123
),
96
- ),
97
- ],
98
- )
99
- ),
100
- Positioned(
101
- top: 65,
102
- right: 0,
103
- child: Text(
104
- '${sourceAmount?.toString()} ${sourceCurrency.title}',
105
- style: TextStyle(
106
- color: primaryTextColor,
107
- fontSize: 16,
108
- fontWeight: FontWeight.bold
124
+ Row(
125
+ children: [
126
+ Icon(
127
+ CupertinoIcons.creditcard,
128
+ size: 12,
129
+ color: primaryTextColor,
130
+ ),
131
+ SizedBox(width: 5),
132
+ Text(
133
+ '${sourceAmount?.toString()} ${sourceCurrency.title}',
134
+ style: TextStyle(
135
+ color: primaryTextColor,
136
+ fontSize: 16,
137
+ fontWeight: FontWeight.bold),
138
+ ),
139
+ ],
140
+ ),
141
+ ],
142
),
110
- ),
111
- )
143
+ ],
144
+ ),
145
],
113
- )
146
+ ),
147
)
148
);
149
}
lib/view_model/buy/buy_view_model.dart
+1
-1
@@ -103,7 +103,7 @@ abstract class BuyViewModelBase with Store {
103
print(e.toString());
104
}
105
106
- if (isMoonPayEnabled) {
106
+ if (isMoonPayEnabled ?? false) {
107
_providerList.add(MoonPayBuyProvider(wallet: wallet));
108
}
109