mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Created the Developer build which has some functionality disabled for those without access to the API keys needed.
This commit is contained in:
@@ -16,47 +16,81 @@ protocol AddAccountDismissDelegate: UIViewController {
|
||||
|
||||
class AddAccountViewController: UITableViewController, AddAccountDismissDelegate {
|
||||
|
||||
@IBOutlet private weak var localAccountImageView: UIImageView!
|
||||
@IBOutlet private weak var localAccountNameLabel: UILabel!
|
||||
|
||||
#if DEBUG
|
||||
private var addableAccountTypes: [AccountType] = [.onMyMac, .feedbin, .feedly, .feedWrangler, .newsBlur]
|
||||
#else
|
||||
private var addableAccountTypes: [AccountType] = [.onMyMac, .feedbin, .feedly]
|
||||
#endif
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
localAccountImageView.image = AppAssets.image(for: .onMyMac)
|
||||
localAccountNameLabel.text = Account.defaultLocalAccountName
|
||||
restrictAccounts()
|
||||
}
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
1
|
||||
}
|
||||
|
||||
#if !DEBUG
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return 3
|
||||
return addableAccountTypes.count
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
|
||||
return 52.0
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "SettingsAccountTableViewCell", for: indexPath) as! SettingsAccountTableViewCell
|
||||
|
||||
switch addableAccountTypes[indexPath.row] {
|
||||
case .onMyMac:
|
||||
cell.accountNameLabel?.text = Account.defaultLocalAccountName
|
||||
cell.accountImage?.image = AppAssets.image(for: .onMyMac)
|
||||
case .feedbin:
|
||||
cell.accountNameLabel?.text = NSLocalizedString("Feedbin", comment: "Feedbin")
|
||||
cell.accountImage?.image = AppAssets.accountFeedbinImage
|
||||
case .feedWrangler:
|
||||
cell.accountNameLabel?.text = NSLocalizedString("Feed Wrangler", comment: "Feed Wrangler")
|
||||
cell.accountImage?.image = AppAssets.accountFeedWranglerImage
|
||||
case .feedly:
|
||||
cell.accountNameLabel?.text = NSLocalizedString("Feedly", comment: "Feedly")
|
||||
cell.accountImage?.image = AppAssets.accountFeedlyImage
|
||||
case .newsBlur:
|
||||
cell.accountNameLabel?.text = NSLocalizedString("NewsBlur", comment: "NewsBlur")
|
||||
cell.accountImage?.image = AppAssets.accountNewsBlurImage
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
return cell
|
||||
}
|
||||
#endif
|
||||
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
switch indexPath.row {
|
||||
case 0:
|
||||
switch addableAccountTypes[indexPath.row] {
|
||||
case .onMyMac:
|
||||
let navController = UIStoryboard.account.instantiateViewController(withIdentifier: "AddLocalAccountNavigationViewController") as! UINavigationController
|
||||
navController.modalPresentationStyle = .currentContext
|
||||
let addViewController = navController.topViewController as! LocalAccountViewController
|
||||
addViewController.delegate = self
|
||||
present(navController, animated: true)
|
||||
case 1:
|
||||
case .feedbin:
|
||||
let navController = UIStoryboard.account.instantiateViewController(withIdentifier: "FeedbinAccountNavigationViewController") as! UINavigationController
|
||||
navController.modalPresentationStyle = .currentContext
|
||||
let addViewController = navController.topViewController as! FeedbinAccountViewController
|
||||
addViewController.delegate = self
|
||||
present(navController, animated: true)
|
||||
case 2:
|
||||
case .feedly:
|
||||
let addAccount = OAuthAccountAuthorizationOperation(accountType: .feedly)
|
||||
addAccount.delegate = self
|
||||
addAccount.presentationAnchor = self.view.window!
|
||||
MainThreadOperationQueue.shared.add(addAccount)
|
||||
case 3:
|
||||
case .feedWrangler:
|
||||
let navController = UIStoryboard.account.instantiateViewController(withIdentifier: "FeedWranglerAccountNavigationViewController") as! UINavigationController
|
||||
navController.modalPresentationStyle = .currentContext
|
||||
let addViewController = navController.topViewController as! FeedWranglerAccountViewController
|
||||
addViewController.delegate = self
|
||||
present(navController, animated: true)
|
||||
case 4:
|
||||
case .newsBlur:
|
||||
let navController = UIStoryboard.account.instantiateViewController(withIdentifier: "NewsBlurAccountNavigationViewController") as! UINavigationController
|
||||
navController.modalPresentationStyle = .currentContext
|
||||
let addViewController = navController.topViewController as! NewsBlurAccountViewController
|
||||
@@ -97,3 +131,28 @@ 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.isDeveloperBuild {
|
||||
removeAccountType(.cloudKit)
|
||||
removeAccountType(.feedly)
|
||||
removeAccountType(.feedWrangler)
|
||||
return
|
||||
}
|
||||
|
||||
if AccountManager.shared.activeAccounts.firstIndex(where: { $0.type == .cloudKit }) != nil {
|
||||
removeAccountType(.cloudKit)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user