2017-04-06 12:27:45 +00:00
|
|
|
/*
|
|
|
|
Copyright 2017 Vector Creations 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 "RoomsViewController.h"
|
|
|
|
|
|
|
|
#import "RecentsDataSource.h"
|
|
|
|
|
2021-10-26 15:42:33 +00:00
|
|
|
#import "GeneratedInterface-Swift.h"
|
2019-01-10 14:12:24 +00:00
|
|
|
|
2021-02-22 16:47:40 +00:00
|
|
|
@interface RoomsViewController ()
|
2017-04-07 12:44:34 +00:00
|
|
|
{
|
|
|
|
RecentsDataSource *recentsDataSource;
|
|
|
|
}
|
2020-09-10 11:56:46 +00:00
|
|
|
|
2017-04-07 12:44:34 +00:00
|
|
|
@end
|
|
|
|
|
2017-04-06 12:27:45 +00:00
|
|
|
@implementation RoomsViewController
|
|
|
|
|
2021-05-20 19:29:08 +00:00
|
|
|
+ (instancetype)instantiate
|
|
|
|
{
|
|
|
|
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
|
|
|
|
RoomsViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"RoomsViewController"];
|
|
|
|
return viewController;
|
|
|
|
}
|
|
|
|
|
2021-12-02 14:25:45 +00:00
|
|
|
- (void)finalizeInit
|
|
|
|
{
|
|
|
|
[super finalizeInit];
|
|
|
|
|
|
|
|
self.screenTimer = [[AnalyticsScreenTimer alloc] initWithScreen:AnalyticsScreenRooms];
|
|
|
|
}
|
|
|
|
|
2017-04-06 12:27:45 +00:00
|
|
|
- (void)viewDidLoad
|
|
|
|
{
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
|
|
|
self.view.accessibilityIdentifier = @"RoomsVCView";
|
|
|
|
self.recentsTableView.accessibilityIdentifier = @"RoomsVCTableView";
|
|
|
|
|
2017-05-19 15:22:26 +00:00
|
|
|
// Tag the recents table with the its recents data source mode.
|
|
|
|
// This will be used by the shared RecentsDataSource instance for sanity checks (see UITableViewDataSource methods).
|
|
|
|
self.recentsTableView.tag = RecentsDataSourceModeRooms;
|
|
|
|
|
2017-05-05 15:08:44 +00:00
|
|
|
// Add the (+) button programmatically
|
2020-10-09 09:40:46 +00:00
|
|
|
plusButtonImageView = [self vc_addFABWithImage:[UIImage imageNamed:@"rooms_floating_action"]
|
|
|
|
target:self
|
|
|
|
action:@selector(onPlusButtonPressed)];
|
2017-04-06 12:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated
|
|
|
|
{
|
|
|
|
[super viewWillAppear:animated];
|
|
|
|
|
2021-09-28 05:40:01 +00:00
|
|
|
[AppDelegate theDelegate].masterTabBarController.navigationItem.title = [VectorL10n titleRooms];
|
2019-01-11 10:45:27 +00:00
|
|
|
[AppDelegate theDelegate].masterTabBarController.tabBar.tintColor = ThemeService.shared.theme.tintColor;
|
2017-04-06 13:49:47 +00:00
|
|
|
|
2017-04-06 12:27:45 +00:00
|
|
|
if ([self.dataSource isKindOfClass:RecentsDataSource.class])
|
|
|
|
{
|
|
|
|
// Take the lead on the shared data source.
|
2017-04-07 12:44:34 +00:00
|
|
|
recentsDataSource = (RecentsDataSource*)self.dataSource;
|
2017-04-06 12:27:45 +00:00
|
|
|
recentsDataSource.areSectionsShrinkable = NO;
|
|
|
|
[recentsDataSource setDelegate:self andRecentsDataSourceMode:RecentsDataSourceModeRooms];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)destroy
|
|
|
|
{
|
|
|
|
[super destroy];
|
|
|
|
}
|
|
|
|
|
2017-04-20 13:00:22 +00:00
|
|
|
#pragma mark - Override RecentsViewController
|
|
|
|
|
2017-05-03 16:51:09 +00:00
|
|
|
- (void)refreshCurrentSelectedCell:(BOOL)forceVisible
|
|
|
|
{
|
|
|
|
// Check whether the recents data source is correctly configured.
|
|
|
|
if (recentsDataSource.recentsDataSourceMode != RecentsDataSourceModeRooms)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
[super refreshCurrentSelectedCell:forceVisible];
|
|
|
|
}
|
|
|
|
|
2021-07-07 16:37:33 +00:00
|
|
|
- (void)onPlusButtonPressed
|
2017-04-20 13:00:22 +00:00
|
|
|
{
|
2021-07-07 16:37:33 +00:00
|
|
|
[self showRoomDirectory];
|
2017-04-20 13:00:22 +00:00
|
|
|
}
|
|
|
|
|
2021-07-07 16:37:33 +00:00
|
|
|
#pragma mark - UITableView delegate
|
|
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
2020-09-09 11:41:00 +00:00
|
|
|
{
|
2021-07-29 21:24:34 +00:00
|
|
|
if ([tableView numberOfSections] <= 1)
|
|
|
|
{
|
|
|
|
// Hide the header to merge Invites and Rooms into a single list.
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [super tableView:tableView heightForHeaderInSection:section];
|
2020-09-09 11:41:00 +00:00
|
|
|
}
|
|
|
|
|
2017-06-14 07:41:15 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
- (void)scrollToNextRoomWithMissedNotifications
|
|
|
|
{
|
|
|
|
// Check whether the recents data source is correctly configured.
|
2017-06-16 14:55:54 +00:00
|
|
|
if (recentsDataSource.recentsDataSourceMode == RecentsDataSourceModeRooms)
|
2017-06-14 07:41:15 +00:00
|
|
|
{
|
2017-06-16 14:55:54 +00:00
|
|
|
[self scrollToTheTopTheNextRoomWithMissedNotificationsInSection:recentsDataSource.conversationSection];
|
2017-06-14 07:41:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-26 10:23:57 +00:00
|
|
|
#pragma mark - Empty view management
|
|
|
|
|
|
|
|
- (void)updateEmptyView
|
|
|
|
{
|
2020-11-30 15:42:47 +00:00
|
|
|
[self.emptyView fillWith:[self emptyViewArtwork]
|
2021-09-28 05:40:01 +00:00
|
|
|
title:[VectorL10n roomsEmptyViewTitle]
|
|
|
|
informationText:[VectorL10n roomsEmptyViewInformation]];
|
2020-11-26 10:23:57 +00:00
|
|
|
}
|
|
|
|
|
2020-11-30 15:42:47 +00:00
|
|
|
- (UIImage*)emptyViewArtwork
|
|
|
|
{
|
|
|
|
if (ThemeService.shared.isCurrentThemeDark)
|
|
|
|
{
|
|
|
|
return [UIImage imageNamed:@"rooms_empty_screen_artwork_dark"];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return [UIImage imageNamed:@"rooms_empty_screen_artwork"];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-06 12:27:45 +00:00
|
|
|
@end
|