Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for copy action #81

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

tomaskraina
Copy link

Closes #80

Static/Row.swift Outdated
@@ -134,7 +144,7 @@ public struct Row: Hashable, Equatable {
// MARK: - Initializers

public init(text: String? = nil, detailText: String? = nil, selection: Selection? = nil,
image: UIImage? = nil, accessory: Accessory = .None, cellClass: CellType.Type? = nil, context: Context? = nil, editActions: [EditAction] = [], UUID: String = NSUUID().UUIDString) {
image: UIImage? = nil, accessory: Accessory = .None, cellClass: CellType.Type? = nil, context: Context? = nil, editActions: [EditAction] = [], copyAction: CopyAction? = nil, UUID: String = NSUUID().UUIDString) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about reverting this whitespace change at the beginning of the line? Agreed that this init takes in a lot of parameters and could use some better clarity, but it might be best to scope that out to a different PR. 😄

@eliperkins
Copy link
Contributor

TIL about those other UITableViewDelegate methods!

I'd love to have this more generic than only supporting NSObject.copy(_:), so as not to box ourselves in. Perhaps we could make some bindings to supported actions here using an enum?

Perhaps something like:

enum RowAction {
    case Copy(Row -> Void)
    case Paste(Row -> Void)
}

I've honestly not used this table view API enough to know use-cases! Would love to learn more.

* commit '8a05589ea367f568542a536ad0bfe7d4731ddded':
  Update readme with Swift version compatibility table
  Update test target to Swift 2.3
  Update to recommended build settings
  Migrate to Swift 2.3
  Update podspec to 1.1.1
  Add gitignore
@soffes soffes force-pushed the master branch 2 times, most recently from 946a03d to 321e997 Compare October 27, 2016 23:12
# Conflicts:
#	Example/CustomTableViewCell.swift
#	Example/ViewController.swift
#	Example/WindowController.swift
#	Static.podspec
#	Static.xcodeproj/project.pbxproj
#	Static/ButtonCell.swift
#	Static/Cell.swift
#	Static/DataSource.swift
#	Static/Row.swift
#	Static/Section.swift
#	Static/SubtitleCell.swift
#	Static/TableViewController.swift
#	Static/Value1Cell.swift
#	Static/Value2Cell.swift
// The parameter indexPath: IndexPath? is optinal for a purpose. See: https://openradar.appspot.com/31375101
public func tableView(_ tableView: UITableView, canPerformAction action: Selector, forRowAt indexPath: IndexPath?, withSender sender: Any?) -> Bool {
guard let indexPath = indexPath else { return false }
public func tableView(_ tableView: UITableView, canPerformAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) -> Bool {
return action == #selector(UIResponder.copy(_:)) && (row(at: indexPath)?.canCopy ?? false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be tied to a specific selector case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants