diff options
author | Fabian Guerra Soto <fabian.guerra@mapbox.com> | 2018-04-16 20:48:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-16 20:48:04 -0400 |
commit | cec46070c65161832edd995defc965e2a3add0ed (patch) | |
tree | c23ded1de0618ae4838335800be7943804740bd0 /platform/ios/app/MBXViewController.m | |
parent | d06d77d482f03b9761007123a6bd88d873c27f8d (diff) | |
download | qtlocation-mapboxgl-cec46070c65161832edd995defc965e2a3add0ed.tar.gz |
[ios, macos] Add NSExpression convenience constructors and helper methods. (#11278)
* [ios, macos] Refactor convinience expression initializers.
# Conflicts:
# platform/darwin/src/NSExpression+MGLAdditions.h
# platform/darwin/src/NSExpression+MGLAdditions.mm
# platform/ios/app/MBXViewController.m
* [ios, macos] Add MGL_MATCH convenience method.
# Conflicts:
# platform/darwin/src/NSExpression+MGLAdditions.h
# platform/darwin/src/NSExpression+MGLAdditions.mm
# platform/darwin/test/MGLExpressionTests.mm
* [ios, macos] Add Swift friendly convenience methods name syntax..
# Conflicts:
# platform/darwin/src/NSExpression+MGLAdditions.h
* [ios, macos] Update runtime styling examples.
# Conflicts:
# platform/ios/app/MBXViewController.m
* [ios, macos] Add NSExpression variable expressions properties.
* [ios, macos] Clarify convenience initializer names.
* [ios, macos] Update Style Authors guides.
* [ios, macos] Fix cherry-pick merge.
* [ios, macos] Update convenience initializers documentation.
Diffstat (limited to 'platform/ios/app/MBXViewController.m')
-rw-r--r-- | platform/ios/app/MBXViewController.m | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 0a76f8c0c5..391af5ea05 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -967,18 +967,20 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { @10.0f: [UIColor redColor], @12.0f: [UIColor greenColor], @14.0f: [UIColor blueColor]}; - waterLayer.fillColor = [NSExpression expressionWithFormat: - @"mgl_interpolate:withCurveType:parameters:stops:($zoomLevel, 'linear', nil, %@)", - waterColorStops]; + NSExpression *fillColorExpression = [NSExpression mgl_expressionForInterpolatingExpression:NSExpression.zoomLevelVariableExpression + withCurveType:MGLExpressionInterpolationModeLinear + parameters:nil + stops:[NSExpression expressionForConstantValue:waterColorStops]]; + waterLayer.fillColor = fillColorExpression; NSDictionary *fillAntialiasedStops = @{@11: @YES, @12: @NO, @13: @YES, @14: @NO, @15: @YES}; - waterLayer.fillAntialiased = [NSExpression expressionWithFormat: - @"mgl_step:from:stops:($zoomLevel, false, %@)", - fillAntialiasedStops]; + waterLayer.fillAntialiased = [NSExpression mgl_expressionForSteppingExpression:NSExpression.zoomLevelVariableExpression + fromExpression:[NSExpression expressionForConstantValue:@NO] + stops:[NSExpression expressionForConstantValue:fillAntialiasedStops]]; } - (void)styleRoadLayer @@ -1467,10 +1469,16 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { // source, categorical function that sets any feature with a "fill" attribute value of true to red color and anything without to green MGLFillStyleLayer *fillStyleLayer = [[MGLFillStyleLayer alloc] initWithIdentifier:@"fill-layer" source:shapeSource]; - fillStyleLayer.fillColor = [NSExpression expressionWithFormat:@"TERNARY(fill == YES, %@, %@)", [UIColor greenColor], [UIColor redColor]]; + fillStyleLayer.fillColor = [NSExpression mgl_expressionForConditional:[NSPredicate predicateWithFormat:@"fill == YES"] + trueExpression:[NSExpression expressionForConstantValue:[UIColor greenColor]] + falseExpresssion:[NSExpression expressionForConstantValue:[UIColor redColor]]]; + + // source, identity function that sets any feature with an "opacity" attribute to use that value and anything without to 1.0 - fillStyleLayer.fillOpacity = [NSExpression expressionWithFormat:@"TERNARY(opacity != nil, opacity, 1.0)"]; + fillStyleLayer.fillOpacity = [NSExpression mgl_expressionForConditional:[NSPredicate predicateWithFormat:@"opacity != nil"] + trueExpression:[NSExpression expressionForKeyPath:@"opacity"] + falseExpresssion:[NSExpression expressionForConstantValue:@1.0]]; [self.mapView.style addLayer:fillStyleLayer]; } |