Commit 4055f4ae by Daniel Dahan

added MaterialTableViewCell

parent 175f214b
...@@ -107,7 +107,7 @@ class LeftViewController: UIViewController { ...@@ -107,7 +107,7 @@ class LeftViewController: UIViewController {
/// Prepares the tableView. /// Prepares the tableView.
private func prepareTableView() { private func prepareTableView() {
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell") tableView.registerClass(MaterialTableViewCell.self, forCellReuseIdentifier: "MaterialTableViewCell")
tableView.dataSource = self tableView.dataSource = self
tableView.delegate = self tableView.delegate = self
tableView.separatorStyle = .None tableView.separatorStyle = .None
...@@ -128,7 +128,7 @@ extension LeftViewController: UITableViewDataSource { ...@@ -128,7 +128,7 @@ extension LeftViewController: UITableViewDataSource {
/// Prepares the cells within the tableView. /// Prepares the cells within the tableView.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 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 cell.backgroundColor = MaterialColor.clear
let item: Cell = items[indexPath.row] let item: Cell = items[indexPath.row]
......
...@@ -78,7 +78,7 @@ class RightViewController: UIViewController { ...@@ -78,7 +78,7 @@ class RightViewController: UIViewController {
/// Prepares the tableView. /// Prepares the tableView.
private func prepareTableView() { private func prepareTableView() {
tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell") tableView.registerClass(MaterialTableViewCell.self, forCellReuseIdentifier: "MaterialTableViewCell")
tableView.backgroundColor = MaterialColor.clear tableView.backgroundColor = MaterialColor.clear
tableView.dataSource = self tableView.dataSource = self
tableView.delegate = self tableView.delegate = self
...@@ -100,7 +100,7 @@ extension RightViewController: UITableViewDataSource { ...@@ -100,7 +100,7 @@ extension RightViewController: UITableViewDataSource {
/// Prepares the cells within the tableView. /// Prepares the cells within the tableView.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 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 cell.backgroundColor = MaterialColor.clear
let item: Cell = items[indexPath.row] let item: Cell = items[indexPath.row]
......
...@@ -107,9 +107,6 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -107,9 +107,6 @@ public class MaterialTableViewCell: UITableViewCell {
} }
set(value) { set(value) {
layer.frame.size.width = value layer.frame.size.width = value
if .None != shape {
layer.frame.size.height = value
}
} }
} }
...@@ -125,9 +122,6 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -125,9 +122,6 @@ public class MaterialTableViewCell: UITableViewCell {
} }
set(value) { set(value) {
layer.frame.size.height = value layer.frame.size.height = value
if .None != shape {
layer.frame.size.width = value
}
} }
} }
...@@ -191,9 +185,6 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -191,9 +185,6 @@ public class MaterialTableViewCell: UITableViewCell {
didSet { didSet {
if let v: MaterialRadius = cornerRadiusPreset { if let v: MaterialRadius = cornerRadiusPreset {
cornerRadius = MaterialRadiusToValue(v) cornerRadius = MaterialRadiusToValue(v)
if .Circle == shape {
shape = .None
}
} }
} }
} }
...@@ -205,23 +196,6 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -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. /// A preset property to set the borderWidth.
public var borderWidthPreset: MaterialBorder = .None { public var borderWidthPreset: MaterialBorder = .None {
didSet { didSet {
...@@ -284,7 +258,6 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -284,7 +258,6 @@ public class MaterialTableViewCell: UITableViewCell {
public override func layoutSublayersOfLayer(layer: CALayer) { public override func layoutSublayersOfLayer(layer: CALayer) {
super.layoutSublayersOfLayer(layer) super.layoutSublayersOfLayer(layer)
if self.layer == layer { if self.layer == layer {
layoutShape()
layoutVisualLayer() layoutVisualLayer()
} }
} }
...@@ -396,6 +369,8 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -396,6 +369,8 @@ public class MaterialTableViewCell: UITableViewCell {
public func prepareView() { public func prepareView() {
prepareVisualLayer() prepareVisualLayer()
selectionStyle = .None selectionStyle = .None
pulseColor = MaterialColor.grey.lighten1
pulseScale = false
imageView?.userInteractionEnabled = false imageView?.userInteractionEnabled = false
textLabel?.userInteractionEnabled = false textLabel?.userInteractionEnabled = false
detailTextLabel?.userInteractionEnabled = false detailTextLabel?.userInteractionEnabled = false
...@@ -405,7 +380,7 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -405,7 +380,7 @@ public class MaterialTableViewCell: UITableViewCell {
internal func prepareVisualLayer() { internal func prepareVisualLayer() {
visualLayer.zPosition = 0 visualLayer.zPosition = 0
visualLayer.masksToBounds = true visualLayer.masksToBounds = true
layer.addSublayer(visualLayer) contentView.layer.addSublayer(visualLayer)
} }
/// Manages the layout for the visualLayer property. /// Manages the layout for the visualLayer property.
...@@ -415,13 +390,6 @@ public class MaterialTableViewCell: UITableViewCell { ...@@ -415,13 +390,6 @@ public class MaterialTableViewCell: UITableViewCell {
visualLayer.cornerRadius = layer.cornerRadius 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. Triggers the pulse animation.
- Parameter point: A point to pulse from. - 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