Prepare for Jekyll Site

This commit is contained in:
Robert Payne 2015-04-15 11:35:29 +12:00
parent 529e7588aa
commit 5713270eff
28 changed files with 0 additions and 3737 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

View File

@ -1,17 +0,0 @@
CHANGELOG
=======
# 0.10.0 - Next Release In Development
* **BREAKING:** The constraint making chain now utilises protocols to tighten the API's to avoid user error. This may break some syntaxes.
* **BREAKING:** Semantic `and` and `with` chain variables were removed
* Added `update###` functions to `Constraint` so their constants and priorities can be updated
* Added a `Snap.Config.interfaceLayoutDirection` variable for richer Leading/Trailing support.
* Fixed memory leaks that could occur on long lived views
* Ensure Swift 1.2 compatibility
# 0.9.x - March 2015
* Re-worked some internal API to allow for future updates
* Added `snp_prepareConstraints -> [Constraint]` which allows pre-building of constraints
* Added a fatal error to `and` when it is used after relation has been set

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>snp_make</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>CodeBlock</string>
</array>
<key>IDECodeSnippetContents</key>
<string>&lt;#view#&gt;.snp_makeConstraints { make in
&lt;#code#&gt;
}</string>
<key>IDECodeSnippetIdentifier</key>
<string>FF434629-7B96-4AB9-BD96-522275E7B106</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Swift</string>
<key>IDECodeSnippetTitle</key>
<string>Snap Constraint Make</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>2</integer>
</dict>
</plist>

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>snp_remake</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>TopLevel</string>
</array>
<key>IDECodeSnippetContents</key>
<string>&lt;#view#&gt;.snp_remakeConstraints { make in
&lt;#code#&gt;
}</string>
<key>IDECodeSnippetIdentifier</key>
<string>FD093546-D614-4311-82C3-E8FE842F62B1</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Swift</string>
<key>IDECodeSnippetTitle</key>
<string>Snap Constraint Remake</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>0</integer>
</dict>
</plist>

19
LICENSE
View File

@ -1,19 +0,0 @@
Copyright (c) 2011-2015 Masonry Team - https://github.com/Masonry
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

349
README.md
View File

@ -1,349 +0,0 @@
<img src="https://raw.githubusercontent.com/Masonry/Snap/develop/Assets/snap-banner.png" alt="">
====
[![Build Status](https://travis-ci.org/Masonry/Snap.svg)](https://travis-ci.org/Masonry/Snap)
Snap is a light-weight layout framework which wraps AutoLayout with a nicer syntax. Snap has its own layout DSL which provides a chainable way of describing your NSLayoutConstraints which results in layout code that is more concise and readable. Snap supports both iOS and OS X.
> Snap uses some Swift-only features like function overloading, so it cannot be used from Objective-C. Because of this weve chosen to swap prefixes from Masonrys `mas_` to `snp_` so you can use both Masonry and Snap in the same project.
## Requirements
* iOS 7.0+ / Mac OS X 10.9+
* Xcode 6.1
## Installation
> **Embedded frameworks require a minimum deployment target of iOS 8 or OS X Mavericks.**
### CocoaPods
[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects.
CocoaPods 0.36 adds supports for Swift and embedded frameworks. You can install it with the following command:
```bash
$ gem install cocoapods
```
To integrate Snap into your Xcode project using CocoaPods, specify it in your `Podfile`:
```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Snap', '~> 0.9.2'
```
Then, run the following command:
```bash
$ pod install
```
### Carthage
Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.
You can install Carthage with [Homebrew](http://brew.sh/) using the following command:
```bash
$ brew update
$ brew install carthage
```
To integrate Snap into your Xcode project using Carthage, specify it in your `Cartfile`:
```
github "Masonry/Snap" >= 0.9.2
```
### Manually
If you prefer not to use either of the aforementioned dependency managers, you can integrate Snap into your project manually.
### Embedded Framework
- Add Snap as a [submodule](http://git-scm.com/docs/git-submodule) by opening the Terminal, `cd`-ing into your top-level project directory, and entering the following command:
```bash
$ git submodule add https://github.com/Masonry/Snap.git
```
- Open the `Snap` folder, and drag `Snap.xcodeproj` into the file navigator of your app project.
- In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar.
- Ensure that the deployment target of Snap.framework matches that of the application target.
- In the tab bar at the top of that window, open the "Build Phases" panel.
- Expand the "Target Dependencies" group, and add `Snap.framework`.
- Click on the `+` button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add `Snap.framework`.
## What's wrong with NSLayoutConstraints?
Under the hood Auto Layout is a powerful and flexible way of organising and laying out your views. However creating constraints from code is verbose and not very descriptive.
Imagine a simple example in which you want to have a view fill its superview but inset by 10 pixels on every side
```swift
let superview = self;
let view1 = UIView()
view1.setTranslatesAutoresizingMaskIntoConstraints(false)
view1.backgroundColor = UIColor.greenColor()
superview.addSubview(view1)
let padding = UIEdgeInsetsMake(10, 10, 10, 10)
superview.addConstraints([
NSLayoutConstraint(
item: view1,
attribute: NSLayoutAttribute.Top,
relatedBy: NSLayoutRelation.Equal,
toItem: superview,
attribute: NSLayoutAttribute.Top,
multiplier: 1.0,
constant: padding.top
),
NSLayoutConstraint(
item: view1,
attribute: NSLayoutAttribute.Left,
relatedBy: NSLayoutRelation.Equal,
toItem: superview,
attribute: NSLayoutAttribute.Left,
multiplier: 1.0,
constant: padding.left
),
NSLayoutConstraint(
item: view1,
attribute: NSLayoutAttribute.Bottom,
relatedBy: NSLayoutRelation.Equal,
toItem: superview,
attribute: NSLayoutAttribute.Bottom,
multiplier: 1.0,
constant: -padding.bottom
),
NSLayoutConstraint(
item: view1,
attribute: NSLayoutAttribute.Right,
relatedBy: NSLayoutRelation.Equal,
toItem: superview,
attribute: NSLayoutAttribute.Right,
multiplier: 1.0,
constant: -padding.right
)
])
```
Even with such a simple example the code needed is quite verbose and quickly becomes unreadable when you have more than 2 or 3 views.
Another option is to use Visual Format Language (VFL), which is a bit less long winded.
However the ASCII type syntax has its own pitfalls and its also a bit harder to animate as `NSLayoutConstraint.constraintsWithVisualFormat` returns an array.
## Prepare to meet your Maker!
Heres the same constraints created using ConstraintMaker
```swift
let padding = UIEdgeInsetsMake(10, 10, 10, 10)
view1.snp_makeConstraints { (make) -> Void in
make.top.equalTo(superview.snp_top).offset(padding.top)
make.left.equalTo(superview.snp_left).offset(padding.left)
make.bottom.equalTo(superview.snp_bottom).offset(-padding.bottom)
make.right.equalTo(superview.snp_right).offset(-padding.right)
}
```
Or even shorter
```swift
view1.snp_makeConstraints { (make) -> Void in
make.edges.equalTo(superview).insets(padding)
}
```
Also note in the first example we had to add the constraints to the superview `superview.addConstraints`.
Snap however will automagically add constraints to the appropriate view.
Snap will also call `view1.setTranslatesAutoresizingMaskIntoConstraints(false)` for you.
## Not all things are created equal
> `.equalTo` equivalent to **NSLayoutRelation.Equal**
> `.lessThanOrEqualTo` equivalent to **NSLayoutRelation.LessThanOrEqual**
> `.greaterThanOrEqualTo` equivalent to **NSLayoutRelation.GreaterThanOrEqual**
These three equality constraints accept one argument which can be any of the following:
#### 1. ViewAttribute
```swift
make.centerX.lessThanOrEqualTo(view2.snp_left)
```
ViewAttribute | NSLayoutAttribute
------------------------- | --------------------------
view.snp_left | NSLayoutAttribute.Left
view.snp_right | NSLayoutAttribute.Right
view.snp_top | NSLayoutAttribute.Top
view.snp_bottom | NSLayoutAttribute.Bottom
view.snp_leading | NSLayoutAttribute.Leading
view.snp_trailing | NSLayoutAttribute.Trailing
view.snp_width | NSLayoutAttribute.Width
view.snp_height | NSLayoutAttribute.Height
view.snp_centerX | NSLayoutAttribute.CenterX
view.snp_centerY | NSLayoutAttribute.CenterY
view.snp_baseline | NSLayoutAttribute.Baseline
#### 2. UIView/NSView
if you want view.left to be greater than or equal to label.left :
```swift
// these two constraints are exactly the same
make.left.greaterThanOrEqualTo(label)
make.left.greaterThanOrEqualTo(label.snp_left)
```
#### 3. Strict Checks
Auto Layout allows width and height to be set to constant values.
if you want to set view to have a minimum and maximum width you could pass a primitive to the equality blocks:
```swift
// width >= 200 && width <= 400
make.width.greaterThanOrEqualTo(200)
make.width.lessThanOrEqualTo(400)
```
However Auto Layout does not allow alignment attributes such as left, right, centerY etc to be set to constant values.
So if you pass a primitive for these attributes Snap will turn these into constraints relative to the view&rsquo;s superview ie:
```swift
// creates view.left <= view.superview.left + 10
make.left.lessThanOrEqualTo(10)
```
You can also use other primitives and structs to build your constraints, like so:
```swift
make.top.equalTo(42)
make.height.equalTo(20)
make.size.equalTo(CGSizeMake(50, 100))
make.edges.equalTo(UIEdgeInsetsMake(10, 0, 10, 0))
make.left.equalTo(view).offset(UIEdgeInsetsMake(10, 0, 10, 0))
```
## Learn to prioritize
> `.prority` allows you to specify an exact priority
> `.priorityHigh` equivalent to **UILayoutPriority.DefaultHigh**
> `.priorityMedium` is half way between high and low
> `.priorityLow` equivalent to **UILayoutPriority.DefaultLow**
Priorities are can be tacked on to the end of a constraint chain like so:
```swift
make.left.greaterThanOrEqualTo(label.snp_left).with.priorityLow();
make.top.equalTo(label.snp_top).with.priority(600);
```
## Composition, composition, composition
Snap also gives you a few convenience methods which create multiple constraints at the same time.
#### edges
```swift
// make top, left, bottom, right equal view2
make.edges.equalTo(view2);
// make top = superview.top + 5, left = superview.left + 10,
// bottom = superview.bottom - 15, right = superview.right - 20
make.edges.equalTo(superview).insets(UIEdgeInsetsMake(5, 10, 15, 20))
```
#### size
```swift
// make width and height greater than or equal to titleLabel
make.size.greaterThanOrEqualTo(titleLabel)
// make width = superview.width + 100, height = superview.height - 50
make.size.equalTo(superview).offset(CGSizeMake(100, -50))
```
#### center
```swift
// make centerX and centerY = button1
make.center.equalTo(button1)
// make centerX = superview.centerX - 5, centerY = superview.centerY + 10
make.center.equalTo(superview).offset(CGPointMake(-5, 10))
```
You can chain view attributes for increased readability:
```swift
// All edges but the top should equal those of the superview
make.left.right.and.bottom.equalTo(superview)
make.top.equalTo(otherView)
```
## Hold on for dear life
Sometimes you need modify existing constraints in order to animate or remove/replace constraints.
In Snap there are a few different approaches to updating constraints.
#### 1. References
You can hold on to a reference of a particular constraint by assigning the result of a constraint make expression to a local variable or a class property.
You could also reference multiple constraints by storing them away in an array.
```swift
var topConstraint: Constraint? = nil
...
// when making constraints
view1.snp_makeConstraints { make in
self.topConstraint = make.top.equalTo(superview).with.offset(padding.top).constraint
make.left.equalTo(superview).with.offset(padding.left)
}
...
// then later you can call
self.topConstraint.uninstall()
```
### 2. snp_remakeConstraints
`snp_remakeConstraints` is similar to `snp_makeConstraints`, but will first remove all existing constraints installed by Snap.
```swift
func changeButtonPosition() {
self.button.snp_remakeConstraints { make in
make.size.equalTo(self.buttonSize)
if topLeft {
make.top.left.equalTo(10)
} else {
make.bottom.equalTo(self.view).offset(-10)
make.right.equalTo(self.view).offset(-10)
}
}
}
```
## Code Snippets
Copy the included code snippets to ``~/Library/Developer/Xcode/UserData/CodeSnippets`` to write your snap closures at lightning speed!
`snp_make` -> `<view>.snp_makeConstraints { make in <code> }`
`snp_remake` -> `<view>.snp_remakeConstraints { make in <code> }`
## TODO
* Eye candy
* Example projects
* Tests

View File

@ -1,17 +0,0 @@
Pod::Spec.new do |s|
s.name = 'Snap'
s.version = '0.9.2'
s.license = 'MIT'
s.summary = 'Harness the power of auto layout with a simplified, chainable, and compile time safe syntax.'
s.homepage = 'https://github.com/Masonry/Snap'
s.authors = { 'Robert Payne' => 'robertpayne@me.com' }
s.social_media_url = 'http://twitter.com/robertjpayne'
s.source = { :git => 'https://github.com/Masonry/Snap.git', :tag => '0.9.2' }
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.9'
s.source_files = 'Source/*.swift'
s.requires_arc = true
end

View File

@ -1,695 +0,0 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
EE94F6091AC0F10A008767FF /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE94F6081AC0F10A008767FF /* UIKit.framework */; };
EE94F60B1AC0F10F008767FF /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EE94F60A1AC0F10F008767FF /* AppKit.framework */; };
EE94F6101AC0F143008767FF /* Snap.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EEBCC9D819CC627D0083B827 /* Snap.framework */; };
EE94F6111AC0F146008767FF /* Snap.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EECDB37A1AC0C9D4006BBC11 /* Snap.framework */; };
EECDB36C1AC0C9A6006BBC11 /* Constraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB35E1AC0C95C006BBC11 /* Constraint.swift */; };
EECDB36D1AC0C9A6006BBC11 /* ConstraintAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB35F1AC0C95C006BBC11 /* ConstraintAttributes.swift */; };
EECDB36E1AC0C9A6006BBC11 /* ConstraintItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB3601AC0C95C006BBC11 /* ConstraintItem.swift */; };
EECDB36F1AC0C9A6006BBC11 /* ConstraintMaker.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB3611AC0C95C006BBC11 /* ConstraintMaker.swift */; };
EECDB3701AC0C9A6006BBC11 /* ConstraintRelation.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB3621AC0C95C006BBC11 /* ConstraintRelation.swift */; };
EECDB3711AC0C9A6006BBC11 /* EdgeInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB3631AC0C95C006BBC11 /* EdgeInsets.swift */; };
EECDB3721AC0C9A6006BBC11 /* LayoutConstraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB3651AC0C95C006BBC11 /* LayoutConstraint.swift */; };
EECDB3731AC0C9A6006BBC11 /* View+Snap.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB3671AC0C95C006BBC11 /* View+Snap.swift */; };
EECDB3741AC0C9B6006BBC11 /* Snap.h in Headers */ = {isa = PBXBuildFile; fileRef = EECDB3661AC0C95C006BBC11 /* Snap.h */; settings = {ATTRIBUTES = (Public, ); }; };
EECDB3931AC0CB52006BBC11 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB36A1AC0C95C006BBC11 /* Tests.swift */; };
EECDB3941AC0CB52006BBC11 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB36A1AC0C95C006BBC11 /* Tests.swift */; };
EECDB3951AC0CBFF006BBC11 /* Constraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB35E1AC0C95C006BBC11 /* Constraint.swift */; };
EECDB3961AC0CBFF006BBC11 /* ConstraintAttributes.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB35F1AC0C95C006BBC11 /* ConstraintAttributes.swift */; };
EECDB3971AC0CBFF006BBC11 /* ConstraintItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB3601AC0C95C006BBC11 /* ConstraintItem.swift */; };
EECDB3981AC0CBFF006BBC11 /* ConstraintMaker.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB3611AC0C95C006BBC11 /* ConstraintMaker.swift */; };
EECDB3991AC0CBFF006BBC11 /* ConstraintRelation.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB3621AC0C95C006BBC11 /* ConstraintRelation.swift */; };
EECDB39A1AC0CBFF006BBC11 /* EdgeInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB3631AC0C95C006BBC11 /* EdgeInsets.swift */; };
EECDB39B1AC0CBFF006BBC11 /* LayoutConstraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB3651AC0C95C006BBC11 /* LayoutConstraint.swift */; };
EECDB39C1AC0CBFF006BBC11 /* View+Snap.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB3671AC0C95C006BBC11 /* View+Snap.swift */; };
EECDB39D1AC0CC03006BBC11 /* Snap.h in Headers */ = {isa = PBXBuildFile; fileRef = EECDB3661AC0C95C006BBC11 /* Snap.h */; settings = {ATTRIBUTES = (Public, ); }; };
EEFCF32C1AD910B900A425FA /* Debugging.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEFCF32B1AD910B900A425FA /* Debugging.swift */; };
EEFCF32D1AD9250C00A425FA /* Debugging.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEFCF32B1AD910B900A425FA /* Debugging.swift */; };
EEFCF32F1AD926AE00A425FA /* Snap.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEFCF32E1AD926AE00A425FA /* Snap.swift */; };
EEFCF3301AD92C2200A425FA /* Snap.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEFCF32E1AD926AE00A425FA /* Snap.swift */; };
EEFCF3321AD9432400A425FA /* ConstraintDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEFCF3311AD9432400A425FA /* ConstraintDescription.swift */; };
EEFCF3331AD9432400A425FA /* ConstraintDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEFCF3311AD9432400A425FA /* ConstraintDescription.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
EECDB3861AC0C9D4006BBC11 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = DDC9FD8D1981B4DD009612C7 /* Project object */;
proxyType = 1;
remoteGlobalIDString = EECDB3791AC0C9D4006BBC11;
remoteInfo = "Snap OSX";
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
EE94F6081AC0F10A008767FF /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
EE94F60A1AC0F10F008767FF /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework; sourceTree = DEVELOPER_DIR; };
EEBCC9D819CC627D0083B827 /* Snap.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Snap.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EEBCC9E219CC627E0083B827 /* Snap iOS Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Snap iOS Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
EECDB35E1AC0C95C006BBC11 /* Constraint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constraint.swift; sourceTree = "<group>"; };
EECDB35F1AC0C95C006BBC11 /* ConstraintAttributes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintAttributes.swift; sourceTree = "<group>"; };
EECDB3601AC0C95C006BBC11 /* ConstraintItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintItem.swift; sourceTree = "<group>"; };
EECDB3611AC0C95C006BBC11 /* ConstraintMaker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintMaker.swift; sourceTree = "<group>"; };
EECDB3621AC0C95C006BBC11 /* ConstraintRelation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintRelation.swift; sourceTree = "<group>"; };
EECDB3631AC0C95C006BBC11 /* EdgeInsets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EdgeInsets.swift; sourceTree = "<group>"; };
EECDB3641AC0C95C006BBC11 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
EECDB3651AC0C95C006BBC11 /* LayoutConstraint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LayoutConstraint.swift; sourceTree = "<group>"; };
EECDB3661AC0C95C006BBC11 /* Snap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Snap.h; sourceTree = "<group>"; };
EECDB3671AC0C95C006BBC11 /* View+Snap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Snap.swift"; sourceTree = "<group>"; };
EECDB3691AC0C95C006BBC11 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
EECDB36A1AC0C95C006BBC11 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = "<group>"; };
EECDB37A1AC0C9D4006BBC11 /* Snap.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Snap.framework; sourceTree = BUILT_PRODUCTS_DIR; };
EECDB3841AC0C9D4006BBC11 /* Snap OSX Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Snap OSX Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
EEFCF32B1AD910B900A425FA /* Debugging.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Debugging.swift; sourceTree = "<group>"; };
EEFCF32E1AD926AE00A425FA /* Snap.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Snap.swift; sourceTree = "<group>"; };
EEFCF3311AD9432400A425FA /* ConstraintDescription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintDescription.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
EE94F60D1AC0F132008767FF /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
EE94F6111AC0F146008767FF /* Snap.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
EE94F60E1AC0F136008767FF /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
EE94F6101AC0F143008767FF /* Snap.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
EEBCC9D419CC627D0083B827 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
EE94F6091AC0F10A008767FF /* UIKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
EECDB3761AC0C9D4006BBC11 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
EE94F60B1AC0F10F008767FF /* AppKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
DDC9FD8C1981B4DD009612C7 = {
isa = PBXGroup;
children = (
EECDB35D1AC0C95C006BBC11 /* Source */,
EE94F60C1AC0F113008767FF /* Frameworks */,
DDC9FD961981B4DD009612C7 /* Products */,
);
sourceTree = "<group>";
};
DDC9FD961981B4DD009612C7 /* Products */ = {
isa = PBXGroup;
children = (
EEBCC9D819CC627D0083B827 /* Snap.framework */,
EEBCC9E219CC627E0083B827 /* Snap iOS Tests.xctest */,
EECDB37A1AC0C9D4006BBC11 /* Snap.framework */,
EECDB3841AC0C9D4006BBC11 /* Snap OSX Tests.xctest */,
);
name = Products;
sourceTree = "<group>";
};
EE94F60C1AC0F113008767FF /* Frameworks */ = {
isa = PBXGroup;
children = (
EE94F60A1AC0F10F008767FF /* AppKit.framework */,
EE94F6081AC0F10A008767FF /* UIKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
EECDB35D1AC0C95C006BBC11 /* Source */ = {
isa = PBXGroup;
children = (
EECDB3661AC0C95C006BBC11 /* Snap.h */,
EEFCF32E1AD926AE00A425FA /* Snap.swift */,
EECDB35E1AC0C95C006BBC11 /* Constraint.swift */,
EEFCF3311AD9432400A425FA /* ConstraintDescription.swift */,
EECDB3611AC0C95C006BBC11 /* ConstraintMaker.swift */,
EECDB3671AC0C95C006BBC11 /* View+Snap.swift */,
EECDB3601AC0C95C006BBC11 /* ConstraintItem.swift */,
EECDB3631AC0C95C006BBC11 /* EdgeInsets.swift */,
EECDB3651AC0C95C006BBC11 /* LayoutConstraint.swift */,
EEFCF32B1AD910B900A425FA /* Debugging.swift */,
EECDB3621AC0C95C006BBC11 /* ConstraintRelation.swift */,
EECDB35F1AC0C95C006BBC11 /* ConstraintAttributes.swift */,
EECDB36B1AC0C967006BBC11 /* Supporting Files */,
EECDB3681AC0C95C006BBC11 /* Tests */,
);
path = Source;
sourceTree = "<group>";
};
EECDB3681AC0C95C006BBC11 /* Tests */ = {
isa = PBXGroup;
children = (
EECDB3691AC0C95C006BBC11 /* Info.plist */,
EECDB36A1AC0C95C006BBC11 /* Tests.swift */,
);
name = Tests;
path = ../Tests;
sourceTree = "<group>";
};
EECDB36B1AC0C967006BBC11 /* Supporting Files */ = {
isa = PBXGroup;
children = (
EECDB3641AC0C95C006BBC11 /* Info.plist */,
);
name = "Supporting Files";
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
EEBCC9D519CC627D0083B827 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
EECDB3741AC0C9B6006BBC11 /* Snap.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
EECDB3771AC0C9D4006BBC11 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
EECDB39D1AC0CC03006BBC11 /* Snap.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
EEBCC9D719CC627D0083B827 /* Snap iOS */ = {
isa = PBXNativeTarget;
buildConfigurationList = EEBCC9E819CC627E0083B827 /* Build configuration list for PBXNativeTarget "Snap iOS" */;
buildPhases = (
EEBCC9D319CC627D0083B827 /* Sources */,
EEBCC9D419CC627D0083B827 /* Frameworks */,
EEBCC9D519CC627D0083B827 /* Headers */,
EEBCC9D619CC627D0083B827 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = "Snap iOS";
productName = Snap;
productReference = EEBCC9D819CC627D0083B827 /* Snap.framework */;
productType = "com.apple.product-type.framework";
};
EEBCC9E119CC627D0083B827 /* Snap iOS Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = EEBCC9EB19CC627E0083B827 /* Build configuration list for PBXNativeTarget "Snap iOS Tests" */;
buildPhases = (
EEBCC9DE19CC627D0083B827 /* Sources */,
EE94F60E1AC0F136008767FF /* Frameworks */,
EEBCC9E019CC627D0083B827 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = "Snap iOS Tests";
productName = SnapTests;
productReference = EEBCC9E219CC627E0083B827 /* Snap iOS Tests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
EECDB3791AC0C9D4006BBC11 /* Snap OSX */ = {
isa = PBXNativeTarget;
buildConfigurationList = EECDB38D1AC0C9D4006BBC11 /* Build configuration list for PBXNativeTarget "Snap OSX" */;
buildPhases = (
EECDB3751AC0C9D4006BBC11 /* Sources */,
EECDB3761AC0C9D4006BBC11 /* Frameworks */,
EECDB3771AC0C9D4006BBC11 /* Headers */,
EECDB3781AC0C9D4006BBC11 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = "Snap OSX";
productName = "Snap OSX";
productReference = EECDB37A1AC0C9D4006BBC11 /* Snap.framework */;
productType = "com.apple.product-type.framework";
};
EECDB3831AC0C9D4006BBC11 /* Snap OSX Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = EECDB3901AC0C9D4006BBC11 /* Build configuration list for PBXNativeTarget "Snap OSX Tests" */;
buildPhases = (
EECDB3801AC0C9D4006BBC11 /* Sources */,
EE94F60D1AC0F132008767FF /* Frameworks */,
EECDB3821AC0C9D4006BBC11 /* Resources */,
);
buildRules = (
);
dependencies = (
EECDB3871AC0C9D4006BBC11 /* PBXTargetDependency */,
);
name = "Snap OSX Tests";
productName = "Snap OSXTests";
productReference = EECDB3841AC0C9D4006BBC11 /* Snap OSX Tests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
DDC9FD8D1981B4DD009612C7 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0600;
ORGANIZATIONNAME = "Masonry Team";
TargetAttributes = {
EEBCC9D719CC627D0083B827 = {
CreatedOnToolsVersion = 6.0;
};
EEBCC9E119CC627D0083B827 = {
CreatedOnToolsVersion = 6.0;
};
EECDB3791AC0C9D4006BBC11 = {
CreatedOnToolsVersion = 6.2;
};
EECDB3831AC0C9D4006BBC11 = {
CreatedOnToolsVersion = 6.2;
};
};
};
buildConfigurationList = DDC9FD901981B4DD009612C7 /* Build configuration list for PBXProject "Snap" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = DDC9FD8C1981B4DD009612C7;
productRefGroup = DDC9FD961981B4DD009612C7 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
EEBCC9D719CC627D0083B827 /* Snap iOS */,
EECDB3791AC0C9D4006BBC11 /* Snap OSX */,
EEBCC9E119CC627D0083B827 /* Snap iOS Tests */,
EECDB3831AC0C9D4006BBC11 /* Snap OSX Tests */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
EEBCC9D619CC627D0083B827 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
EEBCC9E019CC627D0083B827 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
EECDB3781AC0C9D4006BBC11 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
EECDB3821AC0C9D4006BBC11 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
EEBCC9D319CC627D0083B827 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
EECDB36C1AC0C9A6006BBC11 /* Constraint.swift in Sources */,
EEFCF32F1AD926AE00A425FA /* Snap.swift in Sources */,
EEFCF32C1AD910B900A425FA /* Debugging.swift in Sources */,
EECDB3701AC0C9A6006BBC11 /* ConstraintRelation.swift in Sources */,
EEFCF3321AD9432400A425FA /* ConstraintDescription.swift in Sources */,
EECDB3731AC0C9A6006BBC11 /* View+Snap.swift in Sources */,
EECDB3711AC0C9A6006BBC11 /* EdgeInsets.swift in Sources */,
EECDB36F1AC0C9A6006BBC11 /* ConstraintMaker.swift in Sources */,
EECDB36D1AC0C9A6006BBC11 /* ConstraintAttributes.swift in Sources */,
EECDB3721AC0C9A6006BBC11 /* LayoutConstraint.swift in Sources */,
EECDB36E1AC0C9A6006BBC11 /* ConstraintItem.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
EEBCC9DE19CC627D0083B827 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
EECDB3931AC0CB52006BBC11 /* Tests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
EECDB3751AC0C9D4006BBC11 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
EECDB3951AC0CBFF006BBC11 /* Constraint.swift in Sources */,
EEFCF3301AD92C2200A425FA /* Snap.swift in Sources */,
EEFCF32D1AD9250C00A425FA /* Debugging.swift in Sources */,
EECDB3991AC0CBFF006BBC11 /* ConstraintRelation.swift in Sources */,
EEFCF3331AD9432400A425FA /* ConstraintDescription.swift in Sources */,
EECDB39C1AC0CBFF006BBC11 /* View+Snap.swift in Sources */,
EECDB39A1AC0CBFF006BBC11 /* EdgeInsets.swift in Sources */,
EECDB3981AC0CBFF006BBC11 /* ConstraintMaker.swift in Sources */,
EECDB3961AC0CBFF006BBC11 /* ConstraintAttributes.swift in Sources */,
EECDB39B1AC0CBFF006BBC11 /* LayoutConstraint.swift in Sources */,
EECDB3971AC0CBFF006BBC11 /* ConstraintItem.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
EECDB3801AC0C9D4006BBC11 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
EECDB3941AC0CB52006BBC11 /* Tests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
EECDB3871AC0C9D4006BBC11 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = EECDB3791AC0C9D4006BBC11 /* Snap OSX */;
targetProxy = EECDB3861AC0C9D4006BBC11 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
/* Begin XCBuildConfiguration section */
DDC9FDAF1981B4DD009612C7 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
DDC9FDB01981B4DD009612C7 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
EEBCC9E919CC627E0083B827 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = Snap;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Debug;
};
EEBCC9EA19CC627E0083B827 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = Snap;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Release;
};
EEBCC9EC19CC627E0083B827 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = "$(SRCROOT)/Tests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
EEBCC9ED19CC627E0083B827 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
);
INFOPLIST_FILE = "$(SRCROOT)/Tests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
EECDB38E1AC0C9D4006BBC11 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_NAME = Snap;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = macosx;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Debug;
};
EECDB38F1AC0C9D4006BBC11 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_NAME = Snap;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = macosx;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
name = Release;
};
EECDB3911AC0C9D4006BBC11 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(DEVELOPER_FRAMEWORKS_DIR)",
"$(inherited)",
);
INFOPLIST_FILE = "$(SRCROOT)/Tests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
name = Debug;
};
EECDB3921AC0C9D4006BBC11 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
FRAMEWORK_SEARCH_PATHS = (
"$(DEVELOPER_FRAMEWORKS_DIR)",
"$(inherited)",
);
INFOPLIST_FILE = "$(SRCROOT)/Tests/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
DDC9FD901981B4DD009612C7 /* Build configuration list for PBXProject "Snap" */ = {
isa = XCConfigurationList;
buildConfigurations = (
DDC9FDAF1981B4DD009612C7 /* Debug */,
DDC9FDB01981B4DD009612C7 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
EEBCC9E819CC627E0083B827 /* Build configuration list for PBXNativeTarget "Snap iOS" */ = {
isa = XCConfigurationList;
buildConfigurations = (
EEBCC9E919CC627E0083B827 /* Debug */,
EEBCC9EA19CC627E0083B827 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
EEBCC9EB19CC627E0083B827 /* Build configuration list for PBXNativeTarget "Snap iOS Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
EEBCC9EC19CC627E0083B827 /* Debug */,
EEBCC9ED19CC627E0083B827 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
EECDB38D1AC0C9D4006BBC11 /* Build configuration list for PBXNativeTarget "Snap OSX" */ = {
isa = XCConfigurationList;
buildConfigurations = (
EECDB38E1AC0C9D4006BBC11 /* Debug */,
EECDB38F1AC0C9D4006BBC11 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
EECDB3901AC0C9D4006BBC11 /* Build configuration list for PBXNativeTarget "Snap OSX Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
EECDB3911AC0C9D4006BBC11 /* Debug */,
EECDB3921AC0C9D4006BBC11 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = DDC9FD8D1981B4DD009612C7 /* Project object */;
}

View File

@ -1,110 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EECDB3791AC0C9D4006BBC11"
BuildableName = "Snap.framework"
BlueprintName = "Snap OSX"
ReferencedContainer = "container:Snap.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EECDB3831AC0C9D4006BBC11"
BuildableName = "Snap OSX Tests.xctest"
BlueprintName = "Snap OSX Tests"
ReferencedContainer = "container:Snap.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EECDB3831AC0C9D4006BBC11"
BuildableName = "Snap OSX Tests.xctest"
BlueprintName = "Snap OSX Tests"
ReferencedContainer = "container:Snap.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EECDB3791AC0C9D4006BBC11"
BuildableName = "Snap.framework"
BlueprintName = "Snap OSX"
ReferencedContainer = "container:Snap.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EECDB3791AC0C9D4006BBC11"
BuildableName = "Snap.framework"
BlueprintName = "Snap OSX"
ReferencedContainer = "container:Snap.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EECDB3791AC0C9D4006BBC11"
BuildableName = "Snap.framework"
BlueprintName = "Snap OSX"
ReferencedContainer = "container:Snap.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -1,110 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0620"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EEBCC9D719CC627D0083B827"
BuildableName = "Snap.framework"
BlueprintName = "Snap iOS"
ReferencedContainer = "container:Snap.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EEBCC9E119CC627D0083B827"
BuildableName = "Snap iOS Tests.xctest"
BlueprintName = "Snap iOS Tests"
ReferencedContainer = "container:Snap.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EEBCC9E119CC627D0083B827"
BuildableName = "Snap iOS Tests.xctest"
BlueprintName = "Snap iOS Tests"
ReferencedContainer = "container:Snap.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EEBCC9D719CC627D0083B827"
BuildableName = "Snap.framework"
BlueprintName = "Snap iOS"
ReferencedContainer = "container:Snap.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EEBCC9D719CC627D0083B827"
BuildableName = "Snap.framework"
BlueprintName = "Snap iOS"
ReferencedContainer = "container:Snap.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EEBCC9D719CC627D0083B827"
BuildableName = "Snap.framework"
BlueprintName = "Snap iOS"
ReferencedContainer = "container:Snap.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "container:Snap.xcodeproj">
</FileRef>
</Workspace>

View File

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>A81B1AD2-2D5B-4BB2-AAA6-86A53AADC474</string>
<key>IDESourceControlProjectName</key>
<string>Snap</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>3AF18F9C6F5D633BAA0B3F935459E0C777C82047</key>
<string>github.com:Masonry/Snap.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>Snap.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>3AF18F9C6F5D633BAA0B3F935459E0C777C82047</key>
<string>..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>github.com:Masonry/Snap.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>3AF18F9C6F5D633BAA0B3F935459E0C777C82047</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>3AF18F9C6F5D633BAA0B3F935459E0C777C82047</string>
<key>IDESourceControlWCCName</key>
<string>Snap</string>
</dict>
</array>
</dict>
</plist>

View File

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>FDF6DE8D-A35D-47D4-8CB6-ACB35050F0D0</string>
<key>IDESourceControlProjectName</key>
<string>Snap</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>3AF18F9C6F5D633BAA0B3F935459E0C777C82047</key>
<string>github.com:Masonry/Snap.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>Snap.xcodeproj</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>3AF18F9C6F5D633BAA0B3F935459E0C777C82047</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>github.com:Masonry/Snap.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>111</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>3AF18F9C6F5D633BAA0B3F935459E0C777C82047</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>3AF18F9C6F5D633BAA0B3F935459E0C777C82047</string>
<key>IDESourceControlWCCName</key>
<string>Snap</string>
</dict>
</array>
</dict>
</plist>

View File

@ -1,465 +0,0 @@
//
// Snap
//
// Copyright (c) 2011-2015 Masonry Team - https://github.com/Masonry
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if os(iOS)
import UIKit
#else
import AppKit
#endif
/**
Used to expose API's for a Constraint
*/
public protocol Constraint: class {
func install() -> [LayoutConstraint]
func uninstall()
func activate()
func deactivate()
func updateOffset(amount: Float) -> Void
func updateOffset(amount: Double) -> Void
func updateOffset(amount: CGFloat) -> Void
func updateOffset(amount: Int) -> Void
func updateOffset(amount: UInt) -> Void
func updateOffset(amount: CGPoint) -> Void
func updateOffset(amount: CGSize) -> Void
func updateOffset(amount: EdgeInsets) -> Void
func updateInsets(amount: EdgeInsets) -> Void
func updatePriority(priority: Float) -> Void
func updatePriority(priority: Double) -> Void
func updatePriority(priority: CGFloat) -> Void
func updatePriority(priority: UInt) -> Void
func updatePriority(priority: Int) -> Void
func updatePriorityRequired() -> Void
func updatePriorityHigh() -> Void
func updatePriorityMedium() -> Void
func updatePriorityLow() -> Void
}
/**
Used internally to implement a ConcreteConstraint
*/
internal class ConcreteConstraint: Constraint {
internal func updateOffset(amount: Float) -> Void {
self.constant = amount
}
internal func updateOffset(amount: Double) -> Void {
self.updateOffset(Float(amount))
}
internal func updateOffset(amount: CGFloat) -> Void {
self.updateOffset(Float(amount))
}
internal func updateOffset(amount: Int) -> Void {
self.updateOffset(Float(amount))
}
internal func updateOffset(amount: UInt) -> Void {
self.updateOffset(Float(amount))
}
internal func updateOffset(amount: CGPoint) -> Void {
self.constant = amount
}
internal func updateOffset(amount: CGSize) -> Void {
self.constant = amount
}
internal func updateOffset(amount: EdgeInsets) -> Void {
self.constant = amount
}
internal func updateInsets(amount: EdgeInsets) -> Void {
self.constant = EdgeInsets(top: amount.top, left: amount.left, bottom: -amount.bottom, right: -amount.right)
}
internal func updatePriority(priority: Float) -> Void {
self.priority = priority
}
internal func updatePriority(priority: Double) -> Void {
self.updatePriority(Float(priority))
}
internal func updatePriority(priority: CGFloat) -> Void {
self.updatePriority(Float(priority))
}
internal func updatePriority(priority: UInt) -> Void {
self.updatePriority(Float(priority))
}
internal func updatePriority(priority: Int) -> Void {
self.updatePriority(Float(priority))
}
internal func updatePriorityRequired() -> Void {
self.updatePriority(Float(1000.0))
}
internal func updatePriorityHigh() -> Void {
self.updatePriority(Float(750.0))
}
internal func updatePriorityMedium() -> Void {
#if os(iOS)
self.updatePriority(Float(500.0))
#else
self.updatePriority(Float(501.0))
#endif
}
internal func updatePriorityLow() -> Void {
self.updatePriority(Float(250.0))
}
internal func install() -> [LayoutConstraint] {
return self.installOnView(updateExisting: false)
}
internal func uninstall() {
self.uninstallFromView()
}
internal func activate() {
if NSLayoutConstraint.respondsToSelector("activateConstraints:") && self.installInfo != nil {
let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint]
if layoutConstraints.count > 0 {
NSLayoutConstraint.activateConstraints(layoutConstraints)
}
} else {
self.install()
}
}
internal func deactivate() {
if NSLayoutConstraint.respondsToSelector("deactivateConstraints:") && self.installInfo != nil {
let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint]
if layoutConstraints.count > 0 {
NSLayoutConstraint.deactivateConstraints(layoutConstraints)
}
} else {
self.uninstall()
}
}
private let fromItem: ConstraintItem
private let toItem: ConstraintItem
private let relation: ConstraintRelation
private let multiplier: Float
private var constant: Any {
didSet {
if let installInfo = self.installInfo {
for layoutConstraint in installInfo.layoutConstraints.allObjects as! [LayoutConstraint] {
let attribute = (layoutConstraint.secondAttribute == .NotAnAttribute) ? layoutConstraint.firstAttribute : layoutConstraint.secondAttribute
layoutConstraint.constant = attribute.snp_constantForValue(self.constant)
}
}
}
}
private var priority: Float {
didSet {
if let installInfo = self.installInfo {
for layoutConstraint in installInfo.layoutConstraints.allObjects as! [LayoutConstraint] {
layoutConstraint.priority = self.priority
}
}
}
}
private var installInfo: ConcreteConstraintInstallInfo? = nil
internal init(fromItem: ConstraintItem, toItem: ConstraintItem, relation: ConstraintRelation, constant: Any, multiplier: Float, priority: Float) {
self.fromItem = fromItem
self.toItem = toItem
self.relation = relation
self.constant = constant
self.multiplier = multiplier
self.priority = priority
}
internal func installOnView(updateExisting: Bool = false) -> [LayoutConstraint] {
var installOnView: View? = nil
if self.toItem.view != nil {
installOnView = closestCommonSuperviewBetween(self.fromItem.view, self.toItem.view)
if installOnView == nil {
NSException(name: "Cannot Install Constraint", reason: "No common superview between views", userInfo: nil).raise()
return []
}
} else {
installOnView = self.fromItem.view?.superview
if installOnView == nil {
if self.fromItem.attributes == ConstraintAttributes.Width || self.fromItem.attributes == ConstraintAttributes.Height {
installOnView = self.fromItem.view
}
if installOnView == nil {
NSException(name: "Cannot Install Constraint", reason: "Missing superview", userInfo: nil).raise()
return []
}
}
}
if let installedOnView = self.installInfo?.view {
if installedOnView != installOnView {
NSException(name: "Cannot Install Constraint", reason: "Already installed on different view.", userInfo: nil).raise()
return []
}
return self.installInfo?.layoutConstraints.allObjects as? [LayoutConstraint] ?? []
}
var newLayoutConstraints = [LayoutConstraint]()
let layoutFromAttributes = self.fromItem.attributes.layoutAttributes
let layoutToAttributes = self.toItem.attributes.layoutAttributes
// get layout from
let layoutFrom: View? = self.fromItem.view
// get layout relation
let layoutRelation: NSLayoutRelation = self.relation.layoutRelation
for layoutFromAttribute in layoutFromAttributes {
// get layout to attribute
let layoutToAttribute = (layoutToAttributes.count > 0) ? layoutToAttributes[0] : layoutFromAttribute
// get layout constant
var layoutConstant: CGFloat = layoutToAttribute.snp_constantForValue(self.constant)
// get layout to
var layoutTo: View? = self.toItem.view
if layoutTo == nil && layoutToAttribute != .Width && layoutToAttribute != .Height {
layoutTo = installOnView
}
// create layout constraint
let layoutConstraint = LayoutConstraint(
item: layoutFrom!,
attribute: layoutFromAttribute,
relatedBy: layoutRelation,
toItem: layoutTo,
attribute: layoutToAttribute,
multiplier: CGFloat(self.multiplier),
constant: layoutConstant)
// set priority
layoutConstraint.priority = self.priority
// set constraint
layoutConstraint.snp_constraint = self
newLayoutConstraints.append(layoutConstraint)
}
// special logic for updating
if updateExisting {
// get existing constraints for this view
let existingLayoutConstraints = reverse(layoutFrom!.snp_installedLayoutConstraints)
// array that will contain only new layout constraints to keep
var newLayoutConstraintsToKeep = [LayoutConstraint]()
// begin looping
for layoutConstraint in newLayoutConstraints {
// layout constraint that should be updated
var updateLayoutConstraint: LayoutConstraint? = nil
// loop through existing and check for match
for existingLayoutConstraint in existingLayoutConstraints {
if existingLayoutConstraint == layoutConstraint {
updateLayoutConstraint = existingLayoutConstraint
break
}
}
// if we have existing one lets just update the constant
if updateLayoutConstraint != nil {
updateLayoutConstraint!.constant = layoutConstraint.constant
}
// otherwise add this layout constraint to new keep list
else {
newLayoutConstraintsToKeep.append(layoutConstraint)
}
}
// set constraints to only new ones
newLayoutConstraints = newLayoutConstraintsToKeep
}
// add constraints
installOnView!.addConstraints(newLayoutConstraints)
// set install info
self.installInfo = ConcreteConstraintInstallInfo(view: installOnView, layoutConstraints: NSHashTable.weakObjectsHashTable())
// store which layout constraints are installed for this constraint
for layoutConstraint in newLayoutConstraints {
self.installInfo!.layoutConstraints.addObject(layoutConstraint)
}
// store the layout constraints against the layout from view
layoutFrom!.snp_installedLayoutConstraints += newLayoutConstraints
// return the new constraints
return newLayoutConstraints
}
internal func uninstallFromView() {
if let installInfo = self.installInfo,
let installedLayoutConstraints = installInfo.layoutConstraints.allObjects as? [LayoutConstraint] {
if installedLayoutConstraints.count > 0 {
if let installedOnView = installInfo.view {
// remove the constraints from the UIView's storage
installedOnView.removeConstraints(installedLayoutConstraints)
}
// remove the constraints from the from item view
if let fromView = self.fromItem.view {
fromView.snp_installedLayoutConstraints = fromView.snp_installedLayoutConstraints.filter {
return !contains(installedLayoutConstraints, $0)
}
}
}
}
self.installInfo = nil
}
}
private struct ConcreteConstraintInstallInfo {
weak var view: View? = nil
let layoutConstraints: NSHashTable
}
private extension NSLayoutAttribute {
private func snp_constantForValue(value: Any?) -> CGFloat {
// Float
if let float = value as? Float {
return CGFloat(float)
}
// Double
else if let double = value as? Double {
return CGFloat(double)
}
// UInt
else if let int = value as? Int {
return CGFloat(int)
}
// Int
else if let uint = value as? UInt {
return CGFloat(uint)
}
// CGFloat
else if let float = value as? CGFloat {
return float
}
// CGSize
else if let size = value as? CGSize {
if self == .Width {
return size.width
} else if self == .Height {
return size.height
}
}
// CGPoint
else if let point = value as? CGPoint {
#if os(iOS)
switch self {
case .Left, .CenterX, .LeftMargin, .CenterXWithinMargins: return point.x
case .Top, .CenterY, .TopMargin, .CenterYWithinMargins, .Baseline, .FirstBaseline: return point.y
case .Right, .RightMargin: return point.x
case .Bottom, .BottomMargin: return point.y
case .Leading, .LeadingMargin: return point.x
case .Trailing, .TrailingMargin: return point.x
case .Width, .Height, .NotAnAttribute: return CGFloat(0)
}
#else
switch self {
case .Left, .CenterX: return point.x
case .Top, .CenterY, .Baseline: return point.y
case .Right: return point.x
case .Bottom: return point.y
case .Leading: return point.x
case .Trailing: return point.x
case .Width, .Height, .NotAnAttribute: return CGFloat(0)
}
#endif
}
// EdgeInsets
else if let insets = value as? EdgeInsets {
#if os(iOS)
switch self {
case .Left, .CenterX, .LeftMargin, .CenterXWithinMargins: return insets.left
case .Top, .CenterY, .TopMargin, .CenterYWithinMargins, .Baseline, .FirstBaseline: return insets.top
case .Right, .RightMargin: return insets.right
case .Bottom, .BottomMargin: return insets.bottom
case .Leading, .LeadingMargin: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.left : -insets.right
case .Trailing, .TrailingMargin: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.right : -insets.left
case .Width, .Height, .NotAnAttribute: return CGFloat(0)
}
#else
switch self {
case .Left, .CenterX: return insets.left
case .Top, .CenterY, .Baseline: return insets.top
case .Right: return insets.right
case .Bottom: return insets.bottom
case .Leading, .LeadingMargin: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.left : -insets.right
case .Trailing, .TrailingMargin: return (Config.interfaceLayoutDirection == .LeftToRight) ? insets.right : -insets.left
case .Width, .Height, .NotAnAttribute: return CGFloat(0)
}
#endif
}
return CGFloat(0);
}
}
private func closestCommonSuperviewBetween(fromView: View?, toView: View?) -> View? {
var views = Set<View>()
var fromView = fromView
var toView = toView
do {
if let view = toView {
if views.contains(view) {
return view
}
views.insert(view)
toView = view.superview
}
if let view = fromView {
if views.contains(view) {
return view
}
views.insert(view)
fromView = view.superview
}
} while (fromView != nil || toView != nil)
return nil
}
private func ==(left: ConcreteConstraint, right: ConcreteConstraint) -> Bool {
return (left.fromItem == right.fromItem &&
left.toItem == right.toItem &&
left.relation == right.relation &&
left.multiplier == right.multiplier &&
left.priority == right.priority)
}

View File

@ -1,167 +0,0 @@
//
// Snap
//
// Copyright (c) 2011-2015 Masonry Team - https://github.com/Masonry
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if os(iOS)
import UIKit
#else
import AppKit
#endif
/**
Used to define `NSLayoutAttributes` in a more concise and composite manner
*/
internal struct ConstraintAttributes: RawOptionSetType, BooleanType {
internal init(rawValue: UInt) {
self.rawValue = rawValue
}
internal init(_ rawValue: UInt) {
self.init(rawValue: rawValue)
}
internal init(nilLiteral: ()) {
self.rawValue = 0
}
internal private(set) var rawValue: UInt
internal static var allZeros: ConstraintAttributes { return self(0) }
internal static func convertFromNilLiteral() -> ConstraintAttributes { return self(0) }
internal var boolValue: Bool { return self.rawValue != 0 }
internal func toRaw() -> UInt { return self.rawValue }
internal static func fromRaw(raw: UInt) -> ConstraintAttributes? { return self(raw) }
internal static func fromMask(raw: UInt) -> ConstraintAttributes { return self(raw) }
// normal
internal static var None: ConstraintAttributes { return self(0) }
internal static var Left: ConstraintAttributes { return self(1) }
internal static var Top: ConstraintAttributes { return self(2) }
internal static var Right: ConstraintAttributes { return self(4) }
internal static var Bottom: ConstraintAttributes { return self(8) }
internal static var Leading: ConstraintAttributes { return self(16) }
internal static var Trailing: ConstraintAttributes { return self(32) }
internal static var Width: ConstraintAttributes { return self(64) }
internal static var Height: ConstraintAttributes { return self(128) }
internal static var CenterX: ConstraintAttributes { return self(256) }
internal static var CenterY: ConstraintAttributes { return self(512) }
internal static var Baseline: ConstraintAttributes { return self(1024) }
#if os(iOS)
internal static var FirstBaseline: ConstraintAttributes { return self(2048) }
internal static var LeftMargin: ConstraintAttributes { return self(4096) }
internal static var RightMargin: ConstraintAttributes { return self(8192) }
internal static var TopMargin: ConstraintAttributes { return self(16384) }
internal static var BottomMargin: ConstraintAttributes { return self(32768) }
internal static var LeadingMargin: ConstraintAttributes { return self(65536) }
internal static var TrailingMargin: ConstraintAttributes { return self(131072) }
internal static var CenterXWithinMargins: ConstraintAttributes { return self(262144) }
internal static var CenterYWithinMargins: ConstraintAttributes { return self(524288) }
#endif
// aggregates
internal static var Edges: ConstraintAttributes { return self(15) }
internal static var Size: ConstraintAttributes { return self(192) }
internal static var Center: ConstraintAttributes { return self(768) }
#if os(iOS)
internal static var Margins: ConstraintAttributes { return self(61440) }
internal static var CenterWithinMargins: ConstraintAttributes { return self(786432) }
#endif
internal var layoutAttributes:[NSLayoutAttribute] {
var attrs = [NSLayoutAttribute]()
if (self & ConstraintAttributes.Left) {
attrs.append(.Left)
}
if (self & ConstraintAttributes.Top) {
attrs.append(.Top)
}
if (self & ConstraintAttributes.Right) {
attrs.append(.Right)
}
if (self & ConstraintAttributes.Bottom) {
attrs.append(.Bottom)
}
if (self & ConstraintAttributes.Leading) {
attrs.append(.Leading)
}
if (self & ConstraintAttributes.Trailing) {
attrs.append(.Trailing)
}
if (self & ConstraintAttributes.Width) {
attrs.append(.Width)
}
if (self & ConstraintAttributes.Height) {
attrs.append(.Height)
}
if (self & ConstraintAttributes.CenterX) {
attrs.append(.CenterX)
}
if (self & ConstraintAttributes.CenterY) {
attrs.append(.CenterY)
}
if (self & ConstraintAttributes.Baseline) {
attrs.append(.Baseline)
}
#if os(iOS)
if (self & ConstraintAttributes.FirstBaseline) {
attrs.append(.FirstBaseline)
}
if (self & ConstraintAttributes.LeftMargin) {
attrs.append(.LeftMargin)
}
if (self & ConstraintAttributes.RightMargin) {
attrs.append(.RightMargin)
}
if (self & ConstraintAttributes.TopMargin) {
attrs.append(.TopMargin)
}
if (self & ConstraintAttributes.BottomMargin) {
attrs.append(.BottomMargin)
}
if (self & ConstraintAttributes.LeadingMargin) {
attrs.append(.LeadingMargin)
}
if (self & ConstraintAttributes.TrailingMargin) {
attrs.append(.TrailingMargin)
}
if (self & ConstraintAttributes.CenterXWithinMargins) {
attrs.append(.CenterXWithinMargins)
}
if (self & ConstraintAttributes.CenterYWithinMargins) {
attrs.append(.CenterYWithinMargins)
}
#endif
return attrs
}
}
internal func +=(inout left: ConstraintAttributes, right: ConstraintAttributes) {
left = (left | right)
}
internal func -=(inout left: ConstraintAttributes, right: ConstraintAttributes) {
left = left & ~right
}
internal func ==(left: ConstraintAttributes, right: ConstraintAttributes) -> Bool {
return left.rawValue == right.rawValue
}

View File

@ -1,547 +0,0 @@
//
// Snap
//
// Copyright (c) 2011-2015 Masonry Team - https://github.com/Masonry
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if os(iOS)
import UIKit
#else
import AppKit
#endif
/**
Used to expose the final API of a `ConstraintDescription` which allows getting a constraint from it
*/
public protocol ConstraintDescriptionFinalizable: class {
var constraint: Constraint { get }
}
/**
Used to expose priority APIs
*/
public protocol ConstraintDescriptionPriortizable: ConstraintDescriptionFinalizable {
func priority(priority: Float) -> ConstraintDescriptionFinalizable
func priority(priority: Double) -> ConstraintDescriptionFinalizable
func priority(priority: CGFloat) -> ConstraintDescriptionFinalizable
func priority(priority: UInt) -> ConstraintDescriptionFinalizable
func priority(priority: Int) -> ConstraintDescriptionFinalizable
func priorityRequired() -> ConstraintDescriptionFinalizable
func priorityHigh() -> ConstraintDescriptionFinalizable
func priorityMedium() -> ConstraintDescriptionFinalizable
func priorityLow() -> ConstraintDescriptionFinalizable
}
/**
Used to expose multiplier APIs
*/
public protocol ConstraintDescriptionMultipliable: ConstraintDescriptionPriortizable {
func multipliedBy(amount: Float) -> ConstraintDescriptionPriortizable
func multipliedBy(amount: Double) -> ConstraintDescriptionPriortizable
func multipliedBy(amount: CGFloat) -> ConstraintDescriptionPriortizable
func multipliedBy(amount: Int) -> ConstraintDescriptionPriortizable
func multipliedBy(amount: UInt) -> ConstraintDescriptionPriortizable
func dividedBy(amount: Float) -> ConstraintDescriptionPriortizable
func dividedBy(amount: Double) -> ConstraintDescriptionPriortizable
func dividedBy(amount: CGFloat) -> ConstraintDescriptionPriortizable
func dividedBy(amount: Int) -> ConstraintDescriptionPriortizable
func dividedBy(amount: UInt) -> ConstraintDescriptionPriortizable
}
/**
Used to expose constant APIs
*/
public protocol ConstraintDescriptionOffsetable: ConstraintDescriptionMultipliable {
func offset(amount: Float) -> ConstraintDescriptionMultipliable
func offset(amount: Double) -> ConstraintDescriptionMultipliable
func offset(amount: CGFloat) -> ConstraintDescriptionMultipliable
func offset(amount: Int) -> ConstraintDescriptionMultipliable
func offset(amount: UInt) -> ConstraintDescriptionMultipliable
func offset(amount: CGPoint) -> ConstraintDescriptionMultipliable
func offset(amount: CGSize) -> ConstraintDescriptionMultipliable
func offset(amount: EdgeInsets) -> ConstraintDescriptionMultipliable
func insets(amount: EdgeInsets) -> ConstraintDescriptionMultipliable
}
/**
Used to expose relation APIs
*/
public protocol ConstraintDescriptionRelatable: class {
func equalTo(other: ConstraintItem) -> ConstraintDescriptionOffsetable
func equalTo(other: View) -> ConstraintDescriptionOffsetable
#if os(iOS)
func equalTo(other: UILayoutSupport) -> ConstraintDescriptionOffsetable
#endif
func equalTo(other: Float) -> ConstraintDescriptionMultipliable
func equalTo(other: Double) -> ConstraintDescriptionMultipliable
func equalTo(other: CGFloat) -> ConstraintDescriptionMultipliable
func equalTo(other: Int) -> ConstraintDescriptionMultipliable
func equalTo(other: UInt) -> ConstraintDescriptionMultipliable
func equalTo(other: CGSize) -> ConstraintDescriptionMultipliable
func equalTo(other: CGPoint) -> ConstraintDescriptionMultipliable
func equalTo(other: EdgeInsets) -> ConstraintDescriptionMultipliable
func lessThanOrEqualTo(other: ConstraintItem) -> ConstraintDescriptionOffsetable
func lessThanOrEqualTo(other: View) -> ConstraintDescriptionOffsetable
#if os(iOS)
func lessThanOrEqualTo(other: UILayoutSupport) -> ConstraintDescriptionOffsetable
#endif
func lessThanOrEqualTo(other: Float) -> ConstraintDescriptionMultipliable
func lessThanOrEqualTo(other: Double) -> ConstraintDescriptionMultipliable
func lessThanOrEqualTo(other: CGFloat) -> ConstraintDescriptionMultipliable
func lessThanOrEqualTo(other: Int) -> ConstraintDescriptionMultipliable
func lessThanOrEqualTo(other: UInt) -> ConstraintDescriptionMultipliable
func lessThanOrEqualTo(other: CGSize) -> ConstraintDescriptionMultipliable
func lessThanOrEqualTo(other: CGPoint) -> ConstraintDescriptionMultipliable
func lessThanOrEqualTo(other: EdgeInsets) -> ConstraintDescriptionMultipliable
func greaterThanOrEqualTo(other: ConstraintItem) -> ConstraintDescriptionOffsetable
func greaterThanOrEqualTo(other: View) -> ConstraintDescriptionOffsetable
#if os(iOS)
func greaterThanOrEqualTo(other: UILayoutSupport) -> ConstraintDescriptionOffsetable
#endif
func greaterThanOrEqualTo(other: Float) -> ConstraintDescriptionMultipliable
func greaterThanOrEqualTo(other: Double) -> ConstraintDescriptionMultipliable
func greaterThanOrEqualTo(other: CGFloat) -> ConstraintDescriptionMultipliable
func greaterThanOrEqualTo(other: Int) -> ConstraintDescriptionMultipliable
func greaterThanOrEqualTo(other: UInt) -> ConstraintDescriptionMultipliable
func greaterThanOrEqualTo(other: CGSize) -> ConstraintDescriptionMultipliable
func greaterThanOrEqualTo(other: CGPoint) -> ConstraintDescriptionMultipliable
func greaterThanOrEqualTo(other: EdgeInsets) -> ConstraintDescriptionMultipliable
}
/**
Used to expose chaining APIs
*/
public protocol ConstraintDescriptionExtendable: ConstraintDescriptionRelatable {
var left: ConstraintDescriptionExtendable { get }
var top: ConstraintDescriptionExtendable { get }
var bottom: ConstraintDescriptionExtendable { get }
var right: ConstraintDescriptionExtendable { get }
var leading: ConstraintDescriptionExtendable { get }
var trailing: ConstraintDescriptionExtendable { get }
var width: ConstraintDescriptionExtendable { get }
var height: ConstraintDescriptionExtendable { get }
var centerX: ConstraintDescriptionExtendable { get }
var centerY: ConstraintDescriptionExtendable { get }
var baseline: ConstraintDescriptionExtendable { get }
#if os(iOS)
var firstBaseline: ConstraintDescriptionExtendable { get }
var leftMargin: ConstraintDescriptionExtendable { get }
var rightMargin: ConstraintDescriptionExtendable { get }
var topMargin: ConstraintDescriptionExtendable { get }
var bottomMargin: ConstraintDescriptionExtendable { get }
var leadingMargin: ConstraintDescriptionExtendable { get }
var trailingMargin: ConstraintDescriptionExtendable { get }
var centerXWithinMargins: ConstraintDescriptionExtendable { get }
var centerYWithinMargins: ConstraintDescriptionExtendable { get }
#endif
}
/**
Used to internally manage building constraint
*/
final internal class ConstraintDescription: ConstraintDescriptionExtendable, ConstraintDescriptionOffsetable, ConstraintDescriptionFinalizable {
internal var left: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Left) }
internal var top: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Top) }
internal var right: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Right) }
internal var bottom: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Bottom) }
internal var leading: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Leading) }
internal var trailing: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Trailing) }
internal var width: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Width) }
internal var height: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Height) }
internal var centerX: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterX) }
internal var centerY: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterY) }
internal var baseline: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.Baseline) }
#if os(iOS)
internal var firstBaseline: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.FirstBaseline) }
internal var leftMargin: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.LeftMargin) }
internal var rightMargin: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.RightMargin) }
internal var topMargin: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.TopMargin) }
internal var bottomMargin: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.BottomMargin) }
internal var leadingMargin: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.LeadingMargin) }
internal var trailingMargin: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.TrailingMargin) }
internal var centerXWithinMargins: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterXWithinMargins) }
internal var centerYWithinMargins: ConstraintDescriptionExtendable { return self.addConstraint(ConstraintAttributes.CenterYWithinMargins) }
#endif
// MARK: initializer
init(fromItem: ConstraintItem) {
self.fromItem = fromItem
self.toItem = ConstraintItem(object: nil, attributes: ConstraintAttributes.None)
}
// MARK: equalTo
internal func equalTo(other: ConstraintItem) -> ConstraintDescriptionOffsetable {
return self.constrainTo(other, relation: .Equal)
}
internal func equalTo(other: View) -> ConstraintDescriptionOffsetable {
return self.constrainTo(other, relation: .Equal)
}
#if os(iOS)
internal func equalTo(other: UILayoutSupport) -> ConstraintDescriptionOffsetable {
return self.constrainTo(other, relation: .Equal)
}
#endif
internal func equalTo(other: Float) -> ConstraintDescriptionMultipliable {
return self.constrainTo(other, relation: .Equal)
}
internal func equalTo(other: Double) -> ConstraintDescriptionMultipliable {
return self.constrainTo(Float(other), relation: .Equal)
}
internal func equalTo(other: CGFloat) -> ConstraintDescriptionMultipliable {
return self.constrainTo(Float(other), relation: .Equal)
}
internal func equalTo(other: Int) -> ConstraintDescriptionMultipliable {
return self.constrainTo(Float(other), relation: .Equal)
}
internal func equalTo(other: UInt) -> ConstraintDescriptionMultipliable {
return self.constrainTo(Float(other), relation: .Equal)
}
internal func equalTo(other: CGSize) -> ConstraintDescriptionMultipliable {
return self.constrainTo(other, relation: .Equal)
}
internal func equalTo(other: CGPoint) -> ConstraintDescriptionMultipliable {
return self.constrainTo(other, relation: .Equal)
}
internal func equalTo(other: EdgeInsets) -> ConstraintDescriptionMultipliable {
return self.constrainTo(other, relation: .Equal)
}
// MARK: lessThanOrEqualTo
internal func lessThanOrEqualTo(other: ConstraintItem) -> ConstraintDescriptionOffsetable {
return self.constrainTo(other, relation: .LessThanOrEqualTo)
}
internal func lessThanOrEqualTo(other: View) -> ConstraintDescriptionOffsetable {
return self.constrainTo(other, relation: .LessThanOrEqualTo)
}
#if os(iOS)
internal func lessThanOrEqualTo(other: UILayoutSupport) -> ConstraintDescriptionOffsetable {
return self.constrainTo(other, relation: .LessThanOrEqualTo)
}
#endif
internal func lessThanOrEqualTo(other: Float) -> ConstraintDescriptionMultipliable {
return self.constrainTo(other, relation: .LessThanOrEqualTo)
}
internal func lessThanOrEqualTo(other: Double) -> ConstraintDescriptionMultipliable {
return self.constrainTo(Float(other), relation: .LessThanOrEqualTo)
}
internal func lessThanOrEqualTo(other: CGFloat) -> ConstraintDescriptionMultipliable {
return self.constrainTo(Float(other), relation: .LessThanOrEqualTo)
}
internal func lessThanOrEqualTo(other: Int) -> ConstraintDescriptionMultipliable {
return self.constrainTo(Float(other), relation: .LessThanOrEqualTo)
}
internal func lessThanOrEqualTo(other: UInt) -> ConstraintDescriptionMultipliable {
return self.constrainTo(Float(other), relation: .LessThanOrEqualTo)
}
internal func lessThanOrEqualTo(other: CGSize) -> ConstraintDescriptionMultipliable {
return self.constrainTo(other, relation: .LessThanOrEqualTo)
}
internal func lessThanOrEqualTo(other: CGPoint) -> ConstraintDescriptionMultipliable {
return self.constrainTo(other, relation: .LessThanOrEqualTo)
}
internal func lessThanOrEqualTo(other: EdgeInsets) -> ConstraintDescriptionMultipliable {
return self.constrainTo(other, relation: .LessThanOrEqualTo)
}
// MARK: greaterThanOrEqualTo
internal func greaterThanOrEqualTo(other: ConstraintItem) -> ConstraintDescriptionOffsetable {
return self.constrainTo(other, relation: .GreaterThanOrEqualTo)
}
internal func greaterThanOrEqualTo(other: View) -> ConstraintDescriptionOffsetable {
return self.constrainTo(other, relation: .GreaterThanOrEqualTo)
}
#if os(iOS)
internal func greaterThanOrEqualTo(other: UILayoutSupport) -> ConstraintDescriptionOffsetable {
return self.constrainTo(other, relation: .GreaterThanOrEqualTo)
}
#endif
internal func greaterThanOrEqualTo(other: Float) -> ConstraintDescriptionMultipliable {
return self.constrainTo(other, relation: .GreaterThanOrEqualTo)
}
internal func greaterThanOrEqualTo(other: Double) -> ConstraintDescriptionMultipliable {
return self.constrainTo(Float(other), relation: .GreaterThanOrEqualTo)
}
internal func greaterThanOrEqualTo(other: CGFloat) -> ConstraintDescriptionMultipliable {
return self.constrainTo(Float(other), relation: .GreaterThanOrEqualTo)
}
internal func greaterThanOrEqualTo(other: Int) -> ConstraintDescriptionMultipliable {
return self.constrainTo(Float(other), relation: .GreaterThanOrEqualTo)
}
internal func greaterThanOrEqualTo(other: UInt) -> ConstraintDescriptionMultipliable {
return self.constrainTo(Float(other), relation: .GreaterThanOrEqualTo)
}
internal func greaterThanOrEqualTo(other: CGSize) -> ConstraintDescriptionMultipliable {
return self.constrainTo(other, relation: .GreaterThanOrEqualTo)
}
internal func greaterThanOrEqualTo(other: CGPoint) -> ConstraintDescriptionMultipliable {
return self.constrainTo(other, relation: .GreaterThanOrEqualTo)
}
internal func greaterThanOrEqualTo(other: EdgeInsets) -> ConstraintDescriptionMultipliable {
return self.constrainTo(other, relation: .GreaterThanOrEqualTo)
}
// MARK: multiplier
internal func multipliedBy(amount: Float) -> ConstraintDescriptionPriortizable {
self.multiplier = amount
return self
}
internal func multipliedBy(amount: Double) -> ConstraintDescriptionPriortizable {
return self.multipliedBy(Float(amount))
}
internal func multipliedBy(amount: CGFloat) -> ConstraintDescriptionPriortizable {
return self.multipliedBy(Float(amount))
}
internal func multipliedBy(amount: Int) -> ConstraintDescriptionPriortizable {
return self.multipliedBy(Float(amount))
}
internal func multipliedBy(amount: UInt) -> ConstraintDescriptionPriortizable {
return self.multipliedBy(Float(amount))
}
internal func dividedBy(amount: Float) -> ConstraintDescriptionPriortizable {
self.multiplier = 1.0 / amount;
return self
}
internal func dividedBy(amount: Double) -> ConstraintDescriptionPriortizable {
return self.dividedBy(Float(amount))
}
internal func dividedBy(amount: CGFloat) -> ConstraintDescriptionPriortizable {
return self.dividedBy(Float(amount))
}
internal func dividedBy(amount: Int) -> ConstraintDescriptionPriortizable {
return self.dividedBy(Float(amount))
}
internal func dividedBy(amount: UInt) -> ConstraintDescriptionPriortizable {
return self.dividedBy(Float(amount))
}
// MARK: priority
internal func priority(priority: Float) -> ConstraintDescriptionFinalizable {
self.priority = priority
return self
}
internal func priority(priority: Double) -> ConstraintDescriptionFinalizable {
return self.priority(Float(priority))
}
internal func priority(priority: CGFloat) -> ConstraintDescriptionFinalizable {
return self.priority(Float(priority))
}
func priority(priority: UInt) -> ConstraintDescriptionFinalizable {
return self.priority(Float(priority))
}
internal func priority(priority: Int) -> ConstraintDescriptionFinalizable {
return self.priority(Float(priority))
}
internal func priorityRequired() -> ConstraintDescriptionFinalizable {
return self.priority(1000.0)
}
internal func priorityHigh() -> ConstraintDescriptionFinalizable {
return self.priority(750.0)
}
internal func priorityMedium() -> ConstraintDescriptionFinalizable {
#if os(iOS)
return self.priority(500.0)
#else
return self.priority(501.0)
#endif
}
internal func priorityLow() -> ConstraintDescriptionFinalizable {
return self.priority(250.0)
}
// MARK: offset
internal func offset(amount: Float) -> ConstraintDescriptionMultipliable {
self.constant = amount
return self
}
internal func offset(amount: Double) -> ConstraintDescriptionMultipliable {
return self.offset(Float(amount))
}
internal func offset(amount: CGFloat) -> ConstraintDescriptionMultipliable {
return self.offset(Float(amount))
}
internal func offset(amount: Int) -> ConstraintDescriptionMultipliable {
return self.offset(Float(amount))
}
internal func offset(amount: UInt) -> ConstraintDescriptionMultipliable {
return self.offset(Float(amount))
}
internal func offset(amount: CGPoint) -> ConstraintDescriptionMultipliable {
self.constant = amount
return self
}
internal func offset(amount: CGSize) -> ConstraintDescriptionMultipliable {
self.constant = amount
return self
}
internal func offset(amount: EdgeInsets) -> ConstraintDescriptionMultipliable {
self.constant = amount
return self
}
// MARK: insets
internal func insets(amount: EdgeInsets) -> ConstraintDescriptionMultipliable {
self.constant = EdgeInsets(top: amount.top, left: amount.left, bottom: -amount.bottom, right: -amount.right)
return self
}
// MARK: Constraint
internal var constraint: Constraint {
if self.concreteConstraint == nil {
if self.relation == nil {
fatalError("Attempting to create a constraint from a ConstraintDescription before it has been fully chained.")
}
self.concreteConstraint = ConcreteConstraint(
fromItem: self.fromItem,
toItem: self.toItem,
relation: self.relation!,
constant: self.constant,
multiplier: self.multiplier,
priority: self.priority)
}
return self.concreteConstraint!
}
// MARK: Private
private let fromItem: ConstraintItem
private var toItem: ConstraintItem {
willSet {
if self.concreteConstraint != nil {
fatalError("Attempting to modify a ConstraintDescription after its constraint has been created.")
}
}
}
private var relation: ConstraintRelation? {
willSet {
if self.concreteConstraint != nil {
fatalError("Attempting to modify a ConstraintDescription after its constraint has been created.")
}
}
}
private var constant: Any = Float(0.0) {
willSet {
if self.concreteConstraint != nil {
fatalError("Attempting to modify a ConstraintDescription after its constraint has been created.")
}
}
}
private var multiplier: Float = 1.0 {
willSet {
if self.concreteConstraint != nil {
fatalError("Attempting to modify a ConstraintDescription after its constraint has been created.")
}
}
}
private var priority: Float = 1000.0 {
willSet {
if self.concreteConstraint != nil {
fatalError("Attempting to modify a ConstraintDescription after its constraint has been created.")
}
}
}
private var concreteConstraint: ConcreteConstraint? = nil
private func addConstraint(attributes: ConstraintAttributes) -> ConstraintDescription {
if self.relation == nil {
self.fromItem.attributes += attributes
}
return self
}
private func constrainTo(other: ConstraintItem, relation: ConstraintRelation) -> ConstraintDescription {
if other.attributes != ConstraintAttributes.None {
let toLayoutAttributes = other.attributes.layoutAttributes
if toLayoutAttributes.count > 1 {
let fromLayoutAttributes = self.fromItem.attributes.layoutAttributes
if toLayoutAttributes != fromLayoutAttributes {
NSException(name: "Invalid Constraint", reason: "Cannot constrain to multiple non identical attributes", userInfo: nil).raise()
return self
}
other.attributes = ConstraintAttributes.None
}
}
self.toItem = other
self.relation = relation
return self
}
private func constrainTo(other: View, relation: ConstraintRelation) -> ConstraintDescription {
return constrainTo(ConstraintItem(object: other, attributes: ConstraintAttributes.None), relation: relation)
}
#if os(iOS)
private func constrainTo(other: UILayoutSupport, relation: ConstraintRelation) -> ConstraintDescription {
return constrainTo(ConstraintItem(object: other, attributes: ConstraintAttributes.None), relation: relation)
}
#endif
private func constrainTo(other: Float, relation: ConstraintRelation) -> ConstraintDescription {
self.constant = other
return constrainTo(ConstraintItem(object: nil, attributes: ConstraintAttributes.None), relation: relation)
}
private func constrainTo(other: Double, relation: ConstraintRelation) -> ConstraintDescription {
self.constant = other
return constrainTo(ConstraintItem(object: nil, attributes: ConstraintAttributes.None), relation: relation)
}
private func constrainTo(other: CGSize, relation: ConstraintRelation) -> ConstraintDescription {
self.constant = other
return constrainTo(ConstraintItem(object: nil, attributes: ConstraintAttributes.None), relation: relation)
}
private func constrainTo(other: CGPoint, relation: ConstraintRelation) -> ConstraintDescription {
self.constant = other
return constrainTo(ConstraintItem(object: nil, attributes: ConstraintAttributes.None), relation: relation)
}
private func constrainTo(other: EdgeInsets, relation: ConstraintRelation) -> ConstraintDescription {
self.constant = other
return constrainTo(ConstraintItem(object: nil, attributes: ConstraintAttributes.None), relation: relation)
}
}

View File

@ -1,71 +0,0 @@
//
// Snap
//
// Copyright (c) 2011-2015 Masonry Team - https://github.com/Masonry
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if os(iOS)
import UIKit
#else
import AppKit
#endif
/**
Used to assist in building a constraint
*/
final public class ConstraintItem {
internal init(object: AnyObject?, attributes: ConstraintAttributes) {
self.object = object
self.attributes = attributes
}
internal weak var object: AnyObject?
internal var attributes: ConstraintAttributes
internal var view: View? {
return self.object as? View
}
#if os(iOS)
internal var layoutSupport: UILayoutSupport? {
return self.object as? UILayoutSupport
}
#endif
}
internal func ==(left: ConstraintItem, right: ConstraintItem) -> Bool {
if left.object == nil {
return false
}
if right.object == nil {
return false
}
if left.object !== right.object {
return false
}
if left.attributes != right.attributes {
return false
}
return true
}

View File

@ -1,189 +0,0 @@
//
// Snap
//
// Copyright (c) 2011-2015 Masonry Team - https://github.com/Masonry
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if os(iOS)
import UIKit
#else
import AppKit
#endif
/**
Used to make constraints
*/
final public class ConstraintMaker {
/// left edge
public var left: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Left) }
/// top edge
public var top: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Top) }
/// right edge
public var right: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Right) }
/// bottom edge
public var bottom: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Bottom) }
/// leading edge
public var leading: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Leading) }
/// trailing edge
public var trailing: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Trailing) }
/// width dimension
public var width: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Width) }
/// height dimension
public var height: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Height) }
/// centerX dimension
public var centerX: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.CenterX) }
/// centerY dimension
public var centerY: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.CenterY) }
/// baseline position
public var baseline: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Baseline) }
#if os(iOS)
/// firse baseline position
public var firstBaseline: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.FirstBaseline) }
/// left margin
public var leftMargin: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.LeftMargin) }
/// right margin
public var rightMargin: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.RightMargin) }
/// top margin
public var topMargin: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.TopMargin) }
/// bottom margin
public var bottomMargin: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.BottomMargin) }
/// leading margin
public var leadingMargin: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.LeadingMargin) }
/// trailing margin
public var trailingMargin: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.TrailingMargin) }
/// centerX within margins
public var centerXWithinMargins: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.CenterXWithinMargins) }
/// centerY within margins
public var centerYWithinMargins: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.CenterYWithinMargins) }
#endif
/// top + left + bottom + right edges
public var edges: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Edges) }
/// width + height dimensions
public var size: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Size) }
// centerX + centerY positions
public var center: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Center) }
#if os(iOS)
// top + left + bottom + right margins
public var snp_margins: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.Margins) }
// centerX + centerY within margins
public var snp_centerWithinMargins: ConstraintDescriptionExtendable { return self.makeConstraintDescription(ConstraintAttributes.CenterWithinMargins) }
#endif
internal init(view: View) {
self.view = view
}
internal let view: View
internal var constraintDescriptions = [ConstraintDescription]()
internal func makeConstraintDescription(attributes: ConstraintAttributes) -> ConstraintDescription {
let item = ConstraintItem(object: self.view, attributes: attributes)
let constraintDescription = ConstraintDescription(fromItem: item)
self.constraintDescriptions.append(constraintDescription)
return constraintDescription
}
internal class func prepareConstraints(view: View, @noescape closure: (make: ConstraintMaker) -> Void) -> [Constraint] {
let maker = ConstraintMaker(view: view)
closure(make: maker)
return maker.constraintDescriptions.map { $0.constraint }
}
internal class func makeConstraints(view: View, @noescape closure: (make: ConstraintMaker) -> Void) {
#if os(iOS)
view.setTranslatesAutoresizingMaskIntoConstraints(false)
#else
view.translatesAutoresizingMaskIntoConstraints = false
#endif
let maker = ConstraintMaker(view: view)
closure(make: maker)
let constraints = maker.constraintDescriptions.map { $0.constraint as! ConcreteConstraint }
for constraint in constraints {
constraint.installOnView(updateExisting: false)
}
}
internal class func remakeConstraints(view: View, @noescape closure: (make: ConstraintMaker) -> Void) {
#if os(iOS)
view.setTranslatesAutoresizingMaskIntoConstraints(false)
#else
view.translatesAutoresizingMaskIntoConstraints = false
#endif
let maker = ConstraintMaker(view: view)
closure(make: maker)
self.removeConstraints(view)
let constraints = maker.constraintDescriptions.map { $0.constraint as! ConcreteConstraint }
for constraint in constraints {
constraint.installOnView(updateExisting: false)
}
}
internal class func updateConstraints(view: View, @noescape closure: (make: ConstraintMaker) -> Void) {
#if os(iOS)
view.setTranslatesAutoresizingMaskIntoConstraints(false)
#else
view.translatesAutoresizingMaskIntoConstraints = false
#endif
let maker = ConstraintMaker(view: view)
closure(make: maker)
let constraints = maker.constraintDescriptions.map { $0.constraint as! ConcreteConstraint}
for constraint in constraints {
constraint.installOnView(updateExisting: true)
}
}
internal class func removeConstraints(view: View) {
for existingLayoutConstraint in view.snp_installedLayoutConstraints {
existingLayoutConstraint.snp_constraint?.uninstall()
}
}
}

View File

@ -1,48 +0,0 @@
//
// Snap
//
// Copyright (c) 2011-2015 Masonry Team - https://github.com/Masonry
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if os(iOS)
import UIKit
#else
import AppKit
#endif
/**
Used to define `NSLayoutRelation`
*/
internal enum ConstraintRelation: Int {
case Equal = 1, LessThanOrEqualTo, GreaterThanOrEqualTo
internal var layoutRelation: NSLayoutRelation {
get {
switch(self) {
case .LessThanOrEqualTo:
return .LessThanOrEqual
case .GreaterThanOrEqualTo:
return .GreaterThanOrEqual
default:
return .Equal
}
}
}
}

View File

@ -1,175 +0,0 @@
//
// Snap
//
// Copyright (c) 2011-2015 Masonry Team - https://github.com/Masonry
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if os(iOS)
import UIKit
#else
import AppKit
#endif
/**
Used to allow adding a snp_label to a View for debugging purposes
*/
public extension View {
public var snp_label: String? {
get {
return objc_getAssociatedObject(self, &labelKey) as? String
}
set {
objc_setAssociatedObject(self, &labelKey, newValue, objc_AssociationPolicy(OBJC_ASSOCIATION_COPY_NONATOMIC))
}
}
}
/**
Used to allow adding a snp_label to a LayoutConstraint for debugging purposes
*/
public extension LayoutConstraint {
public var snp_label: String? {
get {
return objc_getAssociatedObject(self, &labelKey) as? String
}
set {
objc_setAssociatedObject(self, &labelKey, newValue, objc_AssociationPolicy(OBJC_ASSOCIATION_COPY_NONATOMIC))
}
}
override public var description: String {
var description = "<"
description += descriptionForObject(self)
description += " \(descriptionForObject(self.firstItem))"
if self.firstAttribute != .NotAnAttribute {
description += ".\(self.firstAttribute.snp_description)"
}
description += " \(self.relation.snp_description)"
if let secondItem: AnyObject = self.secondItem {
description += " \(descriptionForObject(secondItem))"
}
if self.secondAttribute != .NotAnAttribute {
description += ".\(self.secondAttribute.snp_description)"
}
if self.multiplier != 1.0 {
description += " * \(self.multiplier)"
}
if self.secondAttribute == .NotAnAttribute {
description += " \(self.constant)"
} else {
if self.constant > 0.0 {
description += " + \(self.constant)"
} else if self.constant < 0.0 {
description += " - \(CGFloat.abs(self.constant))"
}
}
if self.priority != 1000.0 {
description += " ^\(self.priority)"
}
description += ">"
return description
}
}
private var labelKey = ""
private func descriptionForObject(object: AnyObject) -> String {
let pointerDescription = NSString(format: "%p", [object])
if let object = object as? View {
return "<\(object.dynamicType):\(object.snp_label ?? pointerDescription)>"
} else if let object = object as? LayoutConstraint {
return "<\(object.dynamicType):\(object.snp_label ?? pointerDescription)>"
}
return "<\(object.dynamicType):\(pointerDescription)>"
}
private extension NSLayoutRelation {
private var snp_description: String {
switch self {
case .Equal: return "=="
case .GreaterThanOrEqual: return ">="
case .LessThanOrEqual: return "<="
}
}
}
private extension NSLayoutAttribute {
private var snp_description: String {
#if os(iOS)
switch self {
case .NotAnAttribute: return "notAnAttribute"
case .Top: return "top"
case .Left: return "left"
case .Bottom: return "bottom"
case .Right: return "right"
case .Leading: return "leading"
case .Trailing: return "trailing"
case .Width: return "width"
case .Height: return "height"
case .CenterX: return "centerX"
case .CenterY: return "centerY"
case .Baseline: return "baseline"
case .FirstBaseline: return "firstBaseline"
case .TopMargin: return "topMargin"
case .LeftMargin: return "leftMargin"
case .BottomMargin: return "bottomMargin"
case .RightMargin: return "rightMargin"
case .LeadingMargin: return "leadingMargin"
case .TrailingMargin: return "trailingMargin"
case .CenterXWithinMargins: return "centerXWithinMargins"
case .CenterYWithinMargins: return "centerYWithinMargins"
}
#else
switch self {
case .NotAnAttribute: return "notAnAttribute"
case .Top: return "top"
case .Left: return "left"
case .Bottom: return "bottom"
case .Right: return "right"
case .Leading: return "leading"
case .Trailing: return "trailing"
case .Width: return "width"
case .Height: return "height"
case .CenterX: return "centerX"
case .CenterY: return "centerY"
case .Baseline: return "baseline"
}
#endif
}
}

View File

@ -1,43 +0,0 @@
//
// Snap
//
// Copyright (c) 2011-2015 Masonry Team - https://github.com/Masonry
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if os(iOS)
import UIKit
public typealias EdgeInsets = UIEdgeInsets
public func EdgeInsetsMake(top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat) -> EdgeInsets {
return EdgeInsets(top: top, left: left, bottom: bottom, right: right)
}
public let EdgeInsetsZero = EdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
#else
import AppKit
public struct EdgeInsets {
public var top: CGFloat
public var left: CGFloat
public var bottom: CGFloat
public var right: CGFloat
}
public func EdgeInsetsMake(top: CGFloat, left: CGFloat, bottom: CGFloat, right: CGFloat) -> EdgeInsets {
return EdgeInsets(top: top, left: left, bottom: bottom, right: right)
}
public let EdgeInsetsZero = EdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
#endif

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.masonry.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>

View File

@ -1,63 +0,0 @@
//
// Snap
//
// Copyright (c) 2011-2015 Masonry Team - https://github.com/Masonry
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if os(iOS)
import UIKit
#else
import AppKit
#endif
/**
Used to add extra information to the actual `NSLayoutConstraint`'s that will UIKit/AppKit will utilize
*/
final public class LayoutConstraint: NSLayoutConstraint {
internal var snp_constraint: Constraint? = nil
}
internal func ==(left: LayoutConstraint, right: LayoutConstraint) -> Bool {
if left.firstItem !== right.firstItem {
return false
}
if left.secondItem !== right.secondItem {
return false
}
if left.firstAttribute != right.firstAttribute {
return false
}
if left.secondAttribute != right.secondAttribute {
return false
}
if left.relation != right.relation {
return false
}
if left.priority != right.priority {
return false
}
if left.multiplier != right.multiplier {
return false
}
return true
}

View File

@ -1,27 +0,0 @@
//
// Snap
//
// Copyright (c) 2011-2014 Masonry Team - https://github.com/Masonry
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#import <Foundation/Foundation.h>
FOUNDATION_EXPORT double SnapVersionNumber;
FOUNDATION_EXPORT const unsigned char SnapVersionString[];

View File

@ -1,40 +0,0 @@
//
// Snap
//
// Copyright (c) 2011-2015 Masonry Team - https://github.com/Masonry
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if os(iOS)
import UIKit
public typealias InterfaceLayoutDirection = UIUserInterfaceLayoutDirection
#else
import AppKit
public typealias InterfaceLayoutDirection = NSUserInterfaceLayoutDirection
#endif
/**
Used to configure different parts of Snap
*/
public struct Config {
/// The interface layout direction
public static var interfaceLayoutDirection = InterfaceLayoutDirection.LeftToRight
}

View File

@ -1,180 +0,0 @@
//
// Snap
//
// Copyright (c) 2011-2015 Masonry Team - https://github.com/Masonry
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if os(iOS)
import UIKit
public typealias View = UIView
#else
import AppKit
public typealias View = NSView
#endif
/**
Used to expose public API on views
*/
public extension View {
/// left edge
final public var snp_left: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Left) }
/// top edge
final public var snp_top: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Top) }
/// right edge
final public var snp_right: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Right) }
/// bottom edge
final public var snp_bottom: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Bottom) }
/// leading edge
final public var snp_leading: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Leading) }
/// trailing edge
final public var snp_trailing: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Trailing) }
/// width dimension
final public var snp_width: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Width) }
/// height dimension
final public var snp_height: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Height) }
/// centerX position
final public var snp_centerX: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterX) }
/// centerY position
final public var snp_centerY: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterY) }
/// baseline position
final public var snp_baseline: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Baseline) }
#if os(iOS)
/// first baseline position
final public var snp_firstBaseline: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.FirstBaseline) }
/// left margin
final public var snp_leftMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeftMargin) }
/// right margin
final public var snp_rightMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.RightMargin) }
/// top margin
final public var snp_topMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TopMargin) }
/// bottom margin
final public var snp_bottomMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.BottomMargin) }
/// leading margin
final public var snp_leadingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.LeadingMargin) }
/// trailing margin
final public var snp_trailingMargin: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.TrailingMargin) }
/// centerX within margins
final public var snp_centerXWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterXWithinMargins) }
/// centerY within margins
final public var snp_centerYWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterYWithinMargins) }
#endif
// top + left + bottom + right edges
final public var snp_edges: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Edges) }
// width + height dimensions
final public var snp_size: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Size) }
// centerX + centerY positions
final public var snp_center: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Center) }
#if os(iOS)
// top + left + bottom + right margins
final public var snp_margins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.Margins) }
// centerX + centerY within margins
final public var snp_centerWithinMargins: ConstraintItem { return ConstraintItem(object: self, attributes: ConstraintAttributes.CenterWithinMargins) }
#endif
/**
Prepares constraints with a `ConstraintMaker` and returns the made constraints but does not install them.
:param: closure that will be passed the `ConstraintMaker` to make the constraints with
:returns: the constraints made
*/
final public func snp_prepareConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> [Constraint] {
return ConstraintMaker.prepareConstraints(self, closure: closure)
}
/**
Makes constraints with a `ConstraintMaker` and installs them along side any previous made constraints.
:param: closure that will be passed the `ConstraintMaker` to make the constraints with
*/
final public func snp_makeConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> Void {
ConstraintMaker.makeConstraints(self, closure: closure)
}
/**
Updates constraints with a `ConstraintMaker` that will replace existing constraints that match and install new ones.
For constraints to match only the constant can be updated.
:param: closure that will be passed the `ConstraintMaker` to update the constraints with
*/
final public func snp_updateConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> Void {
ConstraintMaker.updateConstraints(self, closure: closure)
}
/**
Remakes constraints with a `ConstraintMaker` that will first remove all previously made constraints and make and install new ones.
:param: closure that will be passed the `ConstraintMaker` to remake the constraints with
*/
final public func snp_remakeConstraints(@noescape closure: (make: ConstraintMaker) -> Void) -> Void {
ConstraintMaker.remakeConstraints(self, closure: closure)
}
/**
Removes all previously made constraints.
*/
final public func snp_removeConstraints() {
ConstraintMaker.removeConstraints(self)
}
final internal var snp_installedLayoutConstraints: [LayoutConstraint] {
get {
if let constraints = objc_getAssociatedObject(self, &installedLayoutConstraintsKey) as? [LayoutConstraint] {
return constraints
}
return []
}
set {
objc_setAssociatedObject(self, &installedLayoutConstraintsKey, newValue, UInt(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
}
}
}
private var installedLayoutConstraintsKey = ""

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.masonry.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

View File

@ -1,214 +0,0 @@
#if os(iOS)
import UIKit
typealias View = UIView
extension View {
var snp_constraints: [AnyObject] { return self.constraints() }
}
#else
import AppKit
typealias View = NSView
extension View {
var snp_constraints: [AnyObject] { return self.constraints }
}
#endif
import XCTest
import Snap
class SnapTests: XCTestCase {
let container = View()
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testMakeConstraints() {
let v1 = View()
let v2 = View()
self.container.addSubview(v1)
self.container.addSubview(v2)
v1.snp_makeConstraints { (make) -> Void in
make.top.equalTo(v2.snp_top).offset(50)
make.left.equalTo(v2.snp_top).offset(50)
return
}
XCTAssertEqual(self.container.snp_constraints.count, 2, "Should have 2 constraints installed")
v2.snp_makeConstraints { (make) -> Void in
make.edges.equalTo(v1)
return
}
XCTAssertEqual(self.container.snp_constraints.count, 6, "Should have 6 constraints installed")
}
func testUpdateConstraints() {
let v1 = View()
let v2 = View()
self.container.addSubview(v1)
self.container.addSubview(v2)
v1.snp_makeConstraints { (make) -> Void in
make.top.equalTo(v2.snp_top).offset(50)
make.left.equalTo(v2.snp_top).offset(50)
return
}
XCTAssertEqual(self.container.snp_constraints.count, 2, "Should have 2 constraints installed")
v1.snp_updateConstraints { (make) -> Void in
make.top.equalTo(v2.snp_top).offset(15)
return
}
XCTAssertEqual(self.container.snp_constraints.count, 2, "Should still have 2 constraints installed")
}
func testRemakeConstraints() {
let v1 = View()
let v2 = View()
self.container.addSubview(v1)
self.container.addSubview(v2)
v1.snp_makeConstraints { (make) -> Void in
make.top.equalTo(v2.snp_top).offset(50)
make.left.equalTo(v2.snp_top).offset(50)
return
}
XCTAssertEqual(self.container.snp_constraints.count, 2, "Should have 2 constraints installed")
v1.snp_remakeConstraints { (make) -> Void in
make.edges.equalTo(v2)
return
}
XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints installed")
}
func testRemoveConstraints() {
let v1 = View()
let v2 = View()
self.container.addSubview(v1)
self.container.addSubview(v2)
v1.snp_makeConstraints { (make) -> Void in
make.top.equalTo(v2.snp_top).offset(50)
make.left.equalTo(v2.snp_top).offset(50)
return
}
XCTAssertEqual(self.container.snp_constraints.count, 2, "Should have 2 constraints installed")
v1.snp_removeConstraints()
XCTAssertEqual(self.container.snp_constraints.count, 0, "Should have 0 constraints installed")
}
func testPrepareConstraints() {
let v1 = View()
let v2 = View()
self.container.addSubview(v1)
self.container.addSubview(v2)
let constraints = v1.snp_prepareConstraints { (make) -> Void in
make.edges.equalTo(v2)
return
}
XCTAssertEqual(self.container.snp_constraints.count, 0, "Should have 0 constraints installed")
for constraint in constraints {
constraint.install()
}
XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints installed")
for constraint in constraints {
constraint.uninstall()
}
XCTAssertEqual(self.container.snp_constraints.count, 0, "Should have 0 constraints installed")
}
func testReinstallConstraints() {
let v1 = View()
let v2 = View()
self.container.addSubview(v1)
self.container.addSubview(v2)
let constraints = v1.snp_prepareConstraints { (make) -> Void in
make.edges.equalTo(v2)
return
}
XCTAssertEqual(self.container.snp_constraints.count, 0, "Should have 0 constraints installed")
for constraint in constraints {
constraint.install()
}
XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints installed")
for constraint in constraints {
constraint.install()
}
XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 0 constraints installed")
}
func testActivateDeactivateConstraints() {
let v1 = View()
let v2 = View()
self.container.addSubview(v1)
self.container.addSubview(v2)
var c1: Constraint? = nil
var c2: Constraint? = nil
v1.snp_prepareConstraints { (make) -> Void in
c1 = make.top.equalTo(v2.snp_top).offset(50).constraint
c2 = make.left.equalTo(v2.snp_top).offset(50).constraint
return
}
XCTAssertEqual(self.container.snp_constraints.count, 0, "Should have 0 constraints")
c1?.activate()
c2?.activate()
XCTAssertEqual(self.container.snp_constraints.count, 2, "Should have 2 constraints")
c1?.deactivate()
c2?.deactivate()
XCTAssertEqual(self.container.snp_constraints.count, 0, "Should have 0 constraints")
c1?.uninstall()
c2?.uninstall()
XCTAssertEqual(self.container.snp_constraints.count, 0, "Should have 0 constraints")
c1?.activate()
c2?.activate()
XCTAssertEqual(self.container.snp_constraints.count, 2, "Should have 2 constraints")
}
}