2020-04-16 15:25:40 +02:00
|
|
|
//
|
|
|
|
// AddExtensionPointViewController.swift
|
|
|
|
// NetNewsWire-iOS
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 4/16/20.
|
|
|
|
// Copyright © 2020 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
|
|
|
protocol AddExtensionPointDismissDelegate: UIViewController {
|
|
|
|
func dismiss()
|
|
|
|
}
|
|
|
|
|
|
|
|
class AddExtensionPointViewController: UITableViewController, AddExtensionPointDismissDelegate {
|
|
|
|
|
|
|
|
private var availableExtensionPointTypes = [ExtensionPoint.Type]()
|
|
|
|
|
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
2020-08-12 17:27:58 +02:00
|
|
|
availableExtensionPointTypes = ExtensionPointManager.shared.availableExtensionPointTypes.sorted(by: { $0.title < $1.title })
|
2020-04-16 15:25:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
override func numberOfSections(in tableView: UITableView) -> Int {
|
|
|
|
1
|
|
|
|
}
|
|
|
|
|
|
|
|
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
|
|
|
return availableExtensionPointTypes.count
|
|
|
|
}
|
|
|
|
|
|
|
|
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
|
|
|
let cell = tableView.dequeueReusableCell(withIdentifier: "SettingsExtensionTableViewCell", for: indexPath) as! SettingsComboTableViewCell
|
|
|
|
|
|
|
|
let extensionPointType = availableExtensionPointTypes[indexPath.row]
|
|
|
|
cell.comboNameLabel?.text = extensionPointType.title
|
2020-10-30 23:10:24 +01:00
|
|
|
cell.comboImage?.image = extensionPointType.image
|
2020-04-16 15:25:40 +02:00
|
|
|
|
|
|
|
return cell
|
|
|
|
}
|
|
|
|
|
2020-10-27 20:25:45 +01:00
|
|
|
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
|
|
|
return NSLocalizedString("Feed Provider", comment: "Feed Provider Header")
|
|
|
|
}
|
|
|
|
|
|
|
|
override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
|
2021-05-17 05:22:15 +02:00
|
|
|
return NSLocalizedString("Feed Providers allow you to subscribe to some pages as if they were RSS feeds.", comment: "Feed Provider Footer")
|
2020-10-27 20:25:45 +01:00
|
|
|
}
|
|
|
|
|
2020-04-16 15:25:40 +02:00
|
|
|
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
|
|
|
let navController = UIStoryboard.settings.instantiateViewController(withIdentifier: "EnableExtensionPointNavigationViewController") as! UINavigationController
|
|
|
|
navController.modalPresentationStyle = .currentContext
|
|
|
|
let enableViewController = navController.topViewController as! EnableExtensionPointViewController
|
|
|
|
enableViewController.delegate = self
|
|
|
|
enableViewController.extensionPointType = availableExtensionPointTypes[indexPath.row]
|
|
|
|
present(navController, animated: true)
|
|
|
|
}
|
|
|
|
|
|
|
|
func dismiss() {
|
|
|
|
navigationController?.popViewController(animated: false)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|