implement UD unit view
This commit is contained in:
parent
776a0f8c75
commit
0233816f68
|
@ -191,5 +191,6 @@
|
|||
"someoneCreatedYourIdentity": "Someone created your {} identity !",
|
||||
"confirmMyIdentity": "Confirm my identity",
|
||||
"revokeMyIdentity": "Revoke my identity",
|
||||
"youCannotRevokeThisIdentity": "You cannot revoke this identity while\nit is member of the blacksmiths web"
|
||||
"youCannotRevokeThisIdentity": "You cannot revoke this identity while\nit is member of the blacksmiths web",
|
||||
"showUdAmounts": "Show amounts in UD"
|
||||
}
|
|
@ -191,5 +191,6 @@
|
|||
"someoneCreatedYourIdentity": "Someone created your {} identity !",
|
||||
"confirmMyIdentity": "Confirm my identity",
|
||||
"revokeMyIdentity": "Revoke my identity",
|
||||
"youCannotRevokeThisIdentity": "You cannot revoke this identity while\nit is member of the blacksmiths web"
|
||||
"youCannotRevokeThisIdentity": "You cannot revoke this identity while\nit is member of the blacksmiths web",
|
||||
"showUdAmounts": "Show amounts in UD"
|
||||
}
|
|
@ -192,5 +192,6 @@
|
|||
"someoneCreatedYourIdentity": "Quelqu'un a créé votre identité {} !",
|
||||
"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"
|
||||
"youCannotRevokeThisIdentity": "Vous ne pouvez pas révoquer cette identité tant\nqu'elle fait partie de la toile forgerons",
|
||||
"showUdAmounts": "Afficher les montants en DU"
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/models/widgets_keys.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
import '../utility/general_actions.dart';
|
||||
|
@ -33,9 +32,9 @@ void main() async {
|
|||
// Background pay 25
|
||||
await bkPay(
|
||||
fromAddress: test1.address, destAddress: test5.address, amount: 25);
|
||||
await waitFor('25.0 $currencyName');
|
||||
await waitFor('25.0', exactMatch: true);
|
||||
await spawnBlock();
|
||||
await waitFor('22.0 $currencyName');
|
||||
await waitFor('22.0', exactMatch: true);
|
||||
await bkCertify(
|
||||
fromAddress: test1.address,
|
||||
destAddress: test5.address,
|
||||
|
@ -53,10 +52,10 @@ void main() async {
|
|||
await waitFor('4', exactMatch: true);
|
||||
// await bkPay(
|
||||
// fromAddress: test2.address, destAddress: test5.address, amount: 40);
|
||||
await waitFor('21.99 $currencyName');
|
||||
await waitFor('21.99', exactMatch: true);
|
||||
await spawnBlock(until: 30);
|
||||
await waitFor('121.99 $currencyName');
|
||||
await waitFor('121.99', exactMatch: true);
|
||||
await spawnBlock(until: 40);
|
||||
await waitFor('221.99 $currencyName');
|
||||
await waitFor('221.99', exactMatch: true);
|
||||
}, timeout: testTimeout());
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ Future payTest2() async {
|
|||
await waitFor(endAddress);
|
||||
await tapKey(keySearchResult(addressToSearch));
|
||||
await waitFor(endAddress);
|
||||
await waitFor('0.0 ĞD');
|
||||
await waitFor('0.0', exactMatch: true);
|
||||
await tapKey(keyPay);
|
||||
await enterText(keyAmountField, '12.14');
|
||||
await tapKey(keyConfirmPayment);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/models/widgets_keys.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
import '../utility/general_actions.dart';
|
||||
|
@ -28,7 +27,7 @@ void main() async {
|
|||
await enterText(keyCesiumId, 'test');
|
||||
await enterText(keyCesiumPassword, 'test');
|
||||
await waitFor(cesiumTest1.shortAddress());
|
||||
await waitFor('100.0 $currencyName');
|
||||
await waitFor('100.0', exactMatch: true);
|
||||
await waitFor('3', exactMatch: true);
|
||||
|
||||
isObscureText();
|
||||
|
@ -51,7 +50,7 @@ void main() async {
|
|||
await waitFor('3', exactMatch: true);
|
||||
await waitFor('Membre validé !');
|
||||
|
||||
await waitFor('99.98 $currencyName');
|
||||
await waitFor('99.98', exactMatch: true);
|
||||
}, timeout: testTimeout());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:gecko/globals.dart';
|
||||
import 'package:gecko/models/widgets_keys.dart';
|
||||
import 'package:integration_test/integration_test.dart';
|
||||
import '../utility/general_actions.dart';
|
||||
|
@ -20,10 +19,10 @@ void main() async {
|
|||
|
||||
// Go to test1 options and check if balance growup with UDs creations
|
||||
await tapKey(keyOpenWallet(test1.address));
|
||||
await waitFor('100.0 $currencyName');
|
||||
await waitFor('100.0', exactMatch: true);
|
||||
await spawnBlock(until: 10);
|
||||
await waitFor('200.0 $currencyName');
|
||||
await waitFor('200.0', exactMatch: true);
|
||||
await spawnBlock(until: 20);
|
||||
await waitFor('300.0 $currencyName');
|
||||
await waitFor('300.0', exactMatch: true);
|
||||
}, timeout: testTimeout());
|
||||
}
|
||||
|
|
|
@ -28,6 +28,12 @@ Future deleteAllWallets() async {
|
|||
if (await isPresent('Rechercher')) {
|
||||
await tapKey(keyDrawerMenu);
|
||||
await tapKey(keyParameters);
|
||||
|
||||
// Check if ud unit checkbox is checked
|
||||
final isUdUnit = await isIconPresent(Icons.check_box);
|
||||
// If yes, tap on to use currency value
|
||||
if (isUdUnit) await tapKey(keyUdUnit, duration: 0);
|
||||
|
||||
await tapKey(keyDeleteAllWallets);
|
||||
await tapKey(keyConfirm);
|
||||
await tester.pumpAndSettle();
|
||||
|
@ -142,9 +148,9 @@ Future onboardingNewChest() async {
|
|||
// Go to wallets home
|
||||
await tapKey(keyGoWalletsHome, duration: 0);
|
||||
|
||||
// Check if string "ĞD" is present in screen
|
||||
// Check if string "Mon portefeuille co" is present in screen
|
||||
await waitFor('Mon portefeuille co');
|
||||
await waitFor('0.0 $currencyName');
|
||||
await waitFor('0.0', exactMatch: true);
|
||||
// await waitFor('Scanner un');
|
||||
}
|
||||
|
||||
|
@ -159,5 +165,5 @@ Future firstOpenChest() async {
|
|||
final isCached = await isIconPresent(Icons.check_box);
|
||||
if (!isCached) await tapKey(keyCachePassword, duration: 0);
|
||||
await enterText(keyPinForm, 'AAAAA', 0);
|
||||
await waitFor('100.0 $currencyName');
|
||||
await waitFor('100.0', exactMatch: true);
|
||||
}
|
||||
|
|
|
@ -280,6 +280,7 @@ Future bkDeleteAllWallets() async {
|
|||
await walletBox.clear();
|
||||
await chestBox.clear();
|
||||
await configBox.delete('defaultWallet');
|
||||
await configBox.delete('isUdUnit');
|
||||
await sub.deleteAllAccounts();
|
||||
myWalletProvider.pinCode = '';
|
||||
myWalletProvider.reload();
|
||||
|
|
|
@ -70,6 +70,7 @@ const keyDeleteAllWallets = Key('keyDeleteAllWallets');
|
|||
const keySelectDuniterNodeDropDown = Key('keySelectDuniterNodeDropDown');
|
||||
const keyCustomDuniterEndpoint = Key('keyCustomDuniterEndpoint');
|
||||
const keyConnectToEndpoint = Key('keyConnectToEndpoint');
|
||||
const keyUdUnit = Key('keyUdUnit');
|
||||
|
||||
// Onboarding
|
||||
const keyPastMnemonic = Key('keyPastMnemonic');
|
||||
|
|
|
@ -313,9 +313,18 @@ class DuniterIndexer with ChangeNotifier {
|
|||
fontWeight: FontWeight.w500),
|
||||
textAlign: TextAlign.center),
|
||||
]),
|
||||
trailing: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [balance(context, profile['id'], 16)]),
|
||||
trailing: SizedBox(
|
||||
width: 110,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
balance(context, profile['id'], 16),
|
||||
]),
|
||||
]),
|
||||
),
|
||||
subtitle: Row(children: <Widget>[
|
||||
Text(profile['name'] ?? '',
|
||||
style: const TextStyle(
|
||||
|
@ -360,16 +369,16 @@ class DuniterIndexer with ChangeNotifier {
|
|||
transBC[i] = [];
|
||||
transBC[i].add(DateTime.parse(transaction['created_at']));
|
||||
final int amountBrut = transaction['amount'];
|
||||
final num amount = removeDecimalZero(amountBrut / 100);
|
||||
final double amount = removeDecimalZero(amountBrut / 100);
|
||||
if (direction == "RECEIVED") {
|
||||
transBC[i].add(transaction['issuer_id']);
|
||||
transBC[i].add(transaction['issuer']['identity']?['name'] ?? '');
|
||||
transBC[i].add(amount.toString());
|
||||
} else if (direction == "SENT") {
|
||||
transBC[i].add(transaction['receiver_id']);
|
||||
transBC[i].add(transaction['receiver']['identity']?['name'] ?? '');
|
||||
transBC[i].add('- $amount');
|
||||
}
|
||||
transBC[i].add(amount);
|
||||
transBC[i].add(direction);
|
||||
// transBC[i].add(''); //transaction comment
|
||||
|
||||
i++;
|
||||
|
@ -429,9 +438,9 @@ class DuniterIndexer with ChangeNotifier {
|
|||
return opts;
|
||||
}
|
||||
|
||||
num removeDecimalZero(double n) {
|
||||
double removeDecimalZero(double n) {
|
||||
String result = n.toStringAsFixed(n.truncateToDouble() == n ? 0 : 2);
|
||||
return num.parse(result);
|
||||
return double.parse(result);
|
||||
}
|
||||
|
||||
// checkHistoryResult(
|
||||
|
|
|
@ -13,6 +13,7 @@ import 'package:gecko/globals.dart';
|
|||
import 'package:gecko/models/wallet_data.dart';
|
||||
import 'package:gecko/models/widgets_keys.dart';
|
||||
import 'package:gecko/providers/my_wallets.dart';
|
||||
import 'package:gecko/providers/wallet_options.dart';
|
||||
import 'package:gecko/providers/wallets_profiles.dart';
|
||||
import 'package:gecko/screens/myWallets/unlocking_wallet.dart';
|
||||
import 'package:gecko/screens/myWallets/wallets_home.dart';
|
||||
|
@ -63,6 +64,13 @@ class HomeProvider with ChangeNotifier {
|
|||
}
|
||||
}
|
||||
|
||||
Future changeCurrencyUnit() async {
|
||||
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
|
||||
await configBox.put('isUdUnit', !isUdUnit);
|
||||
balanceCache = {};
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<String> getAppVersion() async {
|
||||
String version;
|
||||
String buildNumber;
|
||||
|
|
|
@ -41,6 +41,7 @@ class SubstrateSdk with ChangeNotifier {
|
|||
String g1V1NewAddress = '';
|
||||
bool isCesiumIDVisible = false;
|
||||
bool isCesiumAddresLoading = false;
|
||||
late int udValue;
|
||||
|
||||
/////////////////////////////////////
|
||||
////////// 1: API METHODS ///////////
|
||||
|
@ -154,20 +155,10 @@ class SubstrateSdk with ChangeNotifier {
|
|||
return consumers == 0 ? false : true;
|
||||
}
|
||||
|
||||
// Future<double> getBalance(String address) async {
|
||||
// double balance = 0.0;
|
||||
|
||||
// if (nodeConnected) {
|
||||
// final brutBalance = await sdk.api.account.queryBalance(address);
|
||||
// // log.d(brutBalance?.toJson());
|
||||
// balance = int.parse(brutBalance!.freeBalance) / 100;
|
||||
// } else {
|
||||
// balance = -1;
|
||||
// }
|
||||
|
||||
// await getUnclaimedUd(address);
|
||||
// return balance;
|
||||
// }
|
||||
Future<int> getUdValue() async {
|
||||
udValue = int.parse(await _getStorage('universalDividend.currentUd()'));
|
||||
return udValue;
|
||||
}
|
||||
|
||||
Future<Map<String, double>> getBalance(String address) async {
|
||||
// log.d('currencyParameters: $currencyParameters');
|
||||
|
@ -201,11 +192,18 @@ class SubstrateSdk with ChangeNotifier {
|
|||
final int transferableBalance =
|
||||
(balanceGlobal['data']['free'] + unclaimedUds);
|
||||
|
||||
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
|
||||
final udValue = await getUdValue();
|
||||
final double balanceRatio = isUdUnit ? round(udValue / 100, 4) : 1;
|
||||
|
||||
// log.d('udValue: $udValue');
|
||||
|
||||
Map<String, double> finalBalances = {
|
||||
'transferableBalance': transferableBalance / 100,
|
||||
'free': balanceGlobal['data']['free'] / 100,
|
||||
'unclaimedUds': unclaimedUds / 100,
|
||||
'reserved': balanceGlobal['data']['reserved'] / 100,
|
||||
'transferableBalance': round((transferableBalance / balanceRatio) / 100),
|
||||
'free': round((balanceGlobal['data']['free'] / balanceRatio) / 100),
|
||||
'unclaimedUds': round((unclaimedUds / balanceRatio) / 100),
|
||||
'reserved':
|
||||
round((balanceGlobal['data']['reserved'] / balanceRatio) / 100),
|
||||
};
|
||||
|
||||
// log.i(finalBalances);
|
||||
|
@ -701,11 +699,30 @@ class SubstrateSdk with ChangeNotifier {
|
|||
TxInfoData txInfo;
|
||||
List txOptions = [];
|
||||
String? rawParams;
|
||||
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
|
||||
late String palette;
|
||||
late String call;
|
||||
late String tx2;
|
||||
|
||||
if (amount == -1) {
|
||||
palette = 'balances';
|
||||
call = 'transferAll';
|
||||
txOptions = [destAddress, false];
|
||||
tx2 = 'api.tx.balances.transferAll("$destAddress", false)';
|
||||
} else {
|
||||
if (isUdUnit) {
|
||||
palette = 'universalDividend';
|
||||
call = 'transferUd';
|
||||
} else {
|
||||
palette = 'balances';
|
||||
call = 'transferKeepAlive';
|
||||
}
|
||||
txOptions = [destAddress, amountUnit];
|
||||
tx2 = 'api.tx.$palette.$call("$destAddress", $amountUnit)';
|
||||
}
|
||||
|
||||
if (globalBalance['unclaimedUds'] == 0) {
|
||||
txInfo = TxInfoData('balances',
|
||||
amount == -1 ? 'transferAll' : 'transferKeepAlive', sender);
|
||||
txOptions = [destAddress, amount == -1 ? false : amountUnit];
|
||||
txInfo = TxInfoData(palette, call, sender);
|
||||
} else {
|
||||
txInfo = TxInfoData(
|
||||
'utility',
|
||||
|
@ -713,14 +730,9 @@ class SubstrateSdk with ChangeNotifier {
|
|||
sender,
|
||||
);
|
||||
const tx1 = 'api.tx.universalDividend.claimUds()';
|
||||
final tx2 = amount == -1
|
||||
? 'api.tx.balances.transferAll("$destAddress", false)'
|
||||
: 'api.tx.balances.transferKeepAlive("$destAddress", $amountUnit)';
|
||||
|
||||
rawParams = '[[$tx1, $tx2]]';
|
||||
}
|
||||
|
||||
// log.d('pay args: ${txInfo.module}, ${txInfo.call}, $txOptions, $rawParams');
|
||||
return await _executeCall(txInfo, txOptions, password, rawParams);
|
||||
}
|
||||
|
||||
|
@ -1013,3 +1025,7 @@ class PasswordException implements Exception {
|
|||
|
||||
Uint8List _int32bytes(int value) =>
|
||||
Uint8List(4)..buffer.asInt32List()[0] = value;
|
||||
|
||||
double round(double number, [int decimal = 2]) {
|
||||
return double.parse((number.toStringAsFixed(decimal)));
|
||||
}
|
||||
|
|
|
@ -541,10 +541,13 @@ Widget balance(BuildContext context, String address, double size,
|
|||
globalBalance.hasError) {
|
||||
if (balanceCache[address] != null &&
|
||||
balanceCache[address] != -1) {
|
||||
return Text(
|
||||
"${balanceCache[address]!.toString()} $currencyName",
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? size : size * 0.9, color: color));
|
||||
return Row(children: [
|
||||
Text(balanceCache[address]!.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? size : size * 0.9, color: color)),
|
||||
const SizedBox(width: 5),
|
||||
udUnitDisplay(size, color),
|
||||
]);
|
||||
} else {
|
||||
return SizedBox(
|
||||
height: 15,
|
||||
|
@ -558,13 +561,17 @@ Widget balance(BuildContext context, String address, double size,
|
|||
}
|
||||
balanceCache[address] = globalBalance.data!['transferableBalance']!;
|
||||
if (balanceCache[address] != -1) {
|
||||
return Text(
|
||||
"${balanceCache[address]!.toString()} $currencyName",
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? size : size * 0.9,
|
||||
color: color,
|
||||
return Row(children: [
|
||||
Text(
|
||||
balanceCache[address]!.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: isTall ? size : size * 0.9,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
);
|
||||
const SizedBox(width: 5),
|
||||
udUnitDisplay(size, color),
|
||||
]);
|
||||
} else {
|
||||
return const Text('');
|
||||
}
|
||||
|
@ -601,3 +608,32 @@ Widget getCerts(BuildContext context, String address, double size,
|
|||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
Widget udUnitDisplay(double size, [Color color = Colors.black]) {
|
||||
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
|
||||
return isUdUnit
|
||||
? Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'DU',
|
||||
style:
|
||||
TextStyle(fontSize: isTall ? size : size * 0.9, color: color),
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
currencyName,
|
||||
style: TextStyle(
|
||||
fontSize: (isTall ? size : size * 0.9) * 0.7,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: color),
|
||||
),
|
||||
const SizedBox(height: 15)
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
: Text(currencyName,
|
||||
style: TextStyle(fontSize: isTall ? size : size * 0.9, color: color));
|
||||
}
|
||||
|
|
|
@ -195,6 +195,8 @@ class ActivityScreen extends StatelessWidget with ChangeNotifier {
|
|||
BuildContext context, DuniterIndexer duniterIndexer) {
|
||||
CesiumPlusProvider cesiumPlusProvider =
|
||||
Provider.of<CesiumPlusProvider>(context, listen: false);
|
||||
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||
|
||||
int keyID = 0;
|
||||
String? dateDelimiter;
|
||||
String? lastDateDelimiter;
|
||||
|
@ -273,6 +275,18 @@ class ActivityScreen extends StatelessWidget with ChangeNotifier {
|
|||
dateDelimiter = null;
|
||||
}
|
||||
|
||||
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
|
||||
late double amount;
|
||||
late String finalAmount;
|
||||
amount = repository[4] == 'RECEIVED' ? repository[3] : repository[3] * -1;
|
||||
|
||||
if (isUdUnit) {
|
||||
amount = round(amount / (sub.udValue / 100));
|
||||
finalAmount = "$amount DU";
|
||||
} else {
|
||||
finalAmount = '$amount $currencyName';
|
||||
}
|
||||
|
||||
return Column(children: <Widget>[
|
||||
if (dateDelimiter != null)
|
||||
Padding(
|
||||
|
@ -328,7 +342,7 @@ class ActivityScreen extends StatelessWidget with ChangeNotifier {
|
|||
],
|
||||
),
|
||||
),
|
||||
trailing: Text("${repository[3]} $currencyName",
|
||||
trailing: Text(finalAmount,
|
||||
style: const TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.w500),
|
||||
textAlign: TextAlign.justify),
|
||||
|
|
|
@ -31,8 +31,8 @@ class HomeScreen extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
homeContext = context;
|
||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||
MyWalletsProvider myWalletProvider =
|
||||
Provider.of<MyWalletsProvider>(context);
|
||||
Provider.of<ChestProvider>(context);
|
||||
|
|
|
@ -218,7 +218,7 @@ class ChooseWalletScreen extends StatelessWidget {
|
|||
width: double.infinity,
|
||||
color: isDefault ? orangeC : yellowC,
|
||||
child: SizedBox(
|
||||
height: 25,
|
||||
height: 30,
|
||||
child: Column(children: [
|
||||
const Spacer(),
|
||||
// Text(
|
||||
|
@ -226,7 +226,10 @@ class ChooseWalletScreen extends StatelessWidget {
|
|||
// textAlign: TextAlign.center,
|
||||
// style: TextStyle(color: isDefault ? Colors.white : Colors.black),
|
||||
// ),
|
||||
balance(context, address, 15, isDefault ? Colors.white : Colors.black)
|
||||
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
balance(
|
||||
context, address, 16, isDefault ? Colors.white : Colors.black),
|
||||
])
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
|
|
@ -293,12 +293,17 @@ class WalletsHome extends StatelessWidget {
|
|||
color: isDefault ? orangeC : yellowC,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 5, right: 5, top: 38),
|
||||
child: balance(
|
||||
context,
|
||||
address,
|
||||
15,
|
||||
isDefault ? Colors.white : Colors.black,
|
||||
isDefault ? yellowC : orangeC)),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
balance(
|
||||
context,
|
||||
address,
|
||||
15,
|
||||
isDefault ? Colors.white : Colors.black,
|
||||
isDefault ? yellowC : orangeC)
|
||||
],
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,21 @@ class ContactsScreen extends StatelessWidget {
|
|||
trailing: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
balance(context, g1Wallet.pubkey!, 16)
|
||||
SizedBox(
|
||||
width: 110,
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.end,
|
||||
children: [
|
||||
Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
balance(context,
|
||||
g1Wallet.pubkey!, 16),
|
||||
]),
|
||||
]),
|
||||
),
|
||||
]),
|
||||
subtitle: Row(children: <Widget>[
|
||||
duniterIndexer.getNameByAddress(
|
||||
|
|
|
@ -48,7 +48,7 @@ class SearchResultScreen extends StatelessWidget {
|
|||
body: SafeArea(
|
||||
child: Stack(children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||
padding: const EdgeInsets.only(left: 15, right: 10),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
|
@ -111,8 +111,24 @@ class SearchResultScreen extends StatelessWidget {
|
|||
mainAxisAlignment:
|
||||
MainAxisAlignment.center,
|
||||
children: [
|
||||
balance(
|
||||
context, g1Wallet.pubkey!, 16)
|
||||
SizedBox(
|
||||
width: 110,
|
||||
child: Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.end,
|
||||
children: [
|
||||
Column(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment
|
||||
.center,
|
||||
children: [
|
||||
balance(
|
||||
context,
|
||||
g1Wallet.pubkey!,
|
||||
16),
|
||||
]),
|
||||
]),
|
||||
),
|
||||
]),
|
||||
subtitle: Row(children: <Widget>[
|
||||
duniterIndexer.getNameByAddress(
|
||||
|
|
|
@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/services.dart';
|
||||
import 'package:gecko/models/widgets_keys.dart';
|
||||
import 'package:gecko/providers/duniter_indexer.dart';
|
||||
import 'package:gecko/providers/home.dart';
|
||||
import 'package:gecko/providers/my_wallets.dart';
|
||||
import 'package:gecko/providers/settings_provider.dart';
|
||||
import 'package:gecko/providers/substrate_sdk.dart';
|
||||
|
@ -33,9 +34,21 @@ class SettingsScreen extends StatelessWidget {
|
|||
)),
|
||||
body: Column(children: <Widget>[
|
||||
const SizedBox(height: 30),
|
||||
Text(
|
||||
'Connectivité réseau',
|
||||
style: TextStyle(color: Colors.grey[500], fontSize: 22),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
duniterEndpointSelection(context),
|
||||
const SizedBox(height: 50),
|
||||
const SizedBox(height: 30),
|
||||
indexerEndpointSelection(context),
|
||||
const SizedBox(height: 40),
|
||||
Text(
|
||||
'Affichage',
|
||||
style: TextStyle(color: Colors.grey[500], fontSize: 22),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
chooseCurrencyUnit(context),
|
||||
|
||||
// SizedBox(height: isTall ? 80 : 120),
|
||||
const Spacer(),
|
||||
|
@ -66,6 +79,36 @@ class SettingsScreen extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
Widget chooseCurrencyUnit(BuildContext context) {
|
||||
HomeProvider homeProvider =
|
||||
Provider.of<HomeProvider>(context, listen: false);
|
||||
return InkWell(
|
||||
key: keyUdUnit,
|
||||
onTap: () async {
|
||||
await homeProvider.changeCurrencyUnit();
|
||||
},
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(width: 12),
|
||||
Text('showUdAmounts'.tr()),
|
||||
const Spacer(),
|
||||
Consumer<HomeProvider>(builder: (context, homeProvider, _) {
|
||||
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
|
||||
return Icon(
|
||||
isUdUnit ? Icons.check_box : Icons.check_box_outline_blank,
|
||||
color: orangeC,
|
||||
size: 32,
|
||||
);
|
||||
}),
|
||||
const SizedBox(width: 30),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget duniterEndpointSelection(BuildContext context) {
|
||||
SubstrateSdk sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||
String? selectedDuniterEndpoint;
|
||||
|
|
|
@ -41,6 +41,7 @@ class TransactionInProgress extends StatelessWidget {
|
|||
final to = toAddress ?? getShortPubkey(walletViewProvider.address!);
|
||||
final amount = walletViewProvider.payAmount.text;
|
||||
String actionName = '';
|
||||
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
|
||||
|
||||
switch (transType) {
|
||||
case 'pay':
|
||||
|
@ -196,7 +197,7 @@ class TransactionInProgress extends StatelessWidget {
|
|||
const SizedBox(height: 10),
|
||||
if (transType == 'pay')
|
||||
Text(
|
||||
'$amount $currencyName',
|
||||
isUdUnit ? '$amount DU' : '$amount $currencyName',
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontSize: 18, fontWeight: FontWeight.w600),
|
||||
|
|
|
@ -403,9 +403,9 @@ class WalletViewScreen extends StatelessWidget {
|
|||
// WalletsProfilesProvider _walletViewProvider =
|
||||
// Provider.of<WalletsProfilesProvider>(context, listen: false);
|
||||
|
||||
MyWalletsProvider myWalletProvider =
|
||||
final myWalletProvider =
|
||||
Provider.of<MyWalletsProvider>(context, listen: false);
|
||||
// SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||
// final _sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||
|
||||
const double shapeSize = 20;
|
||||
WalletData? defaultWallet = myWalletProvider.getDefaultWallet();
|
||||
|
@ -438,6 +438,7 @@ class WalletViewScreen extends StatelessWidget {
|
|||
} else {
|
||||
canValidate = false;
|
||||
}
|
||||
final bool isUdUnit = configBox.get('isUdUnit') ?? false;
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(
|
||||
bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||
|
@ -524,44 +525,7 @@ class WalletViewScreen extends StatelessWidget {
|
|||
child: Row(children: [
|
||||
Text(defaultWallet.name!),
|
||||
const Spacer(),
|
||||
FutureBuilder(
|
||||
future:
|
||||
sub.getBalance(defaultWallet.address!),
|
||||
builder: (BuildContext context,
|
||||
AsyncSnapshot<Map<String, double>>
|
||||
globalBalance) {
|
||||
if (globalBalance.connectionState !=
|
||||
ConnectionState.done ||
|
||||
globalBalance.hasError) {
|
||||
if (balanceCache[
|
||||
defaultWallet.address!] !=
|
||||
null) {
|
||||
return Text(
|
||||
"${balanceCache[defaultWallet.address!]} $currencyName",
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
));
|
||||
} else {
|
||||
return SizedBox(
|
||||
height: 15,
|
||||
width: 15,
|
||||
child: CircularProgressIndicator(
|
||||
color: orangeC,
|
||||
strokeWidth: 2,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
balanceCache[defaultWallet.address!] =
|
||||
globalBalance
|
||||
.data!['transferableBalance']!;
|
||||
return Text(
|
||||
"${balanceCache[defaultWallet.address!]} $currencyName",
|
||||
style: const TextStyle(
|
||||
fontSize: 20,
|
||||
),
|
||||
);
|
||||
}),
|
||||
balance(context, defaultWallet.address!, 20)
|
||||
]),
|
||||
),
|
||||
);
|
||||
|
@ -597,7 +561,9 @@ class WalletViewScreen extends StatelessWidget {
|
|||
// onChanged: (v) => _searchProvider.reload(),
|
||||
decoration: InputDecoration(
|
||||
hintText: '0.00',
|
||||
suffix: Text(currencyName),
|
||||
suffix: Text(isUdUnit
|
||||
? 'DU'
|
||||
: currencyName), // udUnitDisplay(40),
|
||||
filled: true,
|
||||
fillColor: Colors.transparent,
|
||||
// border: OutlineInputBorder(
|
||||
|
|
Loading…
Reference in New Issue