move view model into di.dart

This commit is contained in:
Czarek Nakamoto 2024-11-26 07:51:18 -05:00
parent 5960c390a4
commit f85ec0631b
No known key found for this signature in database
GPG key ID: 04FB77CB56AB1DF4
2 changed files with 6 additions and 3 deletions

View file

@ -746,6 +746,7 @@ Future<void> setup({
_transactionDescriptionBox, _transactionDescriptionBox,
getIt.get<AppStore>().wallet!.isHardwareWallet ? getIt.get<LedgerViewModel>() : null, getIt.get<AppStore>().wallet!.isHardwareWallet ? getIt.get<LedgerViewModel>() : null,
coinTypeToSpendFrom: coinTypeToSpendFrom ?? UnspentCoinType.any, coinTypeToSpendFrom: coinTypeToSpendFrom ?? UnspentCoinType.any,
getIt.get<UnspentCoinsListViewModel>(param1: coinTypeToSpendFrom),
), ),
); );

View file

@ -65,6 +65,8 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
wallet.type == WalletType.tron; wallet.type == WalletType.tron;
} }
UnspentCoinsListViewModel unspentCoinsListViewModel;
SendViewModelBase( SendViewModelBase(
AppStore appStore, AppStore appStore,
this.sendTemplateViewModel, this.sendTemplateViewModel,
@ -72,7 +74,8 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
this.balanceViewModel, this.balanceViewModel,
this.contactListViewModel, this.contactListViewModel,
this.transactionDescriptionBox, this.transactionDescriptionBox,
this.ledgerViewModel, { this.ledgerViewModel,
this.unspentCoinsListViewModel, {
this.coinTypeToSpendFrom = UnspentCoinType.any, this.coinTypeToSpendFrom = UnspentCoinType.any,
}) : state = InitialExecutionState(), }) : state = InitialExecutionState(),
currencies = appStore.wallet!.balance.keys.toList(), currencies = appStore.wallet!.balance.keys.toList(),
@ -532,9 +535,8 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
} }
if (hasCoinControl) { if (hasCoinControl) {
final vm = getIt.get<UnspentCoinsListViewModel>(param1: coinTypeToSpendFrom);
bool isCoinSelected = false; bool isCoinSelected = false;
for (var coin in vm.items) { for (var coin in unspentCoinsListViewModel.items) {
isCoinSelected = isCoinSelected || (coin.isSending && !coin.isFrozen); isCoinSelected = isCoinSelected || (coin.isSending && !coin.isFrozen);
} }
if (!isCoinSelected) { if (!isCoinSelected) {