fix: default coin units length and banano unit names

This commit is contained in:
julian 2023-06-07 13:17:49 -06:00
parent 00d4ab11c9
commit b6ed690eb6
3 changed files with 94 additions and 92 deletions

View file

@ -46,95 +46,97 @@ class _ChooseUnitSheetState extends ConsumerState<ChooseUnitSheet> {
top: 10, top: 10,
bottom: 0, bottom: 0,
), ),
child: Column( child: SingleChildScrollView(
mainAxisSize: MainAxisSize.min, child: Column(
crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min,
children: [ crossAxisAlignment: CrossAxisAlignment.start,
Center( children: [
child: Container( Center(
decoration: BoxDecoration( child: Container(
color: Theme.of(context) decoration: BoxDecoration(
.extension<StackColors>()! color: Theme.of(context)
.textFieldDefaultBG, .extension<StackColors>()!
borderRadius: BorderRadius.circular( .textFieldDefaultBG,
Constants.size.circularBorderRadius, borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
), ),
width: 60,
height: 4,
), ),
width: 60,
height: 4,
), ),
), const SizedBox(
const SizedBox( height: 36,
height: 36, ),
), Column(
Column( crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start, children: [
children: [ Text(
Text( "Coin units",
"Phrase length", style: STextStyles.pageTitleH2(context),
style: STextStyles.pageTitleH2(context), textAlign: TextAlign.left,
textAlign: TextAlign.left, ),
), const SizedBox(
const SizedBox( height: 16,
height: 16, ),
), for (int i = 0; i < values.length; i++)
for (int i = 0; i < values.length; i++) Column(
Column( children: [
children: [ GestureDetector(
GestureDetector( onTap: () {
onTap: () { setState(() {
setState(() { _current = values[i];
_current = values[i]; });
});
Navigator.of(context).pop(_current); Navigator.of(context).pop(_current);
}, },
child: Container( child: Container(
color: Colors.transparent, color: Colors.transparent,
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: [ children: [
SizedBox( SizedBox(
width: 20, width: 20,
height: 20, height: 20,
child: Radio( child: Radio(
activeColor: Theme.of(context) activeColor: Theme.of(context)
.extension<StackColors>()! .extension<StackColors>()!
.radioButtonIconEnabled, .radioButtonIconEnabled,
value: values[i], value: values[i],
groupValue: _current, groupValue: _current,
onChanged: (x) { onChanged: (x) {
setState(() { setState(() {
_current = values[i]; _current = values[i];
}); });
Navigator.of(context).pop(_current); Navigator.of(context).pop(_current);
}, },
),
), ),
), const SizedBox(
const SizedBox( width: 12,
width: 12, ),
), Text(
Text( values[i].unitForCoin(widget.coin),
values[i].unitForCoin(widget.coin), style: STextStyles.titleBold12(context),
style: STextStyles.titleBold12(context), textAlign: TextAlign.left,
textAlign: TextAlign.left, ),
), ],
], ),
), ),
), ),
), const SizedBox(
const SizedBox( height: 16,
height: 16, ),
), ],
], ),
const SizedBox(
height: 8,
), ),
const SizedBox( ],
height: 8, ),
), ],
], ),
),
],
), ),
), ),
); );

View file

@ -81,7 +81,8 @@ extension AmountUnitExt on AmountUnit {
return "gwei"; return "gwei";
} else if (coin == Coin.wownero || } else if (coin == Coin.wownero ||
coin == Coin.monero || coin == Coin.monero ||
coin == Coin.nano) { coin == Coin.nano ||
coin == Coin.banano) {
return "n${coin.ticker}"; return "n${coin.ticker}";
} else { } else {
return "sats"; return "sats";
@ -91,7 +92,8 @@ extension AmountUnitExt on AmountUnit {
return "mwei"; return "mwei";
} else if (coin == Coin.wownero || } else if (coin == Coin.wownero ||
coin == Coin.monero || coin == Coin.monero ||
coin == Coin.nano) { coin == Coin.nano ||
coin == Coin.banano) {
return "p${coin.ticker}"; return "p${coin.ticker}";
} else { } else {
return "invalid"; return "invalid";
@ -99,7 +101,7 @@ extension AmountUnitExt on AmountUnit {
case AmountUnit.femto: case AmountUnit.femto:
if (coin == Coin.ethereum) { if (coin == Coin.ethereum) {
return "kwei"; return "kwei";
} else if (coin == Coin.nano) { } else if (coin == Coin.nano || coin == Coin.banano) {
return "f${coin.ticker}"; return "f${coin.ticker}";
} else { } else {
return "invalid"; return "invalid";
@ -107,31 +109,31 @@ extension AmountUnitExt on AmountUnit {
case AmountUnit.atto: case AmountUnit.atto:
if (coin == Coin.ethereum) { if (coin == Coin.ethereum) {
return "wei"; return "wei";
} else if (coin == Coin.nano) { } else if (coin == Coin.nano || coin == Coin.banano) {
return "a${coin.ticker}"; return "a${coin.ticker}";
} else { } else {
return "invalid"; return "invalid";
} }
case AmountUnit.zepto: case AmountUnit.zepto:
if (coin == Coin.nano) { if (coin == Coin.nano || coin == Coin.banano) {
return "z${coin.ticker}"; return "z${coin.ticker}";
} else { } else {
return "invalid"; return "invalid";
} }
case AmountUnit.yocto: case AmountUnit.yocto:
if (coin == Coin.nano) { if (coin == Coin.nano || coin == Coin.banano) {
return "y${coin.ticker}"; return "y${coin.ticker}";
} else { } else {
return "invalid"; return "invalid";
} }
case AmountUnit.ronto: case AmountUnit.ronto:
if (coin == Coin.nano) { if (coin == Coin.nano || coin == Coin.banano) {
return "r${coin.ticker}"; return "r${coin.ticker}";
} else { } else {
return "invalid"; return "invalid";
} }
case AmountUnit.quecto: case AmountUnit.quecto:
if (coin == Coin.nano) { if (coin == Coin.nano || coin == Coin.banano) {
return "q${coin.ticker}"; return "q${coin.ticker}";
} else { } else {
return "invalid"; return "invalid";

View file

@ -8,8 +8,6 @@
* *
*/ */
import 'dart:math';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/utilities/amount/amount_unit.dart'; import 'package:stackwallet/utilities/amount/amount_unit.dart';
@ -866,8 +864,8 @@ class Prefs extends ChangeNotifier {
boxName: DB.boxNamePrefs, boxName: DB.boxNamePrefs,
key: "maxDecimalsFor${coin.name}", key: "maxDecimalsFor${coin.name}",
) as int? ?? ) as int? ??
max(coin.decimals, (coin.decimals > 18 ? 18 : coin.decimals);
18); // use some sane max rather than up to 30 that nano uses // use some sane max rather than up to 30 that nano uses
_amountDecimals[coin] = decimals; _amountDecimals[coin] = decimals;
} }
} }