Compare commits

...

6 Commits

7 changed files with 31 additions and 70 deletions

View File

@ -1 +1 @@
5.0
5.7

View File

@ -1,5 +1,4 @@
// swift-tools-version:5.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
// swift-tools-version:5.7
import PackageDescription

View File

@ -1,4 +1,4 @@
public protocol ExpandableCellViewModel: class {
public protocol ExpandableCellViewModel: AnyObject {
var expandableState: ExpandableState { get set }

View File

@ -346,13 +346,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
open func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
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,
leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let currentRow = sections[indexPath.section].rows[indexPath.row]
@ -362,8 +356,7 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
return configuration
}
@available(iOS 11, *)
open func tableView(_ tableView: UITableView,
trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let currentRow = sections[indexPath.section].rows[indexPath.row]
@ -414,36 +407,36 @@ open class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate {
extension TableDirector {
@discardableResult
open func append(section: TableSection) -> Self {
public func append(section: TableSection) -> Self {
append(sections: [section])
return self
}
@discardableResult
open func append(sections: [TableSection]) -> Self {
public func append(sections: [TableSection]) -> Self {
self.sections.append(contentsOf: sections)
return self
}
@discardableResult
open func append(rows: [Row]) -> Self {
public func append(rows: [Row]) -> Self {
append(section: TableSection(rows: rows))
return self
}
@discardableResult
open func insert(section: TableSection, atIndex index: Int) -> Self {
public func insert(section: TableSection, atIndex index: Int) -> Self {
sections.insert(section, at: index)
return self
}
@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 {
sections[index] = section
}
@ -451,20 +444,20 @@ extension TableDirector {
}
@discardableResult
open func delete(sectionAt index: Int) -> Self {
public func delete(sectionAt index: Int) -> Self {
sections.remove(at: index)
return self
}
@discardableResult
open func remove(sectionAt index: Int) -> Self {
public func remove(sectionAt index: Int) -> Self {
return delete(sectionAt: index)
}
@discardableResult
open func clear() -> Self {
public func clear() -> Self {
rowHeightCalculator?.invalidate()
sections.removeAll()
@ -474,7 +467,7 @@ extension TableDirector {
// MARK: - deprecated methods
@available(*, deprecated, message: "Use 'delete(sectionAt:)' method instead")
@discardableResult
open func delete(index: Int) -> Self {
public func delete(index: Int) -> Self {
sections.remove(at: index)
return self

View File

@ -37,18 +37,9 @@ public protocol RowConfigurable {
}
public protocol RowActionable {
@available(iOS 11, *)
var leadingContextualActions: [UIContextualAction] { get }
@available(iOS 11, *)
var trailingContextualActions: [UIContextualAction] { get }
@available(iOS 11, *)
var performsFirstActionWithFullSwipe: Bool { get }
@available(iOS, deprecated: 11, message: "Use leadingContextualActions, trailingContextualActions instead")
var editingActions: [UITableViewRowAction]? { get }
func isEditingAllowed(forIndexPath indexPath: IndexPath) -> Bool

View File

@ -24,21 +24,15 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
public let item: CellType.CellData
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] {
[]
}
@available(iOS 11, *)
open var trailingContextualActions: [UIContextualAction] {
[]
}
@available(iOS 11, *)
open var performsFirstActionWithFullSwipe: Bool {
false
}
@ -67,18 +61,6 @@ open class TableRow<CellType: ConfigurableCell>: Row where CellType: UITableView
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,
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
}
if #available(iOS 11, *) {
return !leadingContextualActions.isEmpty
|| !trailingContextualActions.isEmpty
|| actions[TableRowActionType.clickDelete.key] != nil
} else {
return editingActions?.isEmpty == false || actions[TableRowActionType.clickDelete.key] != nil
}
return !leadingContextualActions.isEmpty
|| !trailingContextualActions.isEmpty
|| actions[TableRowActionType.clickDelete.key] != nil
}
// MARK: - actions -

View File

@ -2,16 +2,16 @@ Pod::Spec.new do |s|
s.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.author = { 'Max Sokolov' => 'i@maxsokolov.net' }
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.platforms = { :ios => '8.0' }
s.ios.deployment_target = '8.0'
s.platforms = { :ios => '12.0' }
s.ios.deployment_target = '12.0'
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