mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-29 09:13:46 +00:00
[ios] Format all Obj C code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -37,11 +37,15 @@ NSString * const kUDDidShowLongTapToShowSideButtonsToast = @"kUDDidShowLongTapTo
|
||||
|
||||
@implementation MWMSideButtons
|
||||
|
||||
- (UIView *)view {
|
||||
- (UIView *)view
|
||||
{
|
||||
return self.sideView;
|
||||
}
|
||||
|
||||
+ (MWMSideButtons *)buttons { return [MWMMapViewControlsManager manager].sideButtons; }
|
||||
+ (MWMSideButtons *)buttons
|
||||
{
|
||||
return [MWMMapViewControlsManager manager].sideButtons;
|
||||
}
|
||||
- (instancetype)initWithParentView:(UIView *)view
|
||||
{
|
||||
self = [super init];
|
||||
@@ -56,7 +60,10 @@ NSString * const kUDDidShowLongTapToShowSideButtonsToast = @"kUDDidShowLongTapTo
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (void)updateAvailableArea:(CGRect)frame { [[self buttons].sideView updateAvailableArea:frame]; }
|
||||
+ (void)updateAvailableArea:(CGRect)frame
|
||||
{
|
||||
[[self buttons].sideView updateAvailableArea:frame];
|
||||
}
|
||||
|
||||
- (void)zoomIn
|
||||
{
|
||||
@@ -82,22 +89,25 @@ NSString * const kUDDidShowLongTapToShowSideButtonsToast = @"kUDDidShowLongTapTo
|
||||
[locBtn.imageView stopRotation];
|
||||
switch (state)
|
||||
{
|
||||
case MWMMyPositionModePendingPosition:
|
||||
{
|
||||
[locBtn setStyleNameAndApply: @"ButtonPending"];
|
||||
[locBtn.imageView startRotation:1];
|
||||
break;
|
||||
}
|
||||
case MWMMyPositionModeNotFollow:
|
||||
case MWMMyPositionModeNotFollowNoPosition: [locBtn setStyleNameAndApply: @"ButtonGetPosition"]; break;
|
||||
case MWMMyPositionModeFollow: [locBtn setStyleNameAndApply: @"ButtonFollow"]; break;
|
||||
case MWMMyPositionModeFollowAndRotate: [locBtn setStyleNameAndApply: @"ButtonFollowAndRotate"]; break;
|
||||
case MWMMyPositionModePendingPosition:
|
||||
{
|
||||
[locBtn setStyleNameAndApply:@"ButtonPending"];
|
||||
[locBtn.imageView startRotation:1];
|
||||
break;
|
||||
}
|
||||
case MWMMyPositionModeNotFollow:
|
||||
case MWMMyPositionModeNotFollowNoPosition: [locBtn setStyleNameAndApply:@"ButtonGetPosition"]; break;
|
||||
case MWMMyPositionModeFollow: [locBtn setStyleNameAndApply:@"ButtonFollow"]; break;
|
||||
case MWMMyPositionModeFollowAndRotate: [locBtn setStyleNameAndApply:@"ButtonFollowAndRotate"]; break;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (IBAction)zoomTouchDown:(UIButton *)sender { self.zoomSwipeEnabled = YES; }
|
||||
- (IBAction)zoomTouchDown:(UIButton *)sender
|
||||
{
|
||||
self.zoomSwipeEnabled = YES;
|
||||
}
|
||||
- (IBAction)zoomTouchUpInside:(UIButton *)sender
|
||||
{
|
||||
self.zoomSwipeEnabled = NO;
|
||||
@@ -107,14 +117,16 @@ NSString * const kUDDidShowLongTapToShowSideButtonsToast = @"kUDDidShowLongTapTo
|
||||
[self zoomOut];
|
||||
}
|
||||
|
||||
- (IBAction)zoomTouchUpOutside:(UIButton *)sender { self.zoomSwipeEnabled = NO; }
|
||||
- (IBAction)zoomTouchUpOutside:(UIButton *)sender
|
||||
{
|
||||
self.zoomSwipeEnabled = NO;
|
||||
}
|
||||
- (IBAction)zoomSwipe:(UIPanGestureRecognizer *)sender
|
||||
{
|
||||
if (!self.zoomSwipeEnabled)
|
||||
return;
|
||||
UIView * const superview = self.sideView.superview;
|
||||
CGFloat const translation =
|
||||
-[sender translationInView:superview].y / superview.bounds.size.height;
|
||||
CGFloat const translation = -[sender translationInView:superview].y / superview.bounds.size.height;
|
||||
|
||||
CGFloat const scaleFactor = exp(translation);
|
||||
GetFramework().Scale(scaleFactor, false);
|
||||
@@ -128,7 +140,10 @@ NSString * const kUDDidShowLongTapToShowSideButtonsToast = @"kUDDidShowLongTapTo
|
||||
|
||||
#pragma mark - Properties
|
||||
|
||||
- (BOOL)zoomHidden { return self.sideView.zoomHidden; }
|
||||
- (BOOL)zoomHidden
|
||||
{
|
||||
return self.sideView.zoomHidden;
|
||||
}
|
||||
- (void)setZoomHidden:(BOOL)zoomHidden
|
||||
{
|
||||
if ([MWMRouter isRoutingActive])
|
||||
@@ -137,8 +152,11 @@ NSString * const kUDDidShowLongTapToShowSideButtonsToast = @"kUDDidShowLongTapTo
|
||||
self.sideView.zoomHidden = [MWMSettings zoomButtonsEnabled] ? zoomHidden : YES;
|
||||
}
|
||||
|
||||
- (BOOL)hidden { return self.sideView.hidden; }
|
||||
- (void)setHidden:(BOOL)hidden
|
||||
- (BOOL)hidden
|
||||
{
|
||||
return self.sideView.hidden;
|
||||
}
|
||||
- (void)setHidden:(BOOL)hidden
|
||||
{
|
||||
if (!self.hidden && hidden)
|
||||
[Toast showWithText:L(@"long_tap_toast")];
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -2,22 +2,20 @@
|
||||
#import "MWMZoomButtonsView.h"
|
||||
#import "Statistics.h"
|
||||
|
||||
|
||||
#include "Framework.h"
|
||||
#include "platform/settings.hpp"
|
||||
#include "indexer/scales.hpp"
|
||||
#include "platform/settings.hpp"
|
||||
|
||||
static NSString * const kMWMZoomButtonsViewNibName = @"MWMZoomButtonsView";
|
||||
|
||||
@interface MWMZoomButtons ()
|
||||
|
||||
@interface MWMZoomButtons()
|
||||
@property(nonatomic) IBOutlet MWMZoomButtonsView * zoomView;
|
||||
@property(weak, nonatomic) IBOutlet UIButton * zoomInButton;
|
||||
@property(weak, nonatomic) IBOutlet UIButton * zoomOutButton;
|
||||
|
||||
@property (nonatomic) IBOutlet MWMZoomButtonsView * zoomView;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * zoomInButton;
|
||||
@property (weak, nonatomic) IBOutlet UIButton * zoomOutButton;
|
||||
|
||||
@property (nonatomic) BOOL zoomSwipeEnabled;
|
||||
@property (nonatomic, readonly) BOOL isZoomEnabled;
|
||||
@property(nonatomic) BOOL zoomSwipeEnabled;
|
||||
@property(nonatomic, readonly) BOOL isZoomEnabled;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#import "Common.h"
|
||||
#import "MWMZoomButtonsView.h"
|
||||
#import "Common.h"
|
||||
#import "MWMMapViewControlsCommon.h"
|
||||
|
||||
static CGFloat const kZoomViewOffsetToTopBound = 12.0;
|
||||
@@ -7,9 +7,9 @@ static CGFloat const kZoomViewOffsetToBottomBound = 40.0;
|
||||
static CGFloat const kZoomViewOffsetToFrameBound = 294.0;
|
||||
static CGFloat const kZoomViewHideBoundPercent = 0.4;
|
||||
|
||||
@interface MWMZoomButtonsView()
|
||||
@interface MWMZoomButtonsView ()
|
||||
|
||||
@property (nonatomic) CGRect defaultBounds;
|
||||
@property(nonatomic) CGRect defaultBounds;
|
||||
|
||||
@end
|
||||
|
||||
@@ -39,7 +39,8 @@ static CGFloat const kZoomViewHideBoundPercent = 0.4;
|
||||
|
||||
- (void)layoutYPosition
|
||||
{
|
||||
CGFloat const maxY = MIN(self.superview.height - kZoomViewOffsetToFrameBound, self.bottomBound - kZoomViewOffsetToBottomBound);
|
||||
CGFloat const maxY =
|
||||
MIN(self.superview.height - kZoomViewOffsetToFrameBound, self.bottomBound - kZoomViewOffsetToBottomBound);
|
||||
self.minY = MAX(maxY - self.height, self.topBound + kZoomViewOffsetToTopBound);
|
||||
}
|
||||
|
||||
@@ -59,7 +60,8 @@ static CGFloat const kZoomViewHideBoundPercent = 0.4;
|
||||
{
|
||||
CGFloat const hideBound = kZoomViewHideBoundPercent * self.superview.height;
|
||||
BOOL const isHidden = self.alpha == 0.0;
|
||||
BOOL const willHide = (self.bottomBound < hideBound) || (self.defaultBounds.size.height > self.bottomBound - self.topBound);
|
||||
BOOL const willHide =
|
||||
(self.bottomBound < hideBound) || (self.defaultBounds.size.height > self.bottomBound - self.topBound);
|
||||
if (willHide)
|
||||
{
|
||||
if (!isHidden)
|
||||
@@ -84,15 +86,12 @@ static CGFloat const kZoomViewHideBoundPercent = 0.4;
|
||||
if (!hidden)
|
||||
self.hidden = NO;
|
||||
[self layoutXPosition:!hidden];
|
||||
[UIView animateWithDuration:framesDuration(kMenuViewHideFramesCount) animations:^
|
||||
{
|
||||
[self layoutXPosition:hidden];
|
||||
}
|
||||
completion:^(BOOL finished)
|
||||
{
|
||||
if (hidden)
|
||||
self.hidden = YES;
|
||||
}];
|
||||
[UIView animateWithDuration:framesDuration(kMenuViewHideFramesCount)
|
||||
animations:^{ [self layoutXPosition:hidden]; }
|
||||
completion:^(BOOL finished) {
|
||||
if (hidden)
|
||||
self.hidden = YES;
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user