1
1
mirror of https://github.com/robb/Cartography.git synced 2024-10-06 21:47:18 +03:00

Merge branch 'master' into swift-2.0

This commit is contained in:
Robert Böhnke 2015-06-20 16:07:33 +02:00
commit 7c0bdca4b6
5 changed files with 70 additions and 10 deletions

29
CODE_OF_CONDUCT.md Normal file
View File

@ -0,0 +1,29 @@
# Contributor Code of Conduct
As contributors and maintainers of this project, we pledge to respect all people
who contribute through reporting issues, posting feature requests, updating
documentation, submitting pull requests or patches, and other activities.
We are committed to making participation in this project a harassment-free
experience for everyone, regardless of level of experience, gender, gender
identity and expression, sexual orientation, disability, personal appearance,
body size, race, ethnicity, age, or religion.
Examples of unacceptable behavior by participants include the use of sexual
language or imagery, derogatory comments or personal attacks, trolling, public
or private harassment, insults, or other unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct. Project maintainers who do not follow the
Code of Conduct may be removed from the project team.
This code of conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community.
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by opening an issue or contacting one or more of the project
maintainers.
This Code of Conduct is adapted from the [Contributor Covenant, version
1.1.0](http://contributor- covenant.org/version/1/1/0/)

View File

@ -98,6 +98,18 @@ public struct LayoutProxy {
return Edge(context, view, .FirstBaseline)
}
/// All edges of the view with their respective margins. This property
/// affects `topMargin`, `bottomMargin`, `leadingMargin` and
/// `trailingMargin`.
public var edgesWithinMargins: Edges {
return Edges(context, [
Edge(context, view, .TopMargin),
Edge(context, view, .LeadingMargin),
Edge(context, view, .BottomMargin),
Edge(context, view, .TrailingMargin)
])
}
/// The left margin of the view. iOS exclusive.
public var leftMargin: Edge {
return Edge(context, view, .LeftMargin)

View File

@ -265,13 +265,13 @@ class EdgeSpec: QuickSpec {
#if os(iOS)
describe("on iOS only") {
beforeEach {
view.layoutMargins = UIEdgeInsets(top: -10, left: -20, bottom: -30, right: -40)
superview.layoutMargins = UIEdgeInsets(top: 10, left: 20, bottom: 30, right: 40)
}
describe("LayoutProxy.topMargin") {
it("should support relative equalities") {
layout(view) { view in
view.topMargin == view.superview!.top
view.top == view.superview!.topMargin
}
expect(view.frame.minY).to(equal(10))
@ -281,29 +281,29 @@ class EdgeSpec: QuickSpec {
describe("LayoutProxy.rightMargin") {
it("should support relative equalities") {
layout(view) { view in
view.rightMargin == view.superview!.right
view.right == view.superview!.rightMargin
}
expect(view.frame.maxX).to(equal(360))
}
}
describe("LayoutProxy.bottomMargin") {
it("should support relative equalities") {
layout(view) { view in
view.bottomMargin == view.superview!.bottom
view.bottom == view.superview!.bottomMargin
}
expect(view.frame.maxY).to(equal(370))
}
}
describe("LayoutProxy.leftMargin") {
it("should support relative equalities") {
layout(view) { view in
view.leftMargin == view.superview!.left
view.left == view.superview!.leftMargin
}
expect(view.frame.minX).to(equal(20))
}
}

View File

@ -61,5 +61,23 @@ class EdgesSpec: QuickSpec {
expect(view.frame).to(equal(CGRectMake(20, 10, 340, 360)))
}
}
#if os(iOS)
describe("on iOS only") {
beforeEach {
superview.layoutMargins = UIEdgeInsets(top: 10, left: 20, bottom: 30, right: 40)
}
describe("LayoutProxy.edgesWithinMargins") {
it("should support relative equalities") {
layout(view) { view in
view.edges == view.superview!.edgesWithinMargins
}
expect(view.frame).to(equal(CGRectMake(20, 10, 340, 360)))
}
}
}
#endif
}
}

View File

@ -122,6 +122,7 @@ as well as the iOS specific
- `trailingMargin`
- `centerXWithinMargins`
- `centerYWithinMargins`
- `edgesWithinMargins`
These can be further refined using the following operators: `*`, `/`, `+` and
`-`.