From 4fc341bc7c5346eac808dc7e8ee814a6d6a4dc7c Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Tue, 16 Jun 2026 21:11:43 -0700 Subject: [PATCH] Add contextual menu to copy home page and feed URL. Fixes #5312. --- .../FeedInspectorViewController.swift | 29 +++++++++++++++++-- iOS/Inspector/Inspector.storyboard | 2 +- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/iOS/Inspector/FeedInspectorViewController.swift b/iOS/Inspector/FeedInspectorViewController.swift index 9fc31267e..975b44b07 100644 --- a/iOS/Inspector/FeedInspectorViewController.swift +++ b/iOS/Inspector/FeedInspectorViewController.swift @@ -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 diff --git a/iOS/Inspector/Inspector.storyboard b/iOS/Inspector/Inspector.storyboard index 06468ddce..632be29e7 100644 --- a/iOS/Inspector/Inspector.storyboard +++ b/iOS/Inspector/Inspector.storyboard @@ -362,7 +362,7 @@ -