Authored by Nikolay Tymchenko

Added MASConstraint private header

... ... @@ -14,6 +14,9 @@
location = "group:MASConstraint.m">
</FileRef>
<FileRef
location = "group:MASConstraint+Private.h">
</FileRef>
<FileRef
location = "group:MASCompositeConstraint.h">
</FileRef>
<FileRef
... ...
... ... @@ -7,6 +7,7 @@
//
#import "MASCompositeConstraint.h"
#import "MASConstraint+Private.h"
@interface MASCompositeConstraint () <MASConstraintDelegate>
... ...
//
// 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
... ...
... ... @@ -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
... ...
... ... @@ -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) {
... ...
... ... @@ -9,6 +9,7 @@
#import "MASConstraintMaker.h"
#import "MASViewConstraint.h"
#import "MASCompositeConstraint.h"
#import "MASConstraint+Private.h"
#import "MASViewAttribute.h"
#import "View+MASAdditions.h"
... ...
... ... @@ -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]) {
... ...
... ... @@ -6,7 +6,7 @@
// Copyright (c) 2013 Jonas Budelmann. All rights reserved.
//
#import "MASConstraint.h"
#import "MASConstraint+Private.h"
@interface MASConstraintDelegateMock : NSObject <MASConstraintDelegate>
... ...
... ... @@ -9,6 +9,7 @@
#import "MASConstraintMaker.h"
#import "MASCompositeConstraint.h"
#import "MASViewConstraint.h"
#import "MASConstraint+Private.h"
@interface MASConstraintMaker () <MASConstraintDelegate>
... ...
... ... @@ -7,6 +7,7 @@
//
#import "MASViewConstraint.h"
#import "MASConstraint+Private.h"
#import "MASConstraint.h"
#import "View+MASAdditions.h"
#import "MASConstraintDelegateMock.h"
... ...