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:
@@ -21,23 +21,23 @@ class AccountInspectorViewController: UITableViewController {
|
||||
|
||||
var isModal = false
|
||||
weak var account: Account?
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
|
||||
guard let account = account else { return }
|
||||
|
||||
|
||||
nameTextField.placeholder = account.defaultName
|
||||
nameTextField.text = account.name
|
||||
nameTextField.delegate = self
|
||||
activeSwitch.isOn = account.isActive
|
||||
|
||||
|
||||
navigationItem.title = account.nameForDisplay
|
||||
|
||||
|
||||
if account.type != .onMyMac {
|
||||
deleteAccountButton.setTitle(NSLocalizedString("Remove Account", comment: "Remove Account"), for: .normal)
|
||||
deleteAccountButton.setTitle(NSLocalizedString("Remove Account", comment: "Remove Account"), for: .normal)
|
||||
}
|
||||
|
||||
|
||||
if account.type != .cloudKit {
|
||||
limitationsAndSolutionsButton.isHidden = true
|
||||
}
|
||||
@@ -46,11 +46,11 @@ class AccountInspectorViewController: UITableViewController {
|
||||
let doneBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(done))
|
||||
navigationItem.leftBarButtonItem = doneBarButtonItem
|
||||
}
|
||||
|
||||
|
||||
tableView.register(ImageHeaderView.self, forHeaderFooterViewReuseIdentifier: "SectionHeader")
|
||||
|
||||
}
|
||||
|
||||
|
||||
override func viewWillDisappear(_ animated: Bool) {
|
||||
account?.name = nameTextField.text
|
||||
account?.isActive = activeSwitch.isOn
|
||||
@@ -59,7 +59,7 @@ class AccountInspectorViewController: UITableViewController {
|
||||
@objc func done() {
|
||||
dismiss(animated: true)
|
||||
}
|
||||
|
||||
|
||||
@IBAction func credentials(_ sender: Any) {
|
||||
guard let account = account else { return }
|
||||
switch account.type {
|
||||
@@ -86,12 +86,12 @@ class AccountInspectorViewController: UITableViewController {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@IBAction func deleteAccount(_ sender: Any) {
|
||||
guard let account = account else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
let title = NSLocalizedString("Remove Account", comment: "Remove Account")
|
||||
let message: String = {
|
||||
switch account.type {
|
||||
@@ -105,9 +105,9 @@ class AccountInspectorViewController: UITableViewController {
|
||||
let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel")
|
||||
let cancelAction = UIAlertAction(title: cancelTitle, style: .cancel)
|
||||
alertController.addAction(cancelAction)
|
||||
|
||||
|
||||
let markTitle = NSLocalizedString("Remove", comment: "Remove")
|
||||
let markAction = UIAlertAction(title: markTitle, style: .default) { [weak self] (action) in
|
||||
let markAction = UIAlertAction(title: markTitle, style: .default) { [weak self] (_) in
|
||||
guard let self = self, let account = self.account else { return }
|
||||
AccountManager.shared.deleteAccount(account)
|
||||
if self.isModal {
|
||||
@@ -118,7 +118,7 @@ class AccountInspectorViewController: UITableViewController {
|
||||
}
|
||||
alertController.addAction(markAction)
|
||||
alertController.preferredAction = markAction
|
||||
|
||||
|
||||
present(alertController, animated: true)
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ class AccountInspectorViewController: UITableViewController {
|
||||
// MARK: Table View
|
||||
|
||||
extension AccountInspectorViewController {
|
||||
|
||||
|
||||
var hidesCredentialsSection: Bool {
|
||||
guard let account = account else {
|
||||
return true
|
||||
@@ -147,7 +147,7 @@ extension AccountInspectorViewController {
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int {
|
||||
guard let account = account else { return 0 }
|
||||
|
||||
|
||||
if account == AccountManager.shared.defaultAccount {
|
||||
return 1
|
||||
} else if hidesCredentialsSection {
|
||||
@@ -156,11 +156,11 @@ extension AccountInspectorViewController {
|
||||
return super.numberOfSections(in: tableView)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
||||
return section == 0 ? ImageHeaderView.rowHeight : super.tableView(tableView, heightForHeaderInSection: section)
|
||||
}
|
||||
|
||||
|
||||
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
||||
guard let account = account else { return nil }
|
||||
|
||||
@@ -172,16 +172,16 @@ extension AccountInspectorViewController {
|
||||
return super.tableView(tableView, viewForHeaderInSection: section)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell: UITableViewCell
|
||||
|
||||
|
||||
if indexPath.section == 1, hidesCredentialsSection {
|
||||
cell = super.tableView(tableView, cellForRowAt: IndexPath(row: 0, section: 2))
|
||||
} else {
|
||||
cell = super.tableView(tableView, cellForRowAt: indexPath)
|
||||
}
|
||||
|
||||
|
||||
return cell
|
||||
}
|
||||
|
||||
@@ -191,17 +191,17 @@ extension AccountInspectorViewController {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
tableView.selectRow(at: nil, animated: true, scrollPosition: .none)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// MARK: UITextFieldDelegate
|
||||
|
||||
extension AccountInspectorViewController: UITextFieldDelegate {
|
||||
|
||||
|
||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
textField.resignFirstResponder()
|
||||
return true
|
||||
|
||||
@@ -12,52 +12,52 @@ import SafariServices
|
||||
import UserNotifications
|
||||
|
||||
class FeedInspectorViewController: UITableViewController {
|
||||
|
||||
|
||||
static let preferredContentSizeForFormSheetDisplay = CGSize(width: 460.0, height: 500.0)
|
||||
|
||||
|
||||
var feed: Feed!
|
||||
@IBOutlet weak var nameTextField: UITextField!
|
||||
@IBOutlet weak var notifyAboutNewArticlesSwitch: UISwitch!
|
||||
@IBOutlet weak var alwaysShowReaderViewSwitch: UISwitch!
|
||||
@IBOutlet weak var homePageLabel: InteractiveLabel!
|
||||
@IBOutlet weak var feedURLLabel: InteractiveLabel!
|
||||
|
||||
|
||||
private var headerView: InspectorIconHeaderView?
|
||||
private var iconImage: IconImage? {
|
||||
return IconImageCache.shared.imageForFeed(feed)
|
||||
}
|
||||
|
||||
|
||||
private let homePageIndexPath = IndexPath(row: 0, section: 1)
|
||||
|
||||
|
||||
private var shouldHideHomePageSection: Bool {
|
||||
return feed.homePageURL == nil
|
||||
}
|
||||
|
||||
|
||||
private var userNotificationSettings: UNNotificationSettings?
|
||||
|
||||
|
||||
override func viewDidLoad() {
|
||||
tableView.register(InspectorIconHeaderView.self, forHeaderFooterViewReuseIdentifier: "SectionHeader")
|
||||
|
||||
|
||||
navigationItem.title = feed.nameForDisplay
|
||||
nameTextField.text = feed.nameForDisplay
|
||||
|
||||
|
||||
notifyAboutNewArticlesSwitch.setOn(feed.isNotifyAboutNewArticles ?? false, animated: false)
|
||||
|
||||
|
||||
alwaysShowReaderViewSwitch.setOn(feed.isArticleExtractorAlwaysOn ?? false, animated: false)
|
||||
|
||||
homePageLabel.text = feed.homePageURL
|
||||
feedURLLabel.text = feed.url
|
||||
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(feedIconDidBecomeAvailable(_:)), name: .feedIconDidBecomeAvailable, object: nil)
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(updateNotificationSettings), name: UIApplication.willEnterForegroundNotification, object: nil)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
updateNotificationSettings()
|
||||
}
|
||||
|
||||
|
||||
override func viewDidDisappear(_ animated: Bool) {
|
||||
if nameTextField.text != feed.nameForDisplay {
|
||||
let nameText = nameTextField.text ?? ""
|
||||
@@ -65,12 +65,12 @@ class FeedInspectorViewController: UITableViewController {
|
||||
feed.rename(to: newName) { _ in }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: Notifications
|
||||
@objc func feedIconDidBecomeAvailable(_ notification: Notification) {
|
||||
headerView?.iconView.iconImage = iconImage
|
||||
}
|
||||
|
||||
|
||||
@IBAction func notifyAboutNewArticlesChanged(_ sender: Any) {
|
||||
guard let settings = userNotificationSettings else {
|
||||
notifyAboutNewArticlesSwitch.isOn = !notifyAboutNewArticlesSwitch.isOn
|
||||
@@ -82,7 +82,7 @@ class FeedInspectorViewController: UITableViewController {
|
||||
} else if settings.authorizationStatus == .authorized {
|
||||
feed.isNotifyAboutNewArticles = notifyAboutNewArticlesSwitch.isOn
|
||||
} else {
|
||||
UNUserNotificationCenter.current().requestAuthorization(options:[.badge, .sound, .alert]) { (granted, error) in
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, _) in
|
||||
self.updateNotificationSettings()
|
||||
if granted {
|
||||
DispatchQueue.main.async {
|
||||
@@ -97,22 +97,22 @@ class FeedInspectorViewController: UITableViewController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@IBAction func alwaysShowReaderViewChanged(_ sender: Any) {
|
||||
feed.isArticleExtractorAlwaysOn = alwaysShowReaderViewSwitch.isOn
|
||||
}
|
||||
|
||||
|
||||
@IBAction func done(_ sender: Any) {
|
||||
dismiss(animated: true)
|
||||
}
|
||||
|
||||
|
||||
/// Returns a new indexPath, taking into consideration any
|
||||
/// conditions that may require the tableView to be
|
||||
/// displayed differently than what is setup in the storyboard.
|
||||
private func shift(_ indexPath: IndexPath) -> IndexPath {
|
||||
return IndexPath(row: indexPath.row, section: shift(indexPath.section))
|
||||
}
|
||||
|
||||
|
||||
/// Returns a new section, taking into consideration any
|
||||
/// conditions that may require the tableView to be
|
||||
/// displayed differently than what is setup in the storyboard.
|
||||
@@ -123,7 +123,6 @@ class FeedInspectorViewController: UITableViewController {
|
||||
return section
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// MARK: Table View
|
||||
@@ -134,15 +133,15 @@ extension FeedInspectorViewController {
|
||||
let numberOfSections = super.numberOfSections(in: tableView)
|
||||
return shouldHideHomePageSection ? numberOfSections - 1 : numberOfSections
|
||||
}
|
||||
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
return super.tableView(tableView, numberOfRowsInSection: shift(section))
|
||||
}
|
||||
|
||||
|
||||
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
|
||||
return section == 0 ? ImageHeaderView.rowHeight : super.tableView(tableView, heightForHeaderInSection: shift(section))
|
||||
}
|
||||
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell = super.tableView(tableView, cellForRowAt: shift(indexPath))
|
||||
if indexPath.section == 0 && indexPath.row == 1 {
|
||||
@@ -154,11 +153,11 @@ extension FeedInspectorViewController {
|
||||
}
|
||||
return cell
|
||||
}
|
||||
|
||||
|
||||
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
||||
super.tableView(tableView, titleForHeaderInSection: shift(section))
|
||||
}
|
||||
|
||||
|
||||
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
|
||||
if shift(section) == 0 {
|
||||
headerView = tableView.dequeueReusableHeaderFooterView(withIdentifier: "SectionHeader") as? InspectorIconHeaderView
|
||||
@@ -168,12 +167,12 @@ extension FeedInspectorViewController {
|
||||
return super.tableView(tableView, viewForHeaderInSection: shift(section))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
|
||||
if shift(indexPath) == homePageIndexPath,
|
||||
let homePageUrlString = feed.homePageURL,
|
||||
let homePageUrl = URL(string: homePageUrlString) {
|
||||
|
||||
|
||||
let safari = SFSafariViewController(url: homePageUrl)
|
||||
safari.modalPresentationStyle = .pageSheet
|
||||
present(safari, animated: true) {
|
||||
@@ -181,24 +180,24 @@ extension FeedInspectorViewController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// MARK: UITextFieldDelegate
|
||||
|
||||
extension FeedInspectorViewController: UITextFieldDelegate {
|
||||
|
||||
|
||||
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
|
||||
textField.resignFirstResponder()
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// MARK: UNUserNotificationCenter
|
||||
|
||||
extension FeedInspectorViewController {
|
||||
|
||||
|
||||
@objc
|
||||
func updateNotificationSettings() {
|
||||
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
|
||||
@@ -210,12 +209,12 @@ extension FeedInspectorViewController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func notificationUpdateErrorAlert() -> UIAlertController {
|
||||
let alert = UIAlertController(title: NSLocalizedString("Enable Notifications", comment: "Notifications"),
|
||||
message: NSLocalizedString("Notifications need to be enabled in the Settings app.", comment: "Notifications need to be enabled in the Settings app."), preferredStyle: .alert)
|
||||
let openSettings = UIAlertAction(title: NSLocalizedString("Open Settings", comment: "Open Settings"), style: .default) { (action) in
|
||||
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [UIApplication.OpenExternalURLOptionsKey.universalLinksOnly : false], completionHandler: nil)
|
||||
let openSettings = UIAlertAction(title: NSLocalizedString("Open Settings", comment: "Open Settings"), style: .default) { (_) in
|
||||
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!, options: [UIApplication.OpenExternalURLOptionsKey.universalLinksOnly: false], completionHandler: nil)
|
||||
}
|
||||
let dismiss = UIAlertAction(title: NSLocalizedString("Dismiss", comment: "Dismiss"), style: .cancel, handler: nil)
|
||||
alert.addAction(openSettings)
|
||||
@@ -223,5 +222,5 @@ extension FeedInspectorViewController {
|
||||
alert.preferredAction = openSettings
|
||||
return alert
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,17 +11,17 @@ import UIKit
|
||||
class InspectorIconHeaderView: UITableViewHeaderFooterView {
|
||||
|
||||
var iconView = IconView()
|
||||
|
||||
|
||||
override init(reuseIdentifier: String?) {
|
||||
super.init(reuseIdentifier: reuseIdentifier)
|
||||
commonInit()
|
||||
}
|
||||
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
super.init(coder: coder)
|
||||
commonInit()
|
||||
}
|
||||
|
||||
|
||||
func commonInit() {
|
||||
addSubview(iconView)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user