Dim accounts that can't be selected

This commit is contained in:
Ivan Grachev 2022-08-17 18:34:58 +03:00
parent b17d32ec79
commit 3412510b38
2 changed files with 9 additions and 3 deletions

View File

@ -612,7 +612,7 @@ extension AccountsListViewController: NSTableViewDataSource {
let account = wallet.accounts[0]
let specificWalletAccount = SpecificWalletAccount(walletId: wallet.id, account: account)
let isSelected = accountSelectionConfiguration?.selectedAccounts.contains(specificWalletAccount) == true
rowView.setup(account: account, isSelected: isSelected)
rowView.setup(account: account, isSelected: isSelected, isDisabled: !accountCanBeSelected(account))
return rowView
case let .mnemonicAccount(walletIndex: walletIndex, accountIndex: accountIndex):
let wallet = wallets[walletIndex]
@ -620,7 +620,7 @@ extension AccountsListViewController: NSTableViewDataSource {
let account = wallet.accounts[accountIndex]
let specificWalletAccount = SpecificWalletAccount(walletId: wallet.id, account: account)
let isSelected = accountSelectionConfiguration?.selectedAccounts.contains(specificWalletAccount) == true
rowView.setup(account: account, isSelected: isSelected)
rowView.setup(account: account, isSelected: isSelected, isDisabled: !accountCanBeSelected(account))
return rowView
case .mnemonicWalletHeader:
let rowView = tableView.makeViewOfType(AccountsHeaderRowView.self, owner: self)

View File

@ -20,10 +20,16 @@ class AccountCellView: NSTableRowView {
wantsLayer = true
}
func setup(account: Account, isSelected: Bool) {
func setup(account: Account, isSelected: Bool, isDisabled: Bool) {
addressImageView.image = account.image
addressTextField.stringValue = account.croppedAddress
setSelected(isSelected)
setDisabled(isDisabled)
}
private func setDisabled(_ disabled: Bool) {
addressImageView.alphaValue = disabled ? 0.4 : 1
addressTextField.alphaValue = disabled ? 0.4 : 1
}
private func setSelected(_ selected: Bool) {