mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 13:23:59 +00:00
[iOS][core] Add branch to search result list
Signed-off-by: eisa01 <eisa01@gmail.com>
This commit is contained in:
committed by
Konstantin Pastbin
parent
c9214d3130
commit
c039d599e4
@@ -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;
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user