Add detail/disclosure to pool group

- Disclosure: select first (default)
- Detail: show options
This commit is contained in:
Davide De Rosa 2019-04-06 16:43:43 +02:00
parent 5bb3a49a84
commit a63525c19a

View File

@ -109,7 +109,7 @@ extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate
// FIXME: checkmark overridden when count > 1 // FIXME: checkmark overridden when count > 1
if groupPools.count > 1 { if groupPools.count > 1 {
cell.rightText = pool.area?.uppercased() cell.rightText = pool.area?.uppercased()
cell.accessoryType = .disclosureIndicator cell.accessoryType = .detailDisclosureButton
} else { } else {
cell.rightText = pool.areaId?.uppercased() cell.rightText = pool.areaId?.uppercased()
cell.applyChecked(pool.id == currentPool?.id, Theme.current) cell.applyChecked(pool.id == currentPool?.id, Theme.current)
@ -124,21 +124,28 @@ extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate
guard let pool = groupPools.first else { guard let pool = groupPools.first else {
fatalError("Empty pools in group \(group)") fatalError("Empty pools in group \(group)")
} }
currentPool = pool
delegate?.providerPoolController(self, didSelectPool: pool)
}
if groupPools.count > 1 { func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) {
let vc = OptionViewController<Pool>() let group = sortedGroups[indexPath.row]
vc.title = pool.localizedCountry let groupPools = poolsByGroup[group]!
vc.options = groupPools guard let pool = groupPools.first else {
vc.selectedOption = currentPool fatalError("Empty pools in group \(group)")
vc.descriptionBlock = { $0.areaId ?? "" } // XXX: fail gracefully
vc.selectionBlock = {
self.currentPool = $0
self.delegate?.providerPoolController(self, didSelectPool: $0)
}
navigationController?.pushViewController(vc, animated: true)
} else {
currentPool = pool
delegate?.providerPoolController(self, didSelectPool: pool)
} }
guard groupPools.count > 1 else {
return
}
let vc = OptionViewController<Pool>()
vc.title = pool.localizedCountry
vc.options = groupPools
vc.selectedOption = currentPool
vc.descriptionBlock = { $0.areaId ?? "" } // XXX: fail gracefully
vc.selectionBlock = {
self.currentPool = $0
self.delegate?.providerPoolController(self, didSelectPool: $0)
}
navigationController?.pushViewController(vc, animated: true)
} }
} }