diff options
author | VladiMihaylenko <vxmihaylenko@gmail.com> | 2016-02-09 17:52:06 +0300 |
---|---|---|
committer | Sergey Yershov <yershov@corp.mail.ru> | 2016-03-23 16:17:02 +0300 |
commit | 90ae342debbd23a26bc7110385a0d77a496c6aa8 (patch) | |
tree | c4b339fdfc889d39bc9216bd92e8c9c2429265af | |
parent | fc54d06072f725332fe6bbd96c22483ee3b66e67 (diff) |
[ios] Review fixes.
-rw-r--r-- | iphone/Maps/Classes/Editor/Cuisine/MWMCuisineEditorViewController.mm | 26 | ||||
-rw-r--r-- | iphone/Maps/Classes/MapsAppDelegate.mm | 7 |
2 files changed, 20 insertions, 13 deletions
diff --git a/iphone/Maps/Classes/Editor/Cuisine/MWMCuisineEditorViewController.mm b/iphone/Maps/Classes/Editor/Cuisine/MWMCuisineEditorViewController.mm index 5959b168f8..7ab181c00e 100644 --- a/iphone/Maps/Classes/Editor/Cuisine/MWMCuisineEditorViewController.mm +++ b/iphone/Maps/Classes/Editor/Cuisine/MWMCuisineEditorViewController.mm @@ -34,12 +34,17 @@ namespace - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { - self.filtredKeys = [_cuisineKeys filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSString * value, NSDictionary<NSString *,id> *) + if (!searchText.length) + { + self.filtredKeys = nil; + return; + } + NSLocale * locale = [NSLocale currentLocale]; + NSString * query = [searchText lowercaseStringWithLocale:locale]; + self.filtredKeys = [self.cuisineKeys filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSString * value, NSDictionary<NSString *,id> *) { - if (!searchText.length) - return YES; NSString * cuisine = [NSString stringWithFormat:@"cuisine_%@", value]; - return [[L(cuisine) capitalizedStringWithLocale:[NSLocale currentLocale]] containsString:searchText]; + return [[L(cuisine) lowercaseStringWithLocale:locale] containsString:query]; }]]; } @@ -51,11 +56,8 @@ namespace - (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar { - if (searchBar.text.length == 0) - { + if (!searchBar.text.length) [self searchBar:searchBar setActiveState:NO]; - self.filtredKeys = nil; - } return YES; } @@ -137,9 +139,9 @@ namespace #pragma mark - Accessors -- (NSArray<NSString *> *)cuisineKeys +- (NSArray<NSString *> *)displayKeys { - return self.filtredKeys != nil ? self.filtredKeys : _cuisineKeys; + return self.filtredKeys != nil ? self.filtredKeys : self.cuisineKeys; } - (void)setFiltredKeys:(NSArray<NSString *> *)filtredKeys @@ -180,7 +182,7 @@ namespace - (NSInteger)tableView:(UITableView * _Nonnull)tableView numberOfRowsInSection:(NSInteger)section { - return self.cuisineKeys.count; + return self.displayKeys.count; } #pragma mark - UITableViewDelegate @@ -188,7 +190,7 @@ namespace - (void)tableView:(UITableView * _Nonnull)tableView willDisplayCell:(MWMCuisineEditorTableViewCell * _Nonnull)cell forRowAtIndexPath:(NSIndexPath * _Nonnull)indexPath { NSInteger const index = indexPath.row; - NSString * cuisine = self.cuisineKeys[index]; + NSString * cuisine = self.displayKeys[index]; BOOL const selected = [self.selectedCuisines containsObject:cuisine]; [cell configWithDelegate:self key:cuisine selected:selected]; } diff --git a/iphone/Maps/Classes/MapsAppDelegate.mm b/iphone/Maps/Classes/MapsAppDelegate.mm index 4db6419c88..03c95a0db3 100644 --- a/iphone/Maps/Classes/MapsAppDelegate.mm +++ b/iphone/Maps/Classes/MapsAppDelegate.mm @@ -666,7 +666,12 @@ using namespace osm_auth_ios; UISearchBar * searchBar = [UISearchBar appearance]; searchBar.barTintColor = [UIColor primary]; - UITextField * textFieldInSearchBar = [UITextField appearanceWhenContainedIn:[UISearchBar class], nil]; + UITextField * textFieldInSearchBar = nil; + if (isIOS7 || isIOS8) + textFieldInSearchBar = [UITextField appearanceWhenContainedIn:[UISearchBar class], nil]; + else + textFieldInSearchBar = [UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]]; + textField.backgroundColor = [UIColor white]; textFieldInSearchBar.defaultTextAttributes = @{NSForegroundColorAttributeName : [UIColor blackPrimaryText]}; } |