mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-08 05:17:56 +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];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user