-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[iOS] Enable developers to change position of ornaments #13911
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@captainbarbosa and I have gone over this PR - apart from the following performance concern this looks good.
Please look at removing the call to [self installScaleBarConstraints]
in -updateScaleBar
- this will probably cause a cascade of changes though - sorry!
if (@available(iOS 11.0, *)) { | ||
return self.safeAreaLayoutGuide.leadingAnchor; | ||
} else { | ||
return self.leadingAnchor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesn't this and mgl_safeTrailingAnchor
also need to check automaticallyAdjustsScrollViewInsets
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I was right the automaticallyAdjustsScrollViewInsets
just affect the top anchor and the bottom anchor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That I do not know. Can we double check?
60d9264
to
3c8dbac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far this looks good, just minor adjustments.
I tested on iOS 9/11/12, my tests consisted on:
- Zoom in/out.
- Modify ornament's offset.
- Rotating the map.
- Time profiling.
if (@available(iOS 11.0, *)) { | ||
return self.safeAreaLayoutGuide.leadingAnchor; | ||
} else { | ||
return self.leadingAnchor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That I do not know. Can we double check?
return viewController.topLayoutGuide.bottomAnchor; | ||
} | ||
else { | ||
return self.topAnchor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC these anchors were introduced in iOS 9. What are your plans for iOS 8?
platform/ios/src/MGLMapView.mm
Outdated
constant:8.0 + self.contentInset.right]]; | ||
[containerView addConstraints:self.attributionButtonConstraints]; | ||
- (void)setScaleBarOffset:(CGPoint)scaleBarOffset { | ||
NSAssert(CGRectContainsPoint(self.bounds, scaleBarOffset), @"The position offset of the scale bar should within the mapview boundaries"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These asserts don't make sense since the offset is a delta, not a position.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, we should remove these asserts from this PR and address in a subsequent PR
platform/ios/src/MGLScaleBar.mm
Outdated
@@ -185,7 +185,7 @@ - (void)commonInit { | |||
#pragma mark - Dimensions | |||
|
|||
- (CGSize)intrinsicContentSize { | |||
return CGSizeMake(self.actualWidth + self.lastLabelWidth/2, 16); | |||
return CGSizeMake(ceil(self.actualWidth + self.lastLabelWidth/2), 16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MGLPointRounded
may be a better choice here than ceil
, since it’s meant to account for pixel scale.
0271a27
to
fda7d18
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
The PR was just a copy for #13556. I use the same branch
lloyd-ui-position
and fixed #13873.Test on multiple size devices and systems
/cc @chriswu42 @chloekraw