mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
fix: default coin units length and banano unit names
This commit is contained in:
parent
00d4ab11c9
commit
b6ed690eb6
3 changed files with 94 additions and 92 deletions
|
@ -46,95 +46,97 @@ class _ChooseUnitSheetState extends ConsumerState<ChooseUnitSheet> {
|
|||
top: 10,
|
||||
bottom: 0,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textFieldDefaultBG,
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.textFieldDefaultBG,
|
||||
borderRadius: BorderRadius.circular(
|
||||
Constants.size.circularBorderRadius,
|
||||
),
|
||||
),
|
||||
width: 60,
|
||||
height: 4,
|
||||
),
|
||||
width: 60,
|
||||
height: 4,
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 36,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Phrase length",
|
||||
style: STextStyles.pageTitleH2(context),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
for (int i = 0; i < values.length; i++)
|
||||
Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_current = values[i];
|
||||
});
|
||||
const SizedBox(
|
||||
height: 36,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"Coin units",
|
||||
style: STextStyles.pageTitleH2(context),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
for (int i = 0; i < values.length; i++)
|
||||
Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_current = values[i];
|
||||
});
|
||||
|
||||
Navigator.of(context).pop(_current);
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: Radio(
|
||||
activeColor: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.radioButtonIconEnabled,
|
||||
value: values[i],
|
||||
groupValue: _current,
|
||||
onChanged: (x) {
|
||||
setState(() {
|
||||
_current = values[i];
|
||||
});
|
||||
Navigator.of(context).pop(_current);
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: Radio(
|
||||
activeColor: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.radioButtonIconEnabled,
|
||||
value: values[i],
|
||||
groupValue: _current,
|
||||
onChanged: (x) {
|
||||
setState(() {
|
||||
_current = values[i];
|
||||
});
|
||||
|
||||
Navigator.of(context).pop(_current);
|
||||
},
|
||||
Navigator.of(context).pop(_current);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
Text(
|
||||
values[i].unitForCoin(widget.coin),
|
||||
style: STextStyles.titleBold12(context),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
],
|
||||
const SizedBox(
|
||||
width: 12,
|
||||
),
|
||||
Text(
|
||||
values[i].unitForCoin(widget.coin),
|
||||
style: STextStyles.titleBold12(context),
|
||||
textAlign: TextAlign.left,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
],
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -81,7 +81,8 @@ extension AmountUnitExt on AmountUnit {
|
|||
return "gwei";
|
||||
} else if (coin == Coin.wownero ||
|
||||
coin == Coin.monero ||
|
||||
coin == Coin.nano) {
|
||||
coin == Coin.nano ||
|
||||
coin == Coin.banano) {
|
||||
return "n${coin.ticker}";
|
||||
} else {
|
||||
return "sats";
|
||||
|
@ -91,7 +92,8 @@ extension AmountUnitExt on AmountUnit {
|
|||
return "mwei";
|
||||
} else if (coin == Coin.wownero ||
|
||||
coin == Coin.monero ||
|
||||
coin == Coin.nano) {
|
||||
coin == Coin.nano ||
|
||||
coin == Coin.banano) {
|
||||
return "p${coin.ticker}";
|
||||
} else {
|
||||
return "invalid";
|
||||
|
@ -99,7 +101,7 @@ extension AmountUnitExt on AmountUnit {
|
|||
case AmountUnit.femto:
|
||||
if (coin == Coin.ethereum) {
|
||||
return "kwei";
|
||||
} else if (coin == Coin.nano) {
|
||||
} else if (coin == Coin.nano || coin == Coin.banano) {
|
||||
return "f${coin.ticker}";
|
||||
} else {
|
||||
return "invalid";
|
||||
|
@ -107,31 +109,31 @@ extension AmountUnitExt on AmountUnit {
|
|||
case AmountUnit.atto:
|
||||
if (coin == Coin.ethereum) {
|
||||
return "wei";
|
||||
} else if (coin == Coin.nano) {
|
||||
} else if (coin == Coin.nano || coin == Coin.banano) {
|
||||
return "a${coin.ticker}";
|
||||
} else {
|
||||
return "invalid";
|
||||
}
|
||||
case AmountUnit.zepto:
|
||||
if (coin == Coin.nano) {
|
||||
if (coin == Coin.nano || coin == Coin.banano) {
|
||||
return "z${coin.ticker}";
|
||||
} else {
|
||||
return "invalid";
|
||||
}
|
||||
case AmountUnit.yocto:
|
||||
if (coin == Coin.nano) {
|
||||
if (coin == Coin.nano || coin == Coin.banano) {
|
||||
return "y${coin.ticker}";
|
||||
} else {
|
||||
return "invalid";
|
||||
}
|
||||
case AmountUnit.ronto:
|
||||
if (coin == Coin.nano) {
|
||||
if (coin == Coin.nano || coin == Coin.banano) {
|
||||
return "r${coin.ticker}";
|
||||
} else {
|
||||
return "invalid";
|
||||
}
|
||||
case AmountUnit.quecto:
|
||||
if (coin == Coin.nano) {
|
||||
if (coin == Coin.nano || coin == Coin.banano) {
|
||||
return "q${coin.ticker}";
|
||||
} else {
|
||||
return "invalid";
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:stackwallet/db/hive/db.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount_unit.dart';
|
||||
|
@ -866,8 +864,8 @@ class Prefs extends ChangeNotifier {
|
|||
boxName: DB.boxNamePrefs,
|
||||
key: "maxDecimalsFor${coin.name}",
|
||||
) as int? ??
|
||||
max(coin.decimals,
|
||||
18); // use some sane max rather than up to 30 that nano uses
|
||||
(coin.decimals > 18 ? 18 : coin.decimals);
|
||||
// use some sane max rather than up to 30 that nano uses
|
||||
_amountDecimals[coin] = decimals;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue