Commit 4055f4ae by Daniel Dahan

added MaterialTableViewCell

parent 175f214b
......@@ -107,7 +107,7 @@ class LeftViewController: UIViewController {
/// Prepares the tableView.
private func prepareTableView() {
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
tableView.registerClass(MaterialTableViewCell.self, forCellReuseIdentifier: "MaterialTableViewCell")
tableView.dataSource = self
tableView.delegate = self
tableView.separatorStyle = .None
......@@ -128,7 +128,7 @@ extension LeftViewController: UITableViewDataSource {
/// Prepares the cells within the tableView.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
let cell: MaterialTableViewCell = tableView.dequeueReusableCellWithIdentifier("MaterialTableViewCell", forIndexPath: indexPath) as! MaterialTableViewCell
cell.backgroundColor = MaterialColor.clear
let item: Cell = items[indexPath.row]
......
......@@ -78,7 +78,7 @@ class RightViewController: UIViewController {
/// Prepares the tableView.
private func prepareTableView() {
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
tableView.registerClass(MaterialTableViewCell.self, forCellReuseIdentifier: "MaterialTableViewCell")
tableView.backgroundColor = MaterialColor.clear
tableView.dataSource = self
tableView.delegate = self
......@@ -100,7 +100,7 @@ extension RightViewController: UITableViewDataSource {
/// Prepares the cells within the tableView.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell: UITableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
let cell: MaterialTableViewCell = tableView.dequeueReusableCellWithIdentifier("MaterialTableViewCell", forIndexPath: indexPath) as! MaterialTableViewCell
cell.backgroundColor = MaterialColor.clear
let item: Cell = items[indexPath.row]
......
......@@ -107,9 +107,6 @@ public class MaterialTableViewCell: UITableViewCell {
}
set(value) {
layer.frame.size.width = value
if .None != shape {
layer.frame.size.height = value
}
}
}
......@@ -125,9 +122,6 @@ public class MaterialTableViewCell: UITableViewCell {
}
set(value) {
layer.frame.size.height = value
if .None != shape {
layer.frame.size.width = value
}
}
}
......@@ -191,9 +185,6 @@ public class MaterialTableViewCell: UITableViewCell {
didSet {
if let v: MaterialRadius = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(v)
if .Circle == shape {
shape = .None
}
}
}
}
......@@ -205,23 +196,6 @@ public class MaterialTableViewCell: UITableViewCell {
}
}
/**
A property that manages the overall shape for the object. If either the
width or height property is set, the other will be automatically adjusted
to maintain the shape of the object.
*/
public var shape: MaterialShape = .None {
didSet {
if .None != shape {
if width < height {
frame.size.width = height
} else {
frame.size.height = width
}
}
}
}
/// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None {
didSet {
......@@ -284,7 +258,6 @@ public class MaterialTableViewCell: UITableViewCell {
public override func layoutSublayersOfLayer(layer: CALayer) {
super.layoutSublayersOfLayer(layer)
if self.layer == layer {
layoutShape()
layoutVisualLayer()
}
}
......@@ -396,6 +369,8 @@ public class MaterialTableViewCell: UITableViewCell {
public func prepareView() {
prepareVisualLayer()
selectionStyle = .None
pulseColor = MaterialColor.grey.lighten1
pulseScale = false
imageView?.userInteractionEnabled = false
textLabel?.userInteractionEnabled = false
detailTextLabel?.userInteractionEnabled = false
......@@ -405,7 +380,7 @@ public class MaterialTableViewCell: UITableViewCell {
internal func prepareVisualLayer() {
visualLayer.zPosition = 0
visualLayer.masksToBounds = true
layer.addSublayer(visualLayer)
contentView.layer.addSublayer(visualLayer)
}
/// Manages the layout for the visualLayer property.
......@@ -415,13 +390,6 @@ public class MaterialTableViewCell: UITableViewCell {
visualLayer.cornerRadius = layer.cornerRadius
}
/// Manages the layout for the shape of the view instance.
internal func layoutShape() {
if .Circle == shape {
layer.cornerRadius = width / 2
}
}
/**
Triggers the pulse animation.
- Parameter point: A point to pulse from.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment