Remove some no-longer-needed #available checks.

This commit is contained in:
Brent Simmons 2024-02-27 20:13:00 -08:00
parent 22f3fb62f8
commit 565b3ac2c3
5 changed files with 45 additions and 97 deletions

View File

@ -191,15 +191,16 @@ private extension FeedTableViewCell {
} }
func addDisclosureView() { func addDisclosureView() {
disclosureButton = NonIntrinsicButton(type: .roundedRect) disclosureButton = NonIntrinsicButton(type: .roundedRect)
disclosureButton!.addTarget(self, action: #selector(buttonPressed(_:)), for: UIControl.Event.touchUpInside) disclosureButton!.addTarget(self, action: #selector(buttonPressed(_:)), for: UIControl.Event.touchUpInside)
disclosureButton?.setImage(AppAssets.disclosureImage, for: .normal) disclosureButton?.setImage(AppAssets.disclosureImage, for: .normal)
disclosureButton?.tintColor = AppAssets.controlBackgroundColor disclosureButton?.tintColor = AppAssets.controlBackgroundColor
disclosureButton?.imageView?.contentMode = .center disclosureButton?.imageView?.contentMode = .center
disclosureButton?.imageView?.clipsToBounds = false disclosureButton?.imageView?.clipsToBounds = false
if #available(iOS 13.4, *) {
disclosureButton?.addInteraction(UIPointerInteraction()) disclosureButton?.addInteraction(UIPointerInteraction())
}
addSubviewAtInit(disclosureButton!) addSubviewAtInit(disclosureButton!)
} }

View File

@ -84,14 +84,15 @@ class FeedTableViewSectionHeader: UITableViewHeaderFooterView {
private let unreadCountView = FeedUnreadCountView(frame: CGRect.zero) private let unreadCountView = FeedUnreadCountView(frame: CGRect.zero)
private lazy var disclosureButton: UIButton = { private lazy var disclosureButton: UIButton = {
let button = NonIntrinsicButton() let button = NonIntrinsicButton()
button.tintColor = UIColor.tertiaryLabel button.tintColor = UIColor.tertiaryLabel
button.setImage(AppAssets.disclosureImage, for: .normal) button.setImage(AppAssets.disclosureImage, for: .normal)
button.contentMode = .center button.contentMode = .center
if #available(iOS 13.4, *) {
button.addInteraction(UIPointerInteraction()) button.addInteraction(UIPointerInteraction())
}
button.addTarget(self, action: #selector(toggleDisclosure), for: .touchUpInside) button.addTarget(self, action: #selector(toggleDisclosure), for: .touchUpInside)
return button return button
}() }()

View File

@ -19,11 +19,7 @@ class FeedsViewController: UITableViewController, UndoableCommandRunner {
private var refreshProgressView: RefreshProgressView? private var refreshProgressView: RefreshProgressView?
@IBOutlet weak var addNewItemButton: UIBarButtonItem! { @IBOutlet weak var addNewItemButton: UIBarButtonItem! {
didSet { didSet {
if #available(iOS 14, *) {
addNewItemButton.primaryAction = nil addNewItemButton.primaryAction = nil
} else {
addNewItemButton.action = #selector(FeedsViewController.add(_:))
}
} }
} }
@ -428,40 +424,6 @@ class FeedsViewController: UITableViewController, UndoableCommandRunner {
coordinator.toggleReadFeedsFilter() coordinator.toggleReadFeedsFilter()
} }
@IBAction func add(_ sender: UIBarButtonItem) {
if #available(iOS 14, *) {
} else {
let title = NSLocalizedString("Add Item", comment: "Add Item")
let alertController = UIAlertController(title: title, message: nil, preferredStyle: .actionSheet)
let cancelTitle = NSLocalizedString("Cancel", comment: "Cancel")
let cancelAction = UIAlertAction(title: cancelTitle, style: .cancel)
let addFeedActionTitle = NSLocalizedString("Add Web Feed", comment: "Add Web Feed")
let addFeedAction = UIAlertAction(title: addFeedActionTitle, style: .default) { _ in
self.coordinator.showAddFeed()
}
let addFolderActionTitle = NSLocalizedString("Add Folder", comment: "Add Folder")
let addFolderAction = UIAlertAction(title: addFolderActionTitle, style: .default) { _ in
self.coordinator.showAddFolder()
}
alertController.addAction(addFeedAction)
alertController.addAction(addFolderAction)
alertController.addAction(cancelAction)
alertController.popoverPresentationController?.barButtonItem = sender
present(alertController, animated: true)
}
}
@objc func toggleSectionHeader(_ sender: UITapGestureRecognizer) { @objc func toggleSectionHeader(_ sender: UITapGestureRecognizer) {
guard let headerView = sender.view as? FeedTableViewSectionHeader else { guard let headerView = sender.view as? FeedTableViewSectionHeader else {
return return
@ -622,9 +584,7 @@ class FeedsViewController: UITableViewController, UndoableCommandRunner {
configureContextMenu() configureContextMenu()
} }
@objc @objc func configureContextMenu(_: Any? = nil) {
func configureContextMenu(_: Any? = nil) {
if #available(iOS 14.0, *) {
/* /*
Context Menu Order: Context Menu Order:
@ -651,7 +611,6 @@ class FeedsViewController: UITableViewController, UndoableCommandRunner {
self.addNewItemButton.menu = contextMenu self.addNewItemButton.menu = contextMenu
} }
}
func focus() { func focus() {
becomeFirstResponder() becomeFirstResponder()

View File

@ -34,19 +34,14 @@ class TimelineTitleView: UIView {
func buttonize() { func buttonize() {
heightAnchor.constraint(equalToConstant: 40.0).isActive = true heightAnchor.constraint(equalToConstant: 40.0).isActive = true
accessibilityTraits = .button accessibilityTraits = .button
if #available(iOS 13.4, *) {
addInteraction(pointerInteraction) addInteraction(pointerInteraction)
} }
}
func debuttonize() { func debuttonize() {
heightAnchor.constraint(equalToConstant: 40.0).isActive = true heightAnchor.constraint(equalToConstant: 40.0).isActive = true
accessibilityTraits.remove(.button) accessibilityTraits.remove(.button)
if #available(iOS 13.4, *) {
removeInteraction(pointerInteraction) removeInteraction(pointerInteraction)
} }
}
} }
extension TimelineTitleView: UIPointerInteractionDelegate { extension TimelineTitleView: UIPointerInteractionDelegate {
@ -58,5 +53,4 @@ extension TimelineTitleView: UIPointerInteractionDelegate {
return UIPointerStyle(effect: .automatic(UITargetedPreview(view: self)), shape: .roundedRect(rect)) return UIPointerStyle(effect: .automatic(UITargetedPreview(view: self)), shape: .roundedRect(rect))
} }
} }

View File

@ -101,15 +101,12 @@ class TimelineViewController: UITableViewController, UndoableCommandRunner {
} }
// Disable swipe back on iPad Mice // Disable swipe back on iPad Mice
if #available(iOS 13.4, *) {
guard let gesture = self.navigationController?.interactivePopGestureRecognizer as? UIPanGestureRecognizer else { guard let gesture = self.navigationController?.interactivePopGestureRecognizer as? UIPanGestureRecognizer else {
return return
} }
gesture.allowedScrollTypesMask = [] gesture.allowedScrollTypesMask = []
} }
}
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
// If the nav bar is hidden, fade it in to avoid it showing stuff as it is getting laid out // If the nav bar is hidden, fade it in to avoid it showing stuff as it is getting laid out
if navigationController?.navigationBar.isHidden ?? false { if navigationController?.navigationBar.isHidden ?? false {
@ -525,12 +522,7 @@ class TimelineViewController: UITableViewController, UndoableCommandRunner {
} }
@objc private func reloadAllVisibleCells() { @objc private func reloadAllVisibleCells() {
if #available(iOS 15, *) {
reconfigureCells(coordinator.articles) reconfigureCells(coordinator.articles)
} else {
let visibleArticles = tableView.indexPathsForVisibleRows!.compactMap { return dataSource.itemIdentifier(for: $0) }
reloadCells(visibleArticles)
}
} }
private func reloadCells(_ articles: [Article]) { private func reloadCells(_ articles: [Article]) {
@ -542,9 +534,10 @@ class TimelineViewController: UITableViewController, UndoableCommandRunner {
} }
private func reconfigureCells(_ articles: [Article]) { private func reconfigureCells(_ articles: [Article]) {
guard #available(iOS 15, *) else { return }
var snapshot = dataSource.snapshot() var snapshot = dataSource.snapshot()
snapshot.reconfigureItems(articles) snapshot.reconfigureItems(articles)
dataSource.apply(snapshot, animatingDifferences: false) { [weak self] in dataSource.apply(snapshot, animatingDifferences: false) { [weak self] in
self?.restoreSelectionIfNecessary(adjustScroll: false) self?.restoreSelectionIfNecessary(adjustScroll: false)
} }