Improved Code Style
This commit is contained in:
@@ -16,31 +16,23 @@
|
||||
@implementation MPFunctionLayout
|
||||
|
||||
#pragma mark Creation Methods
|
||||
+ (MPFunctionLayout *)functionLayoutForFunctionAtIndexPath:(NSIndexPath *)path
|
||||
inRootExpression:(MPExpression *)rootExpression
|
||||
parent:(MPExpressionLayout *)parent
|
||||
+ (MPFunctionLayout *)functionLayoutForFunction:(MPFunction *)function
|
||||
parent:(MPExpressionLayout *)parent
|
||||
{
|
||||
MPFunction *function = [rootExpression elementAtIndexPath:path];
|
||||
Class class = [function class];
|
||||
if (class == [MPSumFunction class]) {
|
||||
return [[MPSumFunctionLayout alloc] initWithElementAtPath:path
|
||||
inRootExpression:rootExpression
|
||||
parent:parent];
|
||||
return [[MPSumFunctionLayout alloc] initWithFunction:function parent:parent];
|
||||
}
|
||||
return [[self alloc] initWithElementAtPath:path
|
||||
inRootExpression:rootExpression
|
||||
parent:parent];
|
||||
return [[self alloc] initWithFunction:function
|
||||
parent:parent];
|
||||
}
|
||||
|
||||
- (instancetype)initWithElementAtPath:(NSIndexPath *)path
|
||||
inRootExpression:(MPExpression *)rootExpression
|
||||
parent:(MPLayout *)parent
|
||||
- (instancetype)initWithFunction:(MPFunction *)function
|
||||
parent:(MPExpressionLayout *)parent
|
||||
{
|
||||
self = [super initWithElementAtPath:path
|
||||
inRootExpression:rootExpression
|
||||
parent:parent];
|
||||
self = [super initWithParent:parent];
|
||||
if (self) {
|
||||
_function = [rootExpression elementAtIndexPath:path];
|
||||
_function = function;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -62,10 +54,9 @@
|
||||
- (MPLayout *)childLayoutAtIndex:(NSUInteger)index
|
||||
{
|
||||
return [self cachableObjectForIndex:index generator:^id{
|
||||
NSIndexPath *childPath = [self.function.indexPath indexPathByAddingIndex:index];
|
||||
MPExpressionLayout *layout = [[MPExpressionLayout alloc] initWithElementAtPath:childPath
|
||||
inRootExpression:self.function.rootExpression
|
||||
parent:self];
|
||||
MPExpression *child = [self.function childAtIndex:index];
|
||||
MPExpressionLayout *layout = [[MPExpressionLayout alloc] initWithExpression:child
|
||||
parent:self];
|
||||
layout.flipped = self.flipped;
|
||||
layout.usesSmallSize = (index == 0 || index == 1) ? YES : self.usesSmallSize;
|
||||
return layout;
|
||||
|
||||
Reference in New Issue
Block a user