From 49391bb39e9585e56d95b480c0352575205040ce Mon Sep 17 00:00:00 2001 From: Yannik Bloscheck Date: Wed, 27 Aug 2025 16:30:29 +0200 Subject: [PATCH] [ios] Improved text thickness in combination with branch name Signed-off-by: Yannik Bloscheck --- iphone/Maps/Categories/UIColor+MapsMeColor.h | 1 + iphone/Maps/Categories/UIColor+MapsMeColor.m | 5 +++ iphone/Maps/Core/Theme/Colors.swift | 2 + .../Maps/Core/Theme/Components/IColors.swift | 1 + .../Maps/Core/Theme/Components/IFonts.swift | 1 + iphone/Maps/Core/Theme/FontStyleSheet.swift | 2 + iphone/Maps/Core/Theme/Fonts.swift | 1 + .../PlacePageHeaderViewController.swift | 2 +- iphone/Maps/UI/PlacePage/PlacePage.storyboard | 2 +- .../Maps/UI/Search/TableView/MWMSearchCell.mm | 38 +++++++++---------- .../Search/TableView/MWMSearchCommonCell.mm | 4 +- .../Search/TableView/MWMSearchCommonCell.xib | 2 +- 12 files changed, 36 insertions(+), 25 deletions(-) diff --git a/iphone/Maps/Categories/UIColor+MapsMeColor.h b/iphone/Maps/Categories/UIColor+MapsMeColor.h index 56a295c43..8c6372c37 100644 --- a/iphone/Maps/Categories/UIColor+MapsMeColor.h +++ b/iphone/Maps/Categories/UIColor+MapsMeColor.h @@ -4,6 +4,7 @@ NS_ASSUME_NONNULL_BEGIN @interface UIColor (MapsMeColor) ++ (UIColor *)black; + (UIColor *)blackPrimaryText; + (UIColor *)blackSecondaryText; + (UIColor *)blackHintText; diff --git a/iphone/Maps/Categories/UIColor+MapsMeColor.m b/iphone/Maps/Categories/UIColor+MapsMeColor.m index b59ea90fb..11bb911ff 100644 --- a/iphone/Maps/Categories/UIColor+MapsMeColor.m +++ b/iphone/Maps/Categories/UIColor+MapsMeColor.m @@ -68,6 +68,11 @@ static BOOL isNightMode = NO; { return StyleManager.shared.theme.colors.buttonRed; } ++ (UIColor *)black +{ + return StyleManager.shared.theme.colors.black; +} + + (UIColor *)blackPrimaryText { return StyleManager.shared.theme.colors.blackPrimaryText; diff --git a/iphone/Maps/Core/Theme/Colors.swift b/iphone/Maps/Core/Theme/Colors.swift index 42fd89e92..799f7481c 100644 --- a/iphone/Maps/Core/Theme/Colors.swift +++ b/iphone/Maps/Core/Theme/Colors.swift @@ -21,6 +21,7 @@ class DayColors: IColors { var linkBlueDark = UIColor.accent var buttonRed = UIColor(244, 67, 67, alpha100) var buttonRedHighlighted = UIColor(183, 28, 28, alpha100) + var black = UIColor(0, 0, 0, alpha100) var blackPrimaryText = UIColor(0, 0, 0, alpha87) var blackSecondaryText = UIColor(0, 0, 0, alpha54) var blackHintText = UIColor(0, 0, 0, alpha26) @@ -83,6 +84,7 @@ class NightColors: IColors { var linkBlueDark = UIColor.accent var buttonRed = UIColor(244, 67, 67, alpha100) var buttonRedHighlighted = UIColor(183, 28, 28, alpha100) + var black = UIColor(255, 255, 255, alpha100) var blackPrimaryText = UIColor(255, 255, 255, alpha90) var blackSecondaryText = UIColor(255, 255, 255, alpha70) var blackHintText = UIColor(255, 255, 255, alpha30) diff --git a/iphone/Maps/Core/Theme/Components/IColors.swift b/iphone/Maps/Core/Theme/Components/IColors.swift index 9c33d2947..6ae5df274 100644 --- a/iphone/Maps/Core/Theme/Components/IColors.swift +++ b/iphone/Maps/Core/Theme/Components/IColors.swift @@ -32,6 +32,7 @@ let alpha100: CGFloat = 1.0 var linkBlueDark: UIColor { get } var buttonRed: UIColor { get } var buttonRedHighlighted: UIColor { get } + var black: UIColor { get } var blackPrimaryText: UIColor { get } var blackSecondaryText: UIColor { get } var blackHintText: UIColor { get } diff --git a/iphone/Maps/Core/Theme/Components/IFonts.swift b/iphone/Maps/Core/Theme/Components/IFonts.swift index 6bcdadef6..c85e48967 100644 --- a/iphone/Maps/Core/Theme/Components/IFonts.swift +++ b/iphone/Maps/Core/Theme/Components/IFonts.swift @@ -56,4 +56,5 @@ var semibold15: UIFont { get } var semibold16: UIFont { get } var semibold18: UIFont { get } + var semibold20: UIFont { get } } diff --git a/iphone/Maps/Core/Theme/FontStyleSheet.swift b/iphone/Maps/Core/Theme/FontStyleSheet.swift index fc7da2766..80784a79a 100644 --- a/iphone/Maps/Core/Theme/FontStyleSheet.swift +++ b/iphone/Maps/Core/Theme/FontStyleSheet.swift @@ -60,6 +60,7 @@ enum FontStyleSheet: String, CaseIterable { case semibold15 case semibold16 case semibold18 + case semibold20 } extension FontStyleSheet: IStyleSheet { @@ -127,6 +128,7 @@ extension FontStyleSheet: IStyleSheet { case .semibold15: return fonts.semibold15 case .semibold16: return fonts.semibold16 case .semibold18: return fonts.semibold18 + case .semibold20: return fonts.semibold20 } }() return .add { s in s.font = font } diff --git a/iphone/Maps/Core/Theme/Fonts.swift b/iphone/Maps/Core/Theme/Fonts.swift index 718b0d7b7..2faae7b21 100644 --- a/iphone/Maps/Core/Theme/Fonts.swift +++ b/iphone/Maps/Core/Theme/Fonts.swift @@ -55,4 +55,5 @@ class Fonts: IFonts { var semibold15 = UIFont.systemFont(ofSize: 15, weight:UIFont.Weight.semibold) var semibold16 = UIFont.systemFont(ofSize: 16, weight:UIFont.Weight.semibold) var semibold18 = UIFont.systemFont(ofSize: 18, weight:UIFont.Weight.semibold) + var semibold20 = UIFont.systemFont(ofSize: 20, weight:UIFont.Weight.semibold) } diff --git a/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderViewController.swift b/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderViewController.swift index 245277497..ef3524cea 100644 --- a/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderViewController.swift +++ b/iphone/Maps/UI/PlacePage/Components/PlacePageHeader/PlacePageHeaderViewController.swift @@ -90,7 +90,7 @@ extension PlacePageHeaderViewController: PlacePageHeaderViewProtocol { } let titleAttributes: [NSAttributedString.Key: Any] = [ - .font: StyleManager.shared.theme!.fonts.medium20, + .font: StyleManager.shared.theme!.fonts.semibold20, .foregroundColor: UIColor.blackPrimaryText() ] diff --git a/iphone/Maps/UI/PlacePage/PlacePage.storyboard b/iphone/Maps/UI/PlacePage/PlacePage.storyboard index 891a528e3..04efc099c 100644 --- a/iphone/Maps/UI/PlacePage/PlacePage.storyboard +++ b/iphone/Maps/UI/PlacePage/PlacePage.storyboard @@ -1349,7 +1349,7 @@ diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchCell.mm b/iphone/Maps/UI/Search/TableView/MWMSearchCell.mm index 2e37792b0..cda34efc2 100644 --- a/iphone/Maps/UI/Search/TableView/MWMSearchCell.mm +++ b/iphone/Maps/UI/Search/TableView/MWMSearchCell.mm @@ -17,42 +17,40 @@ self.titleLabel.text = @""; return; } - + + bool hasBranchName = (result.branchText && result.branchText.length > 0 && ![title containsString:result.branchText]); + NSDictionary * selectedTitleAttributes = [self selectedTitleAttributes]; NSDictionary * unselectedTitleAttributes = [self unselectedTitleAttributes]; - if (!selectedTitleAttributes || !unselectedTitleAttributes) + if ((!selectedTitleAttributes || !unselectedTitleAttributes) && !hasBranchName) { self.titleLabel.text = title; return; } - + NSMutableAttributedString * attributedTitle = [[NSMutableAttributedString alloc] initWithString:title]; - NSDictionary * titleAttributes = isPartialMatching ? unselectedTitleAttributes : selectedTitleAttributes; NSArray *highlightRanges = result.highlightRanges; - [attributedTitle addAttributes:titleAttributes range:NSMakeRange(0, title.length)]; + [attributedTitle addAttributes:unselectedTitleAttributes range:NSMakeRange(0, title.length)]; + + // Add branch with thinner font weight if present and not already in title + if (hasBranchName) { + NSMutableDictionary * branchAttributes = [unselectedTitleAttributes mutableCopy]; + [branchAttributes setValue:[UIFont regular17] forKey:NSFontAttributeName]; + NSAttributedString * branchString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@", result.branchText] attributes:branchAttributes]; + [attributedTitle appendAttributedString:branchString]; + } for (NSValue *rangeValue in highlightRanges) { NSRange range = [rangeValue rangeValue]; - if (NSMaxRange(range) <= result.titleText.length) { - [attributedTitle addAttributes:selectedTitleAttributes range:range]; + if (NSMaxRange(range) <= attributedTitle.string.length) { + [attributedTitle setAttributes:selectedTitleAttributes range:range]; } else { - NSLog(@"Incorrect range: %@ for string: %@", NSStringFromRange(range), result.titleText); + NSLog(@"Incorrect range: %@ for string: %@", NSStringFromRange(range), attributedTitle.string); } } - - // Add branch with thinner font weight if present and not already in title - if (result.branchText && result.branchText.length > 0 && ![title containsString:result.branchText]) { - NSDictionary * branchAttributes = isPartialMatching ? unselectedTitleAttributes : @{ - NSForegroundColorAttributeName : [selectedTitleAttributes objectForKey:NSForegroundColorAttributeName], - NSFontAttributeName : [UIFont regular17] - }; - NSAttributedString * branchString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@" %@", result.branchText] - attributes:branchAttributes]; - [attributedTitle appendAttributedString:branchString]; - } - + self.titleLabel.attributedText = attributedTitle; [self.titleLabel sizeToFit]; } diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.mm b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.mm index dd8d8356b..a34e41afc 100644 --- a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.mm +++ b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.mm @@ -44,7 +44,7 @@ - (NSDictionary *)selectedTitleAttributes { return @{ - NSForegroundColorAttributeName : [UIColor blackPrimaryText], + NSForegroundColorAttributeName : [UIColor black], NSFontAttributeName : [UIFont bold17] }; } @@ -52,7 +52,7 @@ - (NSDictionary *)unselectedTitleAttributes { return @{ NSForegroundColorAttributeName : [UIColor blackPrimaryText], - NSFontAttributeName : [UIFont regular17] + NSFontAttributeName : [UIFont medium17] }; } diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.xib b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.xib index 5390a8422..1184f45c2 100644 --- a/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.xib +++ b/iphone/Maps/UI/Search/TableView/MWMSearchCommonCell.xib @@ -20,7 +20,7 @@