diff --git a/lib/pages/masternodes/sub_widgets/masternodes_list.dart b/lib/pages/masternodes/sub_widgets/masternodes_list.dart index 45446b8e1..6aa200283 100644 --- a/lib/pages/masternodes/sub_widgets/masternodes_list.dart +++ b/lib/pages/masternodes/sub_widgets/masternodes_list.dart @@ -68,16 +68,15 @@ class _MasternodeCard extends StatelessWidget { ), ); } else { - await Navigator.of( - context, - ).pushNamed(MasternodeDetailsView.routeName, arguments: node); + await Navigator.of(context) + .pushNamed(MasternodeDetailsView.routeName, arguments: node); } } @override Widget build(BuildContext context) { final stack = Theme.of(context).extension()!; - final isActive = node.revocationReason == 0; + final status = node.status; return RoundedWhiteContainer( padding: const EdgeInsets.all(16), @@ -97,9 +96,8 @@ class _MasternodeCard extends StatelessWidget { const SizedBox(height: 2), Text( "Last paid height: ${node.lastPaidHeight}", - style: STextStyles.baseXS( - context, - ).copyWith(color: stack.textSubtitle1), + style: STextStyles.baseXS(context) + .copyWith(color: stack.textSubtitle1), ), ], ), @@ -108,14 +106,17 @@ class _MasternodeCard extends StatelessWidget { Container( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), decoration: BoxDecoration( - color: isActive ? stack.accentColorGreen : stack.accentColorRed, + color: switch (status) { + MasternodeStatus.active => stack.accentColorGreen, + MasternodeStatus.banned => stack.accentColorOrange, + MasternodeStatus.revoked => stack.accentColorRed, + }, borderRadius: BorderRadius.circular(8), ), child: Text( - isActive ? "ACTIVE" : "REVOKED", - style: STextStyles.w600_12( - context, - ).copyWith(color: stack.textWhite), + status.label, + style: STextStyles.w600_12(context) + .copyWith(color: stack.textWhite), ), ), ], diff --git a/lib/wallets/wallet/impl/firo_wallet.dart b/lib/wallets/wallet/impl/firo_wallet.dart index ea2751457..2f1609067 100644 --- a/lib/wallets/wallet/impl/firo_wallet.dart +++ b/lib/wallets/wallet/impl/firo_wallet.dart @@ -32,6 +32,16 @@ import '../wallet_mixin_interfaces/extended_keys_interface.dart'; import '../wallet_mixin_interfaces/spark_interface.dart'; import 'firo_transaction_type.dart'; +enum MasternodeStatus { + active("ACTIVE"), + banned("BANNED"), + revoked("REVOKED"); + + const MasternodeStatus(this.label); + + final String label; +} + class MasternodeInfo { final String proTxHash; final String collateralHash; @@ -71,11 +81,17 @@ class MasternodeInfo { required this.pubKeyOperator, }); + MasternodeStatus get status { + if (revocationReason != 0) return MasternodeStatus.revoked; + if (poseBanHeight != -1) return MasternodeStatus.banned; + return MasternodeStatus.active; + } + Map pretty() { return { "ProTx Hash": proTxHash, "IP:Port": "$serviceAddr:$servicePort", - "Status": revocationReason == 0 ? "Active" : "Revoked", + "Status": status.label, "Registered Height": registeredHeight.toString(), "Last Paid Height": lastPaidHeight.toString(), "Payout Address": payoutAddress,