remove any action
This commit is contained in:
parent
162aee0033
commit
1eed11abbf
|
|
@ -20,10 +20,6 @@
|
|||
|
||||
import UIKit
|
||||
|
||||
struct TableKitNotifications {
|
||||
static let CellAction = "TableKitNotificationsCellAction"
|
||||
}
|
||||
|
||||
/**
|
||||
A custom action that you can trigger from your cell.
|
||||
You can easily catch actions using a chaining manner with your row.
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@
|
|||
|
||||
import UIKit
|
||||
|
||||
struct TableKitNotifications {
|
||||
static let CellAction = "TableKitNotificationsCellAction"
|
||||
}
|
||||
|
||||
public protocol RowConfigurable {
|
||||
|
||||
func configure(_ cell: UITableViewCell)
|
||||
|
|
@ -29,8 +33,7 @@ public protocol RowActionable {
|
|||
|
||||
var editingActions: [UITableViewRowAction]? { get }
|
||||
func isEditingAllowed(forIndexPath indexPath: IndexPath) -> Bool
|
||||
|
||||
func on(anyAction action: RowAction) -> Self
|
||||
|
||||
func invoke(action: TableRowActionType, cell: UITableViewCell?, path: IndexPath, userInfo: [AnyHashable: Any]?) -> Any?
|
||||
func has(action: TableRowActionType) -> Bool
|
||||
}
|
||||
|
|
@ -74,14 +77,6 @@ public enum TableRowActionType {
|
|||
}
|
||||
}
|
||||
|
||||
public protocol RowAction {
|
||||
|
||||
var id: String? { get set }
|
||||
var type: TableRowActionType { get }
|
||||
|
||||
func invokeActionOn(cell: UITableViewCell?, item: Any, path: IndexPath, userInfo: [AnyHashable: Any]?) -> Any?
|
||||
}
|
||||
|
||||
public protocol RowHeightCalculator {
|
||||
|
||||
func height(forRow row: Row, at indexPath: IndexPath) -> CGFloat
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ import UIKit
|
|||
open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableViewCell {
|
||||
|
||||
open let item: CellType.T
|
||||
private lazy var actions = [String: [RowAction]]()
|
||||
private lazy var actions = [String: [TableRowAction<CellType>]]()
|
||||
private(set) open var editingActions: [UITableViewRowAction]?
|
||||
|
||||
open var hashValue: Int {
|
||||
|
|
@ -85,7 +85,12 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
|
|||
@discardableResult
|
||||
open func on(_ action: TableRowAction<CellType>) -> Self {
|
||||
|
||||
return on(anyAction: action)
|
||||
if actions[action.type.key] == nil {
|
||||
actions[action.type.key] = [TableRowAction<CellType>]()
|
||||
}
|
||||
actions[action.type.key]?.append(action)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
|
|
@ -93,18 +98,7 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
|
|||
|
||||
return on(TableRowAction<CellType>(type, handler: handler))
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
open func on(anyAction action: RowAction) -> Self {
|
||||
|
||||
if actions[action.type.key] == nil {
|
||||
actions[action.type.key] = [RowAction]()
|
||||
}
|
||||
actions[action.type.key]?.append(action)
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
open func removeAllActions() {
|
||||
|
||||
actions.removeAll()
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ private enum TableRowActionHandler<CellType: ConfigurableCell> where CellType: U
|
|||
}
|
||||
}
|
||||
|
||||
open class TableRowAction<CellType: ConfigurableCell>: RowAction where CellType: UITableViewCell {
|
||||
open class TableRowAction<CellType: ConfigurableCell> where CellType: UITableViewCell {
|
||||
|
||||
open var id: String?
|
||||
open let type: TableRowActionType
|
||||
|
|
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
//
|
||||
// TableRowAnyAction.swift
|
||||
// TableKit
|
||||
//
|
||||
// Created by Max Sokolov on 18/10/16.
|
||||
// Copyright © 2016 Max Sokolov. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
open class TableRowAnyActionOptions {
|
||||
|
||||
|
||||
}
|
||||
|
||||
open class TableRowAnyAction {
|
||||
|
||||
open var id: String?
|
||||
open let type: TableRowActionType
|
||||
|
||||
init(_ type: TableRowActionType, handler: @escaping () -> ()) {
|
||||
|
||||
self.type = type
|
||||
}
|
||||
|
||||
func invoke(cell: UITableViewCell?, item: Any, path: IndexPath, userInfo: [AnyHashable: Any]?) -> Any? {
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,6 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
50826A001DB694CF002AABB5 /* TableRowAnyAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 508269FF1DB694CF002AABB5 /* TableRowAnyAction.swift */; };
|
||||
50CF6E6B1D6704FE004746FF /* TableCellRegisterer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50CF6E6A1D6704FE004746FF /* TableCellRegisterer.swift */; };
|
||||
50E858581DB153F500A9AA55 /* TableKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E858571DB153F500A9AA55 /* TableKit.swift */; };
|
||||
DA9EA7AF1D0EC2C90021F650 /* ConfigurableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA9EA7A61D0EC2C90021F650 /* ConfigurableCell.swift */; };
|
||||
|
|
@ -33,7 +32,6 @@
|
|||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
508269FF1DB694CF002AABB5 /* TableRowAnyAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableRowAnyAction.swift; sourceTree = "<group>"; };
|
||||
50CF6E6A1D6704FE004746FF /* TableCellRegisterer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableCellRegisterer.swift; sourceTree = "<group>"; };
|
||||
50E858571DB153F500A9AA55 /* TableKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableKit.swift; sourceTree = "<group>"; };
|
||||
DA9EA7561D0B679A0021F650 /* TableKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = TableKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
|
@ -96,7 +94,6 @@
|
|||
DA9EA7AA1D0EC2C90021F650 /* TableDirector.swift */,
|
||||
50CF6E6A1D6704FE004746FF /* TableCellRegisterer.swift */,
|
||||
DA9EA7AB1D0EC2C90021F650 /* TableRow.swift */,
|
||||
508269FF1DB694CF002AABB5 /* TableRowAnyAction.swift */,
|
||||
DA9EA7AC1D0EC2C90021F650 /* TableRowAction.swift */,
|
||||
DA9EA7AE1D0EC2C90021F650 /* TableSection.swift */,
|
||||
DA9EA7A91D0EC2C90021F650 /* TableCellAction.swift */,
|
||||
|
|
@ -240,7 +237,6 @@
|
|||
DA9EA7B01D0EC2C90021F650 /* TablePrototypeCellHeightCalculator.swift in Sources */,
|
||||
DA9EA7B51D0EC2C90021F650 /* TableRowAction.swift in Sources */,
|
||||
DA9EA7B21D0EC2C90021F650 /* TableCellAction.swift in Sources */,
|
||||
50826A001DB694CF002AABB5 /* TableRowAnyAction.swift in Sources */,
|
||||
DA9EA7B11D0EC2C90021F650 /* Operators.swift in Sources */,
|
||||
DA9EA7B41D0EC2C90021F650 /* TableRow.swift in Sources */,
|
||||
50E858581DB153F500A9AA55 /* TableKit.swift in Sources */,
|
||||
|
|
|
|||
Loading…
Reference in New Issue