estimated height improvements
This commit is contained in:
parent
051dba0e97
commit
3f54cacab0
|
|
@ -31,7 +31,7 @@ public protocol RowBuilder {
|
|||
func willUpdateDirector(director: TableDirector?)
|
||||
|
||||
func rowHeight(index: Int) -> CGFloat
|
||||
func estimatedRowHeight() -> CGFloat
|
||||
func estimatedRowHeight(index: Int) -> CGFloat
|
||||
|
||||
func invoke(action action: ActionType, cell: UITableViewCell?, indexPath: NSIndexPath, itemIndex: Int, userInfo: [NSObject: AnyObject]?) -> AnyObject?
|
||||
}
|
||||
|
|
@ -57,7 +57,7 @@ public class TableBaseRowBuilder<DataType, CellType where CellType: UITableViewC
|
|||
return UITableViewAutomaticDimension
|
||||
}
|
||||
|
||||
public func estimatedRowHeight() -> CGFloat {
|
||||
public func estimatedRowHeight(index: Int) -> CGFloat {
|
||||
return 44
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -141,7 +141,8 @@ public class TableDirector: NSObject, UITableViewDataSource, UITableViewDelegate
|
|||
// MARK: UITableViewDelegate - actions
|
||||
|
||||
public func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
|
||||
return builderAtIndexPath(indexPath).0.estimatedRowHeight()
|
||||
let builder = builderAtIndexPath(indexPath)
|
||||
return builder.0.estimatedRowHeight(builder.1)
|
||||
}
|
||||
|
||||
public func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class TablePrototypeRowBuilder<DataType: Hashable, CellType: Configurable
|
|||
super.init(items: items, id: CellType.reusableIdentifier())
|
||||
}
|
||||
|
||||
public override func estimatedRowHeight() -> CGFloat {
|
||||
public override func estimatedRowHeight(index: Int) -> CGFloat {
|
||||
return UITableViewAutomaticDimension
|
||||
}
|
||||
|
||||
|
|
@ -74,25 +74,6 @@ public class TablePrototypeRowBuilder<DataType: Hashable, CellType: Configurable
|
|||
return height
|
||||
}
|
||||
|
||||
public func preheat(item: DataType) {
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
|
||||
|
||||
let height = self.heightCall(item, width: 0)
|
||||
|
||||
// check if actual height exists
|
||||
// calc height
|
||||
|
||||
//let heights = self.items.map { self.heightZ($0) }
|
||||
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
|
||||
|
||||
// check if table width is actual
|
||||
// store height in cache
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override func invoke(action action: ActionType, cell: UITableViewCell?, indexPath: NSIndexPath, itemIndex: Int, userInfo: [NSObject: AnyObject]?) -> AnyObject? {
|
||||
|
||||
if case .configure = action {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class TableRowBuilder<DataType, CellType: ConfigurableCell where CellType
|
|||
return super.invoke(action: action, cell: cell, indexPath: indexPath, itemIndex: itemIndex, userInfo: userInfo)
|
||||
}
|
||||
|
||||
public override func estimatedRowHeight() -> CGFloat {
|
||||
public override func estimatedRowHeight(index: Int) -> CGFloat {
|
||||
return CGFloat(CellType.estimatedHeight())
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ import UIKit
|
|||
Can host several row builders.
|
||||
*/
|
||||
public class TableSectionBuilder {
|
||||
|
||||
|
||||
weak var tableDirector: TableDirector? {
|
||||
didSet {
|
||||
guard let director = tableDirector else { return }
|
||||
|
|
|
|||
|
|
@ -110,5 +110,4 @@ public class Action {
|
|||
public func invoke() {
|
||||
NSNotificationCenter.defaultCenter().postNotificationName(TabletNotifications.CellAction, object: self, userInfo: userInfo)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -97,13 +97,13 @@
|
|||
DAC2D68B1C9D7990009E9C19 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DA08A04E1CF3AB0C00BBF1F8 /* ConfigurableCell.swift */,
|
||||
DA08A0501CF3AB6100BBF1F8 /* RowBuilder.swift */,
|
||||
DAC2D68C1C9D799E009E9C19 /* TableDirector.swift */,
|
||||
DA08A0501CF3AB6100BBF1F8 /* RowBuilder.swift */,
|
||||
DAC2D68D1C9D799E009E9C19 /* TableBaseRowBuilder.swift */,
|
||||
5058386D1CF62B0700224C58 /* TableRowBuilder.swift */,
|
||||
5058386F1CF62B1300224C58 /* TablePrototypeRowBuilder.swift */,
|
||||
DAC2D68E1C9D799E009E9C19 /* TableSectionBuilder.swift */,
|
||||
DA08A04E1CF3AB0C00BBF1F8 /* ConfigurableCell.swift */,
|
||||
DAC2D68F1C9D799E009E9C19 /* Tablet.swift */,
|
||||
);
|
||||
name = Classes;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class MainController: UIViewController {
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
let rows = TablePrototypeRowBuilder<String, StoryboardImageTableViewCell>(items: ["1", "1", "1", "1"])
|
||||
let rows = TableRowBuilder<String, StoryboardImageTableViewCell>(items: ["1", "1", "1", "1"])
|
||||
.action(.click) { [unowned self] e in
|
||||
self.performSegueWithIdentifier("headerfooter", sender: nil)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,8 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
5058386B1CF6189D00224C58 /* Tablet.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5058386A1CF6189D00224C58 /* Tablet.framework */; };
|
||||
5058386C1CF6189D00224C58 /* Tablet.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 5058386A1CF6189D00224C58 /* Tablet.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
DA08A0531CF4E9B500BBF1F8 /* StoryboardImageTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA08A0521CF4E9B500BBF1F8 /* StoryboardImageTableViewCell.swift */; };
|
||||
DA539C941CF6610400368ACB /* Tablet.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA539C931CF6610400368ACB /* Tablet.framework */; };
|
||||
DAC2D5CA1C9D303E009E9C19 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAC2D5C91C9D303E009E9C19 /* AppDelegate.swift */; };
|
||||
DAC2D5CF1C9D30A7009E9C19 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DAC2D5CD1C9D30A7009E9C19 /* Main.storyboard */; };
|
||||
DAC2D5D01C9D30A7009E9C19 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DAC2D5CE1C9D30A7009E9C19 /* LaunchScreen.storyboard */; };
|
||||
|
|
@ -19,23 +18,9 @@
|
|||
DACB717A1CC2D89D00432BD3 /* HeaderFooterController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DACB71791CC2D89D00432BD3 /* HeaderFooterController.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
DA539C921CF50E9900368ACB /* Embed Frameworks */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
5058386C1CF6189D00224C58 /* Tablet.framework in Embed Frameworks */,
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
5058386A1CF6189D00224C58 /* Tablet.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Tablet.framework; path = "/Users/max/Library/Developer/Xcode/DerivedData/Tablet-bomgsgklcxthxkeamvdbfmrhqnno/Build/Products/Debug-iphonesimulator/Tablet.framework"; sourceTree = "<absolute>"; };
|
||||
DA08A0521CF4E9B500BBF1F8 /* StoryboardImageTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StoryboardImageTableViewCell.swift; sourceTree = "<group>"; };
|
||||
DA539C931CF6610400368ACB /* Tablet.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Tablet.framework; path = "../../../../../Library/Developer/Xcode/DerivedData/Tablet-hgommdyxtgxijceamltarpblrbwc/Build/Products/Debug-iphoneos/Tablet.framework"; sourceTree = "<group>"; };
|
||||
DAB7EB271BEF787300D2AD5E /* TabletDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TabletDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
DAC2D5C91C9D303E009E9C19 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
DAC2D5CD1C9D30A7009E9C19 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
|
||||
|
|
@ -52,7 +37,7 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5058386B1CF6189D00224C58 /* Tablet.framework in Frameworks */,
|
||||
DA539C941CF6610400368ACB /* Tablet.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
@ -62,6 +47,7 @@
|
|||
DA539C871CF50B1800368ACB /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DA539C931CF6610400368ACB /* Tablet.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -69,7 +55,6 @@
|
|||
DAB7EB1E1BEF787300D2AD5E = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5058386A1CF6189D00224C58 /* Tablet.framework */,
|
||||
DAC2D5C61C9D2FE5009E9C19 /* Classes */,
|
||||
DAC2D5CB1C9D3058009E9C19 /* Resources */,
|
||||
DA539C871CF50B1800368ACB /* Frameworks */,
|
||||
|
|
@ -166,7 +151,6 @@
|
|||
DAB7EB231BEF787300D2AD5E /* Sources */,
|
||||
DAB7EB241BEF787300D2AD5E /* Frameworks */,
|
||||
DAB7EB251BEF787300D2AD5E /* Resources */,
|
||||
DA539C921CF50E9900368ACB /* Embed Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue