2022-12-06 03:35:35 +01:00
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
2022-12-06 22:33:42 +01:00
|
|
|
import 'package:gecko/models/wallet_data.dart';
|
2022-12-06 03:35:35 +01:00
|
|
|
import 'package:gecko/providers/duniter_indexer.dart';
|
|
|
|
import 'package:gecko/providers/substrate_sdk.dart';
|
2022-12-10 08:16:38 +01:00
|
|
|
import 'package:gecko/widgets/commons/animated_text.dart';
|
2022-12-06 22:33:42 +01:00
|
|
|
import 'package:gecko/widgets/name_by_address.dart';
|
2022-12-06 03:35:35 +01:00
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
class IdentityStatus extends StatelessWidget {
|
|
|
|
const IdentityStatus(
|
|
|
|
{Key? key,
|
|
|
|
required this.address,
|
|
|
|
this.isOwner = false,
|
|
|
|
this.color = Colors.black})
|
|
|
|
: super(key: key);
|
|
|
|
final String address;
|
|
|
|
final bool isOwner;
|
|
|
|
final Color color;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final duniterIndexer = Provider.of<DuniterIndexer>(context, listen: false);
|
|
|
|
|
|
|
|
return Consumer<SubstrateSdk>(builder: (context, sub, _) {
|
|
|
|
return FutureBuilder(
|
|
|
|
future: sub.idtyStatus(address),
|
|
|
|
initialData: '',
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
duniterIndexer.idtyStatusCache[address] = snapshot.data.toString();
|
|
|
|
switch (snapshot.data.toString()) {
|
|
|
|
case 'noid':
|
|
|
|
{
|
|
|
|
return showText('noIdentity'.tr());
|
|
|
|
}
|
|
|
|
case 'Created':
|
|
|
|
{
|
|
|
|
return showText('identityCreated'.tr());
|
|
|
|
}
|
|
|
|
case 'ConfirmedByOwner':
|
|
|
|
{
|
|
|
|
return isOwner
|
|
|
|
? showText('identityConfirmed'.tr())
|
2022-12-06 22:33:42 +01:00
|
|
|
: NameByAddress(
|
|
|
|
wallet: WalletData(address: address),
|
|
|
|
size: 20,
|
|
|
|
color: Colors.grey[700]!,
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
fontStyle: FontStyle.italic);
|
2022-12-06 03:35:35 +01:00
|
|
|
}
|
|
|
|
case 'Validated':
|
|
|
|
{
|
|
|
|
return isOwner
|
|
|
|
? showText('memberValidated'.tr(), 18, true)
|
2022-12-06 22:33:42 +01:00
|
|
|
: NameByAddress(
|
|
|
|
wallet: WalletData(address: address),
|
|
|
|
size: 20,
|
|
|
|
color: Colors.black,
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
fontStyle: FontStyle.normal);
|
2022-12-06 03:35:35 +01:00
|
|
|
}
|
|
|
|
case 'expired':
|
|
|
|
{
|
|
|
|
return showText('identityExpired'.tr());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return SizedBox(
|
|
|
|
child: showText('', 18, false, false),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2022-12-07 23:10:28 +01:00
|
|
|
|
|
|
|
AnimatedFadeOutIn showText(String text,
|
|
|
|
[double size = 18, bool bold = false, bool smooth = true]) {
|
|
|
|
// log.d('$address $text');
|
|
|
|
return AnimatedFadeOutIn<String>(
|
|
|
|
data: text,
|
|
|
|
duration: Duration(milliseconds: smooth ? 200 : 0),
|
|
|
|
builder: (value) => Text(
|
|
|
|
value,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
style: TextStyle(
|
|
|
|
fontSize: size,
|
|
|
|
color: bold ? color : Colors.black,
|
|
|
|
fontWeight: bold ? FontWeight.w500 : FontWeight.w400),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2022-12-06 03:35:35 +01:00
|
|
|
}
|