diff --git a/iphone/Maps/Categories/Date+TimeAgo.swift b/iphone/Maps/Categories/Date+TimeAgo.swift deleted file mode 100644 index be1e60ad5..000000000 --- a/iphone/Maps/Categories/Date+TimeAgo.swift +++ /dev/null @@ -1,13 +0,0 @@ -import Foundation - -extension Date { - func formatTimeAgo() -> String { - return Self.relativeFormatter.localizedString(for: self, relativeTo: Date()) - } - - private static let relativeFormatter: RelativeDateTimeFormatter = { - let formatter = RelativeDateTimeFormatter() - formatter.unitsStyle = .full - return formatter - }() -} \ No newline at end of file diff --git a/iphone/Maps/Images.xcassets/Place Page/Press Background Color.colorset/Contents.json b/iphone/Maps/Images.xcassets/Place Page/Press Background Color.colorset/Contents.json new file mode 100644 index 000000000..87b87e8a0 --- /dev/null +++ b/iphone/Maps/Images.xcassets/Place Page/Press Background Color.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.961", + "green" : "0.961", + "red" : "0.961" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0.118", + "green" : "0.110", + "red" : "0.110" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/iphone/Maps/LocalizedStrings/en-GB.lproj/Localizable.strings b/iphone/Maps/LocalizedStrings/en-GB.lproj/Localizable.strings index 6493bbf29..ef24a760a 100644 --- a/iphone/Maps/LocalizedStrings/en-GB.lproj/Localizable.strings +++ b/iphone/Maps/LocalizedStrings/en-GB.lproj/Localizable.strings @@ -533,6 +533,10 @@ "editor_report_problem_send_button" = "Send"; "autodownload" = "Auto-download maps"; +/* Place page confirmation messages and time ago formatting */ +"existence_confirmed_time_ago" = "Existence confirmed %@"; +"hours_confirmed_time_ago" = "Confirmed %@"; + /* Place Page opening hours text */ "closed_now" = "Closed now"; diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 8cf5747b1..0fbc548b7 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -321,7 +321,6 @@ 676507601C10559800830BB3 /* patterns.txt in Resources */ = {isa = PBXBuildFile; fileRef = 451950391B7A3E070085DA05 /* patterns.txt */; }; 676507611C10559B00830BB3 /* colors.txt in Resources */ = {isa = PBXBuildFile; fileRef = 452FCA3A1B6A3DF7007019AB /* colors.txt */; }; 6B9978361C89A316003B8AA0 /* editor.config in Resources */ = {isa = PBXBuildFile; fileRef = 6B9978341C89A316003B8AA0 /* editor.config */; }; - 8325C4E12E45519600457516 /* Date+TimeAgo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8325C4E02E45519600457516 /* Date+TimeAgo.swift */; }; 8C4FB9C72BEFEFF400D44877 /* CarPlayWindowScaleAdjuster.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8C4FB9C62BEFEFF400D44877 /* CarPlayWindowScaleAdjuster.swift */; }; 8CB13C3B2BF1276A004288F2 /* CarplayPlaceholderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8CB13C3A2BF1276A004288F2 /* CarplayPlaceholderView.swift */; }; 99012847243F0D6900C72B10 /* UIViewController+alternative.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99012846243F0D6900C72B10 /* UIViewController+alternative.swift */; }; @@ -1209,7 +1208,6 @@ 5605022E1B6211E100169CAD /* sound-strings */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "sound-strings"; path = "../../data/sound-strings"; sourceTree = ""; }; 6741AA5D1BF340DE002C974C /* CoMaps (Debug).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "CoMaps (Debug).app"; sourceTree = BUILT_PRODUCTS_DIR; }; 6B9978341C89A316003B8AA0 /* editor.config */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = editor.config; path = ../../data/editor.config; sourceTree = ""; }; - 8325C4E02E45519600457516 /* Date+TimeAgo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+TimeAgo.swift"; sourceTree = ""; }; 8C4FB9C62BEFEFF400D44877 /* CarPlayWindowScaleAdjuster.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarPlayWindowScaleAdjuster.swift; sourceTree = ""; }; 8CB13C3A2BF1276A004288F2 /* CarplayPlaceholderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CarplayPlaceholderView.swift; sourceTree = ""; }; 8D1107310486CEB800E47090 /* CoMaps.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = CoMaps.plist; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; @@ -2287,7 +2285,6 @@ 3454D7981E07F045004AF2AD /* Categories */ = { isa = PBXGroup; children = ( - 8325C4E02E45519600457516 /* Date+TimeAgo.swift */, ED83880E2D54DEA4002A0536 /* UIImage+FilledWithColor.swift */, 99A614E223CDD1D900D8D8D0 /* UIButton+RuntimeAttributes.h */, 99A614E323CDD1D900D8D8D0 /* UIButton+RuntimeAttributes.m */, @@ -4640,7 +4637,6 @@ 998927382449E60200260CE2 /* BottomMenuPresenter.swift in Sources */, 27697F832E254AA100FBD913 /* EmbeddedSafariView.swift in Sources */, F6E2FE821E097BA00083EBEC /* MWMPlacePageOpeningHoursDayView.m in Sources */, - 8325C4E12E45519600457516 /* Date+TimeAgo.swift in Sources */, F6E2FD6B1E097BA00083EBEC /* MWMMapDownloaderSubplaceTableViewCell.m in Sources */, CDCA27842245090900167D87 /* ListenerContainer.swift in Sources */, 27AF18582E1DB63A00CD41E2 /* Appearance.swift in Sources */, diff --git a/iphone/Maps/UI/PlacePage/Components/OpeningHoursViewController.swift b/iphone/Maps/UI/PlacePage/Components/OpeningHoursViewController.swift index 835055edf..8e5b0e769 100644 --- a/iphone/Maps/UI/PlacePage/Components/OpeningHoursViewController.swift +++ b/iphone/Maps/UI/PlacePage/Components/OpeningHoursViewController.swift @@ -43,6 +43,9 @@ class OpeningHoursDayViewController: UIViewController { class OpeningHoursViewController: UIViewController { @IBOutlet var stackView: UIStackView! + @IBOutlet var checkDateLabel: UILabel! + @IBOutlet var checkDateLabelTopLayoutConstraint: NSLayoutConstraint! + @IBOutlet var checkDateLabelBottomLayoutConstraint: NSLayoutConstraint! private var otherDaysViews: [OpeningHoursDayViewController] = [] @@ -56,6 +59,7 @@ class OpeningHoursViewController: UIViewController { private var expanded = false var openingHours: OpeningHours! + var openingHoursCheckDate: Date? override func viewDidLoad() { super.viewDidLoad() @@ -79,6 +83,23 @@ class OpeningHoursViewController: UIViewController { self.otherDaysViews.forEach { vc in vc.view.isHidden = !self.expanded } + + if let checkDate = self.openingHoursCheckDate, self.expanded { + let checkDateFormatter = RelativeDateTimeFormatter() + checkDateFormatter.unitsStyle = .spellOut + checkDateFormatter.localizedString(for: checkDate, relativeTo: Date.now) + self.checkDateLabel.text = String(format: L("hours_confirmed_time_ago"), checkDateFormatter.localizedString(for: checkDate, relativeTo: Date.now)) + + NSLayoutConstraint.activate([self.checkDateLabelTopLayoutConstraint]) + NSLayoutConstraint.activate([self.checkDateLabelBottomLayoutConstraint]) + } else { + self.checkDateLabel.text = String() + + NSLayoutConstraint.deactivate([self.checkDateLabelTopLayoutConstraint]) + NSLayoutConstraint.deactivate([self.checkDateLabelBottomLayoutConstraint]) + } + self.checkDateLabel.isHidden = !self.expanded + self.todayView.arrowImageView.transform = self.expanded ? CGAffineTransform(rotationAngle: -CGFloat.pi + 0.01) : CGAffineTransform.identity self.view.layoutIfNeeded() diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderBuilder.swift b/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderBuilder.swift index 389a2da89..73d52a8e5 100644 --- a/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderBuilder.swift +++ b/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderBuilder.swift @@ -5,7 +5,8 @@ class PlacePageHeaderBuilder { let storyboard = UIStoryboard.instance(.placePage) let viewController = storyboard.instantiateViewController(ofType: PlacePageHeaderViewController.self); let presenter = PlacePageHeaderPresenter(view: viewController, - placePageData: data, + placePagePreviewData: data.previewData, + objectType: data.objectType, delegate: delegate, headerType: headerType) diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderPresenter.swift b/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderPresenter.swift index 169dfd25f..daf2b7f32 100644 --- a/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderPresenter.swift +++ b/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderPresenter.swift @@ -23,28 +23,26 @@ class PlacePageHeaderPresenter { private weak var view: PlacePageHeaderViewProtocol? private let placePagePreviewData: PlacePagePreviewData - private let placePageData: PlacePageData let objectType: PlacePageObjectType private weak var delegate: PlacePageHeaderViewControllerDelegate? private let headerType: HeaderType init(view: PlacePageHeaderViewProtocol, - placePageData: PlacePageData, + placePagePreviewData: PlacePagePreviewData, + objectType: PlacePageObjectType, delegate: PlacePageHeaderViewControllerDelegate?, headerType: HeaderType) { self.view = view self.delegate = delegate - self.placePageData = placePageData - self.placePagePreviewData = placePageData.previewData - self.objectType = placePageData.objectType + self.placePagePreviewData = placePagePreviewData + self.objectType = objectType self.headerType = headerType } } extension PlacePageHeaderPresenter: PlacePageHeaderPresenterProtocol { func configure() { - let existenceConfirmation = getExistenceConfirmationText() - view?.setTitle(placePagePreviewData.title, secondaryTitle: placePagePreviewData.secondaryTitle, existenceConfirmation: existenceConfirmation) + view?.setTitle(placePagePreviewData.title, secondaryTitle: placePagePreviewData.secondaryTitle) switch headerType { case .flexible: view?.isExpandViewHidden = false @@ -70,10 +68,4 @@ extension PlacePageHeaderPresenter: PlacePageHeaderPresenterProtocol { func onExportTrackButtonPress(_ type: KmlFileType, from sourceView: UIView) { delegate?.previewDidPressExportTrack(type, from: sourceView) } - - private func getExistenceConfirmationText() -> String? { - guard let mostRecentDate = placePageData.infoData?.getMostRecentCheckDate() else { return nil } - let timeAgoText = mostRecentDate.formatTimeAgo() - return String(format: L("existence_confirmed_time_ago"), timeAgoText) - } } diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderViewController.swift b/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderViewController.swift index f04804a03..b77bfda01 100644 --- a/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderViewController.swift +++ b/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderViewController.swift @@ -3,7 +3,7 @@ protocol PlacePageHeaderViewProtocol: AnyObject { var isExpandViewHidden: Bool { get set } var isShadowViewHidden: Bool { get set } - func setTitle(_ title: String?, secondaryTitle: String?, existenceConfirmation: String?) + func setTitle(_ title: String?, secondaryTitle: String?) func showShareTrackMenu() } @@ -77,7 +77,7 @@ extension PlacePageHeaderViewController: PlacePageHeaderViewProtocol { } } - func setTitle(_ title: String?, secondaryTitle: String?, existenceConfirmation: String? = nil) { + func setTitle(_ title: String?, secondaryTitle: String?) { titleText = title secondaryText = secondaryTitle // XCode 13 is not smart enough to detect that title is used below, and requires explicit unwrapped variable. @@ -93,18 +93,6 @@ extension PlacePageHeaderViewController: PlacePageHeaderViewProtocol { let attributedText = NSMutableAttributedString(string: unwrappedTitle, attributes: titleAttributes) - // Add existence confirmation if available - if let existenceText = existenceConfirmation { - let existenceParagraphStyle = NSMutableParagraphStyle() - existenceParagraphStyle.paragraphSpacingBefore = 1 - let existenceAttributes: [NSAttributedString.Key: Any] = [ - .font: UIFont.systemFont(ofSize: 11), - .foregroundColor: UIColor.blackSecondaryText(), - .paragraphStyle: existenceParagraphStyle - ] - attributedText.append(NSAttributedString(string: "\n" + existenceText, attributes: existenceAttributes)) - } - guard let unwrappedSecondaryTitle = secondaryTitle else { titleLabel?.attributedText = attributedText return diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift b/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift index b04e0938b..d148e3586 100644 --- a/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift +++ b/iphone/Maps/UI/PlacePage/Components/PlacePageInfoViewController.swift @@ -159,6 +159,8 @@ class PlacePageInfoViewController: UIViewController { private typealias Style = InfoItemView.Style @IBOutlet var stackView: UIStackView! + @IBOutlet var checkDateLabel: UILabel! + @IBOutlet var checkDateLabelLayoutConstraint: NSLayoutConstraint! private lazy var openingHoursViewController: OpeningHoursViewController = { storyboard!.instantiateViewController(ofType: OpeningHoursViewController.self) @@ -207,13 +209,8 @@ class PlacePageInfoViewController: UIViewController { stackView.alignment = .fill stackView.spacing = 0 stackView.translatesAutoresizingMaskIntoConstraints = false + stackView.addSeparator(.bottom) view.addSubview(stackView) - NSLayoutConstraint.activate([ - stackView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - stackView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - stackView.topAnchor.constraint(equalTo: view.topAnchor), - stackView.bottomAnchor.constraint(equalTo: view.bottomAnchor) - ]) setupViews() } @@ -221,6 +218,7 @@ class PlacePageInfoViewController: UIViewController { private func setupViews() { if let openingHours = placePageInfoData.openingHours { openingHoursViewController.openingHours = openingHours + openingHoursViewController.openingHoursCheckDate = placePageInfoData.checkDateOpeningHours addChild(openingHoursViewController) addToStack(openingHoursViewController.view) openingHoursViewController.didMove(toParent: self) @@ -436,7 +434,7 @@ class PlacePageInfoViewController: UIViewController { }) } - if let panoramax = placePageInfoData.panoramax { + if let panoramax = placePageInfoData.panoramax { panoramaxView = createInfoItem(L("panoramax_picture"), icon: UIImage(named: "ic_placepage_panoramax"), style: .link, @@ -458,6 +456,19 @@ class PlacePageInfoViewController: UIViewController { setupCoordinatesView() setupOpenWithAppView() + + if let checkDate = placePageInfoData.checkDate { + let checkDateFormatter = RelativeDateTimeFormatter() + checkDateFormatter.unitsStyle = .spellOut + checkDateFormatter.localizedString(for: checkDate, relativeTo: Date.now) + self.checkDateLabel.text = String(format: L("existence_confirmed_time_ago"), checkDateFormatter.localizedString(for: checkDate, relativeTo: Date.now)) + checkDateLabel.isHidden = false + NSLayoutConstraint.activate([checkDateLabelLayoutConstraint]) + } else { + checkDateLabel.text = String() + checkDateLabel.isHidden = true + NSLayoutConstraint.deactivate([checkDateLabelLayoutConstraint]) + } } private func setupCoordinatesView() { diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePagePreviewViewController.swift b/iphone/Maps/UI/PlacePage/Components/PlacePagePreviewViewController.swift index 638d6b533..77a564457 100644 --- a/iphone/Maps/UI/PlacePage/Components/PlacePagePreviewViewController.swift +++ b/iphone/Maps/UI/PlacePage/Components/PlacePagePreviewViewController.swift @@ -40,8 +40,6 @@ final class PlacePagePreviewViewController: UIViewController { } } - var placePageData: PlacePageData? - private var distance: String? = nil private var speedAndAltitude: String? = nil private var heading: CGFloat? = nil @@ -86,9 +84,6 @@ final class PlacePagePreviewViewController: UIViewController { subtitleString.append(NSAttributedString(string: !subtitleString.string.isEmpty ? " • " + subtitle : subtitle, attributes: [.foregroundColor : UIColor.blackSecondaryText(), .font : UIFont.regular14()])) - } - - if !subtitleString.string.isEmpty { subtitleLabel.attributedText = subtitleString subtitleContainerView.isHidden = false } else { @@ -260,15 +255,6 @@ final class PlacePagePreviewViewController: UIViewController { attributedString.append(detailsString) } - if let openingHoursDate = placePageData?.infoData?.checkDateOpeningHours { - let timeAgoText = openingHoursDate.formatTimeAgo() - let openingHoursDateString = NSAttributedString(string: " • " + String(format: L("hours_confirmed_time_ago"), timeAgoText), - attributes: [NSAttributedString.Key.font: UIFont.regular12(), - NSAttributedString.Key.foregroundColor: UIColor.blackSecondaryText()]) - attributedString.append(openingHoursDateString) - } - scheduleLabel.attributedText = attributedString } - } diff --git a/iphone/Maps/UI/PlacePage/PlacePage.storyboard b/iphone/Maps/UI/PlacePage/PlacePage.storyboard index fb1963bfe..891a528e3 100644 --- a/iphone/Maps/UI/PlacePage/PlacePage.storyboard +++ b/iphone/Maps/UI/PlacePage/PlacePage.storyboard @@ -4,6 +4,7 @@ + @@ -391,16 +392,39 @@ - + + + + + + + + + + + + + + + - + + + + @@ -409,6 +433,8 @@ + + @@ -526,18 +552,38 @@ + - - + + + + + + + + + + + + + + + @@ -1243,7 +1289,7 @@ - + @@ -1404,14 +1450,20 @@ + + + + + + - + - + diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageCommonLayout.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageCommonLayout.swift index e72bf933a..151ba5054 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageCommonLayout.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageCommonLayout.swift @@ -33,7 +33,6 @@ class PlacePageCommonLayout: NSObject, IPlacePageLayout { private lazy var previewViewController: PlacePagePreviewViewController = { let vc = storyboard.instantiateViewController(ofType: PlacePagePreviewViewController.self) vc.placePagePreviewData = placePageData.previewData - vc.placePageData = placePageData return vc }() @@ -111,7 +110,6 @@ class PlacePageCommonLayout: NSObject, IPlacePageLayout { guard let self = self else { return } self.actionBarViewController.updateBookmarkButtonState(isSelected: self.placePageData.bookmarkData != nil) self.previewViewController.placePagePreviewData = self.placePageData.previewData - self.previewViewController.placePageData = self.placePageData self.updateBookmarkRelatedSections() } diff --git a/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageTrackLayout.swift b/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageTrackLayout.swift index 3759de22e..1126dc04c 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageTrackLayout.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageLayout/Layouts/PlacePageTrackLayout.swift @@ -28,7 +28,6 @@ class PlacePageTrackLayout: IPlacePageLayout { private lazy var previewViewController: PlacePagePreviewViewController = { let vc = storyboard.instantiateViewController(ofType: PlacePagePreviewViewController.self) vc.placePagePreviewData = placePageData.previewData - vc.placePageData = placePageData return vc }() @@ -81,7 +80,6 @@ class PlacePageTrackLayout: IPlacePageLayout { placePageData.onBookmarkStatusUpdate = { [weak self] in guard let self = self else { return } self.previewViewController.placePagePreviewData = self.placePageData.previewData - self.previewViewController.placePageData = self.placePageData self.updateTrackRelatedSections() } @@ -115,7 +113,6 @@ private extension PlacePageTrackLayout { } if let previewViewController = headerViewControllers.compactMap({ $0 as? PlacePagePreviewViewController }).first { previewViewController.placePagePreviewData = previewData - previewViewController.placePageData = self.placePageData previewViewController.updateViews() } presenter?.layoutIfNeeded() diff --git a/iphone/Maps/UI/PlacePage/PlacePageViewController.swift b/iphone/Maps/UI/PlacePage/PlacePageViewController.swift index 623825ddd..ad642e1f6 100644 --- a/iphone/Maps/UI/PlacePage/PlacePageViewController.swift +++ b/iphone/Maps/UI/PlacePage/PlacePageViewController.swift @@ -214,7 +214,9 @@ final class PlacePageScrollView: UIScrollView { viewController.didMove(toParent: self) if showSeparator { viewController.view.addSeparator(.top) - viewController.view.addSeparator(.bottom) + if !(viewController is PlacePageInfoViewController) { + viewController.view.addSeparator(.bottom) + } } } }