2016-10-12 10:03:39 +00:00
|
|
|
/*
|
|
|
|
Copyright 2016 OpenMarket Ltd
|
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import "RoomFilesViewController.h"
|
|
|
|
|
|
|
|
#import "FilesSearchTableViewCell.h"
|
|
|
|
|
|
|
|
#import "AppDelegate.h"
|
|
|
|
|
|
|
|
#import "VectorDesignValues.h"
|
|
|
|
|
|
|
|
#import "RageShakeManager.h"
|
|
|
|
|
|
|
|
@implementation RoomFilesViewController
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
- (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil
|
|
|
|
{
|
|
|
|
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
|
|
|
|
if (self)
|
|
|
|
{
|
|
|
|
self.autoJoinInvitedRoom = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder
|
|
|
|
{
|
|
|
|
self = [super initWithCoder:aDecoder];
|
|
|
|
if (self)
|
|
|
|
{
|
|
|
|
self.autoJoinInvitedRoom = NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
2017-01-03 13:40:23 +00:00
|
|
|
- (void)finalizeInit
|
|
|
|
{
|
|
|
|
[super finalizeInit];
|
|
|
|
|
|
|
|
// Setup `MXKViewControllerHandling` properties
|
|
|
|
self.defaultBarTintColor = kVectorNavBarTintColor;
|
|
|
|
self.enableBarTintColorStatusChange = NO;
|
|
|
|
self.rageShakeManager = [RageShakeManager sharedManager];
|
|
|
|
}
|
|
|
|
|
2016-10-12 10:03:39 +00:00
|
|
|
- (void)viewDidLoad
|
|
|
|
{
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
|
|
|
// Do not show toolbar
|
|
|
|
[self setRoomInputToolbarViewClass:nil];
|
|
|
|
|
|
|
|
// Update the inputToolBar height
|
|
|
|
[UIView setAnimationsEnabled:NO];
|
|
|
|
[self roomInputToolbarView:self.inputToolbarView heightDidChanged:0 completion:nil];
|
|
|
|
[UIView setAnimationsEnabled:YES];
|
|
|
|
|
|
|
|
// set the default extra
|
|
|
|
[self setRoomActivitiesViewClass:nil];
|
|
|
|
|
|
|
|
// Register first customized cell view classes used to render bubbles
|
|
|
|
[self.bubblesTableView registerClass:FilesSearchTableViewCell.class forCellReuseIdentifier:FilesSearchTableViewCell.defaultReuseIdentifier];
|
2016-10-12 11:54:34 +00:00
|
|
|
|
|
|
|
self.bubblesTableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
|
|
|
|
|
2016-10-13 14:36:11 +00:00
|
|
|
// Hide line separators of empty cells
|
|
|
|
self.bubblesTableView.tableFooterView = [[UIView alloc] init];
|
|
|
|
|
2016-10-12 11:54:34 +00:00
|
|
|
[self setNavBarButtons];
|
|
|
|
}
|
|
|
|
|
|
|
|
// This method is called when the viewcontroller is added or removed from a container view controller.
|
|
|
|
- (void)didMoveToParentViewController:(nullable UIViewController *)parent
|
|
|
|
{
|
|
|
|
[super didMoveToParentViewController:parent];
|
|
|
|
|
|
|
|
[self setNavBarButtons];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setNavBarButtons
|
|
|
|
{
|
|
|
|
// Check whether the view controller is currently displayed inside a segmented view controller or not.
|
|
|
|
UIViewController* topViewController = ((self.parentViewController) ? self.parentViewController : self);
|
|
|
|
topViewController.navigationItem.rightBarButtonItem = nil;
|
|
|
|
topViewController.navigationItem.leftBarButtonItem = nil;
|
2016-10-12 10:03:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - MXKDataSourceDelegate
|
|
|
|
|
|
|
|
- (Class<MXKCellRendering>)cellViewClassForCellData:(MXKCellData*)cellData
|
|
|
|
{
|
|
|
|
Class cellViewClass = nil;
|
|
|
|
|
|
|
|
// Sanity check
|
|
|
|
if ([cellData conformsToProtocol:@protocol(MXKRoomBubbleCellDataStoring)])
|
|
|
|
{
|
|
|
|
id<MXKRoomBubbleCellDataStoring> bubbleData = (id<MXKRoomBubbleCellDataStoring>)cellData;
|
|
|
|
|
|
|
|
// Select the suitable table view cell class
|
|
|
|
if (bubbleData.attachment)
|
|
|
|
{
|
|
|
|
cellViewClass = FilesSearchTableViewCell.class;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return cellViewClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString *)cellReuseIdentifierForCellData:(MXKCellData*)cellData
|
|
|
|
{
|
|
|
|
Class class = [self cellViewClassForCellData:cellData];
|
|
|
|
|
|
|
|
if ([class respondsToSelector:@selector(defaultReuseIdentifier)])
|
|
|
|
{
|
|
|
|
return [class defaultReuseIdentifier];
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - UITableView delegate
|
|
|
|
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
{
|
|
|
|
if (tableView == self.bubblesTableView)
|
|
|
|
{
|
|
|
|
UITableViewCell *cell = [self.bubblesTableView cellForRowAtIndexPath:indexPath];
|
|
|
|
[self showAttachmentInCell:cell];
|
|
|
|
|
|
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|