[iOS] Add branch to title of place page

Signed-off-by: eisa01 <eisa01@gmail.com>
This commit is contained in:
eisa01
2025-08-25 20:22:14 +02:00
committed by Konstantin Pastbin
parent 2f5f9e15c3
commit c9214d3130
5 changed files with 22 additions and 4 deletions

View File

@@ -27,6 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
@property(nonatomic, readonly, nullable) NSURL *emailUrl;
@property(nonatomic, readonly, nullable) NSString *cuisine;
@property(nonatomic, readonly, nullable) NSString *ppOperator;
@property(nonatomic, readonly, nullable) NSString *branch;
@property(nonatomic, readonly, nullable) NSString *address;
@property(nonatomic, readonly, nullable) NSArray *coordFormats;
@property(nonatomic, readonly, nullable) NSString *wifiAvailable;

View File

@@ -116,6 +116,7 @@ NSDate * _Nullable ParseDateString(NSString * _Nullable dateString) {
case MetadataID::FMD_CONTACT_BLUESKY: _bluesky = ToNSString(value); break;
case MetadataID::FMD_PANORAMAX: _panoramax = ToNSString(value); break;
case MetadataID::FMD_OPERATOR: _ppOperator = [NSString stringWithFormat:NSLocalizedString(@"operator", nil), ToNSString(value)]; break;
case MetadataID::FMD_BRANCH: _branch = ToNSString(value); break;
case MetadataID::FMD_INTERNET:
_wifiAvailable = (rawData.GetInternet() == feature::Internet::No)
? NSLocalizedString(@"no_available", nil) : NSLocalizedString(@"yes_available", nil);

View File

@@ -6,6 +6,7 @@ class PlacePageHeaderBuilder {
let viewController = storyboard.instantiateViewController(ofType: PlacePageHeaderViewController.self);
let presenter = PlacePageHeaderPresenter(view: viewController,
placePagePreviewData: data.previewData,
branch: data.infoData?.branch,
objectType: data.objectType,
delegate: delegate,
headerType: headerType)

View File

@@ -23,18 +23,21 @@ class PlacePageHeaderPresenter {
private weak var view: PlacePageHeaderViewProtocol?
private let placePagePreviewData: PlacePagePreviewData
private let branch: String?
let objectType: PlacePageObjectType
private weak var delegate: PlacePageHeaderViewControllerDelegate?
private let headerType: HeaderType
init(view: PlacePageHeaderViewProtocol,
placePagePreviewData: PlacePagePreviewData,
branch: String?,
objectType: PlacePageObjectType,
delegate: PlacePageHeaderViewControllerDelegate?,
headerType: HeaderType) {
self.view = view
self.delegate = delegate
self.placePagePreviewData = placePagePreviewData
self.branch = branch
self.objectType = objectType
self.headerType = headerType
}
@@ -42,7 +45,7 @@ class PlacePageHeaderPresenter {
extension PlacePageHeaderPresenter: PlacePageHeaderPresenterProtocol {
func configure() {
view?.setTitle(placePagePreviewData.title, secondaryTitle: placePagePreviewData.secondaryTitle)
view?.setTitle(placePagePreviewData.title, secondaryTitle: placePagePreviewData.secondaryTitle, branch: branch)
switch headerType {
case .flexible:
view?.isExpandViewHidden = false

View File

@@ -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?, branch: String?)
func showShareTrackMenu()
}
@@ -21,6 +21,7 @@ class PlacePageHeaderViewController: UIViewController {
private var titleText: String?
private var secondaryText: String?
private var branchText: String?
override func viewDidLoad() {
super.viewDidLoad()
@@ -54,7 +55,7 @@ class PlacePageHeaderViewController: UIViewController {
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
guard traitCollection.userInterfaceStyle != previousTraitCollection?.userInterfaceStyle else { return }
setTitle(titleText, secondaryTitle: secondaryText)
setTitle(titleText, secondaryTitle: secondaryText, branch: branchText)
}
}
@@ -77,9 +78,11 @@ extension PlacePageHeaderViewController: PlacePageHeaderViewProtocol {
}
}
func setTitle(_ title: String?, secondaryTitle: String?) {
func setTitle(_ title: String?, secondaryTitle: String?, branch: String? = nil) {
titleText = title
secondaryText = secondaryTitle
branchText = branch
// XCode 13 is not smart enough to detect that title is used below, and requires explicit unwrapped variable.
guard let unwrappedTitle = title else {
titleLabel?.attributedText = nil
@@ -92,6 +95,15 @@ extension PlacePageHeaderViewController: PlacePageHeaderViewProtocol {
]
let attributedText = NSMutableAttributedString(string: unwrappedTitle, attributes: titleAttributes)
// Add branch with thinner font weight if present and not already in title
if let branch = branch, !branch.isEmpty, !unwrappedTitle.contains(branch) {
let branchAttributes: [NSAttributedString.Key: Any] = [
.font: StyleManager.shared.theme!.fonts.regular20,
.foregroundColor: UIColor.blackPrimaryText()
]
attributedText.append(NSAttributedString(string: " \(branch)", attributes: branchAttributes))
}
guard let unwrappedSecondaryTitle = secondaryTitle else {
titleLabel?.attributedText = attributedText