fix bad balance displayed

This commit is contained in:
poka 2022-09-11 14:04:52 +02:00
parent 0233816f68
commit 57cdc23436
11 changed files with 31 additions and 14 deletions

View File

@ -192,5 +192,6 @@
"confirmMyIdentity": "Confirm my identity",
"revokeMyIdentity": "Revoke my identity",
"youCannotRevokeThisIdentity": "You cannot revoke this identity while\nit is member of the blacksmiths web",
"showUdAmounts": "Show amounts in UD"
"showUdAmounts": "Show amounts in UD",
"ud": "{}UD"
}

View File

@ -192,5 +192,6 @@
"confirmMyIdentity": "Confirm my identity",
"revokeMyIdentity": "Revoke my identity",
"youCannotRevokeThisIdentity": "You cannot revoke this identity while\nit is member of the blacksmiths web",
"showUdAmounts": "Show amounts in UD"
"showUdAmounts": "Show amounts in UD",
"ud": "{}UD"
}

View File

@ -193,5 +193,6 @@
"confirmMyIdentity": "Confirmer mon identité",
"revokeMyIdentity": "Révoquer mon identité",
"youCannotRevokeThisIdentity": "Vous ne pouvez pas révoquer cette identité tant\nqu'elle fait partie de la toile forgerons",
"showUdAmounts": "Afficher les montants en DU"
"showUdAmounts": "Afficher les montants en DU",
"ud": "{}DU"
}

View File

@ -27,7 +27,7 @@ void main() async {
await enterText(keyCesiumId, 'test');
await enterText(keyCesiumPassword, 'test');
await waitFor(cesiumTest1.shortAddress());
await waitFor('100.0', exactMatch: true);
await waitFor('100.0');
await waitFor('3', exactMatch: true);
isObscureText();

View File

@ -194,7 +194,7 @@ class SubstrateSdk with ChangeNotifier {
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
final udValue = await getUdValue();
final double balanceRatio = isUdUnit ? round(udValue / 100, 4) : 1;
final double balanceRatio = isUdUnit ? round(udValue / 100, 6) : 1;
// log.d('udValue: $udValue');

View File

@ -616,7 +616,7 @@ Widget udUnitDisplay(double size, [Color color = Colors.black]) {
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
'DU',
'ud'.tr(args: ['']),
style:
TextStyle(fontSize: isTall ? size : size * 0.9, color: color),
),

View File

@ -282,7 +282,7 @@ class ActivityScreen extends StatelessWidget with ChangeNotifier {
if (isUdUnit) {
amount = round(amount / (sub.udValue / 100));
finalAmount = "$amount DU";
finalAmount = 'ud'.tr(args: ['$amount ']);
} else {
finalAmount = '$amount $currencyName';
}

View File

@ -106,6 +106,9 @@ class ImportG1v1 extends StatelessWidget {
validationStatus = '';
}
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
final unit = isUdUnit ? 'ud'.tr(args: ['']) : currencyName;
return Column(children: <Widget>[
const SizedBox(height: 20),
TextFormField(
@ -195,7 +198,7 @@ class ImportG1v1 extends StatelessWidget {
),
const SizedBox(height: 20),
Text(
'${balance['transferableBalance']} $currencyName',
'${balance['transferableBalance']} $unit',
style: const TextStyle(fontSize: 17),
),
Row(

View File

@ -129,6 +129,9 @@ class MigrateIdentityScreen extends StatelessWidget {
.removeWhere((element) => element.address == fromAddress);
// walletsList.add(WalletData(address: 'custom', name: 'custom'));
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
final unit = isUdUnit ? 'ud'.tr(args: ['']) : currencyName;
return Column(children: <Widget>[
Row(children: const []),
const SizedBox(height: 20),
@ -139,7 +142,7 @@ class MigrateIdentityScreen extends StatelessWidget {
data: 'areYouSureMigrateIdentity'.tr(args: [
duniterIndexer.walletNameIndexer[fromAddress] ??
'???',
'${balance['transferableBalance']} $currencyName'
'${balance['transferableBalance']} $unit'
]),
styleSheet: mdStyle),
),

View File

@ -197,7 +197,9 @@ class TransactionInProgress extends StatelessWidget {
const SizedBox(height: 10),
if (transType == 'pay')
Text(
isUdUnit ? '$amount DU' : '$amount $currencyName',
isUdUnit
? 'ud'.tr(args: ['$amount '])
: '$amount $currencyName',
textAlign: TextAlign.center,
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.w600),

View File

@ -405,7 +405,7 @@ class WalletViewScreen extends StatelessWidget {
final myWalletProvider =
Provider.of<MyWalletsProvider>(context, listen: false);
// final _sub = Provider.of<SubstrateSdk>(context, listen: false);
final sub = Provider.of<SubstrateSdk>(context, listen: false);
const double shapeSize = 20;
WalletData? defaultWallet = myWalletProvider.getDefaultWallet();
@ -413,6 +413,10 @@ class WalletViewScreen extends StatelessWidget {
bool canValidate = false;
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
final udValue = sub.udValue;
final double balanceRatio = isUdUnit ? round(udValue / 100, 6) : 1;
showModalBottomSheet<void>(
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
@ -426,11 +430,13 @@ class WalletViewScreen extends StatelessWidget {
return StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
if (walletViewProvider.payAmount.text != '' &&
(double.parse(walletViewProvider.payAmount.text) + 2) <=
(double.parse(walletViewProvider.payAmount.text) +
2 / balanceRatio) <=
(balanceCache[defaultWallet.address] ?? 0) &&
walletViewProvider.address != defaultWallet.address) {
if ((balanceCache[pubkey] == 0 || balanceCache[pubkey] == null) &&
double.parse(walletViewProvider.payAmount.text) < 5) {
double.parse(walletViewProvider.payAmount.text) <
5 / balanceRatio) {
canValidate = false;
} else {
canValidate = true;
@ -562,7 +568,7 @@ class WalletViewScreen extends StatelessWidget {
decoration: InputDecoration(
hintText: '0.00',
suffix: Text(isUdUnit
? 'DU'
? 'ud'.tr(args: [''])
: currencyName), // udUnitDisplay(40),
filled: true,
fillColor: Colors.transparent,