Compare commits
6 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
fec9537745 | |
|
|
246c0d06c0 | |
|
|
54bf141aff | |
|
|
01134b83b4 | |
|
|
3fefa09c3a | |
|
|
4886e43d20 |
|
|
@ -1 +1 @@
|
||||||
5.0
|
5.7
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
// swift-tools-version:5.0
|
// swift-tools-version:5.7
|
||||||
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
|
||||||
|
|
||||||
import PackageDescription
|
import PackageDescription
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
public protocol ExpandableCellViewModel: class {
|
public protocol ExpandableCellViewModel: AnyObject {
|
||||||
|
|
||||||
var expandableState: ExpandableState { get set }
|
var expandableState: ExpandableState { get set }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -346,13 +346,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
|
||||||
open func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
|
open func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
|
||||||
return sections[indexPath.section].rows[indexPath.row].isEditingAllowed(forIndexPath: indexPath)
|
return sections[indexPath.section].rows[indexPath.row].isEditingAllowed(forIndexPath: indexPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS, deprecated: 11, message: "Use leadingSwipeActionsConfigurationForRowAt(:_) and trailingSwipeActionsConfigurationForRowAt(:_) instead")
|
|
||||||
open func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
|
|
||||||
return sections[indexPath.section].rows[indexPath.row].editingActions
|
|
||||||
}
|
|
||||||
|
|
||||||
@available(iOS 11, *)
|
|
||||||
open func tableView(_ tableView: UITableView,
|
open func tableView(_ tableView: UITableView,
|
||||||
leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
|
leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
|
||||||
let currentRow = sections[indexPath.section].rows[indexPath.row]
|
let currentRow = sections[indexPath.section].rows[indexPath.row]
|
||||||
|
|
@ -362,8 +356,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
|
||||||
|
|
||||||
return configuration
|
return configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS 11, *)
|
|
||||||
open func tableView(_ tableView: UITableView,
|
open func tableView(_ tableView: UITableView,
|
||||||
trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
|
trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
|
||||||
let currentRow = sections[indexPath.section].rows[indexPath.row]
|
let currentRow = sections[indexPath.section].rows[indexPath.row]
|
||||||
|
|
@ -414,36 +407,36 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
|
||||||
extension TableDirector {
|
extension TableDirector {
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
open func append(section: TableSection) -> Self {
|
public func append(section: TableSection) -> Self {
|
||||||
|
|
||||||
append(sections: [section])
|
append(sections: [section])
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
open func append(sections: [TableSection]) -> Self {
|
public func append(sections: [TableSection]) -> Self {
|
||||||
|
|
||||||
self.sections.append(contentsOf: sections)
|
self.sections.append(contentsOf: sections)
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
open func append(rows: [Row]) -> Self {
|
public func append(rows: [Row]) -> Self {
|
||||||
|
|
||||||
append(section: TableSection(rows: rows))
|
append(section: TableSection(rows: rows))
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
open func insert(section: TableSection, atIndex index: Int) -> Self {
|
public func insert(section: TableSection, atIndex index: Int) -> Self {
|
||||||
|
|
||||||
sections.insert(section, at: index)
|
sections.insert(section, at: index)
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
open func replaceSection(at index: Int, with section: TableSection) -> Self {
|
public func replaceSection(at index: Int, with section: TableSection) -> Self {
|
||||||
|
|
||||||
if index < sections.count {
|
if index < sections.count {
|
||||||
sections[index] = section
|
sections[index] = section
|
||||||
}
|
}
|
||||||
|
|
@ -451,20 +444,20 @@ extension TableDirector {
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
open func delete(sectionAt index: Int) -> Self {
|
public func delete(sectionAt index: Int) -> Self {
|
||||||
|
|
||||||
sections.remove(at: index)
|
sections.remove(at: index)
|
||||||
return self
|
return self
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
open func remove(sectionAt index: Int) -> Self {
|
public func remove(sectionAt index: Int) -> Self {
|
||||||
return delete(sectionAt: index)
|
return delete(sectionAt: index)
|
||||||
}
|
}
|
||||||
|
|
||||||
@discardableResult
|
@discardableResult
|
||||||
open func clear() -> Self {
|
public func clear() -> Self {
|
||||||
|
|
||||||
rowHeightCalculator?.invalidate()
|
rowHeightCalculator?.invalidate()
|
||||||
sections.removeAll()
|
sections.removeAll()
|
||||||
|
|
||||||
|
|
@ -474,7 +467,7 @@ extension TableDirector {
|
||||||
// MARK: - deprecated methods
|
// MARK: - deprecated methods
|
||||||
@available(*, deprecated, message: "Use 'delete(sectionAt:)' method instead")
|
@available(*, deprecated, message: "Use 'delete(sectionAt:)' method instead")
|
||||||
@discardableResult
|
@discardableResult
|
||||||
open func delete(index: Int) -> Self {
|
public func delete(index: Int) -> Self {
|
||||||
|
|
||||||
sections.remove(at: index)
|
sections.remove(at: index)
|
||||||
return self
|
return self
|
||||||
|
|
|
||||||
|
|
@ -37,18 +37,9 @@ public protocol RowConfigurable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public protocol RowActionable {
|
public protocol RowActionable {
|
||||||
|
|
||||||
@available(iOS 11, *)
|
|
||||||
var leadingContextualActions: [UIContextualAction] { get }
|
var leadingContextualActions: [UIContextualAction] { get }
|
||||||
|
|
||||||
@available(iOS 11, *)
|
|
||||||
var trailingContextualActions: [UIContextualAction] { get }
|
var trailingContextualActions: [UIContextualAction] { get }
|
||||||
|
|
||||||
@available(iOS 11, *)
|
|
||||||
var performsFirstActionWithFullSwipe: Bool { get }
|
var performsFirstActionWithFullSwipe: Bool { get }
|
||||||
|
|
||||||
@available(iOS, deprecated: 11, message: "Use leadingContextualActions, trailingContextualActions instead")
|
|
||||||
var editingActions: [UITableViewRowAction]? { get }
|
|
||||||
|
|
||||||
func isEditingAllowed(forIndexPath indexPath: IndexPath) -> Bool
|
func isEditingAllowed(forIndexPath indexPath: IndexPath) -> Bool
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,21 +24,15 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
|
||||||
|
|
||||||
public let item: CellType.CellData
|
public let item: CellType.CellData
|
||||||
private lazy var actions = [String: [TableRowAction<CellType>]]()
|
private lazy var actions = [String: [TableRowAction<CellType>]]()
|
||||||
|
|
||||||
@available(iOS, deprecated: 11, message: "Use leadingContextualActions, trailingContextualActions instead")
|
|
||||||
open private(set) var editingActions: [UITableViewRowAction]?
|
|
||||||
|
|
||||||
@available(iOS 11, *)
|
|
||||||
open var leadingContextualActions: [UIContextualAction] {
|
open var leadingContextualActions: [UIContextualAction] {
|
||||||
[]
|
[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS 11, *)
|
|
||||||
open var trailingContextualActions: [UIContextualAction] {
|
open var trailingContextualActions: [UIContextualAction] {
|
||||||
[]
|
[]
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS 11, *)
|
|
||||||
open var performsFirstActionWithFullSwipe: Bool {
|
open var performsFirstActionWithFullSwipe: Bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
@ -67,18 +61,6 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
|
||||||
return CellType.self
|
return CellType.self
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOS, deprecated: 11, message: "Use leadingContextualActions, trailingContextualActions instead")
|
|
||||||
public init(item: CellType.CellData,
|
|
||||||
actions: [TableRowAction<CellType>]? = nil,
|
|
||||||
editingActions: [UITableViewRowAction]? = nil) {
|
|
||||||
|
|
||||||
self.item = item
|
|
||||||
self.editingActions = editingActions
|
|
||||||
|
|
||||||
actions?.forEach { on($0) }
|
|
||||||
}
|
|
||||||
|
|
||||||
@available(iOS 11, *)
|
|
||||||
public init(item: CellType.CellData,
|
public init(item: CellType.CellData,
|
||||||
actions: [TableRowAction<CellType>]? = nil) {
|
actions: [TableRowAction<CellType>]? = nil) {
|
||||||
|
|
||||||
|
|
@ -112,13 +94,9 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
|
||||||
return invoke(action: .canEdit, cell: nil, path: indexPath) as? Bool ?? false
|
return invoke(action: .canEdit, cell: nil, path: indexPath) as? Bool ?? false
|
||||||
}
|
}
|
||||||
|
|
||||||
if #available(iOS 11, *) {
|
return !leadingContextualActions.isEmpty
|
||||||
return !leadingContextualActions.isEmpty
|
|| !trailingContextualActions.isEmpty
|
||||||
|| !trailingContextualActions.isEmpty
|
|| actions[TableRowActionType.clickDelete.key] != nil
|
||||||
|| actions[TableRowActionType.clickDelete.key] != nil
|
|
||||||
} else {
|
|
||||||
return editingActions?.isEmpty == false || actions[TableRowActionType.clickDelete.key] != nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - actions -
|
// MARK: - actions -
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,16 @@ Pod::Spec.new do |s|
|
||||||
s.name = 'TableKit'
|
s.name = 'TableKit'
|
||||||
s.module_name = 'TableKit'
|
s.module_name = 'TableKit'
|
||||||
|
|
||||||
s.version = '2.11.0'
|
s.version = '2.12'
|
||||||
|
|
||||||
s.homepage = 'https://github.com/maxsokolov/TableKit'
|
s.homepage = 'https://git.svc.touchin.ru/TouchInstinct/TableKit'
|
||||||
s.summary = 'Type-safe declarative table views with Swift.'
|
s.summary = 'Type-safe declarative table views with Swift.'
|
||||||
|
|
||||||
s.author = { 'Max Sokolov' => 'i@maxsokolov.net' }
|
s.author = { 'Max Sokolov' => 'i@maxsokolov.net' }
|
||||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||||
s.platforms = { :ios => '8.0' }
|
s.platforms = { :ios => '12.0' }
|
||||||
s.ios.deployment_target = '8.0'
|
s.ios.deployment_target = '12.0'
|
||||||
|
|
||||||
s.source_files = 'Sources/*.swift'
|
s.source_files = 'Sources/*.swift'
|
||||||
s.source = { :git => 'https://github.com/maxsokolov/TableKit.git', :tag => s.version }
|
s.source = { :git => 'https://git.svc.touchin.ru/TouchInstinct/TableKit.git', :tag => s.version }
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue