mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-22 06:03:45 +00:00
[ios] refactor search - use SearchQuery class instead of text+locale+isCategory
Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
committed by
Konstantin Pastbin
parent
09171651ff
commit
96c24cf973
@@ -2,6 +2,8 @@
|
||||
#import "MWMCarPlaySearchResultObject.h"
|
||||
#import "MWMSearch.h"
|
||||
|
||||
#import "SwiftBridge.h"
|
||||
|
||||
API_AVAILABLE(ios(12.0))
|
||||
@interface MWMCarPlaySearchService ()<MWMSearchObserver>
|
||||
@property(strong, nonatomic, nullable) void (^completionHandler)(NSArray<MWMCarPlaySearchResultObject *> *searchResults);
|
||||
@@ -30,12 +32,14 @@ API_AVAILABLE(ios(12.0))
|
||||
self.lastResults = @[];
|
||||
self.completionHandler = completionHandler;
|
||||
/// @todo Didn't find pure category request in CarPlay.
|
||||
[MWMSearch searchQuery:text forInputLocale:inputLocale withCategory:NO];
|
||||
SearchQuery * query = [[SearchQuery alloc] init:text locale:inputLocale source:SearchTextSourceTypedText];
|
||||
[MWMSearch searchQuery:query];
|
||||
}
|
||||
|
||||
- (void)saveLastQuery {
|
||||
if (self.lastQuery != nil && self.inputLocale != nil) {
|
||||
[MWMSearch saveQuery:self.lastQuery forInputLocale:self.inputLocale];
|
||||
SearchQuery * query = [[SearchQuery alloc] init:self.lastQuery locale:self.inputLocale source:SearchTextSourceTypedText];
|
||||
[MWMSearch saveQuery:query];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
@class MapViewController;
|
||||
@class BottomTabBarViewController;
|
||||
@class TrackRecordingViewController;
|
||||
@class SearchQuery;
|
||||
|
||||
@protocol MWMFeatureHolder;
|
||||
|
||||
@@ -45,8 +46,8 @@
|
||||
#pragma mark - MWMSearchManager
|
||||
|
||||
- (void)actionDownloadMaps:(MWMMapDownloaderMode)mode;
|
||||
- (BOOL)searchText:(NSString *)text forInputLocale:(NSString *)locale;
|
||||
- (void)searchTextOnMap:(NSString *)text forInputLocale:(NSString *)locale;
|
||||
- (BOOL)search:(SearchQuery *)query;
|
||||
- (void)searchOnMap:(SearchQuery *)query;
|
||||
|
||||
#pragma mark - MWMFeatureHolder
|
||||
|
||||
|
||||
@@ -104,19 +104,19 @@ NSString *const kMapToCategorySelectorSegue = @"MapToCategorySelectorSegue";
|
||||
|
||||
#pragma mark - MWMPlacePageViewManager
|
||||
|
||||
- (void)searchTextOnMap:(NSString *)text forInputLocale:(NSString *)locale {
|
||||
if (![self searchText:text forInputLocale:locale])
|
||||
- (void)searchOnMap:(SearchQuery *)query {
|
||||
if (![self search:query])
|
||||
return;
|
||||
|
||||
[self.searchManager startSearchingWithIsRouting:NO];
|
||||
}
|
||||
|
||||
- (BOOL)searchText:(NSString *)text forInputLocale:(NSString *)locale {
|
||||
if (text.length == 0)
|
||||
- (BOOL)search:(SearchQuery *)query {
|
||||
if (query.text.length == 0)
|
||||
return NO;
|
||||
|
||||
[self.searchManager startSearchingWithIsRouting:NO];
|
||||
[self.searchManager searchText:text locale:locale isCategory:NO];
|
||||
[self.searchManager searchText:query];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
@@ -193,10 +193,11 @@ BOOL defaultOrientation(CGSize const &size) {
|
||||
|
||||
- (IBAction)searchButtonTouchUpInside:(MWMButton *)sender {
|
||||
auto const body = ^(NavigationSearchState state) {
|
||||
NSString *query = [kSearchButtonRequest.at(state) stringByAppendingString:@" "];
|
||||
NSString *locale = [[AppInfo sharedInfo] languageId];
|
||||
NSString * text = [kSearchButtonRequest.at(state) stringByAppendingString:@" "];
|
||||
NSString * locale = [[AppInfo sharedInfo] languageId];
|
||||
// Category request from navigation search wheel.
|
||||
[MWMSearch searchQuery:query forInputLocale:locale withCategory:YES];
|
||||
SearchQuery * query = [[SearchQuery alloc] init:text locale:locale source:SearchTextSourceCategory];
|
||||
[MWMSearch searchQuery:query];
|
||||
[self setSearchState:state animated:YES];
|
||||
};
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
- (void)openEditor;
|
||||
- (void)openBookmarkEditor;
|
||||
- (void)openFullPlaceDescriptionWithHtml:(NSString *_Nonnull)htmlString;
|
||||
- (void)searchText:(NSString *_Nonnull)text;
|
||||
- (void)openDrivingOptions;
|
||||
|
||||
- (void)setPlacePageTopBound:(CGFloat)bound duration:(double)duration;
|
||||
|
||||
@@ -612,10 +612,6 @@ NSString *const kSettingsSegue = @"Map2Settings";
|
||||
[self.navigationController pushViewController:descriptionViewController animated:YES];
|
||||
}
|
||||
|
||||
- (void)searchText:(NSString *)text {
|
||||
[self.controlsManager searchText:text forInputLocale:[[AppInfo sharedInfo] languageId]];
|
||||
}
|
||||
|
||||
- (void)openDrivingOptions {
|
||||
UIStoryboard *sb = [UIStoryboard instance:MWMStoryboardDrivingOptions];
|
||||
UIViewController *vc = [sb instantiateInitialViewController];
|
||||
|
||||
@@ -85,9 +85,10 @@ using namespace osm_auth_ios;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
[[MWMMapViewControlsManager manager] searchText:[searchString stringByAppendingString:@" "]
|
||||
forInputLocale:[MWMSettings spotlightLocaleLanguageId]];
|
||||
SearchQuery * query = [[SearchQuery alloc] init:[searchString stringByAppendingString:@" "]
|
||||
locale:[MWMSettings spotlightLocaleLanguageId]
|
||||
source:SearchTextSourceDeeplink];
|
||||
[[MWMMapViewControlsManager manager] search:query];
|
||||
}
|
||||
|
||||
- (void)commonInit {
|
||||
|
||||
Reference in New Issue
Block a user