forked from organicmaps/organicmaps
[rating_view] [ios] Applied swiftformat.
This commit is contained in:
parent
4cab9e8071
commit
26a19cb849
49 changed files with 307 additions and 277 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -6,13 +6,13 @@ func L(_ key: String) -> String { return NSLocalizedString(key, comment: "") }
|
|||
|
||||
func alternative<T>(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()
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<LoadState>.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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -18,7 +18,7 @@ final class SearchIndex: NSObject {
|
|||
}
|
||||
|
||||
init(suggestionsCount: Int, resultsCount: Int) {
|
||||
for index in 0..<resultsCount {
|
||||
for index in 0 ..< resultsCount {
|
||||
let type: MWMSearchItemType = index < suggestionsCount ? .suggestion : .regular
|
||||
let item = Item(type: type, containerIndex: index)
|
||||
positionItems.append(PositionItem(item: item, position: index))
|
||||
|
@ -45,7 +45,7 @@ final class SearchIndex: NSObject {
|
|||
|
||||
items.removeAll()
|
||||
let keys = itemsDict.keys.sorted()
|
||||
for index in 0..<keys.count {
|
||||
for index in 0 ..< keys.count {
|
||||
let key = keys[index]
|
||||
if index == key {
|
||||
items.append(itemsDict[key]!)
|
||||
|
@ -67,8 +67,8 @@ extension SearchIndex.PositionItem: Equatable {
|
|||
let lhsCache = lhs.item
|
||||
let rhsCache = rhs.item
|
||||
return lhsCache.type == rhsCache.type &&
|
||||
lhs.position == rhs.position &&
|
||||
lhsCache.containerIndex == rhsCache.containerIndex
|
||||
lhs.position == rhs.position &&
|
||||
lhsCache.containerIndex == rhsCache.containerIndex
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ final class AdBanner: UITableViewCell {
|
|||
|
||||
private func configFBBanner(ad: FBNativeAd) {
|
||||
let adCallToActionButtons: [UIView]
|
||||
if (state == .search) {
|
||||
if state == .search {
|
||||
adCallToActionButtons = [self, adCallToActionButtonCompact]
|
||||
} else {
|
||||
adCallToActionButtons = [adCallToActionButtonCompact, adCallToActionButtonDetailed]
|
||||
|
@ -149,9 +149,11 @@ final class AdBanner: UITableViewCell {
|
|||
paragraphStyle.firstLineHeadIndent = 24
|
||||
paragraphStyle.lineBreakMode = .byTruncatingTail
|
||||
let adTitle = NSAttributedString(string: ad.title ?? "",
|
||||
attributes: [NSParagraphStyleAttributeName: paragraphStyle,
|
||||
NSFontAttributeName: UIFont.bold12(),
|
||||
NSForegroundColorAttributeName: UIColor.blackSecondaryText()])
|
||||
attributes: [
|
||||
NSParagraphStyleAttributeName: paragraphStyle,
|
||||
NSFontAttributeName: UIFont.bold12(),
|
||||
NSForegroundColorAttributeName: UIColor.blackSecondaryText(),
|
||||
])
|
||||
adTitleLabel.attributedText = adTitle
|
||||
adBodyLabel.text = ad.body ?? ""
|
||||
let config = state.config()
|
||||
|
@ -169,9 +171,11 @@ final class AdBanner: UITableViewCell {
|
|||
paragraphStyle.firstLineHeadIndent = 24
|
||||
paragraphStyle.lineBreakMode = .byTruncatingTail
|
||||
let adTitle = NSAttributedString(string: banner.title ?? "",
|
||||
attributes: [NSParagraphStyleAttributeName: paragraphStyle,
|
||||
NSFontAttributeName: UIFont.bold12(),
|
||||
NSForegroundColorAttributeName: UIColor.blackSecondaryText()])
|
||||
attributes: [
|
||||
NSParagraphStyleAttributeName: paragraphStyle,
|
||||
NSFontAttributeName: UIFont.bold12(),
|
||||
NSForegroundColorAttributeName: UIColor.blackSecondaryText(),
|
||||
])
|
||||
adTitleLabel.attributedText = adTitle
|
||||
adBodyLabel.text = banner.descriptionText ?? ""
|
||||
let config = state.config()
|
||||
|
@ -199,9 +203,11 @@ final class AdBanner: UITableViewCell {
|
|||
paragraphStyle.firstLineHeadIndent = 24
|
||||
paragraphStyle.lineBreakMode = .byTruncatingTail
|
||||
let adTitle = NSAttributedString(string: ad.title,
|
||||
attributes: [NSParagraphStyleAttributeName: paragraphStyle,
|
||||
NSFontAttributeName: UIFont.bold12(),
|
||||
NSForegroundColorAttributeName: UIColor.blackSecondaryText()])
|
||||
attributes: [
|
||||
NSParagraphStyleAttributeName: paragraphStyle,
|
||||
NSFontAttributeName: UIFont.bold12(),
|
||||
NSForegroundColorAttributeName: UIColor.blackSecondaryText(),
|
||||
])
|
||||
adTitleLabel.attributedText = adTitle
|
||||
adBodyLabel.text = ad.text
|
||||
if let url = URL(string: ad.iconURL) {
|
||||
|
|
|
@ -64,14 +64,15 @@ class AvailableArea: UIView {
|
|||
let add = { (sa: NSLayoutAttribute, oa: NSLayoutAttribute, rel: NSLayoutRelation) in
|
||||
NSLayoutConstraint(item: self, attribute: sa, relatedBy: rel, toItem: otherView, attribute: oa, multiplier: 1, constant: 0).isActive = true
|
||||
}
|
||||
[.top : (.top, .bottom, .greaterThanOrEqual),
|
||||
.bottom : (.bottom, .top, .lessThanOrEqual),
|
||||
.left : (.left, .right, .greaterThanOrEqual),
|
||||
.right : (.right, .left, .lessThanOrEqual)
|
||||
]
|
||||
.filter { directions.contains($0.key) }
|
||||
.map { $0.value }
|
||||
.forEach(add)
|
||||
[
|
||||
.top: (.top, .bottom, .greaterThanOrEqual),
|
||||
.bottom: (.bottom, .top, .lessThanOrEqual),
|
||||
.left: (.left, .right, .greaterThanOrEqual),
|
||||
.right: (.right, .left, .lessThanOrEqual),
|
||||
]
|
||||
.filter { directions.contains($0.key) }
|
||||
.map { $0.value }
|
||||
.forEach(add)
|
||||
}
|
||||
|
||||
@objc
|
||||
|
@ -85,8 +86,8 @@ class AvailableArea: UIView {
|
|||
}
|
||||
}
|
||||
|
||||
func isAreaAffectingView(_ other: UIView) -> Bool { return false }
|
||||
func addAffectingView(_ other: UIView) {}
|
||||
func isAreaAffectingView(_: UIView) -> Bool { return false }
|
||||
func addAffectingView(_: UIView) {}
|
||||
func notifyObserver() {}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -49,7 +49,7 @@ final class GalleryItemViewController: MWMViewController {
|
|||
}
|
||||
|
||||
extension GalleryItemViewController: UIScrollViewDelegate {
|
||||
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
|
||||
func viewForZooming(in _: UIScrollView) -> UIView? {
|
||||
return imageView
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
self.title.text = title
|
||||
styleTitle()
|
||||
|
||||
self.switchButton.isOn = isOn
|
||||
switchButton.isOn = isOn
|
||||
styleSwitchButton()
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ enum Storyboard: Int {
|
|||
case welcome
|
||||
}
|
||||
|
||||
|
||||
extension UIStoryboard {
|
||||
|
||||
static func instance(_ id: Storyboard) -> UIStoryboard {
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -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..<pagesCount).forEach {
|
||||
(0 ..< pagesCount).forEach {
|
||||
let vc = welcomeClass.controller($0)
|
||||
(vc as! WelcomeProtocolBase).pageController = self
|
||||
controllers.append(vc)
|
||||
|
@ -118,23 +118,23 @@ final class WelcomePageController: UIPageViewController {
|
|||
|
||||
extension WelcomePageController: UIPageViewControllerDataSource {
|
||||
|
||||
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> 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)!
|
||||
}
|
||||
|
|
|
@ -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 }
|
||||
|
|
|
@ -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!
|
||||
|
|
Loading…
Add table
Reference in a new issue