-
Notifications
You must be signed in to change notification settings - Fork 57
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
GenericBrick #65
Conversation
Fixes #64
Current coverage is 93.78% (diff: 100%)
|
There was a problem hiding this 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)]" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are anchors also constraints?
The layout anchor API creates a constraint and automatically attaches it to the right view in the hierarchy. (You just need to set the active property on it to true before you're done). I can provide an example later, or you can take a look at the nslayoutanchor type and what anchors uiview has.
…--
Kevin Lundberg
On Jan 24, 2017, at 7:30 PM, Ruben Cagnie ***@***.***> wrote:
@rubencagnie commented on this pull request.
In Source/Bricks/Generic/GenericBrick.swift:
> +
+ public override func updateContent() {
+ super.updateContent()
+
+ clearContentViewAndConstraints()
+
+ if let generic = self._brick as? ViewGenerator {
+ let genericContentView = generic.generateView(self.frame, in: self)
+ genericContentView.translatesAutoresizingMaskIntoConstraints = false
+
+ self.contentView.addSubview(genericContentView)
+
+ 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)
Are anchors also constraints?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
- 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
Fixes #56 |
Introduction of a GenericBrick, that allows to wrap any UIView in a Brick.
This will allow a straight forward syntax:
Fixes #64