[skip-ci] show mweb confirmations, show last mweb balance while syncing

This commit is contained in:
Matthew Fosse 2024-10-21 09:18:31 -07:00
parent 34166c3a11
commit 91998d452a
2 changed files with 33 additions and 17 deletions
cw_bitcoin/lib
lib/view_model/dashboard

View file

@ -24,9 +24,12 @@ class ElectrumBalance extends Balance {
final decoded = json.decode(jsonSource) as Map;
return ElectrumBalance(
confirmed: decoded['confirmed'] as int? ?? 0,
unconfirmed: decoded['unconfirmed'] as int? ?? 0,
frozen: decoded['frozen'] as int? ?? 0);
confirmed: decoded['confirmed'] as int? ?? 0,
unconfirmed: decoded['unconfirmed'] as int? ?? 0,
frozen: decoded['frozen'] as int? ?? 0,
secondConfirmed: decoded['secondConfirmed'] as int? ?? 0,
secondUnconfirmed: decoded['secondUnconfirmed'] as int? ?? 0,
);
}
int confirmed;
@ -36,8 +39,7 @@ class ElectrumBalance extends Balance {
int secondUnconfirmed = 0;
@override
String get formattedAvailableBalance =>
bitcoinAmountToString(amount: confirmed - frozen);
String get formattedAvailableBalance => bitcoinAmountToString(amount: confirmed - frozen);
@override
String get formattedAdditionalBalance => bitcoinAmountToString(amount: unconfirmed);

View file

@ -56,25 +56,39 @@ class TransactionListItem extends ActionListItem with Keyable {
}
String get formattedPendingStatus {
if (balanceViewModel.wallet.type == WalletType.monero ||
balanceViewModel.wallet.type == WalletType.haven) {
if (transaction.confirmations >= 0 && transaction.confirmations < 10) {
return ' (${transaction.confirmations}/10)';
}
} else if (balanceViewModel.wallet.type == WalletType.wownero) {
if (transaction.confirmations >= 0 && transaction.confirmations < 3) {
return ' (${transaction.confirmations}/3)';
}
switch (balanceViewModel.wallet.type) {
case WalletType.monero:
case WalletType.haven:
if (transaction.confirmations >= 0 && transaction.confirmations < 10) {
return ' (${transaction.confirmations}/10)';
}
break;
case WalletType.wownero:
if (transaction.confirmations >= 0 && transaction.confirmations < 3) {
return ' (${transaction.confirmations}/3)';
}
break;
case WalletType.litecoin:
if (transaction.confirmations >= 0 && transaction.confirmations < 6) {
return ' (${transaction.confirmations}/6)';
}
default:
return '';
}
return '';
}
String get formattedStatus {
if (balanceViewModel.wallet.type == WalletType.monero ||
balanceViewModel.wallet.type == WalletType.wownero ||
balanceViewModel.wallet.type == WalletType.haven) {
if ([
WalletType.monero,
WalletType.haven,
WalletType.wownero,
WalletType.litecoin,
].contains(balanceViewModel.wallet.type)) {
return formattedPendingStatus;
}
return transaction.isPending ? S.current.pending : '';
}