Added search in text of some components
Summary: Added a possibility to search for the text not only in name and id of components but also in text for all components, that conforms to a protocol <SKTextSearchable> Reviewed By: priteshrnandgaonkar Differential Revision: D16108297 fbshipit-source-id: 31da4ac6762c487ef644d62c9576d9eff43e8cd4
This commit is contained in:
committed by
Facebook Github Bot
parent
6e1483edfa
commit
7551b6da04
@@ -8,6 +8,7 @@
|
||||
#if FB_SONARKIT_ENABLED
|
||||
|
||||
#import "SKNodeDescriptor.h"
|
||||
#import <FlipperKitLayoutTextSearchable/FKTextSearchable.h>
|
||||
|
||||
@implementation SKNodeDescriptor
|
||||
{
|
||||
@@ -71,7 +72,13 @@
|
||||
|
||||
- (BOOL)matchesQuery:(NSString *)query forNode:(id)node {
|
||||
NSString *name = [self nameForNode: node];
|
||||
return [self string:name contains:query] || [self string:[self identifierForNode: node] contains: query];
|
||||
NSString *text = nil;
|
||||
if ([node conformsToProtocol:@protocol(FKTextSearchable)]) {
|
||||
text = [node searchableText];
|
||||
}
|
||||
return [self string:name contains:query] ||
|
||||
[self string:[self identifierForNode: node] contains: query] ||
|
||||
[self string:text contains:query];
|
||||
}
|
||||
|
||||
- (BOOL)string:(NSString *)string contains:(NSString *)substring {
|
||||
@@ -80,4 +87,5 @@
|
||||
|
||||
@end
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user