[ios] Format all Obj C code via clang-format

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin
2025-08-17 16:37:15 +07:00
parent 52e9ddc038
commit aea784ddd7
109 changed files with 5113 additions and 4270 deletions

View File

@@ -1,11 +1,12 @@
#import "MWMSideButtonsView.h"
#import "MWMButton.h"
#import "MWMRouter.h"
#import "MWMMapViewControlsCommon.h"
#import "MWMRouter.h"
#include "base/math.hpp"
namespace {
namespace
{
CGFloat const kLocationButtonSpacingMax = 52;
CGFloat const kLocationButtonSpacingMin = 8;
CGFloat const kButtonsTopOffset = 6;
@@ -14,9 +15,9 @@ CGFloat const kButtonsBottomOffset = 6;
@interface MWMSideButtonsView ()
@property(weak, nonatomic) IBOutlet MWMButton *zoomIn;
@property(weak, nonatomic) IBOutlet MWMButton *zoomOut;
@property(weak, nonatomic) IBOutlet MWMButton *location;
@property(weak, nonatomic) IBOutlet MWMButton * zoomIn;
@property(weak, nonatomic) IBOutlet MWMButton * zoomOut;
@property(weak, nonatomic) IBOutlet MWMButton * location;
@property(nonatomic) CGRect availableArea;
@@ -24,19 +25,25 @@ CGFloat const kButtonsBottomOffset = 6;
@implementation MWMSideButtonsView
- (void)awakeFromNib {
- (void)awakeFromNib
{
[super awakeFromNib];
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
- (void)layoutSubviews {
- (void)layoutSubviews
{
CGFloat spacing = self.availableHeight - self.zoomOut.maxY - self.location.height;
spacing = math::Clamp(spacing, kLocationButtonSpacingMin, kLocationButtonSpacingMax);
if (!IPAD && (UIDevice.currentDevice.orientation == UIDeviceOrientationLandscapeLeft || UIDevice.currentDevice.orientation == UIDeviceOrientationLandscapeRight) && [MWMRouter isRoutingActive]) {
if (!IPAD &&
(UIDevice.currentDevice.orientation == UIDeviceOrientationLandscapeLeft ||
UIDevice.currentDevice.orientation == UIDeviceOrientationLandscapeRight) &&
[MWMRouter isRoutingActive])
{
spacing = spacing - 36;
}
self.location.minY = self.zoomOut.maxY + spacing;
self.bounds = {{}, {self.zoomOut.width, self.location.maxY}};
if (self.zoomHidden)
@@ -47,14 +54,18 @@ CGFloat const kButtonsBottomOffset = 6;
[super layoutSubviews];
}
- (void)layoutXPosition:(BOOL)hidden {
if (UIApplication.sharedApplication.userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) {
- (void)layoutXPosition:(BOOL)hidden
{
if (UIApplication.sharedApplication.userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft)
{
if (hidden)
self.maxX = 0;
else
self.minX = self.availableArea.origin.x + kViewControlsOffsetToBounds;
} else {
const auto availableAreaMaxX = self.availableArea.origin.x + self.availableArea.size.width;
}
else
{
auto const availableAreaMaxX = self.availableArea.origin.x + self.availableArea.size.width;
if (hidden)
self.minX = self.superview.width;
else
@@ -62,80 +73,84 @@ CGFloat const kButtonsBottomOffset = 6;
}
}
- (void)layoutYPosition {
- (void)layoutYPosition
{
CGFloat const centerShift = (self.height - self.zoomIn.midY - self.zoomOut.midY) / 2;
[UIView animateWithDuration:kDefaultAnimationDuration
animations:^{
self.midY = centerShift + self.superview.height / 2;
if ([MWMRouter isRoutingActive]) {
self.midY = self.midY - 18;
}
if (self.maxY > self.bottomBound)
self.maxY = self.bottomBound;
}];
self.midY = centerShift + self.superview.height / 2;
if ([MWMRouter isRoutingActive])
self.midY = self.midY - 18;
if (self.maxY > self.bottomBound)
self.maxY = self.bottomBound;
}];
}
- (void)fadeZoomButtonsShow:(BOOL)show {
- (void)fadeZoomButtonsShow:(BOOL)show
{
CGFloat const alpha = show ? 1.0 : 0.0;
[UIView animateWithDuration:kDefaultAnimationDuration
animations:^{
self.zoomIn.alpha = alpha;
self.zoomOut.alpha = alpha;
}];
self.zoomIn.alpha = alpha;
self.zoomOut.alpha = alpha;
}];
}
- (void)fadeLocationButtonShow:(BOOL)show {
[UIView animateWithDuration:kDefaultAnimationDuration
animations:^{
self.location.alpha = show ? 1.0 : 0.0;
}];
- (void)fadeLocationButtonShow:(BOOL)show
{
[UIView animateWithDuration:kDefaultAnimationDuration animations:^{ self.location.alpha = show ? 1.0 : 0.0; }];
}
// Show/hide zoom and location buttons depending on available vertical space.
- (void)animate {
- (void)animate
{
[self layoutYPosition];
BOOL const isZoomHidden = self.zoomIn.alpha == 0.0;
BOOL const willZoomHide = (self.location.maxY > self.availableHeight);
if (willZoomHide != isZoomHidden)
[self fadeZoomButtonsShow: !willZoomHide];
[self fadeZoomButtonsShow:!willZoomHide];
BOOL const isLocationHidden = self.location.alpha == 0.0;
BOOL const willLocationHide = (self.location.height > self.availableHeight);
if (willLocationHide != isLocationHidden)
[self fadeLocationButtonShow: !willLocationHide];
[self fadeLocationButtonShow:!willLocationHide];
}
#pragma mark - Properties
- (void)setZoomHidden:(BOOL)zoomHidden {
- (void)setZoomHidden:(BOOL)zoomHidden
{
_zoomHidden = zoomHidden;
self.zoomIn.hidden = zoomHidden;
self.zoomOut.hidden = zoomHidden;
[self setNeedsLayout];
}
- (void)setHidden:(BOOL)hidden animated:(BOOL)animated {
if (animated) {
- (void)setHidden:(BOOL)hidden animated:(BOOL)animated
{
if (animated)
{
if (self.hidden == hidden)
return;
// Side buttons should be visible during any our show/hide anamation.
// Visibility should be detemined by alpha, not self.hidden.
self.hidden = NO;
[UIView animateWithDuration:kDefaultAnimationDuration
animations:^{
self.alpha = hidden ? 0.0 : 1.0;
[self layoutXPosition:hidden];
}
completion:^(BOOL finished) {
self.hidden = hidden;
}];
} else {
animations:^{
self.alpha = hidden ? 0.0 : 1.0;
[self layoutXPosition:hidden];
}
completion:^(BOOL finished) { self.hidden = hidden; }];
}
else
{
self.hidden = hidden;
}
}
- (void)updateAvailableArea:(CGRect)frame {
- (void)updateAvailableArea:(CGRect)frame
{
if (CGRectEqualToRect(self.availableArea, frame))
return;
// If during our show/hide animation position is changed it is corrupted.
@@ -155,14 +170,17 @@ CGFloat const kButtonsBottomOffset = 6;
[self setNeedsLayout];
}
- (CGFloat)availableHeight {
- (CGFloat)availableHeight
{
return self.availableArea.size.height - kButtonsTopOffset - kButtonsBottomOffset;
}
- (CGFloat)topBound {
- (CGFloat)topBound
{
return self.availableArea.origin.y + kButtonsTopOffset;
}
- (CGFloat)bottomBound {
- (CGFloat)bottomBound
{
auto const area = self.availableArea;
return area.origin.y + area.size.height - kButtonsBottomOffset;
}