mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2025-08-12 06:26:36 +00:00
Fix lint issues.
This commit is contained in:
@@ -12,10 +12,10 @@ class AddComboTableViewCell: VibrantTableViewCell {
|
||||
|
||||
@IBOutlet weak var icon: UIImageView!
|
||||
@IBOutlet weak var label: UILabel!
|
||||
|
||||
|
||||
override func updateVibrancy(animated: Bool) {
|
||||
super.updateVibrancy(animated: animated)
|
||||
|
||||
|
||||
let iconTintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : AppAssets.secondaryAccentColor
|
||||
if animated {
|
||||
UIView.animate(withDuration: Self.duration) {
|
||||
@@ -26,5 +26,5 @@ class AddComboTableViewCell: VibrantTableViewCell {
|
||||
}
|
||||
updateLabelVibrancy(label, color: labelColor, animated: animated)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,15 +15,15 @@ protocol AddFeedFolderViewControllerDelegate {
|
||||
}
|
||||
|
||||
class AddFeedFolderViewController: UITableViewController {
|
||||
|
||||
|
||||
var delegate: AddFeedFolderViewControllerDelegate?
|
||||
var initialContainer: Container?
|
||||
|
||||
|
||||
var containers = [Container]()
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
|
||||
let sortedActiveAccounts = AccountManager.shared.sortedActiveAccounts
|
||||
|
||||
for account in sortedActiveAccounts {
|
||||
@@ -53,15 +53,15 @@ class AddFeedFolderViewController: UITableViewController {
|
||||
return tableView.dequeueReusableCell(withIdentifier: "FolderCell", for: indexPath) as! AddComboTableViewCell
|
||||
}
|
||||
}()
|
||||
|
||||
|
||||
if let smallIconProvider = container as? SmallIconProvider {
|
||||
cell.icon?.image = smallIconProvider.smallIcon?.image
|
||||
}
|
||||
|
||||
|
||||
if let displayNameProvider = container as? DisplayNameProvider {
|
||||
cell.label?.text = displayNameProvider.nameForDisplay
|
||||
}
|
||||
|
||||
|
||||
if let compContainer = initialContainer, container === compContainer {
|
||||
cell.accessoryType = .checkmark
|
||||
} else {
|
||||
@@ -73,7 +73,7 @@ class AddFeedFolderViewController: UITableViewController {
|
||||
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
let container = containers[indexPath.row]
|
||||
|
||||
|
||||
if let account = container as? Account, account.behaviors.contains(.disallowFeedInRootFolder) {
|
||||
tableView.selectRow(at: nil, animated: false, scrollPosition: .none)
|
||||
} else {
|
||||
@@ -83,19 +83,19 @@ class AddFeedFolderViewController: UITableViewController {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: Actions
|
||||
|
||||
|
||||
@IBAction func cancel(_ sender: Any) {
|
||||
dismiss()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private extension AddFeedFolderViewController {
|
||||
|
||||
|
||||
func dismiss() {
|
||||
dismiss(animated: true)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
import UIKit
|
||||
|
||||
class AddFeedSelectFolderTableViewCell: VibrantTableViewCell {
|
||||
|
||||
|
||||
@IBOutlet weak var folderLabel: UILabel!
|
||||
@IBOutlet weak var detailLabel: UILabel!
|
||||
|
||||
|
||||
override func updateVibrancy(animated: Bool) {
|
||||
super.updateVibrancy(animated: animated)
|
||||
updateLabelVibrancy(folderLabel, color: labelColor, animated: animated)
|
||||
updateLabelVibrancy(detailLabel, color: labelColor, animated: animated)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ class AddFeedViewController: UITableViewController {
|
||||
@IBOutlet weak var urlTextField: UITextField!
|
||||
@IBOutlet weak var urlTextFieldToSuperViewConstraint: NSLayoutConstraint!
|
||||
@IBOutlet weak var nameTextField: UITextField!
|
||||
|
||||
|
||||
static let preferredContentSizeForFormSheetDisplay = CGSize(width: 460.0, height: 400.0)
|
||||
|
||||
|
||||
private var folderLabel = ""
|
||||
private var userCancelled = false
|
||||
|
||||
@@ -29,88 +29,88 @@ class AddFeedViewController: UITableViewController {
|
||||
var initialFeedName: String?
|
||||
|
||||
var container: Container?
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
activityIndicator.isHidden = true
|
||||
activityIndicator.color = .label
|
||||
|
||||
|
||||
if initialFeed == nil, let urlString = UIPasteboard.general.string {
|
||||
if urlString.mayBeURL {
|
||||
initialFeed = urlString.normalizedURL
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
urlTextField.autocorrectionType = .no
|
||||
urlTextField.autocapitalizationType = .none
|
||||
urlTextField.text = initialFeed
|
||||
urlTextField.delegate = self
|
||||
|
||||
|
||||
if initialFeed != nil {
|
||||
addButton.isEnabled = true
|
||||
}
|
||||
|
||||
|
||||
nameTextField.text = initialFeedName
|
||||
nameTextField.delegate = self
|
||||
|
||||
|
||||
if let defaultContainer = AddFeedDefaultContainer.defaultContainer {
|
||||
container = defaultContainer
|
||||
} else {
|
||||
addButton.isEnabled = false
|
||||
}
|
||||
|
||||
|
||||
updateFolderLabel()
|
||||
|
||||
|
||||
tableView.register(UINib(nibName: "AddFeedSelectFolderTableViewCell", bundle: nil), forCellReuseIdentifier: "AddFeedSelectFolderTableViewCell")
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(textDidChange(_:)), name: UITextField.textDidChangeNotification, object: urlTextField)
|
||||
|
||||
|
||||
if initialFeed == nil {
|
||||
urlTextField.becomeFirstResponder()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@IBAction func cancel(_ sender: Any) {
|
||||
userCancelled = true
|
||||
dismiss(animated: true)
|
||||
}
|
||||
|
||||
|
||||
@IBAction func add(_ sender: Any) {
|
||||
|
||||
let urlString = urlTextField.text ?? ""
|
||||
let normalizedURLString = urlString.normalizedURL
|
||||
|
||||
|
||||
guard !normalizedURLString.isEmpty, let url = URL(string: normalizedURLString) else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
guard let container = container else { return }
|
||||
|
||||
|
||||
var account: Account?
|
||||
if let containerAccount = container as? Account {
|
||||
account = containerAccount
|
||||
} else if let containerFolder = container as? Folder, let containerAccount = containerFolder.account {
|
||||
account = containerAccount
|
||||
}
|
||||
|
||||
|
||||
if account!.hasFeed(withURL: url.absoluteString) {
|
||||
presentError(AccountError.createErrorAlreadySubscribed)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
addButton.isEnabled = false
|
||||
activityIndicator.isHidden = false
|
||||
activityIndicator.startAnimating()
|
||||
|
||||
|
||||
let feedName = (nameTextField.text?.isEmpty ?? true) ? nil : nameTextField.text
|
||||
|
||||
|
||||
BatchUpdate.shared.start()
|
||||
|
||||
|
||||
account!.createFeed(url: url.absoluteString, name: feedName, container: container, validateFeed: true) { result in
|
||||
|
||||
BatchUpdate.shared.end()
|
||||
|
||||
|
||||
switch result {
|
||||
case .success(let feed):
|
||||
self.dismiss(animated: true)
|
||||
@@ -125,11 +125,11 @@ class AddFeedViewController: UITableViewController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@objc func textDidChange(_ note: Notification) {
|
||||
updateUI()
|
||||
}
|
||||
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
if indexPath.row == 2 {
|
||||
let cell = tableView.dequeueReusableCell(withIdentifier: "AddFeedSelectFolderTableViewCell", for: indexPath) as? AddFeedSelectFolderTableViewCell
|
||||
@@ -139,7 +139,7 @@ class AddFeedViewController: UITableViewController {
|
||||
return super.tableView(tableView, cellForRowAt: indexPath)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
if indexPath.row == 2 {
|
||||
let navController = UIStoryboard.add.instantiateViewController(withIdentifier: "AddFeedFolderNavViewController") as! UINavigationController
|
||||
@@ -150,7 +150,7 @@ class AddFeedViewController: UITableViewController {
|
||||
present(navController, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// MARK: AddFeedFolderViewControllerDelegate
|
||||
@@ -166,22 +166,22 @@ extension AddFeedViewController: AddFeedFolderViewControllerDelegate {
|
||||
// MARK: UITextFieldDelegate
|
||||
|
||||
extension AddFeedViewController: UITextFieldDelegate {
|
||||
|
||||
|
||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
textField.resignFirstResponder()
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// MARK: Private
|
||||
|
||||
private extension AddFeedViewController {
|
||||
|
||||
|
||||
func updateUI() {
|
||||
addButton.isEnabled = (urlTextField.text?.mayBeURL ?? false)
|
||||
}
|
||||
|
||||
|
||||
func updateFolderLabel() {
|
||||
if let containerName = (container as? DisplayNameProvider)?.nameForDisplay {
|
||||
if container is Folder {
|
||||
|
||||
@@ -16,13 +16,13 @@ class AddFolderViewController: UITableViewController {
|
||||
@IBOutlet private weak var nameTextField: UITextField!
|
||||
@IBOutlet private weak var accountLabel: UILabel!
|
||||
@IBOutlet private weak var accountPickerView: UIPickerView!
|
||||
|
||||
|
||||
static let preferredContentSizeForFormSheetDisplay = CGSize(width: 460.0, height: 400.0)
|
||||
|
||||
|
||||
private var shouldDisplayPicker: Bool {
|
||||
return accounts.count > 1
|
||||
}
|
||||
|
||||
|
||||
private var accounts: [Account]! {
|
||||
didSet {
|
||||
if let predefinedAccount = accounts.first(where: { $0.accountID == AppDefaults.shared.addFolderAccountID }) {
|
||||
@@ -39,33 +39,33 @@ class AddFolderViewController: UITableViewController {
|
||||
accountLabel.text = selectedAccount.flatMap { ($0 as DisplayNameProvider).nameForDisplay }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
|
||||
accounts = AccountManager.shared
|
||||
.sortedActiveAccounts
|
||||
.filter { !$0.behaviors.contains(.disallowFolderManagement) }
|
||||
|
||||
|
||||
nameTextField.delegate = self
|
||||
|
||||
|
||||
if shouldDisplayPicker {
|
||||
accountPickerView.dataSource = self
|
||||
accountPickerView.delegate = self
|
||||
|
||||
|
||||
if let index = accounts.firstIndex(of: selectedAccount) {
|
||||
accountPickerView.selectRow(index, inComponent: 0, animated: false)
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
accountPickerView.isHidden = true
|
||||
}
|
||||
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(textDidChange(_:)), name: UITextField.textDidChangeNotification, object: nameTextField)
|
||||
|
||||
|
||||
nameTextField.becomeFirstResponder()
|
||||
}
|
||||
|
||||
|
||||
private func didSelect(_ account: Account) {
|
||||
AppDefaults.shared.addFolderAccountID = account.accountID
|
||||
selectedAccount = account
|
||||
@@ -74,7 +74,7 @@ class AddFolderViewController: UITableViewController {
|
||||
@IBAction func cancel(_ sender: Any) {
|
||||
dismiss(animated: true)
|
||||
}
|
||||
|
||||
|
||||
@IBAction func add(_ sender: Any) {
|
||||
guard let folderName = nameTextField.text else {
|
||||
return
|
||||
@@ -93,42 +93,42 @@ class AddFolderViewController: UITableViewController {
|
||||
@objc func textDidChange(_ note: Notification) {
|
||||
addButton.isEnabled = !(nameTextField.text?.isEmpty ?? false)
|
||||
}
|
||||
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
let defaultNumberOfRows = super.tableView(tableView, numberOfRowsInSection: section)
|
||||
if section == 1 && !shouldDisplayPicker {
|
||||
return defaultNumberOfRows - 1
|
||||
}
|
||||
|
||||
return defaultNumberOfRows
|
||||
|
||||
return defaultNumberOfRows
|
||||
}
|
||||
}
|
||||
|
||||
extension AddFolderViewController: UIPickerViewDataSource, UIPickerViewDelegate {
|
||||
|
||||
func numberOfComponents(in pickerView: UIPickerView) ->Int {
|
||||
|
||||
func numberOfComponents(in pickerView: UIPickerView) -> Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
|
||||
return accounts.count
|
||||
}
|
||||
|
||||
|
||||
func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
|
||||
return (accounts[row] as DisplayNameProvider).nameForDisplay
|
||||
}
|
||||
|
||||
|
||||
func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
|
||||
didSelect(accounts[row])
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
extension AddFolderViewController: UITextFieldDelegate {
|
||||
|
||||
|
||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
textField.resignFirstResponder()
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ class SelectComboTableViewCell: VibrantTableViewCell {
|
||||
|
||||
@IBOutlet weak var icon: UIImageView!
|
||||
@IBOutlet weak var label: UILabel!
|
||||
|
||||
|
||||
override func updateVibrancy(animated: Bool) {
|
||||
super.updateVibrancy(animated: animated)
|
||||
|
||||
|
||||
let iconTintColor = isHighlighted || isSelected ? AppAssets.vibrantTextColor : UIColor.label
|
||||
if animated {
|
||||
UIView.animate(withDuration: Self.duration) {
|
||||
@@ -24,8 +24,8 @@ class SelectComboTableViewCell: VibrantTableViewCell {
|
||||
} else {
|
||||
self.icon.tintColor = iconTintColor
|
||||
}
|
||||
|
||||
|
||||
updateLabelVibrancy(label, color: labelColor, animated: animated)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user