Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions lib/pages/masternodes/sub_widgets/masternodes_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<StackColors>()!;
final isActive = node.revocationReason == 0;
final status = node.status;

return RoundedWhiteContainer(
padding: const EdgeInsets.all(16),
Expand All @@ -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),
),
],
),
Expand All @@ -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),
),
),
],
Expand Down
18 changes: 17 additions & 1 deletion lib/wallets/wallet/impl/firo_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, String> 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,
Expand Down
Loading