mirror of
https://github.com/lil-org/tokenary.git
synced 2025-01-06 04:36:45 +03:00
Highlight initially selected accounts on iOS
This commit is contained in:
parent
9281973d16
commit
0fd0b122cf
@ -96,8 +96,10 @@ class AccountsListViewController: UIViewController, DataStateContainer {
|
||||
tableView.contentInset.top += 70
|
||||
tableView.verticalScrollIndicatorInsets.bottom += bottomOverlayHeight
|
||||
|
||||
// TODO: select all correct initiall cells
|
||||
// tableView.selectRow(at: IndexPath(row: 0, section: 0), animated: true, scrollPosition: .none)
|
||||
if let accounts = selectAccountAction?.selectedAccounts {
|
||||
selectRowsForAccounts(accounts)
|
||||
}
|
||||
|
||||
updatePrimaryButton()
|
||||
|
||||
if let peer = selectAccountAction?.peer {
|
||||
@ -120,6 +122,29 @@ class AccountsListViewController: UIViewController, DataStateContainer {
|
||||
}
|
||||
}
|
||||
|
||||
private func selectRowsForAccounts(_ specificWalletAccounts: Set<SpecificWalletAccount>) {
|
||||
var toSelect = specificWalletAccounts
|
||||
for (sectionIndex, section) in sections.enumerated() {
|
||||
for (row, cellModel) in section.items.enumerated() {
|
||||
let account: SpecificWalletAccount
|
||||
switch cellModel {
|
||||
case let .mnemonicAccount(walletIndex, accountIndex):
|
||||
account = SpecificWalletAccount(walletId: wallets[walletIndex].id, account: wallets[walletIndex].accounts[accountIndex])
|
||||
case let .privateKeyAccount(walletIndex):
|
||||
account = SpecificWalletAccount(walletId: wallets[walletIndex].id, account: wallets[walletIndex].accounts[0])
|
||||
}
|
||||
if toSelect.contains(account) {
|
||||
toSelect.remove(account)
|
||||
let indexPath = IndexPath(row: row, section: sectionIndex)
|
||||
tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none)
|
||||
if toSelect.isEmpty {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func walletForIndexPath(_ indexPath: IndexPath) -> TokenaryWallet {
|
||||
let item = sections[indexPath.section].items[indexPath.row]
|
||||
switch item {
|
||||
@ -539,7 +564,7 @@ extension AccountsListViewController: UITableViewDelegate {
|
||||
updatePrimaryButton()
|
||||
return
|
||||
|
||||
tableView.deselectRow(at: indexPath, animated: true)
|
||||
// tableView.deselectRow(at: indexPath, animated: true)
|
||||
let wallet = walletForIndexPath(indexPath)
|
||||
let account = accountForIndexPath(indexPath)
|
||||
if forWalletSelection {
|
||||
|
Loading…
Reference in New Issue
Block a user