mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
CAKE-345 | merged CAKE-349 branch into current
This commit is contained in:
parent
3967cc8d40
commit
a5831a25e7
4 changed files with 15 additions and 25 deletions
|
@ -16,24 +16,12 @@ double bitcoinAmountToDouble({int amount}) =>
|
||||||
cryptoAmountToDouble(amount: amount, divider: bitcoinAmountDivider);
|
cryptoAmountToDouble(amount: amount, divider: bitcoinAmountDivider);
|
||||||
|
|
||||||
int stringDoubleToBitcoinAmount(String amount) {
|
int stringDoubleToBitcoinAmount(String amount) {
|
||||||
final splitted = amount.split('');
|
|
||||||
final dotIndex = amount.indexOf('.');
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
|
try {
|
||||||
for (var i = 0; i < splitted.length; i++) {
|
result = (double.parse(amount) * bitcoinAmountDivider).toInt();
|
||||||
try {
|
} catch (e) {
|
||||||
if (dotIndex == i) {
|
result = 0;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final char = splitted[i];
|
|
||||||
final multiplier = dotIndex < i
|
|
||||||
? bitcoinAmountDivider ~/ pow(10, (i - dotIndex))
|
|
||||||
: (bitcoinAmountDivider * pow(10, (dotIndex - i -1))).toInt();
|
|
||||||
final num = int.parse(char) * multiplier;
|
|
||||||
result += num;
|
|
||||||
} catch (_) {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -165,11 +165,9 @@ class ExchangeCardState extends State<ExchangeCard> {
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
keyboardType: TextInputType.numberWithOptions(
|
keyboardType: TextInputType.numberWithOptions(
|
||||||
signed: false, decimal: true),
|
signed: false, decimal: true),
|
||||||
// inputFormatters: [
|
inputFormatters: [
|
||||||
// LengthLimitingTextInputFormatter(15),
|
FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))
|
||||||
// BlacklistingTextInputFormatter(
|
],
|
||||||
// RegExp('[\\-|\\ |\\,]'))
|
|
||||||
// ],
|
|
||||||
hintText: '0.0000',
|
hintText: '0.0000',
|
||||||
borderColor: widget.borderColor,
|
borderColor: widget.borderColor,
|
||||||
textStyle: TextStyle(
|
textStyle: TextStyle(
|
||||||
|
|
|
@ -156,8 +156,7 @@ class SendTemplatePage extends BasePage {
|
||||||
keyboardType: TextInputType.numberWithOptions(
|
keyboardType: TextInputType.numberWithOptions(
|
||||||
signed: false, decimal: true),
|
signed: false, decimal: true),
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
BlacklistingTextInputFormatter(
|
FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))
|
||||||
RegExp('[\\-|\\ ]'))
|
|
||||||
],
|
],
|
||||||
prefixIcon: Padding(
|
prefixIcon: Padding(
|
||||||
padding: EdgeInsets.only(top: 9),
|
padding: EdgeInsets.only(top: 9),
|
||||||
|
@ -196,8 +195,7 @@ class SendTemplatePage extends BasePage {
|
||||||
keyboardType: TextInputType.numberWithOptions(
|
keyboardType: TextInputType.numberWithOptions(
|
||||||
signed: false, decimal: true),
|
signed: false, decimal: true),
|
||||||
inputFormatters: [
|
inputFormatters: [
|
||||||
BlacklistingTextInputFormatter(
|
FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))
|
||||||
RegExp('[\\-|\\ ]'))
|
|
||||||
],
|
],
|
||||||
prefixIcon: Padding(
|
prefixIcon: Padding(
|
||||||
padding: EdgeInsets.only(top: 9),
|
padding: EdgeInsets.only(top: 9),
|
||||||
|
|
|
@ -164,6 +164,9 @@ class SendCardState extends State<SendCard>
|
||||||
keyboardType:
|
keyboardType:
|
||||||
TextInputType.numberWithOptions(
|
TextInputType.numberWithOptions(
|
||||||
signed: false, decimal: true),
|
signed: false, decimal: true),
|
||||||
|
inputFormatters: [
|
||||||
|
FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))
|
||||||
|
],
|
||||||
prefixIcon: Padding(
|
prefixIcon: Padding(
|
||||||
padding: EdgeInsets.only(top: 9),
|
padding: EdgeInsets.only(top: 9),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
@ -273,6 +276,9 @@ class SendCardState extends State<SendCard>
|
||||||
keyboardType:
|
keyboardType:
|
||||||
TextInputType.numberWithOptions(
|
TextInputType.numberWithOptions(
|
||||||
signed: false, decimal: true),
|
signed: false, decimal: true),
|
||||||
|
inputFormatters: [
|
||||||
|
FilteringTextInputFormatter.deny(RegExp('[\\-|\\ ]'))
|
||||||
|
],
|
||||||
prefixIcon: Padding(
|
prefixIcon: Padding(
|
||||||
padding: EdgeInsets.only(top: 9),
|
padding: EdgeInsets.only(top: 9),
|
||||||
child:
|
child:
|
||||||
|
|
Loading…
Reference in a new issue