// // SkeletonTableViewProtocols.swift // SkeletonView-iOS // // Created by Juanpe Catalán on 06/11/2017. // Copyright © 2017 SkeletonView. All rights reserved. // import UIKit extension UITableView { public static let automaticNumberOfSkeletonRows = -1 } public typealias ReusableHeaderFooterIdentifier = String public protocol SkeletonTableViewDataSource: UITableViewDataSource { func numSections(in collectionSkeletonView: UITableView) -> Int func collectionSkeletonView(_ skeletonView: UITableView, numberOfRowsInSection section: Int) -> Int func collectionSkeletonView(_ skeletonView: UITableView, cellIdentifierForRowAt indexPath: IndexPath) -> ReusableCellIdentifier func collectionSkeletonView(_ skeletonView: UITableView, skeletonCellForRowAt indexPath: IndexPath) -> UITableViewCell? func collectionSkeletonView(_ skeletonView: UITableView, prepareCellForSkeleton cell: UITableViewCell, at indexPath: IndexPath) } public extension SkeletonTableViewDataSource { func collectionSkeletonView(_ skeletonView: UITableView, numberOfRowsInSection section: Int) -> Int { return UITableView.automaticNumberOfSkeletonRows } func numSections(in collectionSkeletonView: UITableView) -> Int { return 1 } /// Keeping the misspelled version around until it can be deprecated /// Right now, it just calls the new correctly spelled method and returns its result @available(*, deprecated, renamed: "collectionSkeletonView(_:cellIdentifierForRowAt:)") func collectionSkeletonView(_ skeletonView: UITableView, cellIdenfierForRowAt indexPath: IndexPath) -> ReusableCellIdentifier { return collectionSkeletonView(skeletonView, cellIdentifierForRowAt: indexPath) } func collectionSkeletonView(_ skeletonView: UITableView, skeletonCellForRowAt indexPath: IndexPath) -> UITableViewCell? { nil } func collectionSkeletonView(_ skeletonView: UITableView, prepareCellForSkeleton cell: UITableViewCell, at indexPath: IndexPath) { } } public protocol SkeletonTableViewDelegate: UITableViewDelegate { func collectionSkeletonView(_ skeletonView: UITableView, identifierForHeaderInSection section: Int) -> ReusableHeaderFooterIdentifier? func collectionSkeletonView(_ skeletonView: UITableView, identifierForFooterInSection section: Int) -> ReusableHeaderFooterIdentifier? } public extension SkeletonTableViewDelegate { func collectionSkeletonView(_ skeletonView: UITableView, identifierForHeaderInSection section: Int) -> ReusableHeaderFooterIdentifier? { return nil } func collectionSkeletonView(_ skeletonView: UITableView, identifierForFooterInSection section: Int) -> ReusableHeaderFooterIdentifier? { return nil } }