diff --git a/iphone/Maps/Categories/Bundle+Init.swift b/iphone/Maps/Categories/Bundle+Init.swift index e0462b21c7..c9dd90bb4c 100644 --- a/iphone/Maps/Categories/Bundle+Init.swift +++ b/iphone/Maps/Categories/Bundle+Init.swift @@ -1,4 +1,8 @@ extension Bundle { + func load(viewClass: T.Type, owner: Any? = nil, options: [AnyHashable: Any]? = nil) -> T? { + return loadNibNamed(String(describing: viewClass), owner: owner, options: options as? [UINib.OptionsKey : Any])?.first as? T + } + @objc func load(viewClass: AnyClass, owner: Any? = nil, options: [AnyHashable: Any]? = nil) -> [Any]? { return loadNibNamed(toString(viewClass), owner: owner, options: options as? [UINib.OptionsKey : Any]) } diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm index d8ab34bde4..afc6bd5287 100644 --- a/iphone/Maps/Classes/EAGLView.mm +++ b/iphone/Maps/Classes/EAGLView.mm @@ -1,7 +1,7 @@ #import "EAGLView.h" #import "iosOGLContextFactory.h" -#import "MWMDirectionView.h" #import "MWMMapWidgets.h" +#import "SwiftBridge.h" #import "3party/Alohalytics/src/alohalytics_objc.h" @@ -184,19 +184,6 @@ double getExactDPI(double contentScaleFactor) LOG(LINFO, ("CreateDrapeEngine Finished")); } -- (void)addSubview:(UIView *)view -{ - [super addSubview:view]; - for (UIView * v in self.subviews) - { - if ([v isKindOfClass:[MWMDirectionView class]]) - { - [self bringSubviewToFront:v]; - break; - } - } -} - - (CGSize)pixelSize { CGSize const s = self.bounds.size; diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 6170e8de75..30db2fc4a5 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -627,6 +627,8 @@ 995739082355CB660019AEE7 /* AllPassSubscriptionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 995739072355CB660019AEE7 /* AllPassSubscriptionViewController.swift */; }; 995F1613244F0AA50060631D /* BottomMenuLayersCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 995F1611244F0AA40060631D /* BottomMenuLayersCell.swift */; }; 995F1614244F0AA50060631D /* BottomMenuLayersCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 995F1612244F0AA40060631D /* BottomMenuLayersCell.xib */; }; + 9959C75624582DA2008FD4FD /* DirectionView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9959C75524582DA2008FD4FD /* DirectionView.xib */; }; + 9959C75C24599CCD008FD4FD /* DirectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9959C75B24599CCC008FD4FD /* DirectionView.swift */; }; 9977E6A12480E1EE0073780C /* BottomMenuLayerButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9977E6A02480E1EE0073780C /* BottomMenuLayerButton.swift */; }; 9977E69C247BFB510073780C /* MWMSearchTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9977E69B247BFB510073780C /* MWMSearchTextField.swift */; }; 9977E6A32480F9BF0073780C /* BottomMenuLayerButtonRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9977E6A22480F9BF0073780C /* BottomMenuLayerButtonRenderer.swift */; }; @@ -847,8 +849,6 @@ F6E2FE2B1E097BA00083EBEC /* MWMStreetEditorEditTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F6E2FC841E097B9F0083EBEC /* MWMStreetEditorEditTableViewCell.m */; }; F6E2FE2E1E097BA00083EBEC /* MWMStreetEditorEditTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F6E2FC851E097B9F0083EBEC /* MWMStreetEditorEditTableViewCell.xib */; }; F6E2FE311E097BA00083EBEC /* MWMStreetEditorViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6E2FC871E097B9F0083EBEC /* MWMStreetEditorViewController.mm */; }; - F6E2FE431E097BA00083EBEC /* MWMDirectionView.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6E2FC951E097B9F0083EBEC /* MWMDirectionView.mm */; }; - F6E2FE461E097BA00083EBEC /* MWMDirectionView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F6E2FC961E097B9F0083EBEC /* MWMDirectionView.xib */; }; F6E2FE4C1E097BA00083EBEC /* MWMPlacePageManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = F6E2FC9A1E097B9F0083EBEC /* MWMPlacePageManager.mm */; }; F6E2FE4F1E097BA00083EBEC /* MWMActionBarButton.m in Sources */ = {isa = PBXBuildFile; fileRef = F6E2FC9F1E097B9F0083EBEC /* MWMActionBarButton.m */; }; F6E2FE521E097BA00083EBEC /* MWMActionBarButton.xib in Resources */ = {isa = PBXBuildFile; fileRef = F6E2FCA01E097B9F0083EBEC /* MWMActionBarButton.xib */; }; @@ -1716,6 +1716,8 @@ 9957FAE0237AE04900855F48 /* MWMMapViewControlsManager+AddPlace.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MWMMapViewControlsManager+AddPlace.h"; sourceTree = ""; }; 995F1610244F07F90060631D /* MWMBottomMenuState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMBottomMenuState.h; sourceTree = ""; }; 995F1611244F0AA40060631D /* BottomMenuLayersCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomMenuLayersCell.swift; sourceTree = ""; }; + 9959C75524582DA2008FD4FD /* DirectionView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = DirectionView.xib; sourceTree = ""; }; + 9959C75B24599CCC008FD4FD /* DirectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DirectionView.swift; sourceTree = ""; }; 995F1612244F0AA40060631D /* BottomMenuLayersCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = BottomMenuLayersCell.xib; sourceTree = ""; }; 9977E6A02480E1EE0073780C /* BottomMenuLayerButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BottomMenuLayerButton.swift; sourceTree = ""; }; 9977E69B247BFB510073780C /* MWMSearchTextField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MWMSearchTextField.swift; sourceTree = ""; }; @@ -2075,9 +2077,6 @@ F6E2FC851E097B9F0083EBEC /* MWMStreetEditorEditTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMStreetEditorEditTableViewCell.xib; sourceTree = ""; }; F6E2FC861E097B9F0083EBEC /* MWMStreetEditorViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMStreetEditorViewController.h; sourceTree = ""; }; F6E2FC871E097B9F0083EBEC /* MWMStreetEditorViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMStreetEditorViewController.mm; sourceTree = ""; }; - F6E2FC941E097B9F0083EBEC /* MWMDirectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMDirectionView.h; sourceTree = ""; }; - F6E2FC951E097B9F0083EBEC /* MWMDirectionView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = MWMDirectionView.mm; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; - F6E2FC961E097B9F0083EBEC /* MWMDirectionView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMDirectionView.xib; sourceTree = ""; }; F6E2FC991E097B9F0083EBEC /* MWMPlacePageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMPlacePageManager.h; sourceTree = ""; }; F6E2FC9A1E097B9F0083EBEC /* MWMPlacePageManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMPlacePageManager.mm; sourceTree = ""; }; F6E2FC9B1E097B9F0083EBEC /* MWMPlacePageProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMPlacePageProtocol.h; sourceTree = ""; }; @@ -4625,9 +4624,8 @@ F6E2FC931E097B9F0083EBEC /* DirectionView */ = { isa = PBXGroup; children = ( - F6E2FC941E097B9F0083EBEC /* MWMDirectionView.h */, - F6E2FC951E097B9F0083EBEC /* MWMDirectionView.mm */, - F6E2FC961E097B9F0083EBEC /* MWMDirectionView.xib */, + 9959C75B24599CCC008FD4FD /* DirectionView.swift */, + 9959C75524582DA2008FD4FD /* DirectionView.xib */, ); path = DirectionView; sourceTree = ""; @@ -5104,10 +5102,10 @@ 349D1AD51E2E325B004A2006 /* BottomMenuItemCell.xib in Resources */, 349D1AE11E2E325C004A2006 /* BottomTabBarViewController.xib in Resources */, 34D3B01E1E389D05004100F9 /* MWMButtonCell.xib in Resources */, + 9959C75624582DA2008FD4FD /* DirectionView.xib in Resources */, 6741A98B1BF340DE002C974C /* MWMCircularProgress.xib in Resources */, CD96C71122A6820800DB7CFE /* DiscoveryGuideCollectionHolderCell.xib in Resources */, 6741A94F1BF340DE002C974C /* MWMDefaultAlert.xib in Resources */, - F6E2FE461E097BA00083EBEC /* MWMDirectionView.xib in Resources */, 6741A9951BF340DE002C974C /* MWMDownloaderDialogCell.xib in Resources */, 6741A9511BF340DE002C974C /* MWMDownloaderDialogHeader.xib in Resources */, 6741A96C1BF340DE002C974C /* MWMDownloadTransitMapAlert.xib in Resources */, @@ -5601,7 +5599,6 @@ 34E776141F14B17F003040B3 /* AvailableArea.swift in Sources */, 34AB66081FC5AA320078E451 /* MWMNavigationDashboardManager.mm in Sources */, 991CE2BF2371D349009EB02A /* PromoCampaignManager.swift in Sources */, - F6E2FE431E097BA00083EBEC /* MWMDirectionView.mm in Sources */, 470F5A5B2181DE7500754295 /* PaidRouteViewController.swift in Sources */, 3486B50D1E27A6DA0069C126 /* MWMPushNotifications.mm in Sources */, 3404F490202898CC0090E401 /* BMCModels.swift in Sources */, @@ -5621,6 +5618,7 @@ 993DF11723F6BDB100AC231A /* UINavigationBarRenderer.swift in Sources */, 6741A9E71BF340DE002C974C /* MWMCircularProgressView.m in Sources */, 34AC8FDB1EFC07FE00E7F910 /* UILabel+NumberOfVisibleLines.swift in Sources */, + 9959C75C24599CCD008FD4FD /* DirectionView.swift in Sources */, 99B6A77F23684573002C94CB /* PromoDiscoveryBuilder.swift in Sources */, 4767CD9F20AAD48A00BD8166 /* Checkmark.swift in Sources */, F6E2FD981E097BA00083EBEC /* MWMBookmarkTitleCell.m in Sources */, diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePagePreviewViewController.swift b/iphone/Maps/UI/PlacePage/Components/PlacePagePreviewViewController.swift index 6c7a647186..ec2ebd1dec 100644 --- a/iphone/Maps/UI/PlacePage/Components/PlacePagePreviewViewController.swift +++ b/iphone/Maps/UI/PlacePage/Components/PlacePagePreviewViewController.swift @@ -1,4 +1,4 @@ -class DirectionView: UIView { +class PlacePageDirectionView: UIView { @IBOutlet var imageView: UIImageView! @IBOutlet var label: UILabel! } @@ -32,10 +32,13 @@ class PlacePagePreviewViewController: UIViewController { @IBOutlet var scheduleContainerView: UIStackView! @IBOutlet var searchSimilarContainerView: UIStackView! - @IBOutlet var subtitleDirectionView: DirectionView! - @IBOutlet var addressDirectionView: DirectionView! + @IBOutlet var subtitleDirectionView: PlacePageDirectionView! + @IBOutlet var addressDirectionView: PlacePageDirectionView! - var directionView: DirectionView? + var placePageDirectionView: PlacePageDirectionView? + lazy var fullScreenDirectionView: DirectionView = { + return Bundle.main.load(viewClass: DirectionView.self)! + }() lazy var adView: AdBannerView = { let view = Bundle.main.load(viewClass: AdBannerView.self)?.first as! AdBannerView view.isHidden = true @@ -72,11 +75,11 @@ class PlacePagePreviewViewController: UIViewController { subtitleLabel.attributedText = subtitleString } - directionView = subtitleDirectionView + placePageDirectionView = subtitleDirectionView if let address = placePagePreviewData.address { addressLabel.text = address - directionView = addressDirectionView + placePageDirectionView = addressDirectionView } else { addressContainerView.isHidden = true } @@ -92,14 +95,14 @@ class PlacePagePreviewViewController: UIViewController { ugcContainerView.isHidden = !placePagePreviewData.isBookingPlace if let distance = distance { - directionView?.isHidden = false - directionView?.label.text = distance + placePageDirectionView?.isHidden = false + placePageDirectionView?.label.text = distance } if let heading = heading { updateHeading(heading) } else { - directionView?.imageView.isHidden = true + placePageDirectionView?.imageView.isHidden = true } stackView.addArrangedSubview(adView) @@ -166,19 +169,21 @@ class PlacePagePreviewViewController: UIViewController { func updateDistance(_ distance: String) { self.distance = distance - directionView?.isHidden = false - directionView?.label.text = distance + placePageDirectionView?.isHidden = false + placePageDirectionView?.label.text = distance + fullScreenDirectionView.updateDistance(distance) } func updateHeading(_ angle: CGFloat) { heading = angle - directionView?.imageView.isHidden = false + placePageDirectionView?.imageView.isHidden = false UIView.animate(withDuration: kDefaultAnimationDuration, delay: 0, options: [.beginFromCurrentState, .curveEaseInOut], animations: { [unowned self] in - self.directionView?.imageView.transform = CGAffineTransform(rotationAngle: CGFloat.pi / 2 - angle) + self.placePageDirectionView?.imageView.transform = CGAffineTransform(rotationAngle: CGFloat.pi / 2 - angle) }) + fullScreenDirectionView.updateHeading(angle) } func updateSpeedAndAltitude(_ speedAndAltitude: String) { @@ -193,6 +198,18 @@ class PlacePagePreviewViewController: UIViewController { @IBAction func onSimilarHotels(_ sender: UIButton) { delegate?.previewDidPressSimilarHotels() } + + @IBAction func onDirectionPressed(_ sender: Any) { + guard let heading = heading else { + return + } + + fullScreenDirectionView.updateTitle(placePagePreviewData.title, + subtitle: placePagePreviewData.subtitle ?? placePagePreviewData.coordinates) + fullScreenDirectionView.updateHeading(heading) + fullScreenDirectionView.updateDistance(distance) + fullScreenDirectionView.show() + } // MARK: private private func configSchedule() { diff --git a/iphone/Maps/UI/PlacePage/DirectionView/DirectionView.swift b/iphone/Maps/UI/PlacePage/DirectionView/DirectionView.swift new file mode 100644 index 0000000000..16dbdf8c80 --- /dev/null +++ b/iphone/Maps/UI/PlacePage/DirectionView/DirectionView.swift @@ -0,0 +1,72 @@ +import UIKit + +class DirectionView: SolidTouchView { + @IBOutlet private var titleLabel: UILabel! + @IBOutlet private var typeLabel: UILabel! + @IBOutlet private var distanceLabel :UILabel! + @IBOutlet private var directionArrow: UIImageView! + @IBOutlet private var contentView: UIView! + + override func awakeFromNib() { + distanceLabel.font = alternative(iPhone: .regular32(), iPad: .regular52()) + typeLabel.font = alternative(iPhone: .regular16(), iPad: .regular24()) + } + + override func didMoveToSuperview() { + super.didMoveToSuperview() + let manager = MWMMapViewControlsManager.manager() + let app = MapsAppDelegate.theApp() + if superview != nil { + app.disableStandby() + manager?.isDirectionViewHidden = false + } else { + app.enableStandby() + manager?.isDirectionViewHidden = true + } + app.mapViewController.updateStatusBarStyle() + } + + override func layoutSubviews() { + var textAlignment = NSTextAlignment.center + if UIDevice.current.orientation == .landscapeLeft || UIDevice.current.orientation == .landscapeRight { + textAlignment = alternative(iPhone: .left, iPad: .center) + } + titleLabel.textAlignment = textAlignment + typeLabel.textAlignment = textAlignment + distanceLabel.textAlignment = textAlignment + + super.layoutSubviews() + } + + func show() { + guard let superview = MapViewController.shared()?.view else { + assertionFailure() + return + } + superview.addSubview(self) + self.alignToSuperview() + setNeedsLayout() + } + + func updateTitle(_ title: String?, subtitle: String?) { + self.titleLabel.text = title + self.typeLabel.text = subtitle + } + + func updateDistance(_ distance: String?) { + distanceLabel?.text = distance + } + + func updateHeading(_ angle: CGFloat) { + UIView.animate(withDuration: kDefaultAnimationDuration, + delay: 0, + options: [.beginFromCurrentState, .curveEaseInOut], + animations: { [unowned self] in + self.directionArrow?.transform = CGAffineTransform(rotationAngle: CGFloat.pi / 2 - angle) + }) + } + + @IBAction func onTap(_ sender: Any) { + removeFromSuperview() + } +} diff --git a/iphone/Maps/UI/PlacePage/DirectionView/DirectionView.xib b/iphone/Maps/UI/PlacePage/DirectionView/DirectionView.xib new file mode 100644 index 0000000000..ce1472e82c --- /dev/null +++ b/iphone/Maps/UI/PlacePage/DirectionView/DirectionView.xib @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/iphone/Maps/UI/PlacePage/DirectionView/MWMDirectionView.h b/iphone/Maps/UI/PlacePage/DirectionView/MWMDirectionView.h deleted file mode 100644 index 830862dcc6..0000000000 --- a/iphone/Maps/UI/PlacePage/DirectionView/MWMDirectionView.h +++ /dev/null @@ -1,20 +0,0 @@ -#import - -@class MWMPlacePageViewManager; - -@interface MWMDirectionView : UIView - -@property (weak, nonatomic) IBOutlet UILabel * titleLabel; -@property (weak, nonatomic) IBOutlet UILabel * typeLabel; -@property (weak, nonatomic) IBOutlet UILabel * distanceLabel; -@property (weak, nonatomic) IBOutlet UIImageView * directionArrow; -@property (weak, nonatomic) IBOutlet UIView * contentView; - -- (void)setDirectionArrowTransform:(CGAffineTransform)transform; - -- (void)show; - -- (instancetype)initWithCoder:(NSCoder *)aDecoder __attribute__((unavailable("initWithCoder is not available"))); -- (instancetype)initWithFrame:(CGRect)frame __attribute__((unavailable("initWithFrame is not available"))); - -@end diff --git a/iphone/Maps/UI/PlacePage/DirectionView/MWMDirectionView.mm b/iphone/Maps/UI/PlacePage/DirectionView/MWMDirectionView.mm deleted file mode 100644 index f01c9588b9..0000000000 --- a/iphone/Maps/UI/PlacePage/DirectionView/MWMDirectionView.mm +++ /dev/null @@ -1,157 +0,0 @@ -#import "MWMDirectionView.h" -#import "MWMMapViewControlsManager.h" -#import "MapViewController.h" -#import "MapsAppDelegate.h" - -static NSString * const kDirectionViewNibName = @"MWMDirectionView"; -static CGFloat const kDirectionArrowSide = IPAD ? 260. : 160.; - -@interface MWMDirectionView () - -@property (nonatomic) CGSize defaultSize; - -@end - -@implementation MWMDirectionView - -- (instancetype)init -{ - self = [NSBundle.mainBundle loadNibNamed:kDirectionViewNibName owner:nil options:nil].firstObject; - [self setup]; - return self; -} - -- (void)setup -{ - self.directionArrow.size = CGSizeMake(kDirectionArrowSide, kDirectionArrowSide); - self.directionArrow.image = [UIImage imageNamed:IPAD ? @"direction_big" : @"direction_mini"]; - - self.distanceLabel.font = IPAD ? [UIFont regular52] : [UIFont regular32]; - self.typeLabel.font = IPAD ? [UIFont regular24] : [UIFont regular16]; - - self.autoresizingMask = self.contentView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; - self.directionArrow.autoresizingMask = UIViewAutoresizingNone; -} - -- (void)show -{ - UIView * superview = [MapsAppDelegate theApp].mapViewController.controlsView; - [superview addSubview:self]; - [superview endEditing:YES]; - [self setNeedsLayout]; -} - -- (void)didMoveToSuperview -{ - [super didMoveToSuperview]; - - MapsAppDelegate * app = [MapsAppDelegate theApp]; - - MWMMapViewControlsManager * manager = [MWMMapViewControlsManager manager]; - - if (self.superview) - { - [app disableStandby]; - manager.isDirectionViewHidden = NO; - } - else - { - [app enableStandby]; - manager.isDirectionViewHidden = YES; - } - - [app.mapViewController updateStatusBarStyle]; -} - -- (void)layoutSubviews -{ - UIView * superview = self.superview; - self.frame = superview.bounds; - CGSize const size = self.superview.size; - self.size = size; - CGFloat const minimumBorderOffset = 40.; - BOOL const isLandscape = size.width > size.height; - if (isLandscape) - { - CGFloat const defaultWidth = size.width - 2. * minimumBorderOffset - kDirectionArrowSide; - [self resizeTitleWithWidth:defaultWidth]; - [self resizeTypeAndDistanceWithWidth:defaultWidth]; - CGFloat const titleOffset = 8.; - CGFloat const typeOffset = 24.; - CGFloat const arrowOffset = 24.; - CGFloat const contentViewHeight = size.height - 2. * minimumBorderOffset; - CGFloat const contentViewOffset = (size.width - self.titleLabel.width - minimumBorderOffset - self.directionArrow.width) / 2.; - CGFloat const contentViewWidth = self.titleLabel.width + minimumBorderOffset + self.directionArrow.width; - self.contentView.frame = CGRectMake(contentViewOffset, minimumBorderOffset, contentViewWidth, contentViewHeight); - self.directionArrow.center = CGPointMake(arrowOffset + kDirectionArrowSide / 2., self.contentView.height / 2.); - CGFloat const directionArrowOffsetX = self.directionArrow.maxX + minimumBorderOffset; - CGFloat const actualLabelsBlockHeight = self.titleLabel.height + titleOffset + self.typeLabel.height + typeOffset + self.distanceLabel.height; - CGFloat const labelsBlockTopOffset = (contentViewHeight - actualLabelsBlockHeight) / 2.; - self.titleLabel.origin = CGPointMake(directionArrowOffsetX, labelsBlockTopOffset); - self.titleLabel.textAlignment = NSTextAlignmentLeft; - self.typeLabel.origin = CGPointMake(directionArrowOffsetX, self.titleLabel.maxY + titleOffset); - self.typeLabel.textAlignment = NSTextAlignmentLeft; - self.distanceLabel.origin = CGPointMake(directionArrowOffsetX, self.typeLabel.maxY + typeOffset); - self.distanceLabel.textAlignment = NSTextAlignmentLeft; - } - else - { - CGFloat const defaultWidth = size.width - 2. * minimumBorderOffset; - [self resizeTitleWithWidth:defaultWidth]; - [self resizeTypeAndDistanceWithWidth:defaultWidth]; - CGFloat const titleOffset = IPAD ? 12. : 8.; - CGFloat const arrowOffset = IPAD ? 80. : 32.; - CGFloat const contentViewActualHeight = self.titleLabel.height + titleOffset + self.typeLabel.height + 2. * arrowOffset + kDirectionArrowSide + self.distanceLabel.height; - CGFloat const contentViewSize = size.height > contentViewActualHeight ? contentViewActualHeight : size.height; - CGFloat const yOffset = (size.height - contentViewSize) / 2.; - self.contentView.frame = CGRectMake(minimumBorderOffset, yOffset, defaultWidth, contentViewSize); - CGFloat const xOffset = self.contentView.width / 2.; - self.titleLabel.origin = CGPointMake(xOffset - self.titleLabel.width / 2., 0.); - self.titleLabel.textAlignment = NSTextAlignmentCenter; - self.typeLabel.origin = CGPointMake(xOffset - self.typeLabel.width / 2., self.titleLabel.maxY + titleOffset); - self.typeLabel.textAlignment = NSTextAlignmentCenter; - self.directionArrow.center = CGPointMake(xOffset, self.typeLabel.maxY + arrowOffset + kDirectionArrowSide / 2.); - self.distanceLabel.origin = CGPointMake(xOffset - self.distanceLabel.width / 2., self.directionArrow.maxY + arrowOffset); - self.distanceLabel.textAlignment = NSTextAlignmentCenter; - } -} - -- (void)resizeTitleWithWidth:(CGFloat)width -{ - CGFloat const fontSize = IPAD ? 52.0 : 32.0; - CGFloat const minFontSize = IPAD ? 24.0 : 16.0; - CGSize const superviewSize = self.superview.size; - BOOL const isLandscape = superviewSize.width > superviewSize.height; - CGFloat const minHeight = (isLandscape ? 0.6 : 0.3) * superviewSize.height; - UIFont * font = self.distanceLabel.font; - UILabel * label = self.titleLabel; - for (CGFloat size = fontSize; size >= minFontSize; size -= 1.0) - { - label.font = [font fontWithSize:size]; - label.width = width; - [label sizeToFit]; - if (label.height <= minHeight) - break; - } -} - -- (void)resizeTypeAndDistanceWithWidth:(CGFloat)width -{ - self.typeLabel.width = self.distanceLabel.width = width; - [self.typeLabel sizeToFit]; - [self.distanceLabel sizeToFit]; -} - -- (void)setDirectionArrowTransform:(CGAffineTransform)transform -{ - self.directionArrow.transform = transform; -} - -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event -{ - // Prevent super call to stop event propagation - // [super touchesBegan:touches withEvent:event]; - [self removeFromSuperview]; -} - -@end diff --git a/iphone/Maps/UI/PlacePage/DirectionView/MWMDirectionView.xib b/iphone/Maps/UI/PlacePage/DirectionView/MWMDirectionView.xib deleted file mode 100644 index f7a6feda66..0000000000 --- a/iphone/Maps/UI/PlacePage/DirectionView/MWMDirectionView.xib +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iphone/Maps/UI/PlacePage/PlacePage.storyboard b/iphone/Maps/UI/PlacePage/PlacePage.storyboard index 94d50161c6..165d1bb7c1 100644 --- a/iphone/Maps/UI/PlacePage/PlacePage.storyboard +++ b/iphone/Maps/UI/PlacePage/PlacePage.storyboard @@ -1,9 +1,9 @@ - + - + @@ -176,7 +176,7 @@ -