Add contextual menu to copy home page and feed URL. Fixes #5312.

This commit is contained in:
Brent Simmons committed 2026-06-16 21:11:43 -07:00
1 parent 60dcd08e7d
commit 4fc341bc7c
2 files changed
+28 -3

No files matched your search

@@ -22,8 +22,8 @@ final class FeedInspectorViewController: UITableViewController {
@IBOutlet var nameTextField: UITextField!
@IBOutlet var newArticleNotificationsEnabledSwitch: UISwitch!
@IBOutlet var readerViewAlwaysEnabledSwitch: UISwitch!
@IBOutlet var homePageLabel: InteractiveLabel!
@IBOutlet var feedURLLabel: InteractiveLabel!
@IBOutlet var homePageLabel: UILabel!
@IBOutlet var feedURLLabel: UILabel!
private var headerView: InspectorIconHeaderView?
private var iconImage: IconImage? {
@@ -31,6 +31,7 @@ final class FeedInspectorViewController: UITableViewController {
}
private let homePageIndexPath = IndexPath(row: 0, section: 1)
private let feedURLIndexPath = IndexPath(row: 0, section: 2)
private var shouldHideHomePageSection: Bool {
return feed.homePageURL == nil
@@ -181,6 +182,30 @@ extension FeedInspectorViewController {
}
}
override func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
let logicalIndexPath = shift(indexPath)
let title: String
let urlString: String?
if logicalIndexPath == homePageIndexPath {
title = NSLocalizedString("Copy Home Page URL", comment: "Command")
urlString = feed.homePageURL
} else if logicalIndexPath == feedURLIndexPath {
title = NSLocalizedString("Copy Feed URL", comment: "Command")
urlString = feed.url
} else {
return nil
}
guard let urlString else {
return nil
}
return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { _ in
let copyAction = UIAction(title: title, image: Assets.Images.copy) { _ in
UIPasteboard.general.string = urlString
}
return UIMenu(title: "", children: [copyAction])
}
}
}
// MARK: UITextFieldDelegate
+1 -1
View File
@@ -362,7 +362,7 @@
<rect key="frame" x="0.0" y="0.0" width="374" height="31"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="characterWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rOV-XS-bNW" customClass="InteractiveLabel" customModule="NetNewsWire" customModuleProvider="target">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="characterWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontForContentSizeCategory="YES" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rOV-XS-bNW">
<rect key="frame" x="20" y="15" width="334" height="1"/>
<fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
<nil key="textColor"/>