Skip to content

Multi-binding syntax #63

Open
Open
@ZevEisenberg

Description

@ZevEisenberg

Not sure if that's the right term for it, but this idea is inspired by SnapKit, which can do this:

someView.snp.makeConstraints { 
    innerView.width.centerX.top.equalToSuperview()
}

I was thinking that an Anchorage-like way to do that would be something more like this:

innerView.anchors([.width, .centerX, .top]) == otherView

As a convenience, we could also supply a constant that means "the superview of the view to the left of the ==:

innerView.anchors([.width, .centerX, .top]) == Anchorage.Superview() // name TBD

Question: would this work with operators that we use to inset/offset things? I think probably not, just to simplify things. We already provide verticalAnchors, horizontalAnchors, edgeAnchors, and centerAnchors for cases where you would want to pin common combinations with an inset/offset. So, I think this should be a compilation error:

innerView.anchors([.width, .centerX, .top]) == otherView + 10

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions