WIP: get received/sent certs
This commit is contained in:
parent
e7e4bca4e3
commit
1eb966046c
|
@ -210,6 +210,20 @@ class SubstrateSdk with ChangeNotifier {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<int>> getCerts(String address) async {
|
||||||
|
final idtyIndex = await sdk.webView!
|
||||||
|
.evalJavascript('api.query.identity.identityIndexOf("$address")');
|
||||||
|
log.d(idtyIndex);
|
||||||
|
|
||||||
|
final _certsReceiver = await sdk.webView!
|
||||||
|
.evalJavascript('api.query.cert.storageIdtyCertMeta($idtyIndex)') ??
|
||||||
|
[];
|
||||||
|
|
||||||
|
log.d(_certsReceiver['receivedCount']);
|
||||||
|
|
||||||
|
return [_certsReceiver['receivedCount'], _certsReceiver['issuedCount']];
|
||||||
|
}
|
||||||
|
|
||||||
Future<double> getBalance(String address, {bool isUd = false}) async {
|
Future<double> getBalance(String address, {bool isUd = false}) async {
|
||||||
double balance = 0.0;
|
double balance = 0.0;
|
||||||
if (nodeConnected) {
|
if (nodeConnected) {
|
||||||
|
|
|
@ -174,7 +174,6 @@ class WalletOptionsProvider with ChangeNotifier {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: 230,
|
|
||||||
child: Column(children: const <Widget>[
|
child: Column(children: const <Widget>[
|
||||||
Text(
|
Text(
|
||||||
'Statut inconnu',
|
'Statut inconnu',
|
||||||
|
@ -291,3 +290,44 @@ Widget balance(BuildContext context, String address, double size,
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, String> certCache = {};
|
||||||
|
Widget getCerts(BuildContext context, String address, double size,
|
||||||
|
[Color _color = Colors.black]) {
|
||||||
|
return Column(children: <Widget>[
|
||||||
|
Consumer<SubstrateSdk>(builder: (context, _sdk, _) {
|
||||||
|
return FutureBuilder(
|
||||||
|
future: _sdk.getCerts(address),
|
||||||
|
builder: (BuildContext context, AsyncSnapshot<List?>? _certs) {
|
||||||
|
if (_certs!.connectionState != ConnectionState.done ||
|
||||||
|
_certs.hasError) {
|
||||||
|
if (certCache[address] != null) {
|
||||||
|
return Text(certCache[address]!,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: isTall ? size : size * 0.9, color: _color));
|
||||||
|
} else {
|
||||||
|
return SizedBox(
|
||||||
|
height: 15,
|
||||||
|
width: 15,
|
||||||
|
child: CircularProgressIndicator(
|
||||||
|
color: orangeC,
|
||||||
|
strokeWidth: 2,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
certCache[address] = _certs.data![0] != 0
|
||||||
|
? "Certifications reçus: ${_certs.data![0].toString()}\nCertifications envoyés: ${_certs.data![1].toString()}"
|
||||||
|
: '';
|
||||||
|
|
||||||
|
return Text(
|
||||||
|
certCache[address]!,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: isTall ? size : size * 0.9,
|
||||||
|
color: _color,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
|
@ -91,23 +91,39 @@ class WalletOptions extends StatelessWidget {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const Spacer(flex: 1),
|
const Spacer(flex: 5),
|
||||||
avatar(walletProvider),
|
avatar(walletProvider),
|
||||||
const Spacer(flex: 1),
|
// const Spacer(flex: 1),
|
||||||
Column(children: <Widget>[
|
Column(children: <Widget>[
|
||||||
walletName(walletProvider, _walletOptions),
|
walletName(walletProvider, _walletOptions),
|
||||||
SizedBox(height: isTall ? 5 : 0),
|
SizedBox(height: isTall ? 5 : 0),
|
||||||
balance(context, walletProvider.address.text, 20),
|
SizedBox(
|
||||||
SizedBox(height: isTall ? 5 : 0),
|
width: 350,
|
||||||
_walletOptions.idtyStatus(
|
child: Row(
|
||||||
context, _walletOptions.address.text,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
isOwner: true),
|
children: [
|
||||||
|
// SizedBox(height: isTall ? 5 : 0),
|
||||||
|
balance(
|
||||||
|
context, walletProvider.address.text, 21),
|
||||||
|
const SizedBox(width: 30),
|
||||||
|
Column(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_walletOptions.idtyStatus(context,
|
||||||
|
_walletOptions.address.text,
|
||||||
|
isOwner: true),
|
||||||
|
getCerts(context,
|
||||||
|
walletProvider.address.text, 15),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
SizedBox(height: 10 * ratio),
|
||||||
]),
|
]),
|
||||||
const Spacer(flex: 3),
|
const Spacer(flex: 1),
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
SizedBox(height: 10 * ratio),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(children: <Widget>[
|
child: Column(children: <Widget>[
|
||||||
|
|
|
@ -609,12 +609,11 @@ class WalletViewScreen extends StatelessWidget {
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
Consumer<WalletOptionsProvider>(
|
|
||||||
builder: (context, walletProvider, _) {
|
balance(context, pubkey!, 22),
|
||||||
return balance(context, pubkey!, 22);
|
|
||||||
}),
|
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
_walletOptions.idtyStatus(context, pubkey!, isOwner: false),
|
_walletOptions.idtyStatus(context, pubkey!, isOwner: false),
|
||||||
|
getCerts(context, pubkey!, 14),
|
||||||
|
|
||||||
// if (username == null &&
|
// if (username == null &&
|
||||||
// g1WalletsBox.get(pubkey)?.username == null)
|
// g1WalletsBox.get(pubkey)?.username == null)
|
||||||
|
|
Loading…
Reference in New Issue