2014-10-02 15:02:47 +00:00
|
|
|
/*
|
2015-04-03 13:02:16 +00:00
|
|
|
Copyright 2015 OpenMarket Ltd
|
2014-10-02 15:02:47 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2014-10-03 17:26:39 +00:00
|
|
|
#import "RecentsViewController.h"
|
|
|
|
#import "RoomViewController.h"
|
2014-10-02 15:02:47 +00:00
|
|
|
|
2014-10-09 17:06:30 +00:00
|
|
|
#import "AppDelegate.h"
|
|
|
|
|
2015-04-03 13:02:16 +00:00
|
|
|
#import "RageShakeManager.h"
|
|
|
|
|
2014-10-15 14:13:35 +00:00
|
|
|
@interface RecentsViewController () {
|
2014-12-02 14:25:00 +00:00
|
|
|
|
2015-05-22 20:32:05 +00:00
|
|
|
// Recents refresh handling
|
2015-04-03 13:02:16 +00:00
|
|
|
BOOL shouldScrollToTopOnRefresh;
|
2014-11-21 15:01:35 +00:00
|
|
|
|
2015-05-21 17:06:34 +00:00
|
|
|
// Selected room description
|
|
|
|
NSString *selectedRoomId;
|
|
|
|
MXSession *selectedRoomSession;
|
|
|
|
|
2015-02-13 13:07:03 +00:00
|
|
|
// Keep reference on the current room view controller to release it correctly
|
2014-11-21 13:26:34 +00:00
|
|
|
RoomViewController *currentRoomViewController;
|
2015-02-13 13:07:03 +00:00
|
|
|
|
|
|
|
// Keep the selected cell index to handle correctly split view controller display in landscape mode
|
2015-05-21 11:12:21 +00:00
|
|
|
NSIndexPath *currentSelectedCellIndexPath;
|
2015-06-10 13:46:59 +00:00
|
|
|
|
|
|
|
// Mark all as read alert
|
|
|
|
MXKAlert *currentAlert;
|
2014-10-15 14:13:35 +00:00
|
|
|
}
|
2014-10-02 15:02:47 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
2014-10-03 17:26:39 +00:00
|
|
|
@implementation RecentsViewController
|
2014-10-02 15:02:47 +00:00
|
|
|
|
|
|
|
- (void)awakeFromNib {
|
|
|
|
[super awakeFromNib];
|
|
|
|
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
|
|
|
|
self.preferredContentSize = CGSizeMake(320.0, 600.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
[super viewDidLoad];
|
|
|
|
// Do any additional setup after loading the view, typically from a nib.
|
|
|
|
self.navigationItem.leftBarButtonItem = self.editButtonItem;
|
|
|
|
|
2015-05-22 20:32:05 +00:00
|
|
|
// Add navigation items
|
|
|
|
NSArray *rightBarButtonItems = self.navigationItem.rightBarButtonItems;
|
2014-10-13 12:45:29 +00:00
|
|
|
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(createNewRoom:)];
|
2015-05-22 20:32:05 +00:00
|
|
|
self.navigationItem.rightBarButtonItems = rightBarButtonItems ? [rightBarButtonItems arrayByAddingObject:addButton] : @[addButton];
|
2014-10-09 17:06:30 +00:00
|
|
|
|
2015-06-10 13:46:59 +00:00
|
|
|
// Add tap gesture on title bar
|
|
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onNavigationBarTap:)];
|
|
|
|
[tap setNumberOfTouchesRequired:1];
|
|
|
|
[tap setNumberOfTapsRequired:1];
|
|
|
|
[tap setDelegate:self];
|
|
|
|
[self.navigationController.navigationBar addGestureRecognizer:tap];
|
|
|
|
self.navigationController.navigationBar.userInteractionEnabled = YES;
|
|
|
|
|
2014-10-15 14:13:35 +00:00
|
|
|
// Initialisation
|
2015-05-21 11:12:21 +00:00
|
|
|
currentSelectedCellIndexPath = nil;
|
2014-11-21 15:01:35 +00:00
|
|
|
|
2015-04-03 13:02:16 +00:00
|
|
|
// Setup `MXKRecentListViewController` properties
|
|
|
|
self.rageShakeManager = [RageShakeManager sharedManager];
|
2014-12-11 13:41:02 +00:00
|
|
|
|
2015-04-03 13:02:16 +00:00
|
|
|
// The view controller handles itself the selected recent
|
|
|
|
self.delegate = self;
|
2014-10-09 17:06:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc {
|
2014-11-21 13:26:34 +00:00
|
|
|
if (currentRoomViewController) {
|
2015-04-01 09:06:48 +00:00
|
|
|
[currentRoomViewController destroy];
|
2014-12-08 13:43:34 +00:00
|
|
|
currentRoomViewController = nil;
|
2014-11-21 13:26:34 +00:00
|
|
|
}
|
2015-05-21 17:06:34 +00:00
|
|
|
selectedRoomId = nil;
|
|
|
|
selectedRoomSession = nil;
|
2015-04-03 13:02:16 +00:00
|
|
|
}
|
|
|
|
|
2015-06-10 13:46:59 +00:00
|
|
|
- (void)destroy
|
|
|
|
{
|
|
|
|
if (currentAlert)
|
|
|
|
{
|
|
|
|
[currentAlert dismiss:NO];
|
|
|
|
currentAlert = nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
[super destroy];
|
|
|
|
}
|
|
|
|
|
2015-04-03 13:02:16 +00:00
|
|
|
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
|
|
|
|
[super setEditing:editing animated:animated];
|
2014-11-21 15:01:35 +00:00
|
|
|
|
2015-05-22 20:32:05 +00:00
|
|
|
self.recentsTableView.editing = editing;
|
2014-10-02 15:02:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
|
|
[super didReceiveMemoryWarning];
|
|
|
|
// Dispose of any resources that can be recreated.
|
|
|
|
}
|
|
|
|
|
2014-10-09 17:06:30 +00:00
|
|
|
- (void)viewWillAppear:(BOOL)animated {
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
2015-06-10 13:46:59 +00:00
|
|
|
[self updateNavigationBarTitle];
|
2015-02-17 15:29:52 +00:00
|
|
|
|
2015-04-29 13:27:43 +00:00
|
|
|
// Deselect the current selected row, it will be restored on viewDidAppear (if any)
|
2015-05-22 20:32:05 +00:00
|
|
|
NSIndexPath *indexPath = [self.recentsTableView indexPathForSelectedRow];
|
2015-04-29 13:27:43 +00:00
|
|
|
if (indexPath) {
|
2015-05-22 20:32:05 +00:00
|
|
|
[self.recentsTableView deselectRowAtIndexPath:indexPath animated:NO];
|
2015-02-17 15:29:52 +00:00
|
|
|
}
|
2014-10-09 17:06:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated {
|
|
|
|
[super viewWillDisappear:animated];
|
2014-10-15 14:13:35 +00:00
|
|
|
|
|
|
|
// Leave potential editing mode
|
|
|
|
[self setEditing:NO];
|
|
|
|
|
2015-05-21 17:06:34 +00:00
|
|
|
selectedRoomId = nil;
|
|
|
|
selectedRoomSession = nil;
|
2015-06-10 13:46:59 +00:00
|
|
|
|
|
|
|
if (currentAlert)
|
|
|
|
{
|
|
|
|
[currentAlert dismiss:NO];
|
|
|
|
currentAlert = nil;
|
|
|
|
}
|
2014-10-09 17:06:30 +00:00
|
|
|
}
|
|
|
|
|
2014-12-09 09:39:56 +00:00
|
|
|
- (void)viewDidAppear:(BOOL)animated {
|
|
|
|
[super viewDidAppear:animated];
|
|
|
|
|
2015-02-17 15:29:52 +00:00
|
|
|
// Release the current selected room (if any) except if the Room ViewController is still visible (see splitViewController.isCollapsed condition)
|
|
|
|
if (!self.splitViewController || self.splitViewController.isCollapsed) {
|
2015-05-21 17:06:34 +00:00
|
|
|
// Release the current selected room (if any).
|
|
|
|
[self closeSelectedRoom];
|
2015-02-17 15:29:52 +00:00
|
|
|
} else {
|
|
|
|
// In case of split view controller where the primary and secondary view controllers are displayed side-by-side onscreen,
|
|
|
|
// the selected room (if any) is highlighted.
|
|
|
|
[self refreshCurrentSelectedCell:YES];
|
2014-12-09 09:39:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-15 14:13:35 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
2015-05-21 17:06:34 +00:00
|
|
|
- (void)selectRoomWithId:(NSString*)roomId inMatrixSession:(MXSession*)matrixSession {
|
|
|
|
if (selectedRoomId && [selectedRoomId isEqualToString:roomId]
|
|
|
|
&& selectedRoomSession && selectedRoomSession == matrixSession) {
|
2015-04-03 13:02:16 +00:00
|
|
|
// Nothing to do
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-21 17:06:34 +00:00
|
|
|
selectedRoomId = roomId;
|
|
|
|
selectedRoomSession = matrixSession;
|
|
|
|
|
|
|
|
if (roomId && matrixSession) {
|
2015-04-03 13:02:16 +00:00
|
|
|
[self performSegueWithIdentifier:@"showDetails" sender:self];
|
2015-05-21 17:06:34 +00:00
|
|
|
} else {
|
|
|
|
[self closeSelectedRoom];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)closeSelectedRoom {
|
|
|
|
selectedRoomId = nil;
|
|
|
|
selectedRoomSession = nil;
|
|
|
|
|
|
|
|
if (currentRoomViewController) {
|
2015-01-22 16:26:51 +00:00
|
|
|
// Release the current selected room
|
2015-04-01 09:06:48 +00:00
|
|
|
[currentRoomViewController destroy];
|
2015-01-22 16:26:51 +00:00
|
|
|
currentRoomViewController = nil;
|
2015-02-13 13:07:03 +00:00
|
|
|
|
|
|
|
// Force table refresh to deselect related cell
|
2015-02-17 15:29:52 +00:00
|
|
|
[self refreshRecentsDisplay];
|
2014-10-15 14:13:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-16 16:14:17 +00:00
|
|
|
#pragma mark - Internal methods
|
2014-10-15 14:13:35 +00:00
|
|
|
|
2015-01-22 12:01:01 +00:00
|
|
|
- (void)refreshRecentsDisplay {
|
2015-04-16 14:25:00 +00:00
|
|
|
|
|
|
|
// Update the unreadCount in the title
|
2015-06-10 13:46:59 +00:00
|
|
|
[self updateNavigationBarTitle];
|
2015-01-22 12:01:01 +00:00
|
|
|
|
2015-05-22 20:32:05 +00:00
|
|
|
[self.recentsTableView reloadData];
|
2015-02-17 15:29:52 +00:00
|
|
|
|
2015-04-03 13:02:16 +00:00
|
|
|
if (shouldScrollToTopOnRefresh) {
|
|
|
|
[self scrollToTop];
|
|
|
|
shouldScrollToTopOnRefresh = NO;
|
|
|
|
}
|
|
|
|
|
2015-03-16 12:32:40 +00:00
|
|
|
// In case of split view controller where the primary and secondary view controllers are displayed side-by-side onscreen,
|
|
|
|
// the selected room (if any) is updated and kept visible.
|
|
|
|
if (self.splitViewController && !self.splitViewController.isCollapsed) {
|
2015-02-17 15:29:52 +00:00
|
|
|
[self refreshCurrentSelectedCell:YES];
|
|
|
|
}
|
2014-12-24 12:25:12 +00:00
|
|
|
}
|
|
|
|
|
2015-06-10 13:46:59 +00:00
|
|
|
- (void)updateNavigationBarTitle {
|
2014-12-22 13:19:33 +00:00
|
|
|
NSString *title = @"Recents";
|
2015-04-03 13:02:16 +00:00
|
|
|
|
|
|
|
if (self.dataSource.unreadCount) {
|
|
|
|
title = [NSString stringWithFormat:@"Recents (%tu)", self.dataSource.unreadCount];
|
2014-12-22 13:19:33 +00:00
|
|
|
}
|
|
|
|
self.navigationItem.title = title;
|
2014-10-09 17:06:30 +00:00
|
|
|
}
|
|
|
|
|
2014-10-13 12:45:29 +00:00
|
|
|
- (void)createNewRoom:(id)sender {
|
|
|
|
[[AppDelegate theDelegate].masterTabBarController showRoomCreationForm];
|
2014-10-09 17:06:30 +00:00
|
|
|
}
|
|
|
|
|
2015-01-23 10:01:38 +00:00
|
|
|
- (void)scrollToTop {
|
|
|
|
// stop any scrolling effect
|
|
|
|
[UIView setAnimationsEnabled:NO];
|
|
|
|
// before scrolling to the tableview top
|
2015-05-22 20:32:05 +00:00
|
|
|
self.recentsTableView.contentOffset = CGPointMake(-self.recentsTableView.contentInset.left, -self.recentsTableView.contentInset.top);
|
2015-01-23 10:01:38 +00:00
|
|
|
[UIView setAnimationsEnabled:YES];
|
|
|
|
}
|
|
|
|
|
2015-02-17 15:29:52 +00:00
|
|
|
- (void)refreshCurrentSelectedCell:(BOOL)forceVisible {
|
|
|
|
// Update here the index of the current selected cell (if any) - Useful in landscape mode with split view controller.
|
2015-05-21 11:12:21 +00:00
|
|
|
currentSelectedCellIndexPath = nil;
|
2015-02-17 15:29:52 +00:00
|
|
|
if (currentRoomViewController) {
|
2015-04-03 13:02:16 +00:00
|
|
|
// Restore the current selected room id, it is erased when view controller disappeared (see viewWillDisappear).
|
2015-05-21 17:06:34 +00:00
|
|
|
if (!selectedRoomId) {
|
|
|
|
selectedRoomId = currentRoomViewController.roomDataSource.roomId;
|
2015-05-28 15:54:50 +00:00
|
|
|
selectedRoomSession = currentRoomViewController.mainSession;
|
2015-04-03 13:02:16 +00:00
|
|
|
}
|
|
|
|
|
2015-02-17 15:29:52 +00:00
|
|
|
// Look for the rank of this selected room in displayed recents
|
2015-05-21 17:06:34 +00:00
|
|
|
currentSelectedCellIndexPath = [self.dataSource cellIndexPathWithRoomId:selectedRoomId andMatrixSession:selectedRoomSession];
|
2015-02-17 15:29:52 +00:00
|
|
|
}
|
|
|
|
|
2015-05-21 11:12:21 +00:00
|
|
|
if (currentSelectedCellIndexPath) {
|
2015-02-17 15:29:52 +00:00
|
|
|
// Select the right row
|
2015-05-22 20:32:05 +00:00
|
|
|
[self.recentsTableView selectRowAtIndexPath:currentSelectedCellIndexPath animated:YES scrollPosition:UITableViewScrollPositionNone];
|
2015-02-17 15:29:52 +00:00
|
|
|
|
|
|
|
if (forceVisible) {
|
|
|
|
// Scroll table view to make the selected row appear at second position
|
2015-05-21 11:12:21 +00:00
|
|
|
NSInteger topCellIndexPathRow = currentSelectedCellIndexPath.row ? currentSelectedCellIndexPath.row - 1: currentSelectedCellIndexPath.row;
|
|
|
|
NSIndexPath* indexPath = [NSIndexPath indexPathForRow:topCellIndexPathRow inSection:currentSelectedCellIndexPath.section];
|
2015-05-22 20:32:05 +00:00
|
|
|
[self.recentsTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
|
2015-02-17 15:29:52 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-05-22 20:32:05 +00:00
|
|
|
NSIndexPath *indexPath = [self.recentsTableView indexPathForSelectedRow];
|
2015-02-17 15:29:52 +00:00
|
|
|
if (indexPath) {
|
2015-05-22 20:32:05 +00:00
|
|
|
[self.recentsTableView deselectRowAtIndexPath:indexPath animated:NO];
|
2015-02-17 15:29:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-10 13:46:59 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
- (void)onNavigationBarTap:(id)sender
|
|
|
|
{
|
|
|
|
if (self.dataSource.unreadCount)
|
|
|
|
{
|
|
|
|
__weak typeof(self) weakSelf = self;
|
|
|
|
|
|
|
|
currentAlert = [[MXKAlert alloc] initWithTitle:@"Mark all as read?" message:nil style:MXKAlertStyleAlert];
|
|
|
|
|
|
|
|
currentAlert.cancelButtonIndex = [currentAlert addActionWithTitle:@"No" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
|
|
|
typeof(self) strongSelf = weakSelf;
|
|
|
|
strongSelf->currentAlert = nil;
|
|
|
|
}];
|
|
|
|
|
|
|
|
[currentAlert addActionWithTitle:@"Yes" style:MXKAlertActionStyleDefault handler:^(MXKAlert *alert) {
|
|
|
|
typeof(self) strongSelf = weakSelf;
|
|
|
|
|
|
|
|
strongSelf->currentAlert = nil;
|
|
|
|
|
|
|
|
[strongSelf.dataSource markAllAsRead];
|
|
|
|
[strongSelf updateNavigationBarTitle];
|
|
|
|
}];
|
|
|
|
|
|
|
|
[currentAlert showInViewController:self];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-02 15:02:47 +00:00
|
|
|
#pragma mark - Segues
|
|
|
|
|
|
|
|
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
|
2015-04-03 13:02:16 +00:00
|
|
|
if ([[segue identifier] isEqualToString:@"showDetails"]) {
|
2015-04-09 06:56:58 +00:00
|
|
|
|
2014-10-02 15:02:47 +00:00
|
|
|
UIViewController *controller;
|
|
|
|
if ([[segue destinationViewController] isKindOfClass:[UINavigationController class]]) {
|
|
|
|
controller = [[segue destinationViewController] topViewController];
|
2014-10-09 17:06:30 +00:00
|
|
|
} else {
|
2014-10-02 15:02:47 +00:00
|
|
|
controller = [segue destinationViewController];
|
|
|
|
}
|
|
|
|
|
2014-10-03 17:26:39 +00:00
|
|
|
if ([controller isKindOfClass:[RoomViewController class]]) {
|
2014-12-09 09:39:56 +00:00
|
|
|
// Release potential Room ViewController
|
|
|
|
if (currentRoomViewController) {
|
2015-04-01 09:06:48 +00:00
|
|
|
[currentRoomViewController destroy];
|
2014-12-09 09:39:56 +00:00
|
|
|
currentRoomViewController = nil;
|
|
|
|
}
|
2015-03-31 13:09:17 +00:00
|
|
|
|
2014-11-21 13:26:34 +00:00
|
|
|
currentRoomViewController = (RoomViewController *)controller;
|
2015-04-09 14:35:03 +00:00
|
|
|
|
2015-05-21 17:06:34 +00:00
|
|
|
MXKRoomDataSourceManager *roomDataSourceManager = [MXKRoomDataSourceManager sharedManagerForMatrixSession:selectedRoomSession];
|
|
|
|
MXKRoomDataSource *roomDataSource = [roomDataSourceManager roomDataSourceForRoom:selectedRoomId create:YES];
|
2015-03-31 13:09:17 +00:00
|
|
|
[currentRoomViewController displayRoom:roomDataSource];
|
2014-10-02 15:02:47 +00:00
|
|
|
}
|
|
|
|
|
2014-12-05 16:48:06 +00:00
|
|
|
// Reset unread count for this room
|
2015-04-09 06:53:12 +00:00
|
|
|
//[roomDataSource resetUnreadCount]; // @TODO: This automatically done by roomDataSource. Is it a good thing?
|
2015-06-10 13:46:59 +00:00
|
|
|
[self updateNavigationBarTitle];
|
2014-12-05 16:48:06 +00:00
|
|
|
|
|
|
|
if (self.splitViewController) {
|
2015-02-17 15:29:52 +00:00
|
|
|
// Refresh selected cell without scrolling the selected cell (We suppose it's visible here)
|
|
|
|
[self refreshCurrentSelectedCell:NO];
|
|
|
|
|
2014-12-16 17:30:49 +00:00
|
|
|
// IOS >= 8
|
|
|
|
if ([self.splitViewController respondsToSelector:@selector(displayModeButtonItem)]) {
|
|
|
|
controller.navigationItem.leftBarButtonItem = self.splitViewController.displayModeButtonItem;
|
|
|
|
}
|
2015-01-23 10:01:38 +00:00
|
|
|
|
2014-12-16 17:30:49 +00:00
|
|
|
//
|
2014-12-05 16:48:06 +00:00
|
|
|
controller.navigationItem.leftItemsSupplementBackButton = YES;
|
|
|
|
}
|
2014-12-15 15:54:31 +00:00
|
|
|
|
|
|
|
// Hide back button title
|
2015-01-23 10:01:38 +00:00
|
|
|
self.navigationItem.backBarButtonItem =[[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
|
2014-10-02 15:02:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-03 13:02:16 +00:00
|
|
|
#pragma mark - MXKDataSourceDelegate
|
|
|
|
- (void)dataSource:(MXKDataSource *)dataSource didCellChange:(id)changes {
|
|
|
|
[self refreshRecentsDisplay];
|
2014-10-09 17:06:30 +00:00
|
|
|
}
|
2014-10-02 15:02:47 +00:00
|
|
|
|
2015-04-03 13:02:16 +00:00
|
|
|
#pragma mark - MXKRecentListViewControllerDelegate
|
2015-05-21 17:06:34 +00:00
|
|
|
- (void)recentListViewController:(MXKRecentListViewController *)recentListViewController didSelectRoom:(NSString *)roomId inMatrixSession:(MXSession *)matrixSession {
|
2014-12-02 14:25:00 +00:00
|
|
|
|
2015-05-21 17:06:34 +00:00
|
|
|
// Open the room
|
|
|
|
[self selectRoomWithId:roomId inMatrixSession:matrixSession];
|
2014-10-02 15:02:47 +00:00
|
|
|
}
|
|
|
|
|
2015-05-22 20:32:05 +00:00
|
|
|
#pragma mark - Override UISearchBarDelegate
|
2014-12-02 14:25:00 +00:00
|
|
|
|
|
|
|
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
|
2015-04-03 13:02:16 +00:00
|
|
|
|
2015-05-22 20:32:05 +00:00
|
|
|
// Prepare table refresh on new search session
|
2015-04-03 13:02:16 +00:00
|
|
|
shouldScrollToTopOnRefresh = YES;
|
2015-05-22 20:32:05 +00:00
|
|
|
|
|
|
|
[super searchBar:searchBar textDidChange:searchText];
|
2014-12-02 14:25:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
|
2015-04-03 13:02:16 +00:00
|
|
|
|
2015-05-22 20:32:05 +00:00
|
|
|
// Prepare table refresh on end of search
|
2015-04-03 13:02:16 +00:00
|
|
|
shouldScrollToTopOnRefresh = YES;
|
2015-05-22 20:32:05 +00:00
|
|
|
|
|
|
|
[super searchBarCancelButtonClicked: searchBar];
|
2014-12-02 14:25:00 +00:00
|
|
|
}
|
|
|
|
|
2014-10-02 15:02:47 +00:00
|
|
|
@end
|