Copy by double tap

This commit is contained in:
Selim Mustafaev 2023-02-19 23:36:09 +03:00
parent 98e0ed9495
commit df43b9ff7f
5 changed files with 70 additions and 0 deletions

View File

@ -71,6 +71,7 @@
7A8A220B248D67B60073DFD9 /* VehicleReportImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A8A220A248D67B60073DFD9 /* VehicleReportImage.swift */; };
7A8AB76525A0DB8F00ECF2C1 /* BundleVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A8AB76425A0DB8F00ECF2C1 /* BundleVersion.swift */; };
7A8AB76B25A1D95500ECF2C1 /* SourceStatusRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A8AB76A25A1D95500ECF2C1 /* SourceStatusRow.swift */; };
7A91894F29A2BD8700519C74 /* GestureRecognizers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A91894E29A2BD8700519C74 /* GestureRecognizers.swift */; };
7A96AE2D246B2B7400297C33 /* GoogleSignInController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A96AE2C246B2B7400297C33 /* GoogleSignInController.swift */; };
7A96AE2F246B2BCD00297C33 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7A96AE2E246B2BCD00297C33 /* WebKit.framework */; };
7A99406426E4BFAE002E9CB6 /* VehicleNoteCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7A99406326E4BFAE002E9CB6 /* VehicleNoteCell.swift */; };
@ -250,6 +251,7 @@
7A8AB76425A0DB8F00ECF2C1 /* BundleVersion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BundleVersion.swift; sourceTree = "<group>"; };
7A8AB76725A0DC8200ECF2C1 /* DebugInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DebugInfo.swift; sourceTree = "<group>"; };
7A8AB76A25A1D95500ECF2C1 /* SourceStatusRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SourceStatusRow.swift; sourceTree = "<group>"; };
7A91894E29A2BD8700519C74 /* GestureRecognizers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GestureRecognizers.swift; sourceTree = "<group>"; };
7A92D0AB240425B100EF3B77 /* ATGMediaBrowser.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ATGMediaBrowser.framework; path = Carthage/Build/iOS/ATGMediaBrowser.framework; sourceTree = "<group>"; };
7A96AE2C246B2B7400297C33 /* GoogleSignInController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoogleSignInController.swift; sourceTree = "<group>"; };
7A96AE2E246B2BCD00297C33 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/WebKit.framework; sourceTree = DEVELOPER_DIR; };
@ -604,6 +606,7 @@
7AC3555129696E3F00889457 /* UIView+layout.swift */,
7AC355582969746600889457 /* UIControl.swift */,
7AC3555A296995B200889457 /* UIEdgeInsets.swift */,
7A91894E29A2BD8700519C74 /* GestureRecognizers.swift */,
);
path = Extensions;
sourceTree = "<group>";
@ -900,6 +903,7 @@
7A8A220B248D67B60073DFD9 /* VehicleReportImage.swift in Sources */,
7AC3555B296995B200889457 /* UIEdgeInsets.swift in Sources */,
7ADF6C95250D037700F237B2 /* ShowEventController.swift in Sources */,
7A91894F29A2BD8700519C74 /* GestureRecognizers.swift in Sources */,
7A27ADC7249D43210035F39E /* RegionsController.swift in Sources */,
7AE492A1259232F000322D2E /* MultilineLinkRow.swift in Sources */,
7ADF6C93250B954900F237B2 /* Navigation.swift in Sources */,

View File

@ -0,0 +1,42 @@
//
// GestureRecognizers.swift
// AutoCat
//
// Created by Selim Mustafaev on 19.02.2023.
// Copyright © 2023 Selim Mustafaev. All rights reserved.
//
import UIKit
extension UIGestureRecognizer {
typealias Action = ((UIGestureRecognizer) -> ())
private struct Keys {
static var actionKey = "ActionKey"
}
private var block: Action? {
set {
if let newValue = newValue {
// Computed properties get stored as associated objects
objc_setAssociatedObject(self, &Keys.actionKey, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN)
}
}
get {
let action = objc_getAssociatedObject(self, &Keys.actionKey) as? Action
return action
}
}
@objc func handleAction(recognizer: UIGestureRecognizer) {
block?(recognizer)
}
convenience public init(block: @escaping ((UIGestureRecognizer) -> ())) {
self.init()
self.block = block
self.addTarget(self, action: #selector(handleAction(recognizer:)))
}
}

View File

@ -195,6 +195,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// MARK: - Global menu
#if targetEnvironment(macCatalyst)
override func buildMenu(with builder: UIMenuBuilder) {
super.buildMenu(with: builder)
@ -213,5 +215,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
sceneDelegate.showAddNumberPanel()
}
#endif
}

View File

@ -60,7 +60,11 @@ class NewNumberController: UIViewController {
view.addSubview(mainStackView)
mainStackView.pin(to: view, insets: .all(16))
#if targetEnvironment(macCatalyst)
addKeyCommand(UIKeyCommand(input: "v", modifierFlags: .command, action: #selector(pasteText)))
#endif
}
func check() {

View File

@ -147,6 +147,22 @@ class ReportController: FormViewController, MediaBrowserViewControllerDataSource
<<< SourceStatusRow("DebugVin01History") { $0.title = NSLocalizedString("Vin01 (history)", comment: "GIBDD registration history") }
<<< SourceStatusRow("DebugNomerogram") { $0.title = NSLocalizedString("Nomerogram", comment: "") }
}
setupCopyBehaviour()
}
func setupCopyBehaviour() {
for row in form.allRows {
if let labelRow = row as? LabelRow {
let doubleTap = UITapGestureRecognizer { _ in
UIPasteboard.general.string = labelRow.value
}
doubleTap.numberOfTapsRequired = 2
labelRow.cell.addGestureRecognizer(doubleTap)
}
}
}
func update(row tag: String, with value: String) {