Authored by Jonas Budelmann

equal -> equalTo etc

... ... @@ -169,21 +169,21 @@
};
}
- (id<MASConstraint> (^)(id))equal {
- (id<MASConstraint> (^)(id))equalTo {
return [self equalityWithBlock:^id(id<MASConstraint> constraint, id attr) {
return constraint.equal(attr);
return constraint.equalTo(attr);
}];
}
- (id<MASConstraint> (^)(id))greaterThanOrEqual {
- (id<MASConstraint> (^)(id))greaterThanOrEqualTo {
return [self equalityWithBlock:^id<MASConstraint>(id<MASConstraint> constraint, id attr) {
return constraint.greaterThanOrEqual(attr);
return constraint.greaterThanOrEqualTo(attr);
}];
}
- (id<MASConstraint> (^)(id))lessThanOrEqual {
- (id<MASConstraint> (^)(id))lessThanOrEqualTo {
return [self equalityWithBlock:^id<MASConstraint>(id<MASConstraint> constraint, id attr) {
return constraint.lessThanOrEqual(attr);
return constraint.lessThanOrEqualTo(attr);
}];
}
... ...
... ... @@ -28,9 +28,9 @@ typedef float MASLayoutPriority;
@property (nonatomic, copy, readonly) id<MASConstraint> (^priorityLow)();
@property (nonatomic, copy, readonly) id<MASConstraint> (^priorityMedium)();
@property (nonatomic, copy, readonly) id<MASConstraint> (^priorityHigh)();
@property (nonatomic, copy, readonly) id<MASConstraint> (^equal)(id attr);
@property (nonatomic, copy, readonly) id<MASConstraint> (^greaterThanOrEqual)(id attr);
@property (nonatomic, copy, readonly) id<MASConstraint> (^lessThanOrEqual)(id attr);
@property (nonatomic, copy, readonly) id<MASConstraint> (^equalTo)(id attr);
@property (nonatomic, copy, readonly) id<MASConstraint> (^greaterThanOrEqualTo)(id attr);
@property (nonatomic, copy, readonly) id<MASConstraint> (^lessThanOrEqualTo)(id attr);
- (void)commit;
... ...
... ... @@ -189,7 +189,7 @@
[self.delegate addConstraint:self];
}
- (id<MASConstraint> (^)(id))equal {
- (id<MASConstraint> (^)(id))equalTo {
return ^id(id attr) {
NSAssert(!self.hasBeenCommitted,
@"Cannot modify constraint equal relation after it has been committed");
... ... @@ -201,7 +201,7 @@
};
}
- (id<MASConstraint> (^)(id))greaterThanOrEqual {
- (id<MASConstraint> (^)(id))greaterThanOrEqualTo {
return ^id(id attr) {
NSAssert(!self.hasBeenCommitted,
@"Cannot modify constraint greaterThanOrEqual relation after it has been committed");
... ... @@ -213,7 +213,7 @@
};
}
- (id<MASConstraint> (^)(id))lessThanOrEqual {
- (id<MASConstraint> (^)(id))lessThanOrEqualTo {
return ^id(id attr) {
NSAssert(!self.hasBeenCommitted,
@"Cannot modify constraint lessThanOrEqual relation after it has been committed");
... ...
... ... @@ -24,6 +24,6 @@
@property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline;
- (void)mas_buildConstraints:(void(^)(MASConstraintBuilder *constrain))block;
- (void)mas_buildConstraints:(void(^)(MASConstraintBuilder *make))block;
@end
\ No newline at end of file
... ...
... ... @@ -25,7 +25,7 @@
@property (nonatomic, strong, readonly) MASViewAttribute *centerY;
@property (nonatomic, strong, readonly) MASViewAttribute *baseline;
- (void)buildConstraints:(void(^)(MASConstraintBuilder *constraints))block;
- (void)buildConstraints:(void(^)(MASConstraintBuilder *make))block;
@end
... ...
... ... @@ -45,38 +45,38 @@
self.animatableConstraints = NSMutableArray.new;
[view1 mas_buildConstraints:^(MASConstraintBuilder *constrain) {
[view1 mas_buildConstraints:^(MASConstraintBuilder *make) {
[self.animatableConstraints addObjectsFromArray:@[
constrain.edges.equal(superview).insets(paddingInsets).priorityLow(),
constrain.bottom.equal(view3.mas_top).offset(-padding),
constrain.right.equal(view2.mas_left).offset(-padding),
make.edges.equalTo(superview).insets(paddingInsets).priorityLow(),
make.bottom.equalTo(view3.mas_top).offset(-padding),
make.right.equalTo(view2.mas_left).offset(-padding),
]];
constrain.size.equal(view2);
constrain.height.equal(view3.mas_height);
make.size.equalTo(view2);
make.height.equalTo(view3.mas_height);
}];
[view2 mas_buildConstraints:^(MASConstraintBuilder *constrain) {
[view2 mas_buildConstraints:^(MASConstraintBuilder *make) {
[self.animatableConstraints addObjectsFromArray:@[
constrain.edges.equal(superview).insets(paddingInsets).priorityLow(),
constrain.left.equal(view1.mas_right).offset(padding),
constrain.bottom.equal(view3.mas_top).offset(-padding),
make.edges.equalTo(superview).insets(paddingInsets).priorityLow(),
make.left.equalTo(view1.mas_right).offset(padding),
make.bottom.equalTo(view3.mas_top).offset(-padding),
]];
constrain.size.equal(view1);
constrain.height.equal(view3.mas_height);
make.size.equalTo(view1);
make.height.equalTo(view3.mas_height);
}];
[view3 mas_buildConstraints:^(MASConstraintBuilder *constrain) {
[view3 mas_buildConstraints:^(MASConstraintBuilder *make) {
[self.animatableConstraints addObjectsFromArray:@[
constrain.edges.equal(superview).insets(paddingInsets).priorityLow(),
constrain.top.equal(view1.mas_bottom).offset(padding),
make.edges.equalTo(superview).insets(paddingInsets).priorityLow(),
make.top.equalTo(view1.mas_bottom).offset(padding),
]];
//TODO or pass an array
//constraints.height.equal(superview.subviews);
constrain.height.equal(view1.mas_height);
constrain.height.equal(view2.mas_height);
make.height.equalTo(view1.mas_height);
make.height.equalTo(view2.mas_height);
}];
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapWithGestureRecognizer:)];
... ...
... ... @@ -35,41 +35,41 @@
UIView *superview = self;
int padding = 10;
[view1 mas_buildConstraints:^(MASConstraintBuilder *constrain) {
constrain.top.greaterThanOrEqual(superview.mas_top).offset(padding);
constrain.left.equal(superview.mas_left).offset(padding);
constrain.bottom.equal(view3.mas_top).offset(-padding);
constrain.right.equal(view2.mas_left).offset(-padding);
constrain.width.equal(view2.mas_width);
[view1 mas_buildConstraints:^(MASConstraintBuilder *make) {
make.top.greaterThanOrEqualTo(superview.mas_top).offset(padding);
make.left.equalTo(superview.mas_left).offset(padding);
make.bottom.equalTo(view3.mas_top).offset(-padding);
make.right.equalTo(view2.mas_left).offset(-padding);
make.width.equalTo(view2.mas_width);
//you can chain same attribute
constrain.height
.equal(view2.mas_height)
.equal(view3.mas_height);
make.height
.equalTo(view2.mas_height)
.equalTo(view3.mas_height);
}];
[view2 mas_buildConstraints:^(MASConstraintBuilder *constrain) {
constrain.top.equal(superview.mas_top).offset(padding);
constrain.left.equal(view1.mas_right).offset(padding);
constrain.bottom.equal(view3.mas_top).offset(-padding);
constrain.right.equal(superview.mas_right).offset(-padding);
constrain.width.equal(view1.mas_width);
[view2 mas_buildConstraints:^(MASConstraintBuilder *make) {
make.top.equalTo(superview.mas_top).offset(padding);
make.left.equalTo(view1.mas_right).offset(padding);
make.bottom.equalTo(view3.mas_top).offset(-padding);
make.right.equalTo(superview.mas_right).offset(-padding);
make.width.equalTo(view1.mas_width);
//or define it multiple times
constrain.height.equal(view1.mas_height);
constrain.height.equal(view3.mas_height);
make.height.equalTo(view1.mas_height);
make.height.equalTo(view3.mas_height);
}];
[view3 mas_buildConstraints:^(MASConstraintBuilder *constrain) {
constrain.top.equal(view1.mas_bottom).offset(padding);
constrain.left.equal(superview.mas_left).offset(padding);
constrain.bottom.equal(superview.mas_bottom).offset(-padding);
constrain.right.equal(superview.mas_right).offset(-padding);
[view3 mas_buildConstraints:^(MASConstraintBuilder *make) {
make.top.equalTo(view1.mas_bottom).offset(padding);
make.left.equalTo(superview.mas_left).offset(padding);
make.bottom.equalTo(superview.mas_bottom).offset(-padding);
make.right.equalTo(superview.mas_right).offset(-padding);
//TODO or pass an array
//constraints.height.equal(superview.subviews);
constrain.height.equal(view1.mas_height);
constrain.height.equal(view2.mas_height);
make.height.equalTo(view1.mas_height);
make.height.equalTo(view2.mas_height);
}];
return self;
... ...
... ... @@ -28,18 +28,18 @@
//example of using constants
[view1 mas_buildConstraints:^(MASConstraintBuilder *constrain) {
constrain.top.equal(@20);
constrain.left.equal(@20);
constrain.bottom.equal(@-20);
constrain.right.equal(@-20);
[view1 mas_buildConstraints:^(MASConstraintBuilder *make) {
make.top.equalTo(@20);
make.left.equalTo(@20);
make.bottom.equalTo(@-20);
make.right.equalTo(@-20);
}];
[view2 mas_buildConstraints:^(MASConstraintBuilder *constrain) {
constrain.centerY.equal(@50);
constrain.centerX.equal(@0);
constrain.width.equal(@200);
constrain.height.equal(@100);
[view2 mas_buildConstraints:^(MASConstraintBuilder *make) {
make.centerY.equalTo(@50);
make.centerX.equalTo(@0);
make.width.equalTo(@200);
make.height.equalTo(@100);
}];
return self;
... ...
... ... @@ -22,8 +22,8 @@
view.layer.borderWidth = 2;
[self addSubview:view];
[view mas_buildConstraints:^(MASConstraintBuilder *constrain) {
constrain.edges.equal(lastView).insets(UIEdgeInsetsMake(5, 10, 15, 20));
[view mas_buildConstraints:^(MASConstraintBuilder *make) {
make.edges.equalTo(lastView).insets(UIEdgeInsetsMake(5, 10, 15, 20));
}];
lastView = view;
... ...
... ... @@ -45,17 +45,17 @@ beforeEach(^{
describe(@"equality chaining", ^{
it(@"should return same constraint when encountering equal for first time", ^{
MASViewConstraint *newConstraint = constraint.equal(secondViewAttribute);
MASViewConstraint *newConstraint = constraint.equalTo(secondViewAttribute);
[verify(delegate) addConstraint:(id)constraint];
expect(newConstraint).to.beIdenticalTo(constraint);
expect(constraint.secondViewAttribute).to.beIdenticalTo(secondViewAttribute);
expect(constraint.layoutRelation).to.ex_equal(NSLayoutRelationEqual);
expect(constraint.layoutRelation).to.equal(NSLayoutRelationEqual);
});
it(@"should start new constraint when encountering equal subsequently", ^{
constraint.greaterThanOrEqual(secondViewAttribute);
MASViewConstraint *newConstraint = constraint.equal(secondViewAttribute);
constraint.greaterThanOrEqualTo(secondViewAttribute);
MASViewConstraint *newConstraint = constraint.equalTo(secondViewAttribute);
[verify(delegate) addConstraint:(id)constraint];
[verify(delegate) addConstraint:(id)newConstraint];
... ... @@ -63,17 +63,17 @@ describe(@"equality chaining", ^{
});
it(@"should return same constraint when encountering greaterThanOrEqual for first time", ^{
MASViewConstraint *newConstraint = constraint.greaterThanOrEqual(secondViewAttribute);
MASViewConstraint *newConstraint = constraint.greaterThanOrEqualTo(secondViewAttribute);
[verify(delegate) addConstraint:(id)constraint];
expect(newConstraint).to.beIdenticalTo(constraint);
expect(constraint.secondViewAttribute).to.beIdenticalTo(secondViewAttribute);
expect(constraint.layoutRelation).to.ex_equal(NSLayoutRelationGreaterThanOrEqual);
expect(constraint.layoutRelation).to.equal(NSLayoutRelationGreaterThanOrEqual);
});
it(@"should start new constraint when encountering greaterThanOrEqual subsequently", ^{
constraint.lessThanOrEqual(secondViewAttribute);
MASViewConstraint *newConstraint = constraint.greaterThanOrEqual(secondViewAttribute);
constraint.lessThanOrEqualTo(secondViewAttribute);
MASViewConstraint *newConstraint = constraint.greaterThanOrEqualTo(secondViewAttribute);
[verify(delegate) addConstraint:(id)constraint];
[verify(delegate) addConstraint:(id)newConstraint];
... ... @@ -81,17 +81,17 @@ describe(@"equality chaining", ^{
});
it(@"should return same constraint when encountering lessThanOrEqual for first time", ^{
MASViewConstraint *newConstraint = constraint.lessThanOrEqual(secondViewAttribute);
MASViewConstraint *newConstraint = constraint.lessThanOrEqualTo(secondViewAttribute);
[verify(delegate) addConstraint:(id)constraint];
expect(newConstraint).to.beIdenticalTo(constraint);
expect(constraint.secondViewAttribute).to.beIdenticalTo(secondViewAttribute);
expect(constraint.layoutRelation).to.ex_equal(NSLayoutRelationLessThanOrEqual);
expect(constraint.layoutRelation).to.equal(NSLayoutRelationLessThanOrEqual);
});
it(@"should start new constraint when encountering lessThanOrEqual subsequently", ^{
constraint.equal(secondViewAttribute);
MASViewConstraint *newConstraint = constraint.lessThanOrEqual(secondViewAttribute);
constraint.equalTo(secondViewAttribute);
MASViewConstraint *newConstraint = constraint.lessThanOrEqualTo(secondViewAttribute);
[verify(delegate) addConstraint:(id)constraint];
[verify(delegate) addConstraint:(id)newConstraint];
... ... @@ -102,7 +102,7 @@ describe(@"equality chaining", ^{
[constraint commit];
expect(^{
constraint.equal(secondViewAttribute);
constraint.equalTo(secondViewAttribute);
}).to.raise(@"NSInternalInconsistencyException");
});
... ... @@ -110,7 +110,7 @@ describe(@"equality chaining", ^{
[constraint commit];
expect(^{
constraint.lessThanOrEqual(secondViewAttribute);
constraint.lessThanOrEqualTo(secondViewAttribute);
}).to.raise(@"NSInternalInconsistencyException");
});
... ... @@ -118,7 +118,7 @@ describe(@"equality chaining", ^{
[constraint commit];
expect(^{
constraint.greaterThanOrEqual(secondViewAttribute);
constraint.greaterThanOrEqualTo(secondViewAttribute);
}).to.raise(@"NSInternalInconsistencyException");
});
... ... @@ -141,8 +141,8 @@ describe(@"multiplier & constant", ^{
[constraint commit];
constraint.offset(10);
expect(constraint.layoutConstant).to.ex_equal(10);
expect(constraint.layoutConstraint.constant).to.ex_equal(10);
expect(constraint.layoutConstant).to.equal(10);
expect(constraint.layoutConstraint.constant).to.equal(10);
});
xit(@"should update sides only", ^{});
... ... @@ -155,20 +155,20 @@ describe(@"multiplier & constant", ^{
describe(@"commit", ^{
it(@"should create layout constraint", ^{
constraint.equal(secondViewAttribute);
constraint.equalTo(secondViewAttribute);
constraint.percent(0.5);
constraint.offset(10);
constraint.priority(345);
[constraint commit];
expect(constraint.layoutConstraint.firstAttribute).to.ex_equal(NSLayoutAttributeWidth);
expect(constraint.layoutConstraint.secondAttribute).to.ex_equal(NSLayoutAttributeHeight);
expect(constraint.layoutConstraint.firstAttribute).to.equal(NSLayoutAttributeWidth);
expect(constraint.layoutConstraint.secondAttribute).to.equal(NSLayoutAttributeHeight);
expect(constraint.layoutConstraint.firstItem).to.beIdenticalTo(constraint.firstViewAttribute.view);
expect(constraint.layoutConstraint.secondItem).to.beIdenticalTo(constraint.secondViewAttribute.view);
expect(constraint.layoutConstraint.relation).to.ex_equal(NSLayoutRelationEqual);
expect(constraint.layoutConstraint.constant).to.ex_equal(10);
expect(constraint.layoutConstraint.priority).to.ex_equal(345);
expect(constraint.layoutConstraint.multiplier).to.ex_equal(0.5);
expect(constraint.layoutConstraint.relation).to.equal(NSLayoutRelationEqual);
expect(constraint.layoutConstraint.constant).to.equal(10);
expect(constraint.layoutConstraint.priority).to.equal(345);
expect(constraint.layoutConstraint.multiplier).to.equal(0.5);
[verify(superview) addConstraint:constraint.layoutConstraint];
});
... ...
... ... @@ -9,11 +9,6 @@
#define EXP_SHORTHAND
#import "Expecta.h"
#undef equal
#define ex_equal(expected) _equal(EXPObjectify((expected)))
#define HC_SHORTHAND
#import <OCHamcrest/OCHamcrest.h>
#define MOCKITO_SHORTHAND
#import <OCMockito/OCMockito.h>
... ...