2
0

Dismiss search when tapped outside.

This commit is contained in:
Maarten Billemont 2014-03-20 16:49:33 -04:00
parent d3d4aeea41
commit f475c15360
3 changed files with 20 additions and 4 deletions

2
External/Pearl vendored

@ -1 +1 @@
Subproject commit 673217287de2920d21ef84f1d6811d8250f187b4
Subproject commit b50115c767e7c0d412099ae169891dbb625b8c64

View File

@ -29,6 +29,7 @@
@property(assign, nonatomic) BOOL active;
@property(nonatomic, copy) NSString *originalQuery;
- (void)setActive:(BOOL)active animated:(BOOL)animated;
@end

View File

@ -33,6 +33,7 @@
__weak id _storeObserver;
__weak id _mocObserver;
NSArray *_notificationObservers;
__weak UITapGestureRecognizer *_passwordsDismissRecognizer;
}
- (void)viewDidLoad {
@ -133,11 +134,13 @@
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar {
if (searchBar == self.passwordsSearchBar) {
self.originalQuery = self.query;
self.passwordsSearchBar.showsCancelButton = YES;
_passwordsDismissRecognizer = [self.view dismissKeyboardForField:self.passwordsSearchBar onTouchForced:NO];
[UIView animateWithDuration:0.3f animations:^{
self.passwordCollectionView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
}];
// [UIView animateWithDuration:0.3f animations:^{
// self.passwordCollectionView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
// }];
}
}
@ -145,6 +148,8 @@
if (searchBar == self.passwordsSearchBar) {
self.passwordsSearchBar.showsCancelButton = NO;
if (_passwordsDismissRecognizer)
[self.view removeGestureRecognizer:_passwordsDismissRecognizer];
[UIView animateWithDuration:0.3f animations:^{
self.passwordCollectionView.backgroundColor = [UIColor clearColor];
@ -152,9 +157,19 @@
}
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
[searchBar resignFirstResponder];
}
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
[searchBar resignFirstResponder];
if (searchBar == self.passwordsSearchBar) {
self.passwordsSearchBar.text = self.originalQuery;
[self updatePasswords];
}
}
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {