CAKE-345 | merged CAKE-349 branch into current

OleksandrSobol committed Aug 16, 2021 at 11:30 UTC a5831a25e76dbafcaccebf22c99daee40746fd68
4 files changed +15 -25
lib/bitcoin/bitcoin_amount_format.dart
+4 -16
@@ -16,24 +16,12 @@ double bitcoinAmountToDouble({int amount}) =>
16 cryptoAmountToDouble(amount: amount, divider: bitcoinAmountDivider);
17
18 int stringDoubleToBitcoinAmount(String amount) {
19 - final splitted = amount.split('');
20 - final dotIndex = amount.indexOf('.');
19 int result = 0;
20
23 -
24 - for (var i = 0; i < splitted.length; i++) {
25 - try {
26 - if (dotIndex == i) {
27 - continue;
28 - }
29 -
30 - final char = splitted[i];
31 - final multiplier = dotIndex < i
32 - ? bitcoinAmountDivider ~/ pow(10, (i - dotIndex))
33 - : (bitcoinAmountDivider * pow(10, (dotIndex - i -1))).toInt();
34 - final num = int.parse(char) * multiplier;
35 - result += num;
36 - } catch (_) {}
21 + try {
22 + result = (double.parse(amount) * bitcoinAmountDivider).toInt();
23 + } catch (e) {
24 + result = 0;
25 }
26
27 return result;
lib/src/screens/exchange/widgets/exchange_card.dart
+3 -5
@@ -165,11 +165,9 @@ class ExchangeCardState extends State<ExchangeCard> {
165 textAlign: TextAlign.left,
166 keyboardType: TextInputType.numberWithOptions(
167 signed: false, decimal: true),
168 - // inputFormatters: [
169 - // LengthLimitingTextInputFormatter(15),
170 - // BlacklistingTextInputFormatter(
171 - // RegExp('[\\-|\\ |\\,]'))
172 - // ],
168 + inputFormatters: [
169 + FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))
170 + ],
171 hintText: '0.0000',
172 borderColor: widget.borderColor,
173 textStyle: TextStyle(
lib/src/screens/send/send_template_page.dart
+2 -4
@@ -156,8 +156,7 @@ class SendTemplatePage extends BasePage {
156 keyboardType: TextInputType.numberWithOptions(
157 signed: false, decimal: true),
158 inputFormatters: [
159 - BlacklistingTextInputFormatter(
160 - RegExp('[\\-|\\ ]'))
159 + FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))
160 ],
161 prefixIcon: Padding(
162 padding: EdgeInsets.only(top: 9),
@@ -196,8 +195,7 @@ class SendTemplatePage extends BasePage {
195 keyboardType: TextInputType.numberWithOptions(
196 signed: false, decimal: true),
197 inputFormatters: [
199 - BlacklistingTextInputFormatter(
200 - RegExp('[\\-|\\ ]'))
198 + FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))
199 ],
200 prefixIcon: Padding(
201 padding: EdgeInsets.only(top: 9),
lib/src/screens/send/widgets/send_card.dart
+6
@@ -164,6 +164,9 @@ class SendCardState extends State<SendCard>
164 keyboardType:
165 TextInputType.numberWithOptions(
166 signed: false, decimal: true),
167 + inputFormatters: [
168 + FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))
169 + ],
170 prefixIcon: Padding(
171 padding: EdgeInsets.only(top: 9),
172 child: Text(
@@ -273,6 +276,9 @@ class SendCardState extends State<SendCard>
276 keyboardType:
277 TextInputType.numberWithOptions(
278 signed: false, decimal: true),
279 + inputFormatters: [
280 + FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))
281 + ],
282 prefixIcon: Padding(
283 padding: EdgeInsets.only(top: 9),
284 child: