Skip to content

Commit

Permalink
Merge pull request #81 from wayfair/80-generic-brick-clear-color
Browse files Browse the repository at this point in the history
Moved place where generic brick background color is set to clear
  • Loading branch information
rubencagnie authored Feb 13, 2017
2 parents 4e2bcaa + 61cc15d commit affa796
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Source/Bricks/Generic/GenericBrick.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public class GenericBrick<T: UIView>: Brick, ViewGenerator {
public func generateView(frame: CGRect, in cell: GenericBrickCell) -> UIView {
let view = T(frame: frame)

view.backgroundColor = .clearColor()

self.configureView(view: view, cell: cell)

return view
Expand Down Expand Up @@ -66,6 +68,9 @@ public class GenericBrickCell: BrickCell {

clearContentViewAndConstraints()

backgroundColor = .clearColor()
contentView.backgroundColor = .clearColor()

if let generic = self._brick as? ViewGenerator {
let genericContentView = generic.generateView(self.frame, in: self)
genericContentView.translatesAutoresizingMaskIntoConstraints = false
Expand All @@ -88,10 +93,6 @@ public class GenericBrickCell: BrickCell {
self.rightSpaceConstraint = rightSpaceConstraint
}

backgroundColor = .clearColor()
contentView.backgroundColor = .clearColor()
genericContentView?.backgroundColor = .clearColor()

}

private func clearContentViewAndConstraints() {
Expand Down
12 changes: 12 additions & 0 deletions Tests/Bricks/GenericBrickTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,16 @@ class GenericBrickTests: XCTestCase {
XCTAssertEqual(label4.text, "LABEL 4")
}

func testThatBackgroundColorIsNotReset() {
brickCollectionView.setupSingleBrickAndLayout(GenericBrick<UILabel>(GenericLabelBrickIdentifier, width: .Ratio(ratio: 1), height: .Fixed(size: 50), backgroundColor: .orangeColor()) { label, view in
label.backgroundColor = .redColor()
})

let cell: GenericBrickCell? = firstCellForIdentifier(GenericLabelBrickIdentifier)

XCTAssertEqual(cell?.genericContentView?.backgroundColor, UIColor.redColor())
XCTAssertEqual(cell?.contentView.backgroundColor, UIColor.orangeColor())
}


}

0 comments on commit affa796

Please sign in to comment.