mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-23 14:43:43 +00:00
[ios] update side buttons animation
The old implementation was rigidly tightened to the place page top bound that breaks the side buttons (zoom, location) hiding/showing logic when the PP is big. Now the side buttons follow the PP top edge with animation and disappear animated when they out of bounds. Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
committed by
Konstantin Pastbin
parent
7117a1b954
commit
3525f36919
@@ -86,11 +86,13 @@ NSArray<UIImage *> *imagesWithName(NSString *name) {
|
||||
- (void)refreshLayout {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
auto const availableArea = self.availableArea;
|
||||
auto const leftOffset = self.hidden ? -self.view.width : availableArea.origin.x + kViewControlsOffsetToBounds;
|
||||
auto const fitInAvailableArea = CGRectGetMaxY(self.view.frame) < CGRectGetMaxY(availableArea) + kTopOffset;
|
||||
auto const shouldHide = self.hidden || !fitInAvailableArea;
|
||||
auto const leftOffset = shouldHide ? -self.view.width : availableArea.origin.x + kViewControlsOffsetToBounds;
|
||||
[self.view.superview animateConstraintsWithAnimations:^{
|
||||
self.topOffset.constant = availableArea.origin.y + kTopOffset;
|
||||
self.leftOffset.constant = leftOffset;
|
||||
self.view.alpha = self.hidden ? 0 : 1;
|
||||
self.view.alpha = shouldHide ? 0 : 1;
|
||||
}];
|
||||
});
|
||||
}
|
||||
@@ -195,8 +197,6 @@ NSArray<UIImage *> *imagesWithName(NSString *name) {
|
||||
if (CGRectEqualToRect(controller.availableArea, frame))
|
||||
return;
|
||||
controller.availableArea = frame;
|
||||
BOOL isHidden = frame.origin.y + frame.size.height < controller.view.origin.y + controller.view.height + kTopOffset;
|
||||
[MapViewController.sharedController.controlsManager setTrafficButtonHidden:isHidden];
|
||||
[controller refreshLayout];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user