[ios] rename PlacePageBookmarkViewController to the ...BookmarkOrTrack...

Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
Kiryl Kaveryn 2024-12-17 14:57:46 +04:00 committed by Roman Tsisyk
parent 3a5c9aee89
commit 3da20576e1
6 changed files with 63 additions and 58 deletions

View file

@ -413,7 +413,7 @@
999FC12B23ABB4B800B0E6F9 /* FontStyleSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 999FC12A23ABB4B800B0E6F9 /* FontStyleSheet.swift */; };
99A614D523C8911A00D8D8D0 /* AuthStyleSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99A614D423C8911A00D8D8D0 /* AuthStyleSheet.swift */; };
99A614E423CDD1D900D8D8D0 /* UIButton+RuntimeAttributes.m in Sources */ = {isa = PBXBuildFile; fileRef = 99A614E323CDD1D900D8D8D0 /* UIButton+RuntimeAttributes.m */; };
99A906DE23F6F7030005872B /* PlacePageBookmarkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99A906CD23F6F7010005872B /* PlacePageBookmarkViewController.swift */; };
99A906DE23F6F7030005872B /* PlacePageEditBookmarkOrTrackViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99A906CD23F6F7010005872B /* PlacePageEditBookmarkOrTrackViewController.swift */; };
99A906E123F6F7030005872B /* PlacePageButtonsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99A906D023F6F7020005872B /* PlacePageButtonsViewController.swift */; };
99A906E523F6F7030005872B /* ActionBarViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99A906D423F6F7020005872B /* ActionBarViewController.swift */; };
99A906E623F6F7030005872B /* OpeningHoursViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99A906D523F6F7020005872B /* OpeningHoursViewController.swift */; };
@ -1340,7 +1340,7 @@
99A614D423C8911A00D8D8D0 /* AuthStyleSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthStyleSheet.swift; sourceTree = "<group>"; };
99A614E223CDD1D900D8D8D0 /* UIButton+RuntimeAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIButton+RuntimeAttributes.h"; sourceTree = "<group>"; };
99A614E323CDD1D900D8D8D0 /* UIButton+RuntimeAttributes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIButton+RuntimeAttributes.m"; sourceTree = "<group>"; };
99A906CD23F6F7010005872B /* PlacePageBookmarkViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlacePageBookmarkViewController.swift; sourceTree = "<group>"; };
99A906CD23F6F7010005872B /* PlacePageEditBookmarkOrTrackViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlacePageEditBookmarkOrTrackViewController.swift; sourceTree = "<group>"; };
99A906D023F6F7020005872B /* PlacePageButtonsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlacePageButtonsViewController.swift; sourceTree = "<group>"; };
99A906D423F6F7020005872B /* ActionBarViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActionBarViewController.swift; sourceTree = "<group>"; };
99A906D523F6F7020005872B /* OpeningHoursViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OpeningHoursViewController.swift; sourceTree = "<group>"; };
@ -3013,7 +3013,7 @@
children = (
99A906D423F6F7020005872B /* ActionBarViewController.swift */,
99A906D523F6F7020005872B /* OpeningHoursViewController.swift */,
99A906CD23F6F7010005872B /* PlacePageBookmarkViewController.swift */,
99A906CD23F6F7010005872B /* PlacePageEditBookmarkOrTrackViewController.swift */,
99A906D023F6F7020005872B /* PlacePageButtonsViewController.swift */,
99A906D923F6F7030005872B /* PlacePageInfoViewController.swift */,
99A906DC23F6F7030005872B /* PlacePagePreviewViewController.swift */,
@ -4540,7 +4540,7 @@
993DF0B523F6B2EF00AC231A /* PlacePageTrackLayout.swift in Sources */,
44360A0D2A7D34990016F412 /* TransportRuler.swift in Sources */,
CD6E8677226774C700D1EDF7 /* CPConstants.swift in Sources */,
99A906DE23F6F7030005872B /* PlacePageBookmarkViewController.swift in Sources */,
99A906DE23F6F7030005872B /* PlacePageEditBookmarkOrTrackViewController.swift in Sources */,
F6791B141C43DF0B007A8A6E /* MWMStartButton.m in Sources */,
9977E6A12480E1EE0073780C /* BottomMenuLayerButton.swift in Sources */,
471527372491C20500E91BBA /* SelectBookmarkGroupViewController.swift in Sources */,

View file

@ -1,13 +1,13 @@
protocol PlacePageBookmarkViewControllerDelegate: AnyObject {
func bookmarkDidPressEdit()
func trackDidPressEdit()
protocol PlacePageEditBookmarkOrTrackViewControllerDelegate: AnyObject {
func didPressEdit(_ data: PlacePageEditData)
}
final class PlacePageBookmarkViewController: UIViewController {
enum BookmarkData {
case bookmark(PlacePageBookmarkData)
case track(PlacePageTrackData)
}
enum PlacePageEditData {
case bookmark(PlacePageBookmarkData)
case track(PlacePageTrackData)
}
final class PlacePageEditBookmarkOrTrackViewController: UIViewController {
@IBOutlet var stackView: UIStackView!
@IBOutlet var spinner: UIImageView!
@ -23,22 +23,29 @@ final class PlacePageBookmarkViewController: UIViewController {
}
}
var bookmarkData: BookmarkData? {
var data: PlacePageEditData? {
didSet {
updateViews()
}
}
weak var delegate: PlacePageBookmarkViewControllerDelegate?
weak var delegate: PlacePageEditBookmarkOrTrackViewControllerDelegate?
override func viewDidLoad() {
super.viewDidLoad()
updateViews()
}
func updateViews() {
guard let bookmarkData else { return }
override func applyTheme() {
super.applyTheme()
updateViews()
}
// MARK: - Private methods
private func updateViews() {
guard let data else { return }
editButton.isEnabled = true
switch bookmarkData {
switch data {
case .bookmark(let bookmark):
editButton.setTitle(L("placepage_edit_bookmark_button"), for: .normal)
if let description = bookmark.bookmarkDescription {
@ -99,18 +106,10 @@ final class PlacePageBookmarkViewController: UIViewController {
spinner.stopRotation()
}
// MARK: - Actions
@IBAction func onEdit(_ sender: UIButton) {
guard let bookmarkData else { return }
switch bookmarkData {
case .bookmark:
delegate?.bookmarkDidPressEdit()
case .track:
delegate?.trackDidPressEdit()
}
}
override func applyTheme() {
super.applyTheme()
updateViews()
guard let data else { return }
delegate?.didPressEdit(data)
}
}

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23094" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="bX8-ZQ-XDA">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="bX8-ZQ-XDA">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="Stack View standard spacing" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
@ -1199,10 +1199,10 @@
</objects>
<point key="canvasLocation" x="929" y="2168"/>
</scene>
<!--Place Page Bookmark View Controller-->
<!--Place Page Edit Bookmark Or Track View Controller-->
<scene sceneID="clb-tD-Svo">
<objects>
<viewController storyboardIdentifier="PlacePageBookmarkViewController" id="cB4-oj-3Tv" customClass="PlacePageBookmarkViewController" customModule="Organic_Maps" customModuleProvider="target" sceneMemberID="viewController">
<viewController storyboardIdentifier="PlacePageEditBookmarkOrTrackViewController" id="cB4-oj-3Tv" customClass="PlacePageEditBookmarkOrTrackViewController" customModule="Organic_Maps" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="bRD-Uv-Uak">
<rect key="frame" x="0.0" y="0.0" width="375" height="200"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
@ -1441,6 +1441,7 @@
</view>
<size key="freeformSize" width="375" height="319"/>
<connections>
<outlet property="chartHeightConstraint" destination="utH-YA-2pe" id="ee1-mM-L7n"/>
<outlet property="chartView" destination="jIS-0e-Ztd" id="KHY-Bn-Pe6"/>
<outlet property="descriptionCollectionView" destination="Xc9-ED-V4K" id="dHB-dH-HYE"/>
<outlet property="difficultyConstraint" destination="vaG-aV-kw5" id="fkz-u2-wYh"/>

View file

@ -175,15 +175,16 @@ extension PlacePageInteractor: PlacePageButtonsViewControllerDelegate {
}
}
// MARK: - PlacePageBookmarkViewControllerDelegate
// MARK: - PlacePageEditBookmarkOrTrackViewControllerDelegate
extension PlacePageInteractor: PlacePageBookmarkViewControllerDelegate {
func bookmarkDidPressEdit() {
MWMPlacePageManagerHelper.editBookmark(placePageData)
}
func trackDidPressEdit() {
MWMPlacePageManagerHelper.editTrack(placePageData)
extension PlacePageInteractor: PlacePageEditBookmarkOrTrackViewControllerDelegate {
func didPressEdit(_ data: PlacePageEditData) {
switch data {
case .bookmark(let placePageBookmarkData):
MWMPlacePageManagerHelper.editBookmark(placePageData)
case .track(let placePageTrackData):
MWMPlacePageManagerHelper.editTrack(placePageData)
}
}
}

View file

@ -43,8 +43,8 @@ class PlacePageCommonLayout: NSObject, IPlacePageLayout {
return vc
} ()
lazy var bookmarkViewController: PlacePageBookmarkViewController = {
let vc = storyboard.instantiateViewController(ofType: PlacePageBookmarkViewController.self)
lazy var editBookmarkViewController: PlacePageEditBookmarkOrTrackViewController = {
let vc = storyboard.instantiateViewController(ofType: PlacePageEditBookmarkOrTrackViewController.self)
vc.view.isHidden = true
vc.delegate = interactor
return vc
@ -101,10 +101,10 @@ class PlacePageCommonLayout: NSObject, IPlacePageLayout {
}
}
viewControllers.append(bookmarkViewController)
viewControllers.append(editBookmarkViewController)
if let bookmarkData = placePageData.bookmarkData {
bookmarkViewController.bookmarkData = .bookmark(bookmarkData)
bookmarkViewController.view.isHidden = false
editBookmarkViewController.data = .bookmark(bookmarkData)
editBookmarkViewController.view.isHidden = false
}
if placePageData.infoData != nil {
@ -183,7 +183,7 @@ extension PlacePageCommonLayout {
func updateBookmarkRelatedSections() {
var isBookmark = false
if let bookmarkData = placePageData.bookmarkData {
bookmarkViewController.bookmarkData = .bookmark(bookmarkData)
editBookmarkViewController.data = .bookmark(bookmarkData)
isBookmark = true
}
if let title = placePageData.previewData.title, let headerViewController = headerViewControllers.compactMap({ $0 as? PlacePageHeaderViewController }).first {
@ -193,7 +193,7 @@ extension PlacePageCommonLayout {
}
presenter?.layoutIfNeeded()
UIView.animate(withDuration: kDefaultAnimationDuration) { [unowned self] in
self.bookmarkViewController.view.isHidden = !isBookmark
self.editBookmarkViewController.view.isHidden = !isBookmark
}
}
}

View file

@ -1,5 +1,6 @@
class PlacePageTrackLayout: IPlacePageLayout {
private var placePageData: PlacePageData
private var trackData: PlacePageTrackData
private var interactor: PlacePageInteractor
private let storyboard: UIStoryboard
weak var presenter: PlacePagePresenterProtocol?
@ -34,19 +35,20 @@ class PlacePageTrackLayout: IPlacePageLayout {
return PlacePageHeaderBuilder.build(data: placePageData.previewData, delegate: interactor, headerType: .fixed)
}()
lazy var bookmarkViewController: PlacePageBookmarkViewController = {
let vc = storyboard.instantiateViewController(ofType: PlacePageBookmarkViewController.self)
lazy var editTrackViewController: PlacePageEditBookmarkOrTrackViewController = {
let vc = storyboard.instantiateViewController(ofType: PlacePageEditBookmarkOrTrackViewController.self)
vc.view.isHidden = true
vc.delegate = interactor
return vc
}()
lazy var elevationMapViewController: ElevationProfileViewController? = {
guard let trackData = placePageData.trackData else {
guard trackData.trackInfo.hasElevationInfo(),
let elevationProfileData = trackData.elevationProfileData else {
return nil
}
return ElevationProfileBuilder.build(trackInfo: trackData.trackInfo,
elevationProfileData: trackData.elevationProfileData,
elevationProfileData: elevationProfileData,
delegate: interactor)
}()
@ -63,16 +65,18 @@ class PlacePageTrackLayout: IPlacePageLayout {
self.interactor = interactor
self.storyboard = storyboard
self.placePageData = data
guard let trackData = data.trackData else {
fatalError("PlacePageData must contain trackData for the PlacePageTrackLayout")
}
self.trackData = trackData
}
private func configureViewControllers() -> [UIViewController] {
var viewControllers = [UIViewController]()
viewControllers.append(bookmarkViewController)
if let trackData = placePageData.trackData {
bookmarkViewController.bookmarkData = .track(trackData)
bookmarkViewController.view.isHidden = false
}
viewControllers.append(editTrackViewController)
editTrackViewController.view.isHidden = false
editTrackViewController.data = .track(trackData)
placePageData.onBookmarkStatusUpdate = { [weak self] in
guard let self = self else { return }
@ -114,7 +118,7 @@ private extension PlacePageTrackLayout {
presenter?.closeAnimated()
return
}
bookmarkViewController.bookmarkData = .track(trackData)
editTrackViewController.data = .track(trackData)
let previewData = placePageData.previewData
if let headerViewController = headerViewControllers.compactMap({ $0 as? PlacePageHeaderViewController }).first {
headerViewController.setTitle(previewData.title, secondaryTitle: previewData.secondaryTitle)