From 165692657cf992f4a72652b3de05fa00c61b45ea Mon Sep 17 00:00:00 2001 From: Kiryl Kaveryn Date: Tue, 10 Dec 2024 17:47:54 +0400 Subject: [PATCH] [ios] add separators to the PlacePage views programmaticalay The separators that was created in the storyboards and xibs is very hard to find/select/edit/change width and color. This is why they should be configured and added programmatically. Signed-off-by: Kiryl Kaveryn --- .../PlacePageInfoViewController.swift | 4 +- iphone/Maps/UI/PlacePage/PlacePage.storyboard | 119 +----------------- .../PlacePage/PlacePageViewController.swift | 37 +++--- 3 files changed, 24 insertions(+), 136 deletions(-) diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift b/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift index 53cd28b8a5..da2c9f3ba1 100644 --- a/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift +++ b/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift @@ -455,9 +455,7 @@ class PlacePageInfoViewController: UIViewController { private extension UIStackView { func addArrangedSubviewWithSeparator(_ view: UIView, insets: UIEdgeInsets = .zero) { if !arrangedSubviews.isEmpty { - view.addSeparator(thickness: CGFloat(1.0), - color: StyleManager.shared.theme?.colors.blackDividers, - insets: insets) + view.addSeparator(thickness: CGFloat(1.0), insets: insets) } addArrangedSubview(view) } diff --git a/iphone/Maps/UI/PlacePage/PlacePage.storyboard b/iphone/Maps/UI/PlacePage/PlacePage.storyboard index 10eae05f46..a9980cd36c 100644 --- a/iphone/Maps/UI/PlacePage/PlacePage.storyboard +++ b/iphone/Maps/UI/PlacePage/PlacePage.storyboard @@ -287,27 +287,14 @@ - - - - - - - - - - - - - @@ -376,41 +363,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -439,40 +400,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -564,40 +499,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1298,16 +1207,6 @@ - - - - - - - - - - @@ -1357,30 +1256,14 @@ - - - - - - - - - - - - - - + - - - diff --git a/iphone/Maps/UI/PlacePage/PlacePageViewController.swift b/iphone/Maps/UI/PlacePage/PlacePageViewController.swift index 590d3635bd..7ccb4812bb 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageViewController.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageViewController.swift @@ -172,8 +172,8 @@ final class PlacePageScrollView: UIScrollView { private func setupLayout(_ layout: IPlacePageLayout) { setLayout(layout) - layout.headerViewControllers.forEach({ addToHeader($0) }) - layout.bodyViewControllers.forEach({ addToBody($0) }) + fillHeader(with: layout.headerViewControllers) + fillBody(with: layout.bodyViewControllers) beginDragging = false if let actionBar = layout.actionBar { @@ -184,6 +184,26 @@ final class PlacePageScrollView: UIScrollView { } } + private func fillHeader(with viewControllers: [UIViewController]) { + viewControllers.forEach { [self] viewController in + if !stackView.arrangedSubviews.contains(headerStackView) { + stackView.addArrangedSubview(headerStackView) + } + headerStackView.addArrangedSubview(viewController.view) + } + headerStackView.addSeparator(.bottom) + } + + private func fillBody(with viewControllers: [UIViewController]) { + viewControllers.forEach { [self] viewController in + addChild(viewController) + stackView.addArrangedSubview(viewController.view) + viewController.didMove(toParent: self) + viewController.view.addSeparator(.top) + viewController.view.addSeparator(.bottom) + } + } + private func cleanupLayout() { layout?.actionBar?.view.removeFromSuperview() layout?.navigationBar?.view.removeFromSuperview() @@ -237,13 +257,6 @@ extension PlacePageViewController: PlacePageViewProtocol { actionBarHeightConstraint.constant = !value ? Constants.actionBarHeight : .zero } - func addToHeader(_ headerViewController: UIViewController) { - if !stackView.arrangedSubviews.contains(headerStackView) { - stackView.addArrangedSubview(headerStackView) - } - headerStackView.addArrangedSubview(headerViewController.view) - } - func updatePreviewOffset() { updateSteps() if !beginDragging { @@ -252,12 +265,6 @@ extension PlacePageViewController: PlacePageViewProtocol { } } - func addToBody(_ viewController: UIViewController) { - addChild(viewController) - stackView.addArrangedSubview(viewController.view) - viewController.didMove(toParent: self) - } - func addActionBar(_ actionBarViewController: UIViewController) { addChild(actionBarViewController) actionBarViewController.view.translatesAutoresizingMaskIntoConstraints = false