Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GenericBrick #65

Merged
merged 3 commits into from
Jan 26, 2017
Merged

GenericBrick #65

merged 3 commits into from
Jan 26, 2017

Conversation

rubencagnie
Copy link
Contributor

Introduction of a GenericBrick, that allows to wrap any UIView in a Brick.

This will allow a straight forward syntax:

GenericBrick<UILabel>(GenericLabelBrickIdentifier, size: BrickSize(...)) { label, cell in
            label.text = "LABEL " + String(cell.index)
            cell.edgeInsets = UIEdgeInsets(top: 5, left: 10, bottom: 15, right: 20)
        }

Fixes #64

@codecov-io
Copy link

codecov-io commented Jan 24, 2017

Current coverage is 93.78% (diff: 100%)

No coverage report found for master at d5028f2.

Powered by Codecov. Last update d5028f2...d1c0ec9

Copy link
Contributor

@klundberg klundberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just 2 comments before we should merge it.

// If not overriden, it uses the same as the Brick class
public override class var nibName: String {
let generic = NSStringFromClass(T.self).componentsSeparatedByString(".").last!
return "Generic[\(generic)]"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can a filename have [] in it? Additionally, how would you configure a nib to interact with this brick? we create the generic view manually with init(frame:) below, so there's no opportunity for a nib to be instantiated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nibName is used to identify the brick when registering. So in this case, there won't be a nib loaded, it will use the cellClass (GenericBrickCell)

let topSpaceConstraint = NSLayoutConstraint(item: genericContentView, attribute: .Top, relatedBy: .Equal, toItem: self.contentView, attribute: .Top, multiplier: 1, constant: edgeInsets.top)
let bottomSpaceConstraint = NSLayoutConstraint(item: self.contentView, attribute: .Bottom, relatedBy: .Equal, toItem: genericContentView, attribute: .Bottom, multiplier: 1, constant: edgeInsets.bottom)
let leftSpaceConstraint = NSLayoutConstraint(item: genericContentView, attribute: .Left, relatedBy: .Equal, toItem: self.contentView, attribute: .Left, multiplier: 1, constant: edgeInsets.left)
let rightSpaceConstraint = NSLayoutConstraint(item: self.contentView, attribute: .Right, relatedBy: .Equal, toItem: genericContentView, attribute: .Right, multiplier: 1, constant: edgeInsets.right)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these could be written using layout anchors a bit more concisely

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are anchors also constraints?

@klundberg
Copy link
Contributor

klundberg commented Jan 25, 2017 via email

- Added internalIdentifier property, that ensures a unique identifier per Brick
- Changed the generation of constraints using anchors
- Removed the extensions of BrickCollectionView and BrickViewController, so that these properties can be overwritten
@rubencagnie
Copy link
Contributor Author

Fixes #56

@rubencagnie rubencagnie merged commit 0b195ca into master Jan 26, 2017
@rubencagnie rubencagnie deleted the 64-generic-brick branch February 8, 2017 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants