Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-25775] iOS: Fix gradient getters #9819

Merged
merged 10 commits into from
May 18, 2018
18 changes: 18 additions & 0 deletions iphone/Classes/TiGradient.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ - (id)type
- (void)setType:(id)newType
{
ENSURE_TYPE(newType, NSString);

[self clearCache];
[self replaceValue:newType forKey:@"type" notification:NO];

if ([newType compare:@"linear" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
type = TiGradientTypeLinear;
return;
Expand All @@ -120,6 +123,7 @@ - (void)setStartPoint:(id)newStart
} else {
[startPoint setValues:newStart];
}
[self replaceValue:newStart forKey:@"startPoint" notification:NO];
}

- (void)setEndPoint:(id)newEnd
Expand All @@ -129,16 +133,29 @@ - (void)setEndPoint:(id)newEnd
} else {
[endPoint setValues:newEnd];
}
[self replaceValue:newEnd forKey:@"endPoint" notification:NO];
}

- (void)setStartRadius:(id)newRadius
{
startRadius = [TiUtils dimensionValue:newRadius];
[self replaceValue:newRadius forKey:@"startRadius" notification:NO];
}

- (void)setEndRadius:(id)newRadius
{
endRadius = [TiUtils dimensionValue:newRadius];
[self replaceValue:newRadius forKey:@"endRadius" notification:NO];
}

- (id)endRadius
{
return [self valueForUndefinedKey:@"endRadius"];
}

- (id)startRadius
{
return [self valueForUndefinedKey:@"startRadius"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't document percentage based radius settings, but this will return it as a number between 0-100, right? I think it should return the original percentage string.

If we don't officially support percentage based radius, then I'm okay for making this a task for later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment above. But you are right, I need to change the return type to id.

}

- (void)setColors:(NSArray *)newColors;
Expand Down Expand Up @@ -190,6 +207,7 @@ - (void)setColors:(NSArray *)newColors;
currentIndex++;
}
[self clearCache];
[self replaceValue:newColors forKey:@"colors" notification:NO];
}

#define PYTHAG(bounds) sqrt(bounds.width *bounds.width + bounds.height * bounds.height) / 2
Expand Down
4 changes: 3 additions & 1 deletion iphone/Classes/TiUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,9 @@ + (id)valueFromDimension:(TiDimension)dimension
case TiDimensionTypeAuto:
return @"auto";
case TiDimensionTypeDip:
return [NSNumber numberWithFloat:dimension.value];
return @(dimension.value);
case TiDimensionTypePercent:
return [NSString stringWithFormat:@"%li%%", (NSInteger)(dimension.value * 100)];
default: {
break;
}
Expand Down