Show AreaID (Area + Num) in pool selector

Rename localizedCountryArea to localizedId.
This commit is contained in:
Davide De Rosa 2019-04-06 14:48:22 +02:00
parent 0cb0874332
commit 8fd5a74dc4
3 changed files with 18 additions and 4 deletions

View File

@ -78,7 +78,7 @@ extension ProviderPoolViewController: UITableViewDataSource, UITableViewDelegate
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.imageView?.image = pool.logo
cell.leftText = pool.localizedName
cell.rightText = pool.area?.uppercased()
cell.rightText = pool.areaId?.uppercased()
cell.applyChecked(pool.id == currentPoolId, Theme.current)
cell.isTappable = true
return cell

View File

@ -673,7 +673,7 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog
case .providerPool:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.Service.Cells.Provider.Pool.caption
cell.rightText = uncheckedProviderProfile.pool?.localizedCountryArea
cell.rightText = uncheckedProviderProfile.pool?.localizedId
return cell
case .providerPreset:

View File

@ -57,6 +57,20 @@ public struct Pool: Codable, Comparable, CustomStringConvertible {
public let num: String?
public var areaId: String? {
let id: String
if let area = area, let num = num {
id = "\(area) #\(num)"
} else if let area = area {
id = area
} else if let num = num {
id = "#\(num)"
} else {
return nil
}
return id.uppercased()
}
public let isFree: Bool?
// public let location: (Double, Double)
@ -82,7 +96,7 @@ public struct Pool: Codable, Comparable, CustomStringConvertible {
// MARK: Comparable
public static func <(lhs: Pool, rhs: Pool) -> Bool {
return lhs.localizedCountryArea < rhs.localizedCountryArea
return lhs.localizedId < rhs.localizedId
}
// MARK: CustomStringConvertible
@ -99,7 +113,7 @@ extension Pool {
return Utils.localizedCountry(country)
}
public var localizedCountryArea: String {
public var localizedId: String {
let countryString = localizedCountry
let zone: String
if let area = area, let num = num {