mirror of
https://github.com/lil-org/tokenary.git
synced 2025-01-08 14:49:38 +03:00
Account selection logic on iOS
This commit is contained in:
parent
79e6b85cb6
commit
d341c5b8e4
@ -559,23 +559,34 @@ extension AccountsListViewController: UITableViewDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
|
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
|
||||||
// TODO: implement deselect
|
guard selectAccountAction != nil else { return }
|
||||||
|
let wallet = walletForIndexPath(indexPath)
|
||||||
|
let account = accountForIndexPath(indexPath)
|
||||||
|
let specificWalletAccount = SpecificWalletAccount(walletId: wallet.id, account: account)
|
||||||
|
selectAccountAction?.selectedAccounts.remove(specificWalletAccount)
|
||||||
updatePrimaryButton()
|
updatePrimaryButton()
|
||||||
}
|
}
|
||||||
|
|
||||||
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||||
// TODO: implement new account selection logic
|
|
||||||
updatePrimaryButton()
|
|
||||||
return
|
|
||||||
|
|
||||||
// tableView.deselectRow(at: indexPath, animated: true)
|
|
||||||
let wallet = walletForIndexPath(indexPath)
|
let wallet = walletForIndexPath(indexPath)
|
||||||
let account = accountForIndexPath(indexPath)
|
let account = accountForIndexPath(indexPath)
|
||||||
if selectAccountAction != nil {
|
if selectAccountAction != nil {
|
||||||
// TODO: do not call completion here anymore
|
if let toDeselect = selectAccountAction?.selectedAccounts.first(where: { $0.account.coin == account.coin }) {
|
||||||
selectAccountAction?.completion(chain, [SpecificWalletAccount(walletId: wallet.id, account: account)])
|
selectAccountAction?.selectedAccounts.remove(toDeselect)
|
||||||
|
for anotherIndexPath in tableView.indexPathsForSelectedRows ?? [] {
|
||||||
|
guard indexPath != anotherIndexPath else { continue }
|
||||||
|
if accountForIndexPath(anotherIndexPath) == toDeselect.account && walletForIndexPath(anotherIndexPath).id == toDeselect.walletId {
|
||||||
|
tableView.deselectRow(at: anotherIndexPath, animated: false)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let specificWalletAccount = SpecificWalletAccount(walletId: wallet.id, account: account)
|
||||||
|
selectAccountAction?.selectedAccounts.insert(specificWalletAccount)
|
||||||
|
updatePrimaryButton()
|
||||||
} else {
|
} else {
|
||||||
showActionsForAccount(account, wallet: wallet, cell: tableView.cellForRow(at: indexPath))
|
showActionsForAccount(account, wallet: wallet, cell: tableView.cellForRow(at: indexPath))
|
||||||
|
tableView.deselectRow(at: indexPath, animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user