Restrict Accounts now part of cellForRow

This commit is contained in:
Stuart Breckenridge 2020-10-27 12:13:45 +08:00
parent 03611bc6ec
commit 5190bf0577
No known key found for this signature in database
GPG Key ID: 802A426F493CA19C
1 changed files with 7 additions and 26 deletions

View File

@ -70,7 +70,6 @@ class AddAccountViewController: UITableViewController, AddAccountDismissDelegate
override func viewDidLoad() {
super.viewDidLoad()
restrictAccounts()
}
override func numberOfSections(in tableView: UITableView) -> Int {
@ -141,9 +140,16 @@ class AddAccountViewController: UITableViewController, AddAccountDismissDelegate
case AddAccountSections.icloud.rawValue:
cell.comboNameLabel?.text = AddAccountSections.icloud.sectionContent[indexPath.row].localizedAccountName()
cell.comboImage?.image = AppAssets.image(for: AddAccountSections.icloud.sectionContent[indexPath.row])?.tinted(color: AddAccountSections.icloud.sectionContent[indexPath.row].iconColor())
if AppDefaults.shared.isDeveloperBuild {
cell.isUserInteractionEnabled = false
}
case AddAccountSections.web.rawValue:
cell.comboNameLabel?.text = AddAccountSections.web.sectionContent[indexPath.row].localizedAccountName()
cell.comboImage?.image = AppAssets.image(for: AddAccountSections.web.sectionContent[indexPath.row])?.tinted(color: AddAccountSections.web.sectionContent[indexPath.row].iconColor())
let type = AddAccountSections.web.sectionContent[indexPath.row]
if (type == .feedly || type == .feedWrangler) && AppDefaults.shared.isDeveloperBuild {
cell.isUserInteractionEnabled = false
}
case AddAccountSections.selfhosted.rawValue:
cell.comboNameLabel?.text = AddAccountSections.selfhosted.sectionContent[indexPath.row].localizedAccountName()
cell.comboImage?.image = AppAssets.image(for: AddAccountSections.selfhosted.sectionContent[indexPath.row])?.tinted(color: AddAccountSections.web.sectionContent[indexPath.row].iconColor())
@ -251,28 +257,3 @@ extension AddAccountViewController: OAuthAccountAuthorizationOperationDelegate {
presentError(error)
}
}
// MARK: Private
private extension AddAccountViewController {
func restrictAccounts() {
func removeAccountType(_ accountType: AccountType) {
if let index = addableAccountTypes.firstIndex(of: accountType) {
addableAccountTypes.remove(at: index)
}
}
if AppDefaults.shared.isDeveloperBuild {
removeAccountType(.cloudKit)
removeAccountType(.feedly)
removeAccountType(.feedWrangler)
return
}
if AccountManager.shared.activeAccounts.firstIndex(where: { $0.type == .cloudKit }) != nil {
removeAccountType(.cloudKit)
}
}
}