From 5713270eff15a7b501ef10b8d8a351a91c6e7a7a Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Wed, 15 Apr 2015 11:35:29 +1200 Subject: [PATCH] Prepare for Jekyll Site --- Assets/snap-banner.png | Bin 18930 -> 0 bytes CHANGELOG.md | 17 - .../Snappy Constraint Make.codesnippet | 26 - .../Snappy Constraint Remake.codesnippet | 26 - LICENSE | 19 - README.md | 349 --------- Snap.podspec | 17 - Snap.xcodeproj/project.pbxproj | 695 ------------------ .../xcshareddata/xcschemes/Snap OSX.xcscheme | 110 --- .../xcshareddata/xcschemes/Snap iOS.xcscheme | 110 --- Snap.xcworkspace/contents.xcworkspacedata | 7 - Snap.xcworkspace/xcshareddata/Snap.xccheckout | 41 -- .../xcshareddata/Snappy.xccheckout | 41 -- Source/Constraint.swift | 465 ------------ Source/ConstraintAttributes.swift | 167 ----- Source/ConstraintDescription.swift | 547 -------------- Source/ConstraintItem.swift | 71 -- Source/ConstraintMaker.swift | 189 ----- Source/ConstraintRelation.swift | 48 -- Source/Debugging.swift | 175 ----- Source/EdgeInsets.swift | 43 -- Source/Info.plist | 26 - Source/LayoutConstraint.swift | 63 -- Source/Snap.h | 27 - Source/Snap.swift | 40 - Source/View+Snap.swift | 180 ----- Tests/Info.plist | 24 - Tests/Tests.swift | 214 ------ 28 files changed, 3737 deletions(-) delete mode 100644 Assets/snap-banner.png delete mode 100644 CHANGELOG.md delete mode 100644 CodeSnippets/Snappy Constraint Make.codesnippet delete mode 100644 CodeSnippets/Snappy Constraint Remake.codesnippet delete mode 100644 LICENSE delete mode 100644 README.md delete mode 100644 Snap.podspec delete mode 100644 Snap.xcodeproj/project.pbxproj delete mode 100644 Snap.xcodeproj/xcshareddata/xcschemes/Snap OSX.xcscheme delete mode 100644 Snap.xcodeproj/xcshareddata/xcschemes/Snap iOS.xcscheme delete mode 100644 Snap.xcworkspace/contents.xcworkspacedata delete mode 100644 Snap.xcworkspace/xcshareddata/Snap.xccheckout delete mode 100644 Snap.xcworkspace/xcshareddata/Snappy.xccheckout delete mode 100644 Source/Constraint.swift delete mode 100644 Source/ConstraintAttributes.swift delete mode 100644 Source/ConstraintDescription.swift delete mode 100644 Source/ConstraintItem.swift delete mode 100644 Source/ConstraintMaker.swift delete mode 100644 Source/ConstraintRelation.swift delete mode 100644 Source/Debugging.swift delete mode 100644 Source/EdgeInsets.swift delete mode 100644 Source/Info.plist delete mode 100644 Source/LayoutConstraint.swift delete mode 100644 Source/Snap.h delete mode 100644 Source/Snap.swift delete mode 100644 Source/View+Snap.swift delete mode 100644 Tests/Info.plist delete mode 100644 Tests/Tests.swift diff --git a/Assets/snap-banner.png b/Assets/snap-banner.png deleted file mode 100644 index 491b6b586304ff5bc4075bcce39559f67711618e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18930 zcmeEuWmDTxw=WX3g&-}oxD@x|?pCzLi@UoM+#L$ExLbkZ?v&zQC=!CZ1&83=@Z3B1 ze1>!8%=`!PhV1OM*ZRp?J4C4}%VJ>?VIm+PV9Co#eL+A#T7bV^LPv%F{IonL0RM&P z`bAa(p=yF;9|1uOL0(E+-3t+#jpju%I~zVZvb-j9(wC2lguxPuO}VAAmqtJmt!9OR zgHD4Z5qLR;(b+#x5~9SBjgX&iGE*DJaP0EkY`AW=@uJ(a(e`9wqN-u~*v9i}dH4PJ z7!;PRGu~=Bk!4##fkgGc&;Lf?e|iLpB`MSeB>&1u<+)*aB`hFR)Gz-UieT+L>ZS#8`k*eL=+?5=9LC{?yPW+B?z}X?9<``rU6e7KB$vFybo)<^^{f z+b-y$izskb(aEB8a9q2Vi$vI~HI-euy6x@qgl{HctY}vmE;tyA=}K4sVSB%M^yR&g z+d1sDsUU@e;;Ub&q__g$lD_`8SNSjsm{nnRFU3-4M*EuhN3%w|Q9c{USoyln?|`tf zjFv6zP8)(CJG{ieY^98H1wflz53wcj*NVpsw8MS%MhC)*SFB`plipsUq2c$}Q*yc_ zSq!jR^c?DUhc`t(Bs{#WQXcsky3nc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UV9iBQl=>Mu2T=vZIA#33EX$cl6Z@amDatBwMZ=N~oRG$_V6?zm?A_=ScnsT+U`i1_<1K{PVOZXWJKDjyjxE#J;<{drOjVf$=eQuL)$cO zH{#V-f<%?&r2llkdb}e9!y6Bob^O0qvmoMtI2r8wR@aT?iLmWU81qQHt)M-udgfuU z_Z^^M!MPoDx2^d3Y40P|-pS;#?r~bJ!Qpi_MjD!u<@5!!dA9f1zEk(F!sO5ib`QTX zd`qUL`|6PSYDt*N65JLilr6~QhTjepT`wAa0TCv54GzOB5BTE7F{T5eW(SEgQ4bDB zy&oXkw-2Z?Js|7oJHdaud39$nU)8o3uOgsA@g%!+`&Io5Tvf{$aR7(dflHBj1TkZ7 z34S|o4!qOGg@tyD7!weh0nlr?#d{3z6_Xh2$t)vM+^Vv|B&hiWYzHxb$9>)<%h_rB z=Pp*057|w%nI0kv4&K533I9K5oKls#gfXN7cj?f>y)%hv2ib}aQ`FwZ`<5e=k@3j6 zZ^IMm)xHE;c^N(#d;u}eqWFZlXOw<-`0lgRT;nz>Ef&9C4c$}5{p$07Zj2?4AsFJ` z)$WdlKE+%K&UPWgR5<4c(=|IMpDfPFoBqlWL;vBf3(V2Zw**7yQ=YLQ`hDG_BG;Km zuVQm4&l6>VO+O4+BkCElenKov#;BG$A*}KW*SD(Xb6mk i05Ajs99aIzuU`NDQ1!>tp1?z#7(8A5T-G@yGywp [Constraint]` which allows pre-building of constraints -* Added a fatal error to `and` when it is used after relation has been set \ No newline at end of file diff --git a/CodeSnippets/Snappy Constraint Make.codesnippet b/CodeSnippets/Snappy Constraint Make.codesnippet deleted file mode 100644 index 598f6b3..0000000 --- a/CodeSnippets/Snappy Constraint Make.codesnippet +++ /dev/null @@ -1,26 +0,0 @@ - - - - - IDECodeSnippetCompletionPrefix - snp_make - IDECodeSnippetCompletionScopes - - CodeBlock - - IDECodeSnippetContents - <#view#>.snp_makeConstraints { make in - <#code#> -} - IDECodeSnippetIdentifier - FF434629-7B96-4AB9-BD96-522275E7B106 - IDECodeSnippetLanguage - Xcode.SourceCodeLanguage.Swift - IDECodeSnippetTitle - Snap Constraint Make - IDECodeSnippetUserSnippet - - IDECodeSnippetVersion - 2 - - diff --git a/CodeSnippets/Snappy Constraint Remake.codesnippet b/CodeSnippets/Snappy Constraint Remake.codesnippet deleted file mode 100644 index 8bdfb9d..0000000 --- a/CodeSnippets/Snappy Constraint Remake.codesnippet +++ /dev/null @@ -1,26 +0,0 @@ - - - - - IDECodeSnippetCompletionPrefix - snp_remake - IDECodeSnippetCompletionScopes - - TopLevel - - IDECodeSnippetContents - <#view#>.snp_remakeConstraints { make in - <#code#> -} - IDECodeSnippetIdentifier - FD093546-D614-4311-82C3-E8FE842F62B1 - IDECodeSnippetLanguage - Xcode.SourceCodeLanguage.Swift - IDECodeSnippetTitle - Snap Constraint Remake - IDECodeSnippetUserSnippet - - IDECodeSnippetVersion - 0 - - diff --git a/LICENSE b/LICENSE deleted file mode 100644 index e334771..0000000 --- a/LICENSE +++ /dev/null @@ -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. diff --git a/README.md b/README.md deleted file mode 100644 index b30fd91..0000000 --- a/README.md +++ /dev/null @@ -1,349 +0,0 @@ - - - -==== - -[![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 we’ve chosen to swap prefixes from Masonry’s `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’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` -> `.snp_makeConstraints { make in }` - -`snp_remake` -> `.snp_remakeConstraints { make in }` - -## TODO - -* Eye candy -* Example projects -* Tests diff --git a/Snap.podspec b/Snap.podspec deleted file mode 100644 index 539643c..0000000 --- a/Snap.podspec +++ /dev/null @@ -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 \ No newline at end of file diff --git a/Snap.xcodeproj/project.pbxproj b/Snap.xcodeproj/project.pbxproj deleted file mode 100644 index a672ccb..0000000 --- a/Snap.xcodeproj/project.pbxproj +++ /dev/null @@ -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 = ""; }; - EECDB35F1AC0C95C006BBC11 /* ConstraintAttributes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintAttributes.swift; sourceTree = ""; }; - EECDB3601AC0C95C006BBC11 /* ConstraintItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintItem.swift; sourceTree = ""; }; - EECDB3611AC0C95C006BBC11 /* ConstraintMaker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintMaker.swift; sourceTree = ""; }; - EECDB3621AC0C95C006BBC11 /* ConstraintRelation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintRelation.swift; sourceTree = ""; }; - EECDB3631AC0C95C006BBC11 /* EdgeInsets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EdgeInsets.swift; sourceTree = ""; }; - EECDB3641AC0C95C006BBC11 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - EECDB3651AC0C95C006BBC11 /* LayoutConstraint.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LayoutConstraint.swift; sourceTree = ""; }; - EECDB3661AC0C95C006BBC11 /* Snap.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Snap.h; sourceTree = ""; }; - EECDB3671AC0C95C006BBC11 /* View+Snap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Snap.swift"; sourceTree = ""; }; - EECDB3691AC0C95C006BBC11 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - EECDB36A1AC0C95C006BBC11 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; - 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 = ""; }; - EEFCF32E1AD926AE00A425FA /* Snap.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Snap.swift; sourceTree = ""; }; - EEFCF3311AD9432400A425FA /* ConstraintDescription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintDescription.swift; sourceTree = ""; }; -/* 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 = ""; - }; - DDC9FD961981B4DD009612C7 /* Products */ = { - isa = PBXGroup; - children = ( - EEBCC9D819CC627D0083B827 /* Snap.framework */, - EEBCC9E219CC627E0083B827 /* Snap iOS Tests.xctest */, - EECDB37A1AC0C9D4006BBC11 /* Snap.framework */, - EECDB3841AC0C9D4006BBC11 /* Snap OSX Tests.xctest */, - ); - name = Products; - sourceTree = ""; - }; - EE94F60C1AC0F113008767FF /* Frameworks */ = { - isa = PBXGroup; - children = ( - EE94F60A1AC0F10F008767FF /* AppKit.framework */, - EE94F6081AC0F10A008767FF /* UIKit.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; - 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 = ""; - }; - EECDB3681AC0C95C006BBC11 /* Tests */ = { - isa = PBXGroup; - children = ( - EECDB3691AC0C95C006BBC11 /* Info.plist */, - EECDB36A1AC0C95C006BBC11 /* Tests.swift */, - ); - name = Tests; - path = ../Tests; - sourceTree = ""; - }; - EECDB36B1AC0C967006BBC11 /* Supporting Files */ = { - isa = PBXGroup; - children = ( - EECDB3641AC0C95C006BBC11 /* Info.plist */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; -/* 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 */; -} diff --git a/Snap.xcodeproj/xcshareddata/xcschemes/Snap OSX.xcscheme b/Snap.xcodeproj/xcshareddata/xcschemes/Snap OSX.xcscheme deleted file mode 100644 index cf8990d..0000000 --- a/Snap.xcodeproj/xcshareddata/xcschemes/Snap OSX.xcscheme +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Snap.xcodeproj/xcshareddata/xcschemes/Snap iOS.xcscheme b/Snap.xcodeproj/xcshareddata/xcschemes/Snap iOS.xcscheme deleted file mode 100644 index f33a6f1..0000000 --- a/Snap.xcodeproj/xcshareddata/xcschemes/Snap iOS.xcscheme +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Snap.xcworkspace/contents.xcworkspacedata b/Snap.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 8ae6f15..0000000 --- a/Snap.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Snap.xcworkspace/xcshareddata/Snap.xccheckout b/Snap.xcworkspace/xcshareddata/Snap.xccheckout deleted file mode 100644 index 19c212e..0000000 --- a/Snap.xcworkspace/xcshareddata/Snap.xccheckout +++ /dev/null @@ -1,41 +0,0 @@ - - - - - IDESourceControlProjectFavoriteDictionaryKey - - IDESourceControlProjectIdentifier - A81B1AD2-2D5B-4BB2-AAA6-86A53AADC474 - IDESourceControlProjectName - Snap - IDESourceControlProjectOriginsDictionary - - 3AF18F9C6F5D633BAA0B3F935459E0C777C82047 - github.com:Masonry/Snap.git - - IDESourceControlProjectPath - Snap.xcworkspace - IDESourceControlProjectRelativeInstallPathDictionary - - 3AF18F9C6F5D633BAA0B3F935459E0C777C82047 - .. - - IDESourceControlProjectURL - github.com:Masonry/Snap.git - IDESourceControlProjectVersion - 111 - IDESourceControlProjectWCCIdentifier - 3AF18F9C6F5D633BAA0B3F935459E0C777C82047 - IDESourceControlProjectWCConfigurations - - - IDESourceControlRepositoryExtensionIdentifierKey - public.vcs.git - IDESourceControlWCCIdentifierKey - 3AF18F9C6F5D633BAA0B3F935459E0C777C82047 - IDESourceControlWCCName - Snap - - - - diff --git a/Snap.xcworkspace/xcshareddata/Snappy.xccheckout b/Snap.xcworkspace/xcshareddata/Snappy.xccheckout deleted file mode 100644 index 91c9f46..0000000 --- a/Snap.xcworkspace/xcshareddata/Snappy.xccheckout +++ /dev/null @@ -1,41 +0,0 @@ - - - - - IDESourceControlProjectFavoriteDictionaryKey - - IDESourceControlProjectIdentifier - FDF6DE8D-A35D-47D4-8CB6-ACB35050F0D0 - IDESourceControlProjectName - Snap - IDESourceControlProjectOriginsDictionary - - 3AF18F9C6F5D633BAA0B3F935459E0C777C82047 - github.com:Masonry/Snap.git - - IDESourceControlProjectPath - Snap.xcodeproj - IDESourceControlProjectRelativeInstallPathDictionary - - 3AF18F9C6F5D633BAA0B3F935459E0C777C82047 - ../.. - - IDESourceControlProjectURL - github.com:Masonry/Snap.git - IDESourceControlProjectVersion - 111 - IDESourceControlProjectWCCIdentifier - 3AF18F9C6F5D633BAA0B3F935459E0C777C82047 - IDESourceControlProjectWCConfigurations - - - IDESourceControlRepositoryExtensionIdentifierKey - public.vcs.git - IDESourceControlWCCIdentifierKey - 3AF18F9C6F5D633BAA0B3F935459E0C777C82047 - IDESourceControlWCCName - Snap - - - - diff --git a/Source/Constraint.swift b/Source/Constraint.swift deleted file mode 100644 index e3aefd4..0000000 --- a/Source/Constraint.swift +++ /dev/null @@ -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() - 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) -} \ No newline at end of file diff --git a/Source/ConstraintAttributes.swift b/Source/ConstraintAttributes.swift deleted file mode 100644 index 25dd209..0000000 --- a/Source/ConstraintAttributes.swift +++ /dev/null @@ -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 -} diff --git a/Source/ConstraintDescription.swift b/Source/ConstraintDescription.swift deleted file mode 100644 index 0ab8c4b..0000000 --- a/Source/ConstraintDescription.swift +++ /dev/null @@ -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) - } -} \ No newline at end of file diff --git a/Source/ConstraintItem.swift b/Source/ConstraintItem.swift deleted file mode 100644 index 3b99b55..0000000 --- a/Source/ConstraintItem.swift +++ /dev/null @@ -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 -} \ No newline at end of file diff --git a/Source/ConstraintMaker.swift b/Source/ConstraintMaker.swift deleted file mode 100644 index bc19cd1..0000000 --- a/Source/ConstraintMaker.swift +++ /dev/null @@ -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() - } - } -} \ No newline at end of file diff --git a/Source/ConstraintRelation.swift b/Source/ConstraintRelation.swift deleted file mode 100644 index 57cb3f9..0000000 --- a/Source/ConstraintRelation.swift +++ /dev/null @@ -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 - } - } - } -} \ No newline at end of file diff --git a/Source/Debugging.swift b/Source/Debugging.swift deleted file mode 100644 index 9449afb..0000000 --- a/Source/Debugging.swift +++ /dev/null @@ -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 - - } - -} diff --git a/Source/EdgeInsets.swift b/Source/EdgeInsets.swift deleted file mode 100644 index 301838a..0000000 --- a/Source/EdgeInsets.swift +++ /dev/null @@ -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 diff --git a/Source/Info.plist b/Source/Info.plist deleted file mode 100644 index 7613312..0000000 --- a/Source/Info.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - com.masonry.$(PRODUCT_NAME:rfc1034identifier) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - $(CURRENT_PROJECT_VERSION) - NSPrincipalClass - - - diff --git a/Source/LayoutConstraint.swift b/Source/LayoutConstraint.swift deleted file mode 100644 index dad99ff..0000000 --- a/Source/LayoutConstraint.swift +++ /dev/null @@ -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 -} - diff --git a/Source/Snap.h b/Source/Snap.h deleted file mode 100644 index 0b37559..0000000 --- a/Source/Snap.h +++ /dev/null @@ -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_EXPORT double SnapVersionNumber; -FOUNDATION_EXPORT const unsigned char SnapVersionString[]; \ No newline at end of file diff --git a/Source/Snap.swift b/Source/Snap.swift deleted file mode 100644 index ad9d1e7..0000000 --- a/Source/Snap.swift +++ /dev/null @@ -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 - -} \ No newline at end of file diff --git a/Source/View+Snap.swift b/Source/View+Snap.swift deleted file mode 100644 index 44f452d..0000000 --- a/Source/View+Snap.swift +++ /dev/null @@ -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 = "" diff --git a/Tests/Info.plist b/Tests/Info.plist deleted file mode 100644 index 1235593..0000000 --- a/Tests/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - com.masonry.$(PRODUCT_NAME:rfc1034identifier) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/Tests/Tests.swift b/Tests/Tests.swift deleted file mode 100644 index cb2315e..0000000 --- a/Tests/Tests.swift +++ /dev/null @@ -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") - - } - -}