diff --git a/iphone/Maps/Core/Search/SearchResult.h b/iphone/Maps/Core/Search/SearchResult.h index f3d425b1d..9c4b0307a 100644 --- a/iphone/Maps/Core/Search/SearchResult.h +++ b/iphone/Maps/Core/Search/SearchResult.h @@ -9,6 +9,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) NSUInteger index; @property (nonatomic, readonly) NSString * titleText; +@property (nonatomic, readonly, nullable) NSString * branchText; @property (nonatomic, readonly) NSString * iconImageName; @property (nonatomic, readonly) NSString * addressText; @property (nonatomic, readonly) NSString * infoText; diff --git a/iphone/Maps/Core/Search/SearchResult.mm b/iphone/Maps/Core/Search/SearchResult.mm index 64c656276..00308e41e 100644 --- a/iphone/Maps/Core/Search/SearchResult.mm +++ b/iphone/Maps/Core/Search/SearchResult.mm @@ -33,6 +33,7 @@ _titleText = result.GetString().empty() ? @(result.GetLocalizedFeatureType().c_str()) : @(result.GetString().c_str()); _addressText = @(result.GetAddress().c_str()); _infoText = @(result.GetFeatureDescription().c_str()); + _branchText = result.GetBranch().empty() ? nil : @(result.GetBranch().c_str()); if (result.IsSuggest()) _suggestion = @(result.GetSuggestionString().c_str()); diff --git a/iphone/Maps/UI/Search/TableView/MWMSearchCell.mm b/iphone/Maps/UI/Search/TableView/MWMSearchCell.mm index e447d19f7..2e37792b0 100644 --- a/iphone/Maps/UI/Search/TableView/MWMSearchCell.mm +++ b/iphone/Maps/UI/Search/TableView/MWMSearchCell.mm @@ -25,6 +25,7 @@ self.titleLabel.text = title; return; } + NSMutableAttributedString * attributedTitle = [[NSMutableAttributedString alloc] initWithString:title]; NSDictionary * titleAttributes = isPartialMatching ? unselectedTitleAttributes : selectedTitleAttributes; @@ -40,6 +41,18 @@ NSLog(@"Incorrect range: %@ for string: %@", NSStringFromRange(range), result.titleText); } } + + // 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/libs/search/ranker.cpp b/libs/search/ranker.cpp index c7f7a8bf7..455101c66 100644 --- a/libs/search/ranker.cpp +++ b/libs/search/ranker.cpp @@ -732,6 +732,16 @@ Result Ranker::MakeResult(RankerResult const & rankerResult, bool needAddress, b case RankerResult::Type::Building: res.FromFeature(rankerResult.GetID(), rankerResult.GetBestType(), rankerResult.GetBestType(&m_params.m_preferredTypes), rankerResult.m_details); + + // Extract branch metadata if available + if (rankerResult.GetID().IsValid()) + { + m_dataSource.ReadFeature([&](FeatureType & ft) { + auto const branch = ft.GetMetadata(feature::Metadata::FMD_BRANCH); + if (!branch.empty()) + res.SetBranch(std::string(branch)); + }, rankerResult.GetID()); + } break; case RankerResult::Type::LatLon: res.SetType(Result::Type::LatLon); break; case RankerResult::Type::Postcode: res.SetType(Result::Type::Postcode); break; diff --git a/libs/search/result.cpp b/libs/search/result.cpp index 92d4257d4..38ca38274 100644 --- a/libs/search/result.cpp +++ b/libs/search/result.cpp @@ -134,6 +134,11 @@ string const & Result::GetSuggestionString() const return m_suggestionStr; } +string Result::GetBranch() const +{ + return m_branch; +} + bool Result::IsEqualSuggest(Result const & r) const { return m_suggestionStr == r.m_suggestionStr; diff --git a/libs/search/result.hpp b/libs/search/result.hpp index a7a3c13c3..b639310fe 100644 --- a/libs/search/result.hpp +++ b/libs/search/result.hpp @@ -62,6 +62,7 @@ public: void FromFeature(FeatureID const & id, uint32_t mainType, uint32_t matchedType, Details const & details); void SetAddress(std::string && address) { m_address = std::move(address); } + void SetBranch(std::string && branch) { m_branch = std::move(branch); } void SetType(Result::Type type) { m_resultType = type; } // For Type::PureSuggest. @@ -75,6 +76,7 @@ public: std::string const & GetString() const { return m_str; } std::string const & GetAddress() const { return m_address; } std::string const & GetDescription() const { return m_details.m_description; } + std::string GetBranch() const; osm::YesNoUnknown IsOpenNow() const { return m_details.m_isOpenNow; } uint16_t GetMinutesUntilOpen() const { return m_details.m_minutesUntilOpen; } @@ -152,6 +154,7 @@ private: m2::PointD m_center; std::string m_str; std::string m_address; + std::string m_branch; uint32_t m_mainType = 0; uint32_t m_matchedType = 0; std::string m_suggestionStr;