Select only one account for each network

This commit is contained in:
Ivan Grachev 2022-08-17 16:30:22 +03:00
parent 3ad698c842
commit b2dae33adc
2 changed files with 8 additions and 3 deletions

View File

@ -554,13 +554,18 @@ extension AccountsListViewController: NSTableViewDelegate {
if accountSelectionConfiguration != nil {
let specificWalletAccount = SpecificWalletAccount(walletId: wallet.id, account: account)
let wasSelected = selectedAccounts.contains(specificWalletAccount)
(tableView.rowView(atRow: row, makeIfNecessary: false) as? AccountCellView)?.setSelected(!wasSelected)
if !wasSelected, let toDeselect = selectedAccounts.first(where: { $0.account.coin == account.coin }) {
selectedAccounts.remove(toDeselect)
}
if wasSelected {
selectedAccounts.remove(specificWalletAccount)
} else {
selectedAccounts.insert(specificWalletAccount)
}
// TODO: select only one account for each network
tableView.reloadData()
return false
} else {
showMenuOnCellSelection(row: row)

View File

@ -26,7 +26,7 @@ class AccountCellView: NSTableRowView {
setSelected(isSelected)
}
func setSelected(_ selected: Bool) {
private func setSelected(_ selected: Bool) {
layer?.backgroundColor = (selected ? NSColor.selectedContentBackgroundColor : NSColor.clear).cgColor
addressTextField.textColor = selected ? NSColor.selectedMenuItemTextColor : NSColor.labelColor
}