Add copy capabilities to Feed URL and Homepage labels. Issue #1239.

This commit is contained in:
Maurice Parker 2019-11-03 07:18:00 -06:00
parent 68fe9e2b62
commit 27e00ee5c7
4 changed files with 87 additions and 2 deletions

View File

@ -24,6 +24,8 @@
5127B238222B4849006D641D /* DetailKeyboardDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5127B236222B4849006D641D /* DetailKeyboardDelegate.swift */; };
5127B23A222B4849006D641D /* DetailKeyboardShortcuts.plist in Resources */ = {isa = PBXBuildFile; fileRef = 5127B237222B4849006D641D /* DetailKeyboardShortcuts.plist */; };
512AF9C2236ED52C0066F8BE /* InspectorHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 512AF9C1236ED52C0066F8BE /* InspectorHeaderView.swift */; };
512AF9DD236F05230066F8BE /* InteractiveLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 512AF9DC236F05230066F8BE /* InteractiveLabel.swift */; };
512AF9DF236F074B0066F8BE /* FeedInspectorLabelView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 512AF9DE236F074B0066F8BE /* FeedInspectorLabelView.swift */; };
512E08E62268800D00BDCFDD /* FolderTreeControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97A11ED9F180007D329B /* FolderTreeControllerDelegate.swift */; };
512E08E72268801200BDCFDD /* FeedTreeControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A97611ED9EB96007D329B /* FeedTreeControllerDelegate.swift */; };
512E09012268907400BDCFDD /* MasterFeedTableViewSectionHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 512E08F722688F7C00BDCFDD /* MasterFeedTableViewSectionHeader.swift */; };
@ -1208,6 +1210,8 @@
5127B236222B4849006D641D /* DetailKeyboardDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DetailKeyboardDelegate.swift; sourceTree = "<group>"; };
5127B237222B4849006D641D /* DetailKeyboardShortcuts.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = DetailKeyboardShortcuts.plist; sourceTree = "<group>"; };
512AF9C1236ED52C0066F8BE /* InspectorHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InspectorHeaderView.swift; sourceTree = "<group>"; };
512AF9DC236F05230066F8BE /* InteractiveLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InteractiveLabel.swift; sourceTree = "<group>"; };
512AF9DE236F074B0066F8BE /* FeedInspectorLabelView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedInspectorLabelView.swift; sourceTree = "<group>"; };
512E08F722688F7C00BDCFDD /* MasterFeedTableViewSectionHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MasterFeedTableViewSectionHeader.swift; sourceTree = "<group>"; };
512E092B2268B25500BDCFDD /* UISplitViewController-Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UISplitViewController-Extensions.swift"; sourceTree = "<group>"; };
51314617235A797400387FDC /* NetNewsWire_iOSintentextension_target.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = NetNewsWire_iOSintentextension_target.xcconfig; sourceTree = "<group>"; };
@ -1678,6 +1682,7 @@
516A09412361248000EAE89B /* Inspector.storyboard */,
51A16991235E10D600EB091F /* AccountInspectorViewController.swift */,
5123DB9E233EC6FD00282CC9 /* FeedInspectorView.swift */,
512AF9DE236F074B0066F8BE /* FeedInspectorLabelView.swift */,
512AF9C1236ED52C0066F8BE /* InspectorHeaderView.swift */,
);
path = Inspector;
@ -1829,6 +1834,7 @@
children = (
51F85BFA2275D85000C787DC /* Array-Extensions.swift */,
51F85BF42273625800C787DC /* Bundle-Extensions.swift */,
512AF9DC236F05230066F8BE /* InteractiveLabel.swift */,
51EAED95231363EF00A9EEE3 /* NonIntrinsicButton.swift */,
5183CCD9226E31A50010922C /* NonIntrinsicImageView.swift */,
5183CCCF226E1E880010922C /* NonIntrinsicLabel.swift */,
@ -3876,6 +3882,7 @@
51C4527B2265091600C03939 /* MasterUnreadIndicatorView.swift in Sources */,
5186A635235EF3A800C97195 /* VibrantLabel.swift in Sources */,
51F85BF92274AA7B00C787DC /* UIBarButtonItem-Extensions.swift in Sources */,
512AF9DF236F074B0066F8BE /* FeedInspectorLabelView.swift in Sources */,
51B62E68233186730085F949 /* AvatarView.swift in Sources */,
51C45296226509D300C03939 /* OPMLExporter.swift in Sources */,
51C45291226509C800C03939 /* SmartFeed.swift in Sources */,
@ -3921,6 +3928,7 @@
51C45292226509C800C03939 /* TodayFeedDelegate.swift in Sources */,
51C452A222650A1900C03939 /* RSHTMLMetadata+Extension.swift in Sources */,
514B7D1F23219F3C00BAC947 /* AddControllerType.swift in Sources */,
512AF9DD236F05230066F8BE /* InteractiveLabel.swift in Sources */,
51E3EB3D229AB08300645299 /* ErrorHandler.swift in Sources */,
5183CCE5226F4DFA0010922C /* RefreshInterval.swift in Sources */,
51C4529D22650A1000C03939 /* FaviconURLFinder.swift in Sources */,

View File

@ -0,0 +1,23 @@
//
// FeedInspectorLabel.swift
// NetNewsWire-iOS
//
// Created by Maurice Parker on 11/3/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import SwiftUI
struct FeedInspectorLabelView : UIViewRepresentable {
let text: String
func makeUIView(context: Context) -> InteractiveLabel {
return InteractiveLabel()
}
func updateUIView(_ label: InteractiveLabel, context: Context) {
label.text = text
}
}

View File

@ -60,10 +60,10 @@ struct FeedInspectorView : View {
}
}
Section(header: Text("HOME PAGE")) {
Text(verbatim: self.viewModel.homePageURL)
FeedInspectorLabelView(text: self.viewModel.homePageURL)
}
Section(header: Text("FEED URL")) {
Text(verbatim: self.viewModel.feedLinkURL)
FeedInspectorLabelView(text: self.viewModel.feedLinkURL)
}
}
.onDisappear { self.viewModel.save() }

View File

@ -0,0 +1,54 @@
//
// InteractiveLabel.swift
// NetNewsWire-iOS
//
// Created by Maurice Parker on 11/3/19.
// Copyright © 2019 Ranchero Software. All rights reserved.
//
import UIKit
@IBDesignable
class InteractiveLabel: UILabel {
override init(frame: CGRect) {
super.init(frame: frame)
commonInit()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
commonInit()
}
func commonInit() {
let gestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPressGesture(_:)))
self.addGestureRecognizer(gestureRecognizer)
self.isUserInteractionEnabled = true
}
@objc func handleLongPressGesture(_ recognizer: UIGestureRecognizer) {
guard recognizer.state == .began,
let recognizerView = recognizer.view,
let recognizerSuperView = recognizerView.superview,
recognizerView.becomeFirstResponder() else {
return
}
UIMenuController.shared.showMenu(from: recognizerSuperView, rect: recognizerView.frame)
}
override var canBecomeFirstResponder: Bool {
return true
}
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
return (action == #selector(UIResponderStandardEditActions.copy(_:)))
}
override func copy(_ sender: Any?) {
UIPasteboard.general.string = text
}
}