Files
comaps/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderPresenter.swift
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

74 lines
2.2 KiB
Swift

protocol PlacePageHeaderPresenterProtocol: AnyObject {
var objectType: PlacePageObjectType { get }
func configure()
func onClosePress()
func onExpandPress()
func onShareButtonPress(from sourceView: UIView)
func onExportTrackButtonPress(_ type: KmlFileType, from sourceView: UIView)
}
protocol PlacePageHeaderViewControllerDelegate: AnyObject {
func previewDidPressClose()
func previewDidPressExpand()
func previewDidPressShare(from sourceView: UIView)
func previewDidPressExportTrack(_ type: KmlFileType, from sourceView: UIView)
}
class PlacePageHeaderPresenter {
enum HeaderType {
case flexible
case fixed
}
private weak var view: PlacePageHeaderViewProtocol?
private let placePagePreviewData: PlacePagePreviewData
let objectType: PlacePageObjectType
private weak var delegate: PlacePageHeaderViewControllerDelegate?
private let headerType: HeaderType
init(view: PlacePageHeaderViewProtocol,
placePagePreviewData: PlacePagePreviewData,
objectType: PlacePageObjectType,
delegate: PlacePageHeaderViewControllerDelegate?,
headerType: HeaderType) {
self.view = view
self.delegate = delegate
self.placePagePreviewData = placePagePreviewData
self.objectType = objectType
self.headerType = headerType
}
}
extension PlacePageHeaderPresenter: PlacePageHeaderPresenterProtocol {
func configure() {
view?.setTitle(placePagePreviewData.title, secondaryTitle: placePagePreviewData.secondaryTitle)
switch headerType {
case .flexible:
view?.isExpandViewHidden = false
view?.isShadowViewHidden = true
case .fixed:
view?.isExpandViewHidden = true
view?.isShadowViewHidden = false
}
// TODO: (KK) Enable share button for the tracks to share the whole track gpx/kml
view?.isShareButtonHidden = false
}
func onClosePress() {
delegate?.previewDidPressClose()
}
func onExpandPress() {
delegate?.previewDidPressExpand()
}
func onShareButtonPress(from sourceView: UIView) {
delegate?.previewDidPressShare(from: sourceView)
}
func onExportTrackButtonPress(_ type: KmlFileType, from sourceView: UIView) {
delegate?.previewDidPressExportTrack(type, from: sourceView)
}
}