[iOS][core] Add branch to search result list

Signed-off-by: eisa01 <eisa01@gmail.com>
This commit is contained in:
eisa01
2025-08-25 20:51:59 +02:00
committed by Konstantin Pastbin
parent c9214d3130
commit c039d599e4
6 changed files with 33 additions and 0 deletions

View File

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

View File

@@ -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());

View File

@@ -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];
}