diff --git a/iphone/Maps/UI/PlacePage/Components/ElevationProfile/ElevationProfilePresenter.swift b/iphone/Maps/UI/PlacePage/Components/ElevationProfile/ElevationProfilePresenter.swift
index f705307c8..ae74fdf48 100644
--- a/iphone/Maps/UI/PlacePage/Components/ElevationProfile/ElevationProfilePresenter.swift
+++ b/iphone/Maps/UI/PlacePage/Components/ElevationProfile/ElevationProfilePresenter.swift
@@ -26,8 +26,8 @@ fileprivate struct DescriptionsViewModel {
final class ElevationProfilePresenter: NSObject {
private weak var view: ElevationProfileViewProtocol?
- private var trackData: PlacePageTrackData
- private let delegate: ElevationProfileViewControllerDelegate?
+ private weak var trackData: PlacePageTrackData?
+ private weak var delegate: ElevationProfileViewControllerDelegate?
private let bookmarkManager: BookmarksManager = .shared()
private let cellSpacing: CGFloat = 8
@@ -85,7 +85,8 @@ extension ElevationProfilePresenter: ElevationProfilePresenterProtocol {
view?.isChartViewHidden = false
let kMinPointsToDraw = 2
- guard let profileData = trackData.elevationProfileData,
+ guard let trackData = trackData,
+ let profileData = trackData.elevationProfileData,
let chartData,
chartData.points.count >= kMinPointsToDraw else {
view?.userInteractionEnabled = false
diff --git a/iphone/Maps/UI/PlacePage/PlacePage.storyboard b/iphone/Maps/UI/PlacePage/PlacePage.storyboard
index d82778b6e..fb1963bfe 100644
--- a/iphone/Maps/UI/PlacePage/PlacePage.storyboard
+++ b/iphone/Maps/UI/PlacePage/PlacePage.storyboard
@@ -1270,7 +1270,7 @@
-
+
@@ -1280,7 +1280,7 @@
-
+
@@ -1405,13 +1405,13 @@
-
+
-
+
diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageCommonLayout.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageCommonLayout.swift
index b9f72bb55..151ba5054 100644
--- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageCommonLayout.swift
+++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageCommonLayout.swift
@@ -1,81 +1,81 @@
class PlacePageCommonLayout: NSObject, IPlacePageLayout {
-
+
private let distanceFormatter = DistanceFormatter.self
private let altitudeFormatter = AltitudeFormatter.self
private var placePageData: PlacePageData
private var interactor: PlacePageInteractor
private let storyboard: UIStoryboard
+ private var lastLocation: CLLocation?
+
weak var presenter: PlacePagePresenterProtocol?
- fileprivate var lastLocation: CLLocation?
-
- lazy var headerViewControllers: [UIViewController] = {
+ var headerViewControllers: [UIViewController] {
[headerViewController, previewViewController]
- }()
+ }
lazy var bodyViewControllers: [UIViewController] = {
- return configureViewControllers()
+ configureViewControllers()
}()
var actionBar: ActionBarViewController? {
- return actionBarViewController
+ actionBarViewController
}
var navigationBar: UIViewController? {
- return placePageNavigationViewController
+ placePageNavigationViewController
}
-
+
lazy var headerViewController: PlacePageHeaderViewController = {
PlacePageHeaderBuilder.build(data: placePageData, delegate: interactor, headerType: .flexible)
}()
- lazy var previewViewController: PlacePagePreviewViewController = {
+ private lazy var previewViewController: PlacePagePreviewViewController = {
let vc = storyboard.instantiateViewController(ofType: PlacePagePreviewViewController.self)
vc.placePagePreviewData = placePageData.previewData
return vc
- } ()
+ }()
- lazy var wikiDescriptionViewController: WikiDescriptionViewController = {
+ private lazy var wikiDescriptionViewController: WikiDescriptionViewController = {
let vc = storyboard.instantiateViewController(ofType: WikiDescriptionViewController.self)
vc.view.isHidden = true
vc.delegate = interactor
return vc
- } ()
+ }()
- lazy var editBookmarkViewController: PlacePageEditBookmarkOrTrackViewController = {
+ private lazy var editBookmarkViewController: PlacePageEditBookmarkOrTrackViewController = {
let vc = storyboard.instantiateViewController(ofType: PlacePageEditBookmarkOrTrackViewController.self)
vc.view.isHidden = true
vc.delegate = interactor
return vc
- } ()
+ }()
- lazy var infoViewController: PlacePageInfoViewController = {
+ private lazy var infoViewController: PlacePageInfoViewController = {
let vc = storyboard.instantiateViewController(ofType: PlacePageInfoViewController.self)
vc.placePageInfoData = placePageData.infoData
vc.delegate = interactor
return vc
- } ()
+ }()
- lazy var buttonsViewController: PlacePageButtonsViewController = {
+ private lazy var buttonsViewController: PlacePageButtonsViewController = {
let vc = storyboard.instantiateViewController(ofType: PlacePageButtonsViewController.self)
vc.buttonsData = placePageData.buttonsData!
vc.delegate = interactor
return vc
- } ()
+ }()
- lazy var actionBarViewController: ActionBarViewController = {
+ private lazy var actionBarViewController: ActionBarViewController = {
let vc = storyboard.instantiateViewController(ofType: ActionBarViewController.self)
vc.placePageData = placePageData
vc.canAddStop = MWMRouter.canAddIntermediatePoint()
vc.isRoutePlanning = MWMNavigationDashboardManager.shared().state != .hidden
vc.delegate = interactor
return vc
- } ()
+ }()
- lazy var placePageNavigationViewController: PlacePageHeaderViewController = {
+ private lazy var placePageNavigationViewController: PlacePageHeaderViewController = {
return PlacePageHeaderBuilder.build(data: placePageData, delegate: interactor, headerType: .fixed)
- } ()
+ }()
init(interactor: PlacePageInteractor, storyboard: UIStoryboard, data: PlacePageData) {
self.interactor = interactor
@@ -163,7 +163,6 @@ class PlacePageCommonLayout: NSObject, IPlacePageLayout {
}
}
-
// MARK: - PlacePageData async callbacks for loaders
extension PlacePageCommonLayout {
diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageTrackLayout.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageTrackLayout.swift
index 918eab891..1126dc04c 100644
--- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageTrackLayout.swift
+++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageTrackLayout.swift
@@ -17,25 +17,25 @@ class PlacePageTrackLayout: IPlacePageLayout {
placePageNavigationViewController
}
- lazy var headerViewControllers: [UIViewController] = {
+ var headerViewControllers: [UIViewController] {
[headerViewController, previewViewController]
- }()
+ }
lazy var headerViewController: PlacePageHeaderViewController = {
PlacePageHeaderBuilder.build(data: placePageData, delegate: interactor, headerType: .flexible)
}()
- lazy var previewViewController: PlacePagePreviewViewController = {
+ private lazy var previewViewController: PlacePagePreviewViewController = {
let vc = storyboard.instantiateViewController(ofType: PlacePagePreviewViewController.self)
vc.placePagePreviewData = placePageData.previewData
return vc
}()
- lazy var placePageNavigationViewController: PlacePageHeaderViewController = {
+ private lazy var placePageNavigationViewController: PlacePageHeaderViewController = {
return PlacePageHeaderBuilder.build(data: placePageData, delegate: interactor, headerType: .fixed)
}()
- lazy var editTrackViewController: PlacePageEditBookmarkOrTrackViewController = {
+ private lazy var editTrackViewController: PlacePageEditBookmarkOrTrackViewController = {
let vc = storyboard.instantiateViewController(ofType: PlacePageEditBookmarkOrTrackViewController.self)
vc.view.isHidden = true
vc.delegate = interactor
@@ -49,7 +49,7 @@ class PlacePageTrackLayout: IPlacePageLayout {
return ElevationProfileBuilder.build(trackData: trackData, delegate: interactor)
}()
- lazy var actionBarViewController: ActionBarViewController = {
+ private lazy var actionBarViewController: ActionBarViewController = {
let vc = storyboard.instantiateViewController(ofType: ActionBarViewController.self)
vc.placePageData = placePageData
vc.canAddStop = MWMRouter.canAddIntermediatePoint()
diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageTrackRecordingLayout.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageTrackRecordingLayout.swift
index 3dc4c6d5f..3c8f00d0d 100644
--- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageTrackRecordingLayout.swift
+++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageTrackRecordingLayout.swift
@@ -5,7 +5,7 @@ final class PlacePageTrackRecordingLayout: IPlacePageLayout {
weak var presenter: PlacePagePresenterProtocol?
lazy var bodyViewControllers: [UIViewController] = {
- return configureViewControllers()
+ configureViewControllers()
}()
var actionBar: ActionBarViewController? {
@@ -16,19 +16,19 @@ final class PlacePageTrackRecordingLayout: IPlacePageLayout {
placePageNavigationViewController
}
- lazy var headerViewControllers: [UIViewController] = {
+ var headerViewControllers: [UIViewController] {
[headerViewController]
- }()
+ }
lazy var headerViewController: PlacePageHeaderViewController = {
- return PlacePageHeaderBuilder.build(data: placePageData, delegate: interactor, headerType: .flexible)
+ PlacePageHeaderBuilder.build(data: placePageData, delegate: interactor, headerType: .flexible)
}()
- lazy var placePageNavigationViewController: PlacePageHeaderViewController = {
- return PlacePageHeaderBuilder.build(data: placePageData, delegate: interactor, headerType: .fixed)
+ private lazy var placePageNavigationViewController: PlacePageHeaderViewController = {
+ PlacePageHeaderBuilder.build(data: placePageData, delegate: interactor, headerType: .fixed)
}()
- lazy var elevationProfileViewController: ElevationProfileViewController? = {
+ private lazy var elevationProfileViewController: ElevationProfileViewController? = {
guard let trackData = placePageData.trackData else {
return nil
}
@@ -36,7 +36,7 @@ final class PlacePageTrackRecordingLayout: IPlacePageLayout {
delegate: interactor)
}()
- lazy var actionBarViewController: ActionBarViewController = {
+ private lazy var actionBarViewController: ActionBarViewController = {
let vc = storyboard.instantiateViewController(ofType: ActionBarViewController.self)
vc.placePageData = placePageData
vc.canAddStop = MWMRouter.canAddIntermediatePoint()
diff --git a/iphone/Maps/UI/PlacePage/PlacePageViewController.swift b/iphone/Maps/UI/PlacePage/PlacePageViewController.swift
index 37965519a..623825ddd 100644
--- a/iphone/Maps/UI/PlacePage/PlacePageViewController.swift
+++ b/iphone/Maps/UI/PlacePage/PlacePageViewController.swift
@@ -1,5 +1,5 @@
protocol PlacePageViewProtocol: AnyObject {
- var interactor: PlacePageInteractorProtocol! { get set }
+ var interactor: PlacePageInteractorProtocol? { get set }
func setLayout(_ layout: IPlacePageLayout)
func closeAnimated(completion: (() -> Void)?)
@@ -35,7 +35,7 @@ final class PlacePageScrollView: UIScrollView {
stackView.distribution = .fill
return stackView
}()
- var interactor: PlacePageInteractorProtocol!
+ var interactor: PlacePageInteractorProtocol?
var beginDragging = false
var rootViewController: MapViewController {
MapViewController.shared()!
@@ -220,8 +220,13 @@ final class PlacePageScrollView: UIScrollView {
}
private func cleanupLayout() {
- layout?.actionBar?.view.removeFromSuperview()
- layout?.navigationBar?.view.removeFromSuperview()
+ guard let layout else { return }
+ let childViewControllers = [layout.actionBar, layout.navigationBar] + layout.headerViewControllers + layout.bodyViewControllers
+ childViewControllers.forEach {
+ $0?.willMove(toParent: nil)
+ $0?.view.removeFromSuperview()
+ $0?.removeFromParent()
+ }
headerStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
stackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
}
@@ -293,7 +298,7 @@ final class PlacePageScrollView: UIScrollView {
private func updateTopBound(_ bound: CGFloat, duration: TimeInterval) {
alternativeSizeClass(iPhone: {
- interactor.updateTopBound(bound, duration: duration)
+ interactor?.updateTopBound(bound, duration: duration)
}, iPad: {})
}
}