mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-08 05:17:56 +00:00
[iOS] Add Existence and Opening Hour confirmation to Place Page
Signed-off-by: eisa01 <your.email@example.com>
This commit is contained in:
committed by
Yannik Bloscheck
parent
795fe0ee09
commit
d1f9806901
@@ -5,8 +5,7 @@ class PlacePageHeaderBuilder {
|
||||
let storyboard = UIStoryboard.instance(.placePage)
|
||||
let viewController = storyboard.instantiateViewController(ofType: PlacePageHeaderViewController.self);
|
||||
let presenter = PlacePageHeaderPresenter(view: viewController,
|
||||
placePagePreviewData: data.previewData,
|
||||
objectType: data.objectType,
|
||||
placePageData: data,
|
||||
delegate: delegate,
|
||||
headerType: headerType)
|
||||
|
||||
|
||||
@@ -23,26 +23,28 @@ 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,
|
||||
placePagePreviewData: PlacePagePreviewData,
|
||||
objectType: PlacePageObjectType,
|
||||
placePageData: PlacePageData,
|
||||
delegate: PlacePageHeaderViewControllerDelegate?,
|
||||
headerType: HeaderType) {
|
||||
self.view = view
|
||||
self.delegate = delegate
|
||||
self.placePagePreviewData = placePagePreviewData
|
||||
self.objectType = objectType
|
||||
self.placePageData = placePageData
|
||||
self.placePagePreviewData = placePageData.previewData
|
||||
self.objectType = placePageData.objectType
|
||||
self.headerType = headerType
|
||||
}
|
||||
}
|
||||
|
||||
extension PlacePageHeaderPresenter: PlacePageHeaderPresenterProtocol {
|
||||
func configure() {
|
||||
view?.setTitle(placePagePreviewData.title, secondaryTitle: placePagePreviewData.secondaryTitle)
|
||||
let existenceConfirmation = getExistenceConfirmationText()
|
||||
view?.setTitle(placePagePreviewData.title, secondaryTitle: placePagePreviewData.secondaryTitle, existenceConfirmation: existenceConfirmation)
|
||||
switch headerType {
|
||||
case .flexible:
|
||||
view?.isExpandViewHidden = false
|
||||
@@ -68,4 +70,10 @@ 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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ protocol PlacePageHeaderViewProtocol: AnyObject {
|
||||
var isExpandViewHidden: Bool { get set }
|
||||
var isShadowViewHidden: Bool { get set }
|
||||
|
||||
func setTitle(_ title: String?, secondaryTitle: String?)
|
||||
func setTitle(_ title: String?, secondaryTitle: String?, existenceConfirmation: String?)
|
||||
func showShareTrackMenu()
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ extension PlacePageHeaderViewController: PlacePageHeaderViewProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func setTitle(_ title: String?, secondaryTitle: String?) {
|
||||
func setTitle(_ title: String?, secondaryTitle: String?, existenceConfirmation: String? = nil) {
|
||||
titleText = title
|
||||
secondaryText = secondaryTitle
|
||||
// XCode 13 is not smart enough to detect that title is used below, and requires explicit unwrapped variable.
|
||||
@@ -93,6 +93,18 @@ 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
|
||||
|
||||
@@ -40,6 +40,8 @@ final class PlacePagePreviewViewController: UIViewController {
|
||||
}
|
||||
}
|
||||
|
||||
var placePageData: PlacePageData?
|
||||
|
||||
private var distance: String? = nil
|
||||
private var speedAndAltitude: String? = nil
|
||||
private var heading: CGFloat? = nil
|
||||
@@ -84,6 +86,9 @@ 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 {
|
||||
@@ -254,6 +259,16 @@ final class PlacePagePreviewViewController: UIViewController {
|
||||
NSAttributedString.Key.foregroundColor: UIColor.blackSecondaryText()])
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user