separate mweb balances, pt.2

This commit is contained in:
Matthew Fosse 2024-09-12 13:15:20 -07:00
parent 9dd696a474
commit 6a4327a53b
3 changed files with 67 additions and 29 deletions

View file

@ -319,7 +319,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
lastFewProgresses.add(syncStatus.progress()); lastFewProgresses.add(syncStatus.progress());
if (lastFewProgresses.length < 4) return; if (lastFewProgresses.length < 4) return;
// limit list size to 4: // limit list size to 4:
while(lastFewProgresses.length > 4) { while (lastFewProgresses.length > 4) {
lastFewProgresses.removeAt(0); lastFewProgresses.removeAt(0);
} }
// if the progress is the same over the last 40 seconds, restart the sync: // if the progress is the same over the last 40 seconds, restart the sync:
@ -676,12 +676,14 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
int confirmed = balance.confirmed; int confirmed = balance.confirmed;
int unconfirmed = balance.unconfirmed; int unconfirmed = balance.unconfirmed;
int confirmedMweb = 0;
int unconfirmedMweb = 0;
try { try {
mwebUtxosBox.values.forEach((utxo) { mwebUtxosBox.values.forEach((utxo) {
if (utxo.height > 0) { if (utxo.height > 0) {
confirmed += utxo.value.toInt(); confirmedMweb += utxo.value.toInt();
} else { } else {
unconfirmed += utxo.value.toInt(); unconfirmedMweb += utxo.value.toInt();
} }
}); });
} catch (_) {} } catch (_) {}
@ -733,7 +735,13 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
} }
} }
return ElectrumBalance(confirmed: confirmed, unconfirmed: unconfirmed, frozen: balance.frozen); return ElectrumBalance(
confirmed: confirmed,
unconfirmed: unconfirmed,
frozen: balance.frozen,
secondConfirmed: confirmedMweb,
secondUnconfirmed: unconfirmedMweb,
);
} }
@override @override

View file

@ -281,10 +281,9 @@ class CryptoBalanceWidget extends StatelessWidget {
secondAvailableBalance: balance.secondAvailableBalance, secondAvailableBalance: balance.secondAvailableBalance,
secondAvailableFiatBalance: balance.fiatSecondAvailableBalance, secondAvailableFiatBalance: balance.fiatSecondAvailableBalance,
secondAdditionalBalanceLabel: secondAdditionalBalanceLabel:
'${dashboardViewModel.balanceViewModel.additionalBalanceLabel}', '${dashboardViewModel.balanceViewModel.secondAdditionalBalanceLabel}',
secondAvailableBalanceLabel: secondAvailableBalanceLabel:
'${dashboardViewModel.balanceViewModel.availableBalanceLabel}', '${dashboardViewModel.balanceViewModel.secondAvailableBalanceLabel}',
isTestnet: dashboardViewModel.isTestnet, isTestnet: dashboardViewModel.isTestnet,
); );
}); });
@ -792,7 +791,7 @@ class BalanceRowWidget extends StatelessWidget {
children: [ children: [
SizedBox(height: 24), SizedBox(height: 24),
Text( Text(
'${additionalBalanceLabel}', '${secondAvailableBalanceLabel}',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
@ -804,7 +803,7 @@ class BalanceRowWidget extends StatelessWidget {
), ),
SizedBox(height: 8), SizedBox(height: 8),
AutoSizeText( AutoSizeText(
additionalBalance, secondAvailableBalance,
style: TextStyle( style: TextStyle(
fontSize: 20, fontSize: 20,
fontFamily: 'Lato', fontFamily: 'Lato',
@ -818,7 +817,7 @@ class BalanceRowWidget extends StatelessWidget {
SizedBox(height: 4), SizedBox(height: 4),
if (!isTestnet) if (!isTestnet)
Text( Text(
'${additionalFiatBalance}', '${secondAvailableFiatBalance}',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
@ -836,7 +835,7 @@ class BalanceRowWidget extends StatelessWidget {
children: [ children: [
SizedBox(height: 24), SizedBox(height: 24),
Text( Text(
'${additionalBalanceLabel}', '${secondAdditionalBalanceLabel}',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,
@ -848,7 +847,7 @@ class BalanceRowWidget extends StatelessWidget {
), ),
SizedBox(height: 8), SizedBox(height: 8),
AutoSizeText( AutoSizeText(
additionalBalance, secondAdditionalBalance,
style: TextStyle( style: TextStyle(
fontSize: 20, fontSize: 20,
fontFamily: 'Lato', fontFamily: 'Lato',
@ -862,7 +861,7 @@ class BalanceRowWidget extends StatelessWidget {
SizedBox(height: 4), SizedBox(height: 4),
if (!isTestnet) if (!isTestnet)
Text( Text(
'${additionalFiatBalance}', '${secondAdditionalFiatBalance}',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 12,

View file

@ -166,6 +166,26 @@ abstract class BalanceViewModelBase with Store {
} }
} }
@computed
String get secondAvailableBalanceLabel {
switch (wallet.type) {
case WalletType.litecoin:
return "T: mweb confirmed";
default:
return S.current.confirmed;
}
}
@computed
String get secondAdditionalBalanceLabel {
switch (wallet.type) {
case WalletType.litecoin:
return "T: mweb unconfirmed";
default:
return S.current.unconfirmed;
}
}
@computed @computed
bool get hasMultiBalance => appStore.wallet!.type == WalletType.haven; bool get hasMultiBalance => appStore.wallet!.type == WalletType.haven;
@ -215,6 +235,17 @@ abstract class BalanceViewModelBase with Store {
return walletBalance.formattedAdditionalBalance; return walletBalance.formattedAdditionalBalance;
} }
@computed
String get secondAdditionalBalance {
final walletBalance = _walletBalance;
if (displayMode == BalanceDisplayMode.hiddenBalance) {
return '---';
}
return walletBalance.formattedSecondAdditionalBalance;
}
@computed @computed
String get availableFiatBalance { String get availableFiatBalance {
final walletBalance = _walletBalance; final walletBalance = _walletBalance;
@ -317,15 +348,15 @@ abstract class BalanceViewModelBase with Store {
} }
@computed @computed
bool get hasAdditionalBalance => _hasAdditionBalanceForWalletType(wallet.type); bool get hasAdditionalBalance => _hasAdditionalBalanceForWalletType(wallet.type);
@computed @computed
bool get hasSecondAdditionalBalance => _hasSecondAddtionalBalanceForWalletType(wallet.type); bool get hasSecondAdditionalBalance => _hasSecondAdditionalBalanceForWalletType(wallet.type);
@computed @computed
bool get hasSecondAvailableBalance => _hasSecondAvailableBalanceForWalletType(wallet.type); bool get hasSecondAvailableBalance => _hasSecondAvailableBalanceForWalletType(wallet.type);
bool _hasAdditionBalanceForWalletType(WalletType type) { bool _hasAdditionalBalanceForWalletType(WalletType type) {
switch (type) { switch (type) {
case WalletType.ethereum: case WalletType.ethereum:
case WalletType.polygon: case WalletType.polygon:
@ -337,22 +368,22 @@ abstract class BalanceViewModelBase with Store {
} }
} }
bool _hasSecondAddtionalBalanceForWalletType(WalletType type) { bool _hasSecondAdditionalBalanceForWalletType(WalletType type) {
switch (type) { // return _walletBalance.secondAdditional != null && _walletBalance.secondAdditional! != 0;
case WalletType.litecoin: // if (wallet.type == WalletType.litecoin && settingsStore.mwebEnabled) {
// return true;
// }
// return false;
return true; return true;
default:
return false;
}
} }
bool _hasSecondAvailableBalanceForWalletType(WalletType type) { bool _hasSecondAvailableBalanceForWalletType(WalletType type) {
switch (type) { // return _walletBalance.secondAdditional != null && _walletBalance.secondAdditional! != 0;
case WalletType.litecoin: // if (wallet.type == WalletType.litecoin && settingsStore.mwebEnabled) {
// return true;
// }
// return false;
return true; return true;
default:
return false;
}
} }
@computed @computed