Skip to content

Commit c95cd3e

Browse files
Merge pull request #1449 from levoncrypto/masternode-ui
Fix masternode status
2 parents ae6a439 + 852c4df commit c95cd3e

2 files changed

Lines changed: 30 additions & 13 deletions

File tree

‎lib/pages/masternodes/sub_widgets/masternodes_list.dart‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,15 @@ class _MasternodeCard extends StatelessWidget {
6868
),
6969
);
7070
} else {
71-
await Navigator.of(
72-
context,
73-
).pushNamed(MasternodeDetailsView.routeName, arguments: node);
71+
await Navigator.of(context)
72+
.pushNamed(MasternodeDetailsView.routeName, arguments: node);
7473
}
7574
}
7675

7776
@override
7877
Widget build(BuildContext context) {
7978
final stack = Theme.of(context).extension<StackColors>()!;
80-
final isActive = node.revocationReason == 0;
79+
final status = node.status;
8180

8281
return RoundedWhiteContainer(
8382
padding: const EdgeInsets.all(16),
@@ -97,9 +96,8 @@ class _MasternodeCard extends StatelessWidget {
9796
const SizedBox(height: 2),
9897
Text(
9998
"Last paid height: ${node.lastPaidHeight}",
100-
style: STextStyles.baseXS(
101-
context,
102-
).copyWith(color: stack.textSubtitle1),
99+
style: STextStyles.baseXS(context)
100+
.copyWith(color: stack.textSubtitle1),
103101
),
104102
],
105103
),
@@ -108,14 +106,17 @@ class _MasternodeCard extends StatelessWidget {
108106
Container(
109107
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
110108
decoration: BoxDecoration(
111-
color: isActive ? stack.accentColorGreen : stack.accentColorRed,
109+
color: switch (status) {
110+
MasternodeStatus.active => stack.accentColorGreen,
111+
MasternodeStatus.banned => stack.accentColorOrange,
112+
MasternodeStatus.revoked => stack.accentColorRed,
113+
},
112114
borderRadius: BorderRadius.circular(8),
113115
),
114116
child: Text(
115-
isActive ? "ACTIVE" : "REVOKED",
116-
style: STextStyles.w600_12(
117-
context,
118-
).copyWith(color: stack.textWhite),
117+
status.label,
118+
style: STextStyles.w600_12(context)
119+
.copyWith(color: stack.textWhite),
119120
),
120121
),
121122
],

‎lib/wallets/wallet/impl/firo_wallet.dart‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ import '../wallet_mixin_interfaces/extended_keys_interface.dart';
3232
import '../wallet_mixin_interfaces/spark_interface.dart';
3333
import 'firo_transaction_type.dart';
3434

35+
enum MasternodeStatus {
36+
active("ACTIVE"),
37+
banned("BANNED"),
38+
revoked("REVOKED");
39+
40+
const MasternodeStatus(this.label);
41+
42+
final String label;
43+
}
44+
3545
class MasternodeInfo {
3646
final String proTxHash;
3747
final String collateralHash;
@@ -71,11 +81,17 @@ class MasternodeInfo {
7181
required this.pubKeyOperator,
7282
});
7383

84+
MasternodeStatus get status {
85+
if (revocationReason != 0) return MasternodeStatus.revoked;
86+
if (poseBanHeight != -1) return MasternodeStatus.banned;
87+
return MasternodeStatus.active;
88+
}
89+
7490
Map<String, String> pretty() {
7591
return {
7692
"ProTx Hash": proTxHash,
7793
"IP:Port": "$serviceAddr:$servicePort",
78-
"Status": revocationReason == 0 ? "Active" : "Revoked",
94+
"Status": status.label,
7995
"Registered Height": registeredHeight.toString(),
8096
"Last Paid Height": lastPaidHeight.toString(),
8197
"Payout Address": payoutAddress,

0 commit comments

Comments
 (0)