[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

@@ -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