Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ios
/
Masonry
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Nikolay Tymchenko
11 years ago
Commit
1a577997f2693a4c94e3d29e267231cfbf3cb33f
1 parent
775740e9
Added MASConstraint private header
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
77 additions
and
58 deletions
Masonry.xcworkspace/contents.xcworkspacedata
Masonry/MASCompositeConstraint.m
Masonry/MASConstraint+Private.h
Masonry/MASConstraint.h
Masonry/MASConstraint.m
Masonry/MASConstraintMaker.m
Masonry/MASViewConstraint.m
Tests/Specs/MASConstraintDelegateMock.h
Tests/Specs/MASConstraintMakerSpec.m
Tests/Specs/MASViewConstraintSpec.m
Masonry.xcworkspace/contents.xcworkspacedata
View file @
1a57799
...
...
@@ -14,6 +14,9 @@
location =
"group:MASConstraint.m"
>
</FileRef>
<FileRef
location =
"group:MASConstraint+Private.h"
>
</FileRef>
<FileRef
location =
"group:MASCompositeConstraint.h"
>
</FileRef>
<FileRef
...
...
Masonry/MASCompositeConstraint.m
View file @
1a57799
...
...
@@ -7,6 +7,7 @@
//
#import "MASCompositeConstraint.h"
#import "MASConstraint+Private.h"
@interface
MASCompositeConstraint
()
<
MASConstraintDelegate
>
...
...
Masonry/MASConstraint+Private.h
0 → 100644
View file @
1a57799
//
// MASConstraint+Private.h
// Masonry
//
// Created by Nick Tymchenko on 29/04/14.
// Copyright (c) 2014 cloudling. All rights reserved.
//
#import "MASConstraint.h"
@protocol
MASConstraintDelegate
;
@interface
MASConstraint
()
/**
* Whether or not to check for an existing constraint instead of adding constraint
*/
@property
(
nonatomic
,
assign
)
BOOL
updateExisting
;
/**
* Usually MASConstraintMaker but could be a parent MASConstraint
*/
@property
(
nonatomic
,
weak
)
id
<
MASConstraintDelegate
>
delegate
;
/**
* Based on a provided value type, is equal to calling:
* NSNumber - setOffset:
* NSValue with CGPoint - setPointOffset:
* NSValue with CGSize - setSizeOffset:
* NSValue with MASEdgeInsets - setInsets:
*/
-
(
void
)
setLayoutConstantWithValue
:(
NSValue
*
)
value
;
@end
@protocol
MASConstraintDelegate
<
NSObject
>
/**
* Notifies the delegate when the constraint needs to be replaced with another constraint. For example
* A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks
*/
-
(
void
)
constraint
:
(
MASConstraint
*
)
constraint
shouldBeReplacedWithConstraint
:
(
MASConstraint
*
)
replacementConstraint
;
@end
\ No newline at end of file
...
...
Masonry/MASConstraint.h
View file @
1a57799
...
...
@@ -8,8 +8,6 @@
#import "MASUtilities.h"
@protocol
MASConstraintDelegate
;
/**
* Enables Constraints to be created with chainable syntax
* Constraint can represent single NSLayoutConstraint (MASViewConstraint)
...
...
@@ -150,16 +148,6 @@
#endif
/**
* Whether or not to check for an existing constraint instead of adding constraint
*/
@property
(
nonatomic
,
assign
)
BOOL
updateExisting
;
/**
* Usually MASConstraintMaker but could be a parent MASConstraint
*/
@property
(
nonatomic
,
weak
)
id
<
MASConstraintDelegate
>
delegate
;
/**
* Creates a NSLayoutConstraint and adds it to the appropriate view.
*/
-
(
void
)
install
;
...
...
@@ -172,45 +160,6 @@
@end
@interface
MASConstraint
(
Private
)
/**
* Modifies the NSLayoutConstraint constant based on a value type,
* see _setLayoutConstantWithValue: for details
*/
-
(
MASConstraint
*
(
^
)(
id
))
_valueOffset
;
/**
* Based on a provided value type, is equal to calling:
* NSNumber - setOffset:
* NSValue with CGPoint - setPointOffset:
* NSValue with CGSize - setSizeOffset:
* NSValue with MASEdgeInsets - setInsets:
*/
-
(
void
)
_setLayoutConstantWithValue
:(
NSValue
*
)
value
;
/**
* Sets the constraint relation to given NSLayoutRelation
* returns a block which accepts one of the following:
* MASViewAttribute, UIView, NSValue, NSArray
* see readme for more details.
*/
-
(
MASConstraint
*
(
^
)(
id
attr
,
NSLayoutRelation
relation
))
_equalToWithRelation
;
@end
@protocol
MASConstraintDelegate
<
NSObject
>
/**
* Notifies the delegate when the constraint needs to be replaced with another constraint. For example
* A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks
*/
-
(
void
)
constraint
:
(
MASConstraint
*
)
constraint
shouldBeReplacedWithConstraint
:
(
MASConstraint
*
)
replacementConstraint
;
@end
/**
* Convenience auto-boxing macros for MASConstraint methods.
*
...
...
@@ -235,12 +184,27 @@
#endif
@interface
MASConstraint
(
AutocompletionSupport
)
@interface
MASConstraint
(
AutoboxingSupport
)
/**
* Modifies the NSLayoutConstraint constant based on a value type
*/
-
(
MASConstraint
*
(
^
)(
id
))
_valueOffset
;
/**
* Sets the constraint relation to given NSLayoutRelation
* returns a block which accepts one of the following:
* MASViewAttribute, UIView, NSValue, NSArray
* see readme for more details.
*/
-
(
MASConstraint
*
(
^
)(
id
attr
,
NSLayoutRelation
relation
))
_equalToWithRelation
;
/**
* Dummy methods to aid autocompletion
*/
-
(
MASConstraint
*
(
^
)(
id
attr
))
mas_equalTo
;
-
(
MASConstraint
*
(
^
)(
id
attr
))
mas_greaterThanOrEqualTo
;
-
(
MASConstraint
*
(
^
)(
id
attr
))
mas_lessThanOrEqualTo
;
-
(
MASConstraint
*
(
^
)(
id
offset
))
mas_offset
;
@end
@end
\ No newline at end of file
...
...
Masonry/MASConstraint.m
View file @
1a57799
...
...
@@ -6,6 +6,7 @@
//
#import "MASConstraint.h"
#import "MASConstraint+Private.h"
#define methodNotImplemented() \
@throw [NSException exceptionWithName:NSInternalInconsistencyException \
...
...
@@ -97,14 +98,14 @@
-
(
MASConstraint
*
(
^
)(
id
))
_valueOffset
{
return
^
id
(
id
offset
)
{
NSAssert
([
offset
isKindOfClass
:
NSValue
.
class
],
@"expected an NSValue offset, got: %@"
,
offset
);
[
self
_
setLayoutConstantWithValue
:
offset
];
[
self
setLayoutConstantWithValue
:
offset
];
return
self
;
};
}
#pragma mark - NSLayoutConstraint constant setter
-
(
void
)
_
setLayoutConstantWithValue
:
(
NSValue
*
)
value
{
-
(
void
)
setLayoutConstantWithValue
:
(
NSValue
*
)
value
{
if
([
value
isKindOfClass
:
NSNumber
.
class
])
{
self
.
offset
=
[(
NSNumber
*
)
value
doubleValue
];
}
else
if
(
strcmp
(
value
.
objCType
,
@encode
(
CGPoint
))
==
0
)
{
...
...
Masonry/MASConstraintMaker.m
View file @
1a57799
...
...
@@ -9,6 +9,7 @@
#import "MASConstraintMaker.h"
#import "MASViewConstraint.h"
#import "MASCompositeConstraint.h"
#import "MASConstraint+Private.h"
#import "MASViewAttribute.h"
#import "View+MASAdditions.h"
...
...
Masonry/MASViewConstraint.m
View file @
1a57799
...
...
@@ -7,6 +7,7 @@
//
#import "MASViewConstraint.h"
#import "MASConstraint+Private.h"
#import "MASCompositeConstraint.h"
#import "MASLayoutConstraint.h"
#import "View+MASAdditions.h"
...
...
@@ -78,7 +79,7 @@
-
(
void
)
setSecondViewAttribute
:
(
id
)
secondViewAttribute
{
if
([
secondViewAttribute
isKindOfClass
:
NSValue
.
class
])
{
[
self
_
setLayoutConstantWithValue
:
secondViewAttribute
];
[
self
setLayoutConstantWithValue
:
secondViewAttribute
];
}
else
if
([
secondViewAttribute
isKindOfClass
:
MAS_VIEW
.
class
])
{
_secondViewAttribute
=
[[
MASViewAttribute
alloc
]
initWithView
:
secondViewAttribute
layoutAttribute
:
self
.
firstViewAttribute
.
layoutAttribute
];
}
else
if
([
secondViewAttribute
isKindOfClass
:
MASViewAttribute
.
class
])
{
...
...
Tests/Specs/MASConstraintDelegateMock.h
View file @
1a57799
...
...
@@ -6,7 +6,7 @@
// Copyright (c) 2013 Jonas Budelmann. All rights reserved.
//
#import "MASConstraint.h"
#import "MASConstraint
+Private
.h"
@interface
MASConstraintDelegateMock
:
NSObject
<
MASConstraintDelegate
>
...
...
Tests/Specs/MASConstraintMakerSpec.m
View file @
1a57799
...
...
@@ -9,6 +9,7 @@
#import "MASConstraintMaker.h"
#import "MASCompositeConstraint.h"
#import "MASViewConstraint.h"
#import "MASConstraint+Private.h"
@interface
MASConstraintMaker
()
<
MASConstraintDelegate
>
...
...
Tests/Specs/MASViewConstraintSpec.m
View file @
1a57799
...
...
@@ -7,6 +7,7 @@
//
#import "MASViewConstraint.h"
#import "MASConstraint+Private.h"
#import "MASConstraint.h"
#import "View+MASAdditions.h"
#import "MASConstraintDelegateMock.h"
...
...
Please
register
or
login
to post a comment