diff --git a/iphone/Maps/Categories/Bundle+Init.swift b/iphone/Maps/Categories/Bundle+Init.swift index 5b8f0f141c..87a39e9ee0 100644 --- a/iphone/Maps/Categories/Bundle+Init.swift +++ b/iphone/Maps/Categories/Bundle+Init.swift @@ -1,5 +1,5 @@ extension Bundle { - func load(viewClass: AnyClass, owner: Any? = nil, options: [AnyHashable : Any]? = nil) -> [Any]? { + func load(viewClass: AnyClass, owner: Any? = nil, options: [AnyHashable: Any]? = nil) -> [Any]? { return loadNibNamed(toString(viewClass), owner: owner, options: options) } } diff --git a/iphone/Maps/Categories/UIColor+Modifications.swift b/iphone/Maps/Categories/UIColor+Modifications.swift index e81e848d9b..98658eb046 100644 --- a/iphone/Maps/Categories/UIColor+Modifications.swift +++ b/iphone/Maps/Categories/UIColor+Modifications.swift @@ -1,9 +1,9 @@ extension UIColor { - func lighter(percent: CGFloat) -> UIColor { + func lighter(percent: CGFloat) -> UIColor { return colorWithBrightnessFactor(factor: 1 + percent) } - func darker(percent: CGFloat) -> UIColor { + func darker(percent: CGFloat) -> UIColor { return colorWithBrightnessFactor(factor: 1 - percent) } @@ -16,7 +16,7 @@ extension UIColor { if getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: &alpha) { return UIColor(hue: hue, saturation: saturation, brightness: brightness * factor, alpha: alpha) } else { - return self; + return self } } } diff --git a/iphone/Maps/Categories/UIView+Coordinates.swift b/iphone/Maps/Categories/UIView+Coordinates.swift index 57a42cae7b..ec7f187afe 100644 --- a/iphone/Maps/Categories/UIView+Coordinates.swift +++ b/iphone/Maps/Categories/UIView+Coordinates.swift @@ -5,7 +5,7 @@ extension UIView { guard let sv = superview else { return .zero } var centerPoint = center - if let scrollView = sv as? UIScrollView , scrollView.zoomScale != 1.0 { + if let scrollView = sv as? UIScrollView, scrollView.zoomScale != 1.0 { centerPoint.x += (scrollView.bounds.width - scrollView.contentSize.width) / 2.0 + scrollView.contentOffset.x centerPoint.y += (scrollView.bounds.height - scrollView.contentSize.height) / 2.0 + scrollView.contentOffset.y } diff --git a/iphone/Maps/Categories/UIView+Hierarchy.swift b/iphone/Maps/Categories/UIView+Hierarchy.swift index c08cd4e498..ba36db3e7e 100644 --- a/iphone/Maps/Categories/UIView+Hierarchy.swift +++ b/iphone/Maps/Categories/UIView+Hierarchy.swift @@ -1,5 +1,5 @@ extension UIView { func hasSubview(viewClass: AnyClass) -> Bool { - return !subviews.filter{ type(of: $0) == viewClass }.isEmpty + return !subviews.filter { type(of: $0) == viewClass }.isEmpty } } diff --git a/iphone/Maps/Classes/Components/DimBackground.swift b/iphone/Maps/Classes/Components/DimBackground.swift index a6b98cc113..da96fcd84a 100644 --- a/iphone/Maps/Classes/Components/DimBackground.swift +++ b/iphone/Maps/Classes/Components/DimBackground.swift @@ -7,11 +7,11 @@ final class DimBackground: SolidTouchView { self.mainView = mainView super.init(frame: mainView.superview!.bounds) backgroundColor = UIColor.fadeBackground() - autoresizingMask = [.flexibleWidth, .flexibleHeight]; + autoresizingMask = [.flexibleWidth, .flexibleHeight] addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(onTap))) } - - required init?(coder aDecoder: NSCoder) { + + required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -30,9 +30,9 @@ final class DimBackground: SolidTouchView { UIView.animate(withDuration: kDefaultAnimationDuration, animations: { self.alpha = visible ? 0.8 : 0 }, completion: { _ in - if !visible { - self.removeFromSuperview() - } + if !visible { + self.removeFromSuperview() + } }) } diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/NavigationControlView.swift b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/NavigationControlView.swift index 0b93527153..ed3963efd5 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/NavigationControlView.swift +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/NavigationControlView.swift @@ -38,6 +38,7 @@ final class NavigationControlView: SolidTouchView, MWMTextToSpeechObserver, MWMT private lazy var dimBackground: DimBackground = { DimBackground(mainView: self) }() + weak var ownerView: UIView! private weak var navigationInfo: MWMNavigationDashboardEntity? @@ -58,9 +59,9 @@ final class NavigationControlView: SolidTouchView, MWMTextToSpeechObserver, MWMT UIView.animate(withDuration: kDefaultAnimationDuration, animations: { self.superview?.layoutIfNeeded() }, completion: { _ in - if (!self.isVisible) { - self.removeFromSuperview() - } + if !self.isVisible { + self.removeFromSuperview() + } }) } } @@ -136,10 +137,10 @@ final class NavigationControlView: SolidTouchView, MWMTextToSpeechObserver, MWMT navigationInfo = info guard !MWMRouter.isTaxi() else { return } - let routingNumberAttributes: [String : Any] = - [NSForegroundColorAttributeName : UIColor.blackPrimaryText(), NSFontAttributeName : UIFont.bold24()] - let routingLegendAttributes: [String : Any] = - [NSForegroundColorAttributeName : UIColor.blackSecondaryText(), NSFontAttributeName : UIFont.bold14()] + let routingNumberAttributes: [String: Any] = + [NSForegroundColorAttributeName: UIColor.blackPrimaryText(), NSFontAttributeName: UIFont.bold24()] + let routingLegendAttributes: [String: Any] = + [NSForegroundColorAttributeName: UIColor.blackSecondaryText(), NSFontAttributeName: UIFont.bold14()] if timePageControl.currentPage == 0 { timeLabel.text = info.eta diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerCell.swift b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerCell.swift index d39ac94716..35d3c3f14c 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerCell.swift +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerCell.swift @@ -6,24 +6,28 @@ final class RouteManagerCell: MWMTableViewCell { titleLabel.font = UIFont.regular16() } } + @IBOutlet weak var subtitleLabel: UILabel! { didSet { subtitleLabel.textColor = UIColor.blackSecondaryText() subtitleLabel.font = UIFont.regular14() } } + @IBOutlet private weak var dragImage: UIImageView! { didSet { dragImage.image = #imageLiteral(resourceName: "ic_route_manager_move") dragImage.tintColor = UIColor.blackHintText() } } + @IBOutlet private weak var separator1: UIView! { didSet { separator1.backgroundColor = UIColor.blackDividers() separator1.layer.cornerRadius = 2 } } + @IBOutlet weak var separator2: UIView! { didSet { separator2.backgroundColor = UIColor.blackDividers() @@ -60,25 +64,25 @@ final class RouteManagerCell: MWMTableViewCell { typeImage.tintColor = UIColor.linkBlue() } else { switch model.type { - case .start: - typeImage.image = #imageLiteral(resourceName: "ic_route_manager_start") - typeImage.tintColor = UIColor.linkBlue() - case .intermediate: - switch model.intermediateIndex { - case 0: - typeImage.image = #imageLiteral(resourceName: "ic_route_manager_stop_a") - typeImage.tintColor = UIColor.primary() - case 1: - typeImage.image = #imageLiteral(resourceName: "ic_route_manager_stop_b") - typeImage.tintColor = UIColor.primary() - case 2: - typeImage.image = #imageLiteral(resourceName: "ic_route_manager_stop_c") - typeImage.tintColor = UIColor.primary() - default: fatalError("Unsupported route point intermediateIndex.") + case .start: + typeImage.image = #imageLiteral(resourceName: "ic_route_manager_start") + typeImage.tintColor = UIColor.linkBlue() + case .intermediate: + switch model.intermediateIndex { + case 0: + typeImage.image = #imageLiteral(resourceName: "ic_route_manager_stop_a") + typeImage.tintColor = UIColor.primary() + case 1: + typeImage.image = #imageLiteral(resourceName: "ic_route_manager_stop_b") + typeImage.tintColor = UIColor.primary() + case 2: + typeImage.image = #imageLiteral(resourceName: "ic_route_manager_stop_c") + typeImage.tintColor = UIColor.primary() + default: fatalError("Unsupported route point intermediateIndex.") } - case .finish: - typeImage.image = #imageLiteral(resourceName: "ic_route_manager_finish") - typeImage.tintColor = UIColor.blackPrimaryText() + case .finish: + typeImage.image = #imageLiteral(resourceName: "ic_route_manager_finish") + typeImage.tintColor = UIColor.blackPrimaryText() } } } diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerDimView.swift b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerDimView.swift index ee772c95e9..d9591a9a1b 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerDimView.swift +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerDimView.swift @@ -7,6 +7,7 @@ final class RouteManagerDimView: UIView { label.textColor = UIColor.white() } } + @IBOutlet private weak var messageView: UIView! @IBOutlet private weak var messageViewContainer: UIView! @IBOutlet private var messageViewVerticalCenter: NSLayoutConstraint! @@ -48,15 +49,15 @@ final class RouteManagerDimView: UIView { label.alpha = isVisible ? 0 : componentsAlpha UIView.animate(withDuration: kDefaultAnimationDuration, animations: { - self.alpha = self.isVisible ? 1 : 0 - self.image.alpha = self.isVisible ? componentsAlpha : 0 - self.label.alpha = self.isVisible ? componentsAlpha : 0 - }, + self.alpha = self.isVisible ? 1 : 0 + self.image.alpha = self.isVisible ? componentsAlpha : 0 + self.label.alpha = self.isVisible ? componentsAlpha : 0 + }, completion: { _ in - self.alpha = 1 - if !self.isVisible { - self.backgroundColor = UIColor.clear - } + self.alpha = 1 + if !self.isVisible { + self.backgroundColor = UIColor.clear + } }) setNeedsLayout() } @@ -71,7 +72,7 @@ final class RouteManagerDimView: UIView { NSLayoutConstraint(item: self, attribute: .left, relatedBy: .equal, toItem: self.messageViewContainer, attribute: .left, multiplier: 1, constant: 0).isActive = true NSLayoutConstraint(item: manager, attribute: .top, relatedBy: .equal, toItem: self.messageViewContainer, attribute: .bottom, multiplier: 1, constant: 0).isActive = true }, - iPad: { + iPad: { container.insertSubview(self, at: 0) NSLayoutConstraint(item: self, attribute: .bottom, relatedBy: .equal, toItem: self.messageViewContainer, attribute: .bottom, multiplier: 1, constant: 0).isActive = true diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerTransitioning.swift b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerTransitioning.swift index 549ea9c0f6..4aafcf2157 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerTransitioning.swift +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerTransitioning.swift @@ -6,13 +6,13 @@ final class RouteManagerTransitioning: NSObject, UIViewControllerAnimatedTransit super.init() } - func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { + func transitionDuration(using _: UIViewControllerContextTransitioning?) -> TimeInterval { return kDefaultAnimationDuration } func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { guard let fromVC = transitionContext.viewController(forKey: .from), - let toVC = transitionContext.viewController(forKey: .to) else { return } + let toVC = transitionContext.viewController(forKey: .to) else { return } let animatingVC = isPresentation ? toVC : fromVC guard let animatingView = animatingVC.view else { return } @@ -29,7 +29,7 @@ final class RouteManagerTransitioning: NSObject, UIViewControllerAnimatedTransit UIView.animate(withDuration: transitionDuration(using: transitionContext), animations: { animatingView.frame = finalFrame }, completion: { _ in - transitionContext.completeTransition(true) + transitionContext.completeTransition(true) }) } } diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerTransitioningManager.swift b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerTransitioningManager.swift index e22f5ba888..4ad3dec17d 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerTransitioningManager.swift +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerTransitioningManager.swift @@ -13,12 +13,12 @@ final class RouteManagerTransitioningManager: NSObject, UIViewControllerTransiti super.init() } - func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? { + func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source _: UIViewController) -> UIPresentationController? { return alternative(iPhone: { () -> UIPresentationController in - return RouteManageriPhonePresentationController(presentedViewController: presented, - presenting: presenting) + RouteManageriPhonePresentationController(presentedViewController: presented, + presenting: presenting) }, - iPad: { () -> UIPresentationController in + iPad: { () -> UIPresentationController in let popover = RouteManageriPadPresentationController(presentedViewController: presented, presenting: presenting) popover.sourceView = self.popoverSourceView @@ -28,11 +28,11 @@ final class RouteManagerTransitioningManager: NSObject, UIViewControllerTransiti })() } - func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { + func animationController(forPresented _: UIViewController, presenting _: UIViewController, source _: UIViewController) -> UIViewControllerAnimatedTransitioning? { return RouteManagerTransitioning(isPresentation: true) } - func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { + func animationController(forDismissed _: UIViewController) -> UIViewControllerAnimatedTransitioning? { return RouteManagerTransitioning(isPresentation: false) } } diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.swift b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.swift index 7cb002e6a9..1f1143f9ed 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.swift +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManagerViewController.swift @@ -41,10 +41,10 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource cell.isHidden = true UIView.animate(withDuration: kDefaultAnimationDuration, animations: { [snapshot] in - snapshot.center = dragPoint - let scaleFactor: CGFloat = 1.05 - snapshot.transform = CGAffineTransform(scaleX: scaleFactor, y: scaleFactor) - }) + snapshot.center = dragPoint + let scaleFactor: CGFloat = 1.05 + snapshot.transform = CGAffineTransform(scaleX: scaleFactor, y: scaleFactor) + }) } func move(dragPoint: CGPoint, indexPath: IndexPath?, inManagerView: Bool) { @@ -57,7 +57,7 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource if let cell = cell { let (centerX, centerY) = (snapshot.width / 2, snapshot.height / 2) canMoveCell = cell.point(inside: cell.convert(CGPoint(x: centerX, y: 1.5 * centerY), from: snapshot), with: nil) && - cell.point(inside: cell.convert(CGPoint(x: centerX, y: 0.5 * centerY), from: snapshot), with: nil) + cell.point(inside: cell.convert(CGPoint(x: centerX, y: 0.5 * centerY), from: snapshot), with: nil) } else { canMoveCell = true } @@ -68,7 +68,7 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource controller.viewModel.movePoint(at: currentRow, to: newRow) tv.moveRow(at: currentIP, to: newIP) - let reloadRows = (min(currentRow, newRow)...max(currentRow, newRow)).map { IndexPath(row: $0, section: 0) } + let reloadRows = (min(currentRow, newRow) ... max(currentRow, newRow)).map { IndexPath(row: $0, section: 0) } tv.reloadRows(at: reloadRows, with: .fade) tv.cellForRow(at: newIP)?.isHidden = true @@ -89,12 +89,12 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource let dropCenter = tv.cellForRow(at: indexPath)?.center ?? snapshot.center UIView.animate(withDuration: kDefaultAnimationDuration, animations: { [snapshot] in - snapshot.center = containerView.convert(dropCenter, from: tv) - snapshot.transform = CGAffineTransform.identity - }, + snapshot.center = containerView.convert(dropCenter, from: tv) + snapshot.transform = CGAffineTransform.identity + }, completion: { [indexPath] _ in - tv.reloadRows(at: [indexPath], with: .none) - removeSnapshot() + tv.reloadRows(at: [indexPath], with: .none) + removeSnapshot() }) } else { controller.viewModel.deletePoint(at: indexPath.row) @@ -103,12 +103,12 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource let dimView = controller.dimView! UIView.animate(withDuration: kDefaultAnimationDuration, animations: { [snapshot] in - snapshot.center = containerView.convert(dimView.binDropPoint, from: dimView) - let scaleFactor: CGFloat = 0.2 - snapshot.transform = CGAffineTransform(scaleX: scaleFactor, y: scaleFactor) - }, + snapshot.center = containerView.convert(dimView.binDropPoint, from: dimView) + let scaleFactor: CGFloat = 0.2 + snapshot.transform = CGAffineTransform(scaleX: scaleFactor, y: scaleFactor) + }, completion: { _ in - removeSnapshot() + removeSnapshot() }) } } @@ -125,7 +125,7 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource super.init(nibName: toString(type(of: self)), bundle: nil) } - required init?(coder aDecoder: NSCoder) { + required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -205,7 +205,7 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource switch longPress.state { case .began: guard let indexPath = tableView.indexPathForRow(at: locationInTableView), - let cell = tableView.cellForRow(at: indexPath) else { return } + let cell = tableView.cellForRow(at: indexPath) else { return } dragCell = DragCell(controller: self, cell: cell, dragPoint: locationInView, indexPath: indexPath) case .changed: guard let dragCell = dragCell else { return } @@ -226,8 +226,8 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource return location } -// MARK: - UITableViewDataSource - func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + // MARK: - UITableViewDataSource + func tableView(_: UITableView, numberOfRowsInSection _: Int) -> Int { return viewModel.routePoints.count } @@ -238,13 +238,13 @@ final class RouteManagerViewController: MWMViewController, UITableViewDataSource return cell } - func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { + func tableView(_ tableView: UITableView, commit _: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) { viewModel.deletePoint(at: indexPath.row) tableView.deleteRows(at: [indexPath], with: .automatic) } -// MARK: - UITableViewDelegate - func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle { + // MARK: - UITableViewDelegate + func tableView(_: UITableView, editingStyleForRowAt _: IndexPath) -> UITableViewCellEditingStyle { return .delete } } diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManageriPhonePresentationController.swift b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManageriPhonePresentationController.swift index d5abe50be3..bd629bb6f3 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManageriPhonePresentationController.swift +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RouteManager/RouteManageriPhonePresentationController.swift @@ -8,8 +8,8 @@ final class RouteManageriPhonePresentationController: UIPresentationController { override func presentationTransitionWillBegin() { super.presentationTransitionWillBegin() guard let presentedViewController = presentedViewController as? RouteManagerViewController, - let coordinator = presentedViewController.transitionCoordinator, - let containerView = containerView else { return } + let coordinator = presentedViewController.transitionCoordinator, + let containerView = containerView else { return } containerView.addSubview(presentedView!) presentedViewController.containerView = containerView @@ -24,8 +24,8 @@ final class RouteManageriPhonePresentationController: UIPresentationController { override func dismissalTransitionWillBegin() { super.dismissalTransitionWillBegin() guard let presentedViewController = presentedViewController as? RouteManagerViewController, - let coordinator = presentedViewController.transitionCoordinator, - let presentedView = presentedView else { return } + let coordinator = presentedViewController.transitionCoordinator, + let presentedView = presentedView else { return } coordinator.animate(alongsideTransition: { _ in presentedViewController.chromeView.alpha = 0 diff --git a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RoutePreviewStatus.swift b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RoutePreviewStatus.swift index 6801b44037..08f8ac9d48 100644 --- a/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RoutePreviewStatus.swift +++ b/iphone/Maps/Classes/CustomViews/NavigationDashboard/Views/RoutePreview/RoutePreviewStatus.swift @@ -10,6 +10,7 @@ final class RoutePreviewStatus: SolidTouchView { } } } + @IBOutlet private weak var taxiBox: UIView! @IBOutlet private weak var errorLabel: UILabel! @IBOutlet private weak var resultLabel: UILabel! @@ -21,6 +22,7 @@ final class RoutePreviewStatus: SolidTouchView { configManageRouteButton(manageRouteButtonRegular) } } + @IBOutlet private weak var manageRouteButtonCompact: UIButton? { didSet { configManageRouteButton(manageRouteButtonCompact!) @@ -51,13 +53,13 @@ final class RoutePreviewStatus: SolidTouchView { UIView.animate(withDuration: kDefaultAnimationDuration, animations: { sv.layoutIfNeeded() }, completion: { _ in - if (!self.isVisible) { - self.removeFromSuperview() - } + if !self.isVisible { + self.removeFromSuperview() + } }) } }, - iPad: { self.isHidden = !self.isVisible })() + iPad: { self.isHidden = !self.isVisible })() } } @@ -143,9 +145,9 @@ final class RoutePreviewStatus: SolidTouchView { if MWMRouter.hasRouteAltitude() { heightBox.isHidden = false MWMRouter.routeAltitudeImage(for: heightProfileImage.frame.size, - completion: { (image, elevation) in - self.heightProfileImage.image = image - self.heightProfileElevationHeight?.text = elevation + completion: { image, elevation in + self.heightProfileImage.image = image + self.heightProfileElevationHeight?.text = elevation }) } else { heightBox.isHidden = true diff --git a/iphone/Maps/Common/Common.swift b/iphone/Maps/Common/Common.swift index 72e6e53021..eac2f5c84e 100644 --- a/iphone/Maps/Common/Common.swift +++ b/iphone/Maps/Common/Common.swift @@ -6,13 +6,13 @@ func L(_ key: String) -> String { return NSLocalizedString(key, comment: "") } func alternative(iPhone: T, iPad: T) -> T { return IPAD() ? iPad : iPhone } -func iPadSpecific( _ f: () -> Void) { +func iPadSpecific(_ f: () -> Void) { if IPAD() { f() } } -func iPhoneSpecific( _ f: () -> Void) { +func iPhoneSpecific(_ f: () -> Void) { if !IPAD() { f() } diff --git a/iphone/Maps/Core/Ads/Banner.swift b/iphone/Maps/Core/Ads/Banner.swift index 06e2ebd111..a823fe0e29 100644 --- a/iphone/Maps/Core/Ads/Banner.swift +++ b/iphone/Maps/Core/Ads/Banner.swift @@ -1,6 +1,6 @@ protocol Banner: MWMBanner { typealias EventName = String - typealias ErrorDetails = [String : Any] + typealias ErrorDetails = [String: Any] typealias Success = (Banner) -> Void typealias Failure = (BannerType, EventName, ErrorDetails, NSError) -> Void typealias Click = (Banner) -> Void diff --git a/iphone/Maps/Core/Ads/BannersCache.swift b/iphone/Maps/Core/Ads/BannersCache.swift index de12ca0fec..838e5de386 100644 --- a/iphone/Maps/Core/Ads/BannersCache.swift +++ b/iphone/Maps/Core/Ads/BannersCache.swift @@ -1,7 +1,7 @@ import Crashlytics import MyTrackerSDK -@objc (MWMBannersCache) +@objc(MWMBannersCache) final class BannersCache: NSObject { static let cache = BannersCache() private override init() {} @@ -14,8 +14,8 @@ final class BannersCache: NSObject { typealias Completion = (MWMBanner, Bool) -> Void - private var cache: [BannerType : Banner] = [:] - private var requests: [BannerType : Banner] = [:] + private var cache: [BannerType: Banner] = [:] + private var requests: [BannerType: Banner] = [:] private var completion: Completion? private var loadStates: [LoadState]! private var cacheOnly = false @@ -25,10 +25,10 @@ final class BannersCache: NSObject { var banner: Banner? statesLoop: for loadState in loadStates { switch loadState { - case .notLoaded(let type): + case let .notLoaded(type): banner = cache[type] break statesLoop - case .loaded(let type): + case let .loaded(type): banner = cache[type] break statesLoop case .error: continue @@ -83,7 +83,7 @@ final class BannersCache: NSObject { private func notLoadedIndex(bannerType: BannerType) -> Array.Index? { return loadStates.index(where: { - if case .notLoaded(let type) = $0, type == bannerType { + if case let .notLoaded(type) = $0, type == bannerType { return true } return false diff --git a/iphone/Maps/Core/Ads/Facebook/FacebookBanner.swift b/iphone/Maps/Core/Ads/Facebook/FacebookBanner.swift index 446be3246e..b6b61ddc09 100644 --- a/iphone/Maps/Core/Ads/Facebook/FacebookBanner.swift +++ b/iphone/Maps/Core/Ads/Facebook/FacebookBanner.swift @@ -62,7 +62,7 @@ final class FacebookBanner: NSObject, Banner { loadBannerDate = Date() } - if (remainingTime > 0) { + if remainingTime > 0 { perform(#selector(setEnoughTimeOnScreen), with: nil, afterDelay: remainingTime) } } @@ -74,7 +74,7 @@ final class FacebookBanner: NSObject, Banner { } let timePassed = Date().timeIntervalSince(date) - if (timePassed < Limits.minTimeOnScreen) { + if timePassed < Limits.minTimeOnScreen { remainingTime = Limits.minTimeOnScreen - timePassed NSObject.cancelPreviousPerformRequests(withTarget: self) } else { @@ -109,7 +109,7 @@ final class FacebookBanner: NSObject, Banner { } @objc private func enterBackground() { - if (isBannerOnScreen) { + if isBannerOnScreen { stopCountTimeOnScreen() } } @@ -131,7 +131,7 @@ extension FacebookBanner: FBNativeAdDelegate { guard nativeAd === self.nativeAd else { return } // https://developers.facebook.com/docs/audience-network/testing - var params: [String: Any] = [kStatBanner : nativeAd.placementID, kStatProvider : kStatFacebook] + var params: [String: Any] = [kStatBanner: nativeAd.placementID, kStatProvider: kStatFacebook] let e = error as NSError let event: String @@ -141,8 +141,8 @@ extension FacebookBanner: FBNativeAdDelegate { event = kStatPlacePageBannerError params[kStatErrorCode] = e.code } - - failure(self.type, event, params, e) + + failure(type, event, params, e) } func nativeAdDidClick(_ nativeAd: FBNativeAd) { @@ -150,4 +150,3 @@ extension FacebookBanner: FBNativeAdDelegate { click(self) } } - diff --git a/iphone/Maps/Core/Ads/Mopub/MopubBanner.swift b/iphone/Maps/Core/Ads/Mopub/MopubBanner.swift index fea8fbd31f..e11b62c2f1 100644 --- a/iphone/Maps/Core/Ads/Mopub/MopubBanner.swift +++ b/iphone/Maps/Core/Ads/Mopub/MopubBanner.swift @@ -78,7 +78,7 @@ final class MopubBanner: NSObject, Banner { } @objc private func enterBackground() { - if (isBannerOnScreen) { + if isBannerOnScreen { stopCountTimeOnScreen() } } @@ -88,7 +88,7 @@ final class MopubBanner: NSObject, Banner { showDate = Date() } - if (remainingTime > 0) { + if remainingTime > 0 { perform(#selector(setEnoughTimeOnScreen), with: nil, afterDelay: remainingTime) } } @@ -100,7 +100,7 @@ final class MopubBanner: NSObject, Banner { } let timePassed = Date().timeIntervalSince(date) - if (timePassed < Limits.minTimeOnScreen) { + if timePassed < Limits.minTimeOnScreen { remainingTime = Limits.minTimeOnScreen - timePassed NSObject.cancelPreviousPerformRequests(withTarget: self) } else { @@ -112,7 +112,7 @@ final class MopubBanner: NSObject, Banner { isNeedToRetain = false } - //MARK: - Content + // MARK: - Content private(set) var nativeAd: MPNativeAd? var title: String { @@ -135,7 +135,7 @@ final class MopubBanner: NSObject, Banner { return nativeAd?.properties[kDAAIconTapDestinationURL] as? String } - //MARK: - Helpers + // MARK: - Helpers private var request: MPNativeAdRequest! private func load() { @@ -149,11 +149,13 @@ final class MopubBanner: NSObject, Banner { } request.targeting = targeting - request.start { [weak self] request, nativeAd, error in + request.start { [weak self] _, nativeAd, error in guard let s = self else { return } if let error = error as NSError? { - let params: [String : Any] = [kStatBanner : s.bannerID, - kStatProvider : kStatMopub] + let params: [String: Any] = [ + kStatBanner: s.bannerID, + kStatProvider: kStatMopub, + ] let event = kStatPlacePageBannerError s.failure(s.type, event, params, error) } else { diff --git a/iphone/Maps/Core/Ads/RB/RBBanner.swift b/iphone/Maps/Core/Ads/RB/RBBanner.swift index f4808b3d60..eeff28fb53 100644 --- a/iphone/Maps/Core/Ads/RB/RBBanner.swift +++ b/iphone/Maps/Core/Ads/RB/RBBanner.swift @@ -42,7 +42,7 @@ final class RBBanner: MTRGNativeAd, Banner { } @objc private func enterBackground() { - if (isBannerOnScreen) { + if isBannerOnScreen { stopCountTimeOnScreen() } } @@ -52,7 +52,7 @@ final class RBBanner: MTRGNativeAd, Banner { showDate = Date() } - if (remainingTime > 0) { + if remainingTime > 0 { perform(#selector(setEnoughTimeOnScreen), with: nil, afterDelay: remainingTime) } } @@ -64,7 +64,7 @@ final class RBBanner: MTRGNativeAd, Banner { } let timePassed = Date().timeIntervalSince(date) - if (timePassed < Limits.minTimeOnScreen) { + if timePassed < Limits.minTimeOnScreen { remainingTime = Limits.minTimeOnScreen - timePassed NSObject.cancelPreviousPerformRequests(withTarget: self) } else { @@ -76,7 +76,7 @@ final class RBBanner: MTRGNativeAd, Banner { isNeedToRetain = false } - //MARK: - Banner + // MARK: - Banner func reload(success: @escaping Banner.Success, failure: @escaping Banner.Failure, click: @escaping Click) { self.success = success self.failure = failure @@ -126,16 +126,18 @@ final class RBBanner: MTRGNativeAd, Banner { } extension RBBanner: MTRGNativeAdDelegate { - func onLoad(with promoBanner: MTRGNativePromoBanner!, nativeAd: MTRGNativeAd!) { + func onLoad(with _: MTRGNativePromoBanner!, nativeAd: MTRGNativeAd!) { guard nativeAd === self else { return } success(self) } func onNoAd(withReason reason: String!, nativeAd: MTRGNativeAd!) { guard nativeAd === self else { return } - let params: [String: Any] = [kStatBanner : bannerID, - kStatProvider : kStatRB, - kStatReason : reason] + let params: [String: Any] = [ + kStatBanner: bannerID, + kStatProvider: kStatRB, + kStatReason: reason, + ] let event = kStatPlacePageBannerError let error = NSError(domain: kMapsmeErrorDomain, code: 1001, userInfo: params) failure(self.type, event, params, error) diff --git a/iphone/Maps/Core/Search/SearchIndex.swift b/iphone/Maps/Core/Search/SearchIndex.swift index 6b6ed59434..89119187d1 100644 --- a/iphone/Maps/Core/Search/SearchIndex.swift +++ b/iphone/Maps/Core/Search/SearchIndex.swift @@ -18,7 +18,7 @@ final class SearchIndex: NSObject { } init(suggestionsCount: Int, resultsCount: Int) { - for index in 0.. Bool { return false } - func addAffectingView(_ other: UIView) {} + func isAreaAffectingView(_: UIView) -> Bool { return false } + func addAffectingView(_: UIView) {} func notifyObserver() {} } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelCarouselCell.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelCarouselCell.swift index 4289013603..61cba56c60 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelCarouselCell.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelCarouselCell.swift @@ -1,4 +1,4 @@ -final class CarouselElement : UICollectionViewCell { +final class CarouselElement: UICollectionViewCell { @IBOutlet private weak var image: UIImageView! @IBOutlet private var dimMask: [UIView]! @@ -44,7 +44,7 @@ extension PPHotelCarouselCell: UICollectionViewDelegate, UICollectionViewDataSou return cell } - func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + func collectionView(_: UICollectionView, numberOfItemsInSection _: Int) -> Int { return isFullPhotosCarousel ? dataSource.count : kMaximumNumberOfPhotos } @@ -56,7 +56,8 @@ extension PPHotelCarouselCell: UICollectionViewDelegate, UICollectionViewDataSou } else { let section = indexPath.section d.showPhoto(at: indexPath.item, - referenceView: collectionView.cellForItem(at: indexPath), referenceViewWhenDismissingHandler: { index -> UIView? in + referenceView: collectionView.cellForItem(at: indexPath), + referenceViewWhenDismissingHandler: { index -> UIView? in let indexPath = IndexPath(item: index, section: section) return collectionView.cellForItem(at: indexPath) }) diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelDescriptionCell.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelDescriptionCell.swift index b748a076d9..13239b458f 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelDescriptionCell.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/BookingCells/PPHotelDescriptionCell.swift @@ -1,6 +1,5 @@ @objc(MWMPPHotelDescriptionCell) -final class PPHotelDescriptionCell: MWMTableViewCell -{ +final class PPHotelDescriptionCell: MWMTableViewCell { private let kMaximumDescriptionHeight: CGFloat = 60 @IBOutlet private var compactModeConstraints: [NSLayoutConstraint]! @@ -11,7 +10,7 @@ final class PPHotelDescriptionCell: MWMTableViewCell private var isNeedToForceLayout: Bool = false func config(with description: String, delegate: MWMPlacePageCellUpdateProtocol) { - descriptionText.text = description; + descriptionText.text = description descriptionText.sizeToFit() updateDelegate = delegate @@ -22,8 +21,8 @@ final class PPHotelDescriptionCell: MWMTableViewCell super.layoutSubviews() if isNeedToForceLayout { isNeedToForceLayout = false - let isCompact = descriptionText.height > kMaximumDescriptionHeight; - if (isCompact) { + let isCompact = descriptionText.height > kMaximumDescriptionHeight + if isCompact { compactModeConstraints.forEach { $0.priority = UILayoutPriorityDefaultHigh } } @@ -31,7 +30,7 @@ final class PPHotelDescriptionCell: MWMTableViewCell } } - private func hideButton(_ isHidden:Bool = true) { + private func hideButton(_ isHidden: Bool = true) { button.isHidden = isHidden buttonZeroHeight.priority = isHidden ? UILayoutPriorityDefaultHigh : UILayoutPriorityDefaultLow } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Cian/CianElement.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Cian/CianElement.swift index cfc1325365..cdc2701b40 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Cian/CianElement.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Cian/CianElement.swift @@ -1,4 +1,4 @@ -final class CianElement : UICollectionViewCell { +final class CianElement: UICollectionViewCell { enum State { case pending(onButtonAction: () -> Void) case offer(model: CianItemModel?, onButtonAction: (CianItemModel?) -> Void) @@ -16,18 +16,21 @@ final class CianElement : UICollectionViewCell { price.textColor = UIColor.linkBlue() } } + @IBOutlet private weak var descr: UILabel! { didSet { descr.font = UIFont.medium14() descr.textColor = UIColor.blackPrimaryText() } } + @IBOutlet private weak var address: UILabel! { didSet { address.font = UIFont.regular12() address.textColor = UIColor.blackSecondaryText() } } + @IBOutlet private weak var details: UIButton! { didSet { details.setTitleColor(UIColor.linkBlue(), for: .normal) @@ -50,6 +53,7 @@ final class CianElement : UICollectionViewCell { pendingSpinnerView.tintColor = UIColor.linkBlue() } } + @IBOutlet private weak var pendingTitleTopOffset: NSLayoutConstraint! @IBOutlet private weak var pendingTitle: UILabel! { didSet { @@ -58,6 +62,7 @@ final class CianElement : UICollectionViewCell { pendingTitle.text = L("preloader_cian_title") } } + @IBOutlet private weak var pendingDescription: UILabel! { didSet { pendingDescription.font = UIFont.regular12() @@ -66,7 +71,6 @@ final class CianElement : UICollectionViewCell { } } - @IBAction func onButtonAction() { switch state! { case let .pending(action): action() @@ -75,7 +79,6 @@ final class CianElement : UICollectionViewCell { } } - var state: State! { didSet { setupAppearance() @@ -96,14 +99,15 @@ final class CianElement : UICollectionViewCell { configError() } UIView.animate(withDuration: kDefaultAnimationDuration, - animations: { - self.pendingSpinnerView.alpha = pendingSpinnerViewAlpha - self.contentViews.forEach { $0.alpha = 0 } - visibleView.alpha = 1 - self.layoutIfNeeded() - }, completion: { _ in - self.contentViews.forEach { $0.isHidden = true } - visibleView.isHidden = false + animations: { + self.pendingSpinnerView.alpha = pendingSpinnerViewAlpha + self.contentViews.forEach { $0.alpha = 0 } + visibleView.alpha = 1 + self.layoutIfNeeded() + }, + completion: { _ in + self.contentViews.forEach { $0.isHidden = true } + visibleView.isHidden = false }) } } @@ -157,7 +161,7 @@ final class CianElement : UICollectionViewCell { } let descrFormat = L("room").replacingOccurrences(of: "%s", with: "%@") - descr.text = String(format: descrFormat, arguments:["\(model.roomsCount)"]) + descr.text = String(format: descrFormat, arguments: ["\(model.roomsCount)"]) address.text = model.address diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Cian/PPCianCarouselCell.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Cian/PPCianCarouselCell.swift index 2aaaca2870..8dc95d72e1 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Cian/PPCianCarouselCell.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Cian/PPCianCarouselCell.swift @@ -9,6 +9,7 @@ final class PPCianCarouselCell: MWMTableViewCell { title.textColor = UIColor.blackSecondaryText() } } + @IBOutlet private weak var more: UIButton! { didSet { more.setImage(#imageLiteral(resourceName: "logo_cian"), for: .normal) @@ -25,10 +26,11 @@ final class PPCianCarouselCell: MWMTableViewCell { } } } + fileprivate let kMaximumNumberOfElements = 5 fileprivate var delegate: MWMPlacePageButtonsProtocol? - fileprivate var statisticsParameters: [AnyHashable: Any] { return [kStatProvider : kStatCian] } + fileprivate var statisticsParameters: [AnyHashable: Any] { return [kStatProvider: kStatCian] } func config(delegate d: MWMPlacePageButtonsProtocol?) { delegate = d @@ -110,7 +112,7 @@ extension PPCianCarouselCell: UICollectionViewDelegate, UICollectionViewDataSour return cell } - func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + func collectionView(_: UICollectionView, numberOfItemsInSection _: Int) -> Int { if let data = data { if data.isEmpty { return 1 diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/GalleryItemViewController.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/GalleryItemViewController.swift index eaf5283c21..e0124aed53 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/GalleryItemViewController.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/GalleryItemViewController.swift @@ -49,7 +49,7 @@ final class GalleryItemViewController: MWMViewController { } extension GalleryItemViewController: UIScrollViewDelegate { - func viewForZooming(in scrollView: UIScrollView) -> UIView? { + func viewForZooming(in _: UIScrollView) -> UIView? { return imageView } } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/GalleryViewController.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/GalleryViewController.swift index 0e162dac50..136dc6484f 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/GalleryViewController.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/GalleryViewController.swift @@ -50,7 +50,7 @@ final class GalleryViewController: MWMCollectionViewController { } // MARK: UICollectionViewDataSource - override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + override func collectionView(_: UICollectionView, numberOfItemsInSection _: Int) -> Int { return model.items.count } @@ -68,7 +68,7 @@ final class GalleryViewController: MWMCollectionViewController { let photoVC = PhotosViewController(photos: model, initialPhoto: currentPhoto, referenceView: cell) photoVC.referenceViewForPhotoWhenDismissingHandler = { [weak self] photo in - if let index = self?.model.items.index(where: {$0 === photo}) { + if let index = self?.model.items.index(where: { $0 === photo }) { let indexPath = IndexPath(item: index, section: 0) return collectionView.cellForItem(at: indexPath) } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotoScalingView.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotoScalingView.swift index 6336de3e96..6a70541e75 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotoScalingView.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotoScalingView.swift @@ -64,7 +64,7 @@ final class PhotoScalingView: UIScrollView { s.imageView.frame = CGRect(origin: CGPoint.zero, size: s.contentSize) s.updateZoomScale() s.centerScrollViewContents() - }) + }) } private func updateZoomScale() { diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotoViewController.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotoViewController.swift index 11f799e0eb..2f3868bdc4 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotoViewController.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotoViewController.swift @@ -15,8 +15,8 @@ final class PhotoViewController: UIViewController { self.photo = photo super.init(nibName: nil, bundle: nil) } - - required init?(coder aDecoder: NSCoder) { + + required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -44,7 +44,7 @@ final class PhotoViewController: UIViewController { var newZoomScale = scalingView.maximumZoomScale if scalingView.zoomScale >= scalingView.maximumZoomScale || - abs(scalingView.zoomScale - scalingView.maximumZoomScale) <= 0.01 { + abs(scalingView.zoomScale - scalingView.maximumZoomScale) <= 0.01 { newZoomScale = scalingView.minimumZoomScale } @@ -60,16 +60,16 @@ final class PhotoViewController: UIViewController { } extension PhotoViewController: UIScrollViewDelegate { - func viewForZooming(in scrollView: UIScrollView) -> UIView? { + func viewForZooming(in _: UIScrollView) -> UIView? { return scalingView.imageView } - func scrollViewWillBeginZooming(_ scrollView: UIScrollView, with view: UIView?) { + func scrollViewWillBeginZooming(_ scrollView: UIScrollView, with _: UIView?) { scrollView.panGestureRecognizer.isEnabled = true } - func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) { - if (scrollView.zoomScale == scrollView.minimumZoomScale) { + func scrollViewDidEndZooming(_ scrollView: UIScrollView, with _: UIView?, atScale _: CGFloat) { + if scrollView.zoomScale == scrollView.minimumZoomScale { scrollView.panGestureRecognizer.isEnabled = false } } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosInteractionAnimator.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosInteractionAnimator.swift index 43c7992dd8..0c03106718 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosInteractionAnimator.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosInteractionAnimator.swift @@ -61,8 +61,10 @@ final class PhotosInteractionAnimator: NSObject { } let finalBackgroundColor = fromView.backgroundColor?.withAlphaComponent(finalBackgroundAlpha) finishPanWithoutAnimator(duration: animationDuration, - viewToPan: viewToPan, fromView: fromView, - finalPageViewCenterPoint: finalPageViewCenterPoint, finalBackgroundColor: finalBackgroundColor, + viewToPan: viewToPan, + fromView: fromView, + finalPageViewCenterPoint: finalPageViewCenterPoint, + finalBackgroundColor: finalBackgroundColor, isDismissing: isDismissing) } @@ -71,29 +73,29 @@ final class PhotosInteractionAnimator: NSObject { delay: 0, options: .curveEaseOut, animations: { - viewToPan.center = finalPageViewCenterPoint - fromView.backgroundColor = finalBackgroundColor - }, + viewToPan.center = finalPageViewCenterPoint + fromView.backgroundColor = finalBackgroundColor + }, completion: { [weak self] _ in - guard let s = self else { return } - if isDismissing { - s.transitionContext?.finishInteractiveTransition() - } else { - s.transitionContext?.cancelInteractiveTransition() - if !s.isRadar20070670Fixed() { - s.fixCancellationStatusBarAppearanceBug() - } - } - s.viewToHideWhenBeginningTransition?.alpha = 1.0 - s.transitionContext?.completeTransition(isDismissing && !(s.transitionContext?.transitionWasCancelled ?? false)) - s.transitionContext = nil + guard let s = self else { return } + if isDismissing { + s.transitionContext?.finishInteractiveTransition() + } else { + s.transitionContext?.cancelInteractiveTransition() + if !s.isRadar20070670Fixed() { + s.fixCancellationStatusBarAppearanceBug() + } + } + s.viewToHideWhenBeginningTransition?.alpha = 1.0 + s.transitionContext?.completeTransition(isDismissing && !(s.transitionContext?.transitionWasCancelled ?? false)) + s.transitionContext = nil }) } private func fixCancellationStatusBarAppearanceBug() { guard let toViewController = self.transitionContext?.viewController(forKey: UITransitionContextViewControllerKey.to), let fromViewController = self.transitionContext?.viewController(forKey: UITransitionContextViewControllerKey.from) else { - return + return } let statusBarViewControllerSelector = Selector("_setPresentedSta" + "tusBarViewController:") @@ -103,7 +105,7 @@ final class PhotosInteractionAnimator: NSObject { } private func isRadar20070670Fixed() -> Bool { - return ProcessInfo.processInfo.isOperatingSystemAtLeast(OperatingSystemVersion.init(majorVersion: 8, minorVersion: 3, patchVersion: 0)) + return ProcessInfo.processInfo.isOperatingSystemAtLeast(OperatingSystemVersion(majorVersion: 8, minorVersion: 3, patchVersion: 0)) } private func backgroundAlphaForPanningWithVerticalDelta(_ delta: CGFloat) -> CGFloat { diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosOverlayView.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosOverlayView.swift index df221078c3..cb0f78fbf0 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosOverlayView.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosOverlayView.swift @@ -24,17 +24,17 @@ final class PhotosOverlayView: UIView { setupNavigationBar() } - required init?(coder aDecoder: NSCoder) { + required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @objc - private func closeButtonTapped(_ sender: UIBarButtonItem) { + private func closeButtonTapped(_: UIBarButtonItem) { photosViewController?.dismiss(animated: true, completion: nil) } override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { - if let hitView = super.hitTest(point, with: event) , hitView != self { + if let hitView = super.hitTest(point, with: event), hitView != self { return hitView } return nil @@ -56,7 +56,7 @@ final class PhotosOverlayView: UIView { let topConstraint = NSLayoutConstraint(item: navigationBar, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1.0, constant: statusBarHeight()) let widthConstraint = NSLayoutConstraint(item: navigationBar, attribute: .width, relatedBy: .equal, toItem: self, attribute: .width, multiplier: 1.0, constant: 0.0) let horizontalPositionConstraint = NSLayoutConstraint(item: navigationBar, attribute: .centerX, relatedBy: .equal, toItem: self, attribute: .centerX, multiplier: 1.0, constant: 0.0) - addConstraints([topConstraint,widthConstraint,horizontalPositionConstraint]) + addConstraints([topConstraint, widthConstraint, horizontalPositionConstraint]) navigationItem.leftBarButtonItem = UIBarButtonItem(image: #imageLiteral(resourceName: "ic_nav_bar_back"), style: .plain, target: self, action: #selector(closeButtonTapped(_:))) } @@ -81,6 +81,6 @@ final class PhotosOverlayView: UIView { completion: { [weak self] _ in self?.alpha = 1.0 self?.isHidden = hidden - }) + }) } } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosTransitionAnimator.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosTransitionAnimator.swift index ab15e8a55f..14d98ff3d4 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosTransitionAnimator.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosTransitionAnimator.swift @@ -27,7 +27,7 @@ final class PhotosTransitionAnimator: NSObject, UIViewControllerAnimatedTransiti performFadeAnimationWithTransitionContext(transitionContext) } - func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { + func transitionDuration(using _: UIViewControllerContextTransitioning?) -> TimeInterval { return shouldPerformZoomingAnimation ? Settings.animationDurationWithZooming : Settings.animationDurationWithoutZooming } @@ -86,24 +86,24 @@ final class PhotosTransitionAnimator: NSObject, UIViewControllerAnimatedTransiti UIView.animate(withDuration: fadeInDuration, delay: 0.0, - options: [.allowAnimatedContent,.beginFromCurrentState], + options: [.allowAnimatedContent, .beginFromCurrentState], animations: { endingViewForAnimation.alpha = 1.0 }, completion: { _ in - UIView.animate(withDuration: fadeOutDuration, - delay: 0.0, - options: [.allowAnimatedContent,.beginFromCurrentState], - animations: { startingViewForAnimation.alpha = 0.0 }, - completion: { _ in - startingViewForAnimation.removeFromSuperview() - }) - + UIView.animate(withDuration: fadeOutDuration, + delay: 0.0, + options: [.allowAnimatedContent, .beginFromCurrentState], + animations: { startingViewForAnimation.alpha = 0.0 }, + completion: { _ in + startingViewForAnimation.removeFromSuperview() + }) + }) UIView.animate(withDuration: transDuration, delay: 0.0, - usingSpringWithDamping:Settings.zoomingAnimationSpringDamping, - initialSpringVelocity:0, - options: [.allowAnimatedContent,.beginFromCurrentState], + usingSpringWithDamping: Settings.zoomingAnimationSpringDamping, + initialSpringVelocity: 0, + options: [.allowAnimatedContent, .beginFromCurrentState], animations: { () -> Void in endingViewForAnimation.transform = finalEndingViewTransform endingViewForAnimation.center = translatedEndingViewFinalCenter @@ -115,7 +115,7 @@ final class PhotosTransitionAnimator: NSObject, UIViewControllerAnimatedTransiti endingView.alpha = 1.0 startingView.alpha = 1.0 self?.completeTransitionWithTransitionContext(transitionContext) - }) + }) } private func performFadeAnimationWithTransitionContext(_ transitionContext: UIViewControllerContextTransitioning) { @@ -127,7 +127,7 @@ final class PhotosTransitionAnimator: NSObject, UIViewControllerAnimatedTransiti UIView.animate(withDuration: fadeDurationForTransitionContext(transitionContext), animations: { fadeView?.alpha = endingAlpha - }) { finished in + }) { _ in if !self.shouldPerformZoomingAnimation { self.completeTransitionWithTransitionContext(transitionContext) } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosViewController.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosViewController.swift index 9b9889fca7..8793cd0e66 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosViewController.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/Gallery/Photos/PhotosViewController.swift @@ -13,10 +13,11 @@ final class PhotosViewController: MWMViewController { private var overlayViewHidden = false private lazy var singleTapGestureRecognizer: UITapGestureRecognizer = { - return UITapGestureRecognizer(target: self, action: #selector(handleSingleTapGestureRecognizer(_:))) + UITapGestureRecognizer(target: self, action: #selector(handleSingleTapGestureRecognizer(_:))) }() + private lazy var panGestureRecognizer: UIPanGestureRecognizer = { - return UIPanGestureRecognizer(target: self, action: #selector(handlePanGestureRecognizer(_:))) + UIPanGestureRecognizer(target: self, action: #selector(handlePanGestureRecognizer(_:))) }() fileprivate var interactiveDismissal = false @@ -36,8 +37,8 @@ final class PhotosViewController: MWMViewController { transitionAnimator.startingView = referenceView transitionAnimator.endingView = currentPhotoViewController?.scalingView.imageView } - - required init?(coder aDecoder: NSCoder) { + + required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -143,11 +144,11 @@ final class PhotosViewController: MWMViewController { } @objc - private func handleSingleTapGestureRecognizer(_ gestureRecognizer: UITapGestureRecognizer) { + private func handleSingleTapGestureRecognizer(_: UITapGestureRecognizer) { setOverlayHidden(!overlayView.isHidden, animated: true) } - //MARK: - Orientations + // MARK: - Orientations override var supportedInterfaceOrientations: UIInterfaceOrientationMask { return .all } @@ -167,17 +168,17 @@ final class PhotosViewController: MWMViewController { } extension PhotosViewController: UIViewControllerTransitioningDelegate { - func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { + func animationController(forPresented _: UIViewController, presenting _: UIViewController, source _: UIViewController) -> UIViewControllerAnimatedTransitioning? { transitionAnimator.dismissing = false return transitionAnimator } - func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { + func animationController(forDismissed _: UIViewController) -> UIViewControllerAnimatedTransitioning? { transitionAnimator.dismissing = true return transitionAnimator } - func interactionControllerForDismissal(using animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? { + func interactionControllerForDismissal(using _: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? { if interactiveDismissal { interactiveAnimator.animator = transitionAnimator interactiveAnimator.shouldAnimateUsingAnimator = transitionAnimator.endingView != nil @@ -189,21 +190,21 @@ extension PhotosViewController: UIViewControllerTransitioningDelegate { } extension PhotosViewController: UIPageViewControllerDataSource { - func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? { + func pageViewController(_: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? { guard let photoViewController = viewController as? PhotoViewController, - let photoIndex = photos.items.index(where: { $0 === photoViewController.photo }), - photoIndex - 1 >= 0 else { - return nil + let photoIndex = photos.items.index(where: { $0 === photoViewController.photo }), + photoIndex - 1 >= 0 else { + return nil } let newPhoto = photos.items[photoIndex - 1] return initializePhotoViewController(photo: newPhoto) } - func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? { + func pageViewController(_: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? { guard let photoViewController = viewController as? PhotoViewController, - let photoIndex = photos.items.index(where: { $0 === photoViewController.photo }), - photoIndex + 1 < photos.items.count else { - return nil + let photoIndex = photos.items.index(where: { $0 === photoViewController.photo }), + photoIndex + 1 < photos.items.count else { + return nil } let newPhoto = photos.items[photoIndex + 1] return initializePhotoViewController(photo: newPhoto) @@ -211,7 +212,7 @@ extension PhotosViewController: UIPageViewControllerDataSource { } extension PhotosViewController: UIPageViewControllerDelegate { - func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) { + func pageViewController(_: UIPageViewController, didFinishAnimating _: Bool, previousViewControllers _: [UIViewController], transitionCompleted completed: Bool) { if completed { if let currentPhoto = currentPhoto { overlayView.photo = currentPhoto diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSelectImpressionCell.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSelectImpressionCell.swift index f75fd5bbdf..e679213eef 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSelectImpressionCell.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSelectImpressionCell.swift @@ -9,7 +9,7 @@ final class UGCSelectImpressionCell: MWMTableViewCell { @IBAction private func tap(on: UIButton) { buttons.forEach { $0.isSelected = false } - on.isSelected = true; + on.isSelected = true delegate?.review(on: on.tag) } } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSpecificReviewCell.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSpecificReviewCell.swift index 1d6f5bc31e..ab642cbb1d 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSpecificReviewCell.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCSpecificReviewCell.swift @@ -22,11 +22,11 @@ final class UGCSpecificReviewCell: MWMTableViewCell { delegate?.changeReviewRate(on.tag, atIndexPath: indexPath) } - //TODO: Make highlighting and dragging. + // TODO: Make highlighting and dragging. - @IBAction private func highlight(on: UIButton) { } + @IBAction private func highlight(on _: UIButton) {} - @IBAction private func touchingCanceled(on: UIButton) { } + @IBAction private func touchingCanceled(on _: UIButton) {} - @IBAction private func drag(inside: UIButton) { } + @IBAction private func drag(inside _: UIButton) {} } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCTextReviewCell.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCTextReviewCell.swift index 384677ea12..59800d9d0a 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCTextReviewCell.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/UGC/UGCTextReviewCell.swift @@ -23,8 +23,8 @@ final class UGCTextReviewCell: MWMTableViewCell, UITextViewDelegate { countLabel.text = "\(count)/\(Consts.kMaxNumberOfSymbols)" } - //MARK: UITextViewDelegate - func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { + // MARK: UITextViewDelegate + func textView(_ textView: UITextView, shouldChangeTextIn _: NSRange, replacementText _: String) -> Bool { return textView.text.characters.count <= Consts.kMaxNumberOfSymbols } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/ViatorCells/PPViatorCarouselCell.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/ViatorCells/PPViatorCarouselCell.swift index ea20581a1b..3e60991842 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/ViatorCells/PPViatorCarouselCell.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/ViatorCells/PPViatorCarouselCell.swift @@ -7,6 +7,7 @@ final class PPViatorCarouselCell: MWMTableViewCell { title.textColor = UIColor.blackSecondaryText() } } + @IBOutlet private weak var more: UIButton! { didSet { more.setTitle(L("placepage_more_button"), for: .normal) @@ -20,7 +21,7 @@ final class PPViatorCarouselCell: MWMTableViewCell { fileprivate let kMaximumNumberOfElements = 5 fileprivate var delegate: MWMPlacePageButtonsProtocol? - fileprivate var statisticsParameters: [AnyHashable: Any] { return [kStatProvider : kStatViator] } + fileprivate var statisticsParameters: [AnyHashable: Any] { return [kStatProvider: kStatViator] } func config(with ds: [ViatorItemModel], delegate d: MWMPlacePageButtonsProtocol?) { if ds.isEmpty { @@ -60,11 +61,11 @@ extension PPViatorCarouselCell: UICollectionViewDelegate, UICollectionViewDataSo return cell } - func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + func collectionView(_: UICollectionView, numberOfItemsInSection _: Int) -> Int { return min(dataSource.count, kMaximumNumberOfElements) + 1 } - func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + func collectionView(_: UICollectionView, didSelectItemAt indexPath: IndexPath) { let isMore = isLastCell(indexPath) let url: URL? = isMore ? nil : dataSource[indexPath.item].pageURL delegate?.openSponsoredURL(url) diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/ViatorCells/ViatorElement.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/ViatorCells/ViatorElement.swift index f5db7a17e5..7b6238a792 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/ViatorCells/ViatorElement.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Content/ViatorCells/ViatorElement.swift @@ -1,4 +1,4 @@ -final class ViatorElement : UICollectionViewCell { +final class ViatorElement: UICollectionViewCell { @IBOutlet private weak var more: UIButton! @IBOutlet private weak var image: UIImageView! @@ -8,18 +8,21 @@ final class ViatorElement : UICollectionViewCell { title.textColor = UIColor.blackPrimaryText() } } + @IBOutlet private weak var duration: UILabel! { didSet { duration.font = UIFont.regular12() duration.textColor = UIColor.blackSecondaryText() } } + @IBOutlet private weak var price: UILabel! { didSet { price.font = UIFont.medium14() price.textColor = UIColor.linkBlue() } } + @IBOutlet private var rating: [UIImageView]! private var isLastCell = false { diff --git a/iphone/Maps/UI/Search/Filters/FilterCollectionHolderCell.swift b/iphone/Maps/UI/Search/Filters/FilterCollectionHolderCell.swift index 0acf0b261f..7fda6f354a 100644 --- a/iphone/Maps/UI/Search/Filters/FilterCollectionHolderCell.swift +++ b/iphone/Maps/UI/Search/Filters/FilterCollectionHolderCell.swift @@ -7,7 +7,7 @@ final class FilterCollectionHolderCell: MWMTableViewCell { override var frame: CGRect { didSet { guard #available(iOS 10, *) else { - if (frame.size.height < 1 /* minimal correct height */) { + if frame.size.height < 1 /* minimal correct height */ { frame.size.height = max(collectionViewHeight.constant, 1) tableView?.refresh() } @@ -24,7 +24,7 @@ final class FilterCollectionHolderCell: MWMTableViewCell { func config(tableView: UITableView?) { layout() - collectionView.allowsMultipleSelection = true; + collectionView.allowsMultipleSelection = true isSeparatorHidden = true backgroundColor = UIColor.pressBackground() diff --git a/iphone/Maps/UI/Search/Filters/FilterPriceCategoryCell.swift b/iphone/Maps/UI/Search/Filters/FilterPriceCategoryCell.swift index 9f26255e17..e1fab397c6 100644 --- a/iphone/Maps/UI/Search/Filters/FilterPriceCategoryCell.swift +++ b/iphone/Maps/UI/Search/Filters/FilterPriceCategoryCell.swift @@ -1,11 +1,11 @@ -@objc (MWMFilterPriceCategoryCell) +@objc(MWMFilterPriceCategoryCell) final class FilterPriceCategoryCell: UITableViewCell { - + @IBOutlet weak var one: UIButton! @IBOutlet weak var two: UIButton! @IBOutlet weak var three: UIButton! @IBAction private func tap(sender: UIButton!) { - sender.isSelected = !sender.isSelected; + sender.isSelected = !sender.isSelected } } diff --git a/iphone/Maps/UI/Search/Filters/FilterRatingCell.swift b/iphone/Maps/UI/Search/Filters/FilterRatingCell.swift index 388e3b3085..a36259a67f 100644 --- a/iphone/Maps/UI/Search/Filters/FilterRatingCell.swift +++ b/iphone/Maps/UI/Search/Filters/FilterRatingCell.swift @@ -1,6 +1,6 @@ -@objc (MWMFilterRatingCell) +@objc(MWMFilterRatingCell) final class FilterRatingCell: UITableViewCell { - + @IBOutlet private var ratingButtons: [UIButton]! @IBOutlet weak var any: UIButton! @IBOutlet weak var good: UIButton! diff --git a/iphone/Maps/UI/Search/Filters/FilterTypeCell.swift b/iphone/Maps/UI/Search/Filters/FilterTypeCell.swift index f5b8ca5af8..ad1765af4a 100644 --- a/iphone/Maps/UI/Search/Filters/FilterTypeCell.swift +++ b/iphone/Maps/UI/Search/Filters/FilterTypeCell.swift @@ -1,5 +1,5 @@ final class TypeCellFlowLayout: UICollectionViewFlowLayout { - + override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { let attributes = super.layoutAttributesForElements(in: rect) @@ -12,7 +12,7 @@ final class TypeCellFlowLayout: UICollectionViewFlowLayout { layoutAttribute.frame.origin.x = leftMargin leftMargin += layoutAttribute.frame.width + minimumInteritemSpacing - maxY = max(layoutAttribute.frame.maxY , maxY) + maxY = max(layoutAttribute.frame.maxY, maxY) } return attributes } @@ -20,7 +20,7 @@ final class TypeCellFlowLayout: UICollectionViewFlowLayout { @objc(MWMFilterTypeCell) final class FilterTypeCell: UICollectionViewCell { - + @IBOutlet weak var tagName: UILabel! override var isSelected: Bool { diff --git a/iphone/Maps/UI/Settings/Cells/SettingsTableViewSwitchCell.swift b/iphone/Maps/UI/Settings/Cells/SettingsTableViewSwitchCell.swift index a3c1f1e9de..8dd850ad90 100644 --- a/iphone/Maps/UI/Settings/Cells/SettingsTableViewSwitchCell.swift +++ b/iphone/Maps/UI/Settings/Cells/SettingsTableViewSwitchCell.swift @@ -22,7 +22,7 @@ self.title.text = title styleTitle() - self.switchButton.isOn = isOn + switchButton.isOn = isOn styleSwitchButton() } diff --git a/iphone/Maps/UI/Storyboard/Storyboard.swift b/iphone/Maps/UI/Storyboard/Storyboard.swift index 43540e0c74..0f7de7cc89 100644 --- a/iphone/Maps/UI/Storyboard/Storyboard.swift +++ b/iphone/Maps/UI/Storyboard/Storyboard.swift @@ -11,7 +11,6 @@ enum Storyboard: Int { case welcome } - extension UIStoryboard { static func instance(_ id: Storyboard) -> UIStoryboard { diff --git a/iphone/Maps/UI/Welcome/FirstLaunchController.swift b/iphone/Maps/UI/Welcome/FirstLaunchController.swift index 999d9bbab0..fc8e45a0c6 100644 --- a/iphone/Maps/UI/Welcome/FirstLaunchController.swift +++ b/iphone/Maps/UI/Welcome/FirstLaunchController.swift @@ -3,26 +3,26 @@ import UIKit final class FirstLaunchController: MWMViewController, WelcomeProtocol { static var welcomeConfigs: [WelcomeConfig] = [ - WelcomeConfig(image: #imageLiteral(resourceName: "img_onboarding_offline_maps"), + WelcomeConfig(image: #imageLiteral(resourceName: "img_onboarding_offline_maps"), title: "onboarding_offline_maps_title", text: "onboarding_offline_maps_message", buttonTitle: "whats_new_next_button", buttonAction: #selector(nextPage)), - WelcomeConfig(image: #imageLiteral(resourceName: "img_onboarding_geoposition"), + WelcomeConfig(image: #imageLiteral(resourceName: "img_onboarding_geoposition"), title: "onboarding_location_title", text: "onboarding_location_message", buttonTitle: "whats_new_next_button", buttonAction: #selector(nextPage)), - WelcomeConfig(image: #imageLiteral(resourceName: "img_onboarding_notification"), + WelcomeConfig(image: #imageLiteral(resourceName: "img_onboarding_notification"), title: "onboarding_notifications_title", text: "onboarding_notifications_message", buttonTitle: "whats_new_next_button", buttonAction: #selector(nextPage)), - WelcomeConfig(image: #imageLiteral(resourceName: "img_onboarding_done"), + WelcomeConfig(image: #imageLiteral(resourceName: "img_onboarding_done"), title: "first_launch_congrats_title", text: "first_launch_congrats_text", buttonTitle: "done", - buttonAction: #selector(close)) + buttonAction: #selector(close)), ] var pageIndex: Int! diff --git a/iphone/Maps/UI/Welcome/WelcomePageController.swift b/iphone/Maps/UI/Welcome/WelcomePageController.swift index 3850524237..afa15d1093 100644 --- a/iphone/Maps/UI/Welcome/WelcomePageController.swift +++ b/iphone/Maps/UI/Welcome/WelcomePageController.swift @@ -67,7 +67,7 @@ final class WelcomePageController: UIPageViewController { let isFirstSession = Alohalytics.isFirstSession() let pagesCount = isFirstSession ? FirstLaunchController.pagesCount : WhatsNewController.pagesCount let welcomeClass: WelcomeProtocolBase.Type = isFirstSession ? FirstLaunchController.self : WhatsNewController.self - (0.. UIViewController? { + func pageViewController(_: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? { guard viewController != controllers.first else { return nil } let index = controllers.index(before: controllers.index(of: viewController)!) return controllers[index] } - func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? { + func pageViewController(_: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? { guard viewController != controllers.last else { return nil } let index = controllers.index(after: controllers.index(of: viewController)!) return controllers[index] } - func presentationCount(for pageViewController: UIPageViewController) -> Int { + func presentationCount(for _: UIPageViewController) -> Int { return controllers.count } - func presentationIndex(for pageViewController: UIPageViewController) -> Int { + func presentationIndex(for _: UIPageViewController) -> Int { guard let vc = currentController else { return 0 } return controllers.index(of: vc)! } diff --git a/iphone/Maps/UI/Welcome/WelcomeProtocol.swift b/iphone/Maps/UI/Welcome/WelcomeProtocol.swift index 730992024f..131908ec6d 100644 --- a/iphone/Maps/UI/Welcome/WelcomeProtocol.swift +++ b/iphone/Maps/UI/Welcome/WelcomeProtocol.swift @@ -67,11 +67,11 @@ extension WelcomeProtocol { static func configBlock(pageIndex: Int) -> ConfigBlock { let welcomeConfig = welcomeConfigs[pageIndex] return { - $0.setup(image:welcomeConfig.image, - title:L(welcomeConfig.title), - text:L(welcomeConfig.text), - buttonTitle:L(welcomeConfig.buttonTitle), - buttonAction:welcomeConfig.buttonAction) + $0.setup(image: welcomeConfig.image, + title: L(welcomeConfig.title), + text: L(welcomeConfig.text), + buttonTitle: L(welcomeConfig.buttonTitle), + buttonAction: welcomeConfig.buttonAction) } } static var pagesCount: Int { return welcomeConfigs.count } diff --git a/iphone/Maps/UI/Welcome/WhatsNewController.swift b/iphone/Maps/UI/Welcome/WhatsNewController.swift index 1dd4fc1d8a..1575f9b458 100644 --- a/iphone/Maps/UI/Welcome/WhatsNewController.swift +++ b/iphone/Maps/UI/Welcome/WhatsNewController.swift @@ -3,16 +3,16 @@ import UIKit final class WhatsNewController: MWMViewController, WelcomeProtocol { static var welcomeConfigs: [WelcomeConfig] = [ - WelcomeConfig(image: #imageLiteral(resourceName: "img_whats_new_route"), + WelcomeConfig(image: #imageLiteral(resourceName: "img_whats_new_route"), title: "whats_new_title_route", text: "whats_new_message_route", buttonTitle: "whats_new_next_button", buttonAction: #selector(nextPage)), - WelcomeConfig(image: #imageLiteral(resourceName: "img_whats_new_update"), + WelcomeConfig(image: #imageLiteral(resourceName: "img_whats_new_update"), title: "whats_new_message_title_update", text: "whats_new_message_maps_update", buttonTitle: "done", - buttonAction: #selector(close)) + buttonAction: #selector(close)), ] var pageIndex: Int!