addAction -> action
This commit is contained in:
parent
d4efb6a679
commit
1266a91446
|
|
@ -37,13 +37,13 @@ class MainController: UIViewController {
|
|||
let row3 = TableRow<String, StoryboardImageTableViewCell>(item: "3", actions: [a])
|
||||
|
||||
row1
|
||||
.addAction(TableRowAction(.shouldHighlight) { (data) -> Bool in
|
||||
.action(TableRowAction(.shouldHighlight) { (data) -> Bool in
|
||||
|
||||
print("1")
|
||||
|
||||
return false
|
||||
})
|
||||
.addAction(TableRowAction(.click) { (data) in
|
||||
.action(TableRowAction(.click) { (data) in
|
||||
|
||||
print("2")
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15G7b" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15B42" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="dOU-ON-YYD">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10116" systemVersion="15G7b" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="dOU-ON-YYD">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
<!--Main Controller-->
|
||||
<scene sceneID="bgC-Xq-OSw">
|
||||
<objects>
|
||||
<viewController id="grv-aL-Qbb" customClass="MainController" customModule="TabletDemo" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<viewController id="grv-aL-Qbb" customClass="MainController" customModule="TableKitDemo" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="COn-EH-LKP"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="iga-ib-rj1"/>
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<prototypes>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="StoryboardImageTableViewCell" rowHeight="141" id="IBY-tW-SgU" customClass="StoryboardImageTableViewCell" customModule="TabletDemo" customModuleProvider="target">
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="StoryboardImageTableViewCell" rowHeight="141" id="IBY-tW-SgU" customClass="StoryboardImageTableViewCell" customModule="TableKitDemo" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="92" width="600" height="141"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="IBY-tW-SgU" id="UNZ-nz-200">
|
||||
|
|
@ -85,7 +85,7 @@
|
|||
<outlet property="titleLabel" destination="YnK-4H-0SS" id="ilA-7H-pq7"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="StoryboardTableViewCell" id="nE5-Y5-OFf" customClass="StoryboardTableViewCell" customModule="TabletDemo" customModuleProvider="target">
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="StoryboardTableViewCell" id="nE5-Y5-OFf" customClass="StoryboardTableViewCell" customModule="TableKitDemo" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="233" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="nE5-Y5-OFf" id="3yF-sl-yNq">
|
||||
|
|
@ -117,7 +117,7 @@
|
|||
<!--Header Footer Controller-->
|
||||
<scene sceneID="Jd0-of-RF9">
|
||||
<objects>
|
||||
<viewController id="sSs-TX-Ch0" customClass="HeaderFooterController" customModule="TabletDemo" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<viewController id="sSs-TX-Ch0" customClass="HeaderFooterController" customModule="TableKitDemo" customModuleProvider="target" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="s9s-Gu-3M6"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="Tux-up-dnH"/>
|
||||
|
|
@ -130,7 +130,7 @@
|
|||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<prototypes>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="StoryboardTableViewCell" id="lqW-2N-6mf" customClass="StoryboardTableViewCell" customModule="TabletDemo" customModuleProvider="target">
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="StoryboardTableViewCell" id="lqW-2N-6mf" customClass="StoryboardTableViewCell" customModule="TableKitDemo" customModuleProvider="target">
|
||||
<rect key="frame" x="0.0" y="92" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="lqW-2N-6mf" id="tjN-ow-437">
|
||||
|
|
|
|||
|
|
@ -82,12 +82,10 @@ let row = TableRow<String, StringTableViewCell>(item: "some", actions: [action])
|
|||
Or, using nice chaining approach:
|
||||
```swift
|
||||
let row = TableRow<String, StringTableViewCell>(item: "some")
|
||||
|
||||
row
|
||||
.addAction(TableRowAction(.click) { (data) in
|
||||
.action(TableRowAction(.click) { (data) in
|
||||
|
||||
})
|
||||
.addAction(TableRowAction(.shouldHighlight) { (data) -> Bool in
|
||||
.action(TableRowAction(.shouldHighlight) { (data) -> Bool in
|
||||
return false
|
||||
})
|
||||
```
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ public protocol CellHeightCalculatable {
|
|||
public class PrototypeHeightStrategy: CellHeightCalculatable {
|
||||
|
||||
public weak var tableView: UITableView?
|
||||
private var prototypes = [String: UITableViewCell]()
|
||||
private var cachedHeights = [Int: CGFloat]()
|
||||
private var separatorHeight = 1 / UIScreen.mainScreen().scale
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public class TableRow<ItemType, CellType: ConfigurableCell where CellType.T == I
|
|||
|
||||
// MARK: - actions -
|
||||
|
||||
public func addAction(action: TableRowAction<ItemType, CellType>) -> Self {
|
||||
public func action(action: TableRowAction<ItemType, CellType>) -> Self {
|
||||
|
||||
actions[action.type.key] = action
|
||||
return self
|
||||
|
|
|
|||
Loading…
Reference in New Issue