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 "PeopleViewController.h"
|
|
|
|
|
|
|
|
#import "UIViewController+RiotSearch.h"
|
|
|
|
|
|
|
|
#import "RageShakeManager.h"
|
|
|
|
|
2017-04-11 07:36:22 +00:00
|
|
|
#import "RecentsDataSource.h"
|
2017-04-06 12:27:45 +00:00
|
|
|
#import "RecentTableViewCell.h"
|
|
|
|
#import "InviteRecentTableViewCell.h"
|
|
|
|
|
2021-10-26 15:42:33 +00:00
|
|
|
#import "GeneratedInterface-Swift.h"
|
2020-07-10 13:37:19 +00:00
|
|
|
|
2021-09-02 06:34:25 +00:00
|
|
|
@interface PeopleViewController () <SpaceMembersCoordinatorBridgePresenterDelegate>
|
2017-04-06 12:27:45 +00:00
|
|
|
{
|
|
|
|
NSInteger directRoomsSectionNumber;
|
2017-06-16 14:55:54 +00:00
|
|
|
RecentsDataSource *recentsDataSource;
|
2017-04-06 12:27:45 +00:00
|
|
|
}
|
|
|
|
|
2021-09-02 06:34:25 +00:00
|
|
|
@property(nonatomic) SpaceMembersCoordinatorBridgePresenter *spaceMembersCoordinatorBridgePresenter;
|
2022-01-04 01:31:18 +00:00
|
|
|
@property (nonatomic, strong) MXThrottler *tableViewPaginationThrottler;
|
2021-08-22 06:23:58 +00:00
|
|
|
|
2017-04-06 12:27:45 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation PeopleViewController
|
|
|
|
|
2021-05-20 19:29:08 +00:00
|
|
|
+ (instancetype)instantiate
|
|
|
|
{
|
|
|
|
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
|
|
|
|
PeopleViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"PeopleViewController"];
|
|
|
|
return viewController;
|
|
|
|
}
|
|
|
|
|
2017-04-06 12:27:45 +00:00
|
|
|
- (void)finalizeInit
|
|
|
|
{
|
|
|
|
[super finalizeInit];
|
|
|
|
|
|
|
|
directRoomsSectionNumber = 0;
|
2021-12-02 14:25:45 +00:00
|
|
|
|
|
|
|
self.screenTimer = [[AnalyticsScreenTimer alloc] initWithScreen:AnalyticsScreenPeople];
|
2022-01-04 01:31:18 +00:00
|
|
|
self.tableViewPaginationThrottler = [[MXThrottler alloc] initWithMinimumDelay:0.1];
|
2017-04-06 12:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewDidLoad
|
|
|
|
{
|
|
|
|
[super viewDidLoad];
|
|
|
|
// Do any additional setup after loading the view, typically from a nib.
|
|
|
|
|
|
|
|
self.view.accessibilityIdentifier = @"PeopleVCView";
|
2017-04-11 07:36:22 +00:00
|
|
|
self.recentsTableView.accessibilityIdentifier = @"PeopleVCTableView";
|
2017-04-06 12:27:45 +00:00
|
|
|
|
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 = RecentsDataSourceModePeople;
|
|
|
|
|
2017-05-05 15:08:44 +00:00
|
|
|
// Add the (+) button programmatically
|
2022-02-10 16:13:23 +00:00
|
|
|
plusButtonImageView = [self vc_addFABWithImage:AssetImages.peopleFloatingAction.image
|
2020-10-09 09:40:46 +00:00
|
|
|
target:self
|
|
|
|
action:@selector(onPlusButtonPressed)];
|
2017-04-06 12:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)didReceiveMemoryWarning
|
|
|
|
{
|
|
|
|
[super didReceiveMemoryWarning];
|
|
|
|
// Dispose of any resources that can be recreated.
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)viewWillAppear:(BOOL)animated
|
|
|
|
{
|
|
|
|
[super viewWillAppear:animated];
|
2020-07-30 13:45:30 +00:00
|
|
|
|
2021-09-28 05:40:01 +00:00
|
|
|
[AppDelegate theDelegate].masterTabBarController.navigationItem.title = [VectorL10n titlePeople];
|
2020-07-10 13:37:19 +00:00
|
|
|
[AppDelegate theDelegate].masterTabBarController.tabBar.tintColor = ThemeService.shared.theme.tintColor;
|
2017-04-06 13:49:47 +00:00
|
|
|
|
2021-07-27 13:51:10 +00:00
|
|
|
if ([self.dataSource isKindOfClass:RecentsDataSource.class])
|
2017-04-11 07:36:22 +00:00
|
|
|
{
|
|
|
|
// Take the lead on the shared data source.
|
2021-07-27 13:51:10 +00:00
|
|
|
recentsDataSource = (RecentsDataSource*)self.dataSource;
|
2017-04-11 07:36:22 +00:00
|
|
|
recentsDataSource.areSectionsShrinkable = NO;
|
|
|
|
[recentsDataSource setDelegate:self andRecentsDataSourceMode:RecentsDataSourceModePeople];
|
|
|
|
}
|
2017-04-06 12:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - UITableView delegate
|
|
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
|
|
|
{
|
2021-07-09 13:22:33 +00:00
|
|
|
return 0.0;
|
2017-04-06 12:27:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
|
|
|
|
{
|
2021-07-09 13:22:33 +00:00
|
|
|
return nil;
|
2017-04-06 12:27:45 +00:00
|
|
|
}
|
|
|
|
|
2022-01-04 01:31:18 +00:00
|
|
|
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
{
|
|
|
|
if ([super respondsToSelector:@selector(tableView:willDisplayCell:forRowAtIndexPath:)])
|
|
|
|
{
|
|
|
|
[super tableView:tableView willDisplayCell:cell forRowAtIndexPath:indexPath];
|
|
|
|
}
|
|
|
|
|
|
|
|
[self.tableViewPaginationThrottler throttle:^{
|
|
|
|
NSInteger section = indexPath.section;
|
|
|
|
NSInteger numberOfRowsInSection = [tableView numberOfRowsInSection:section];
|
|
|
|
if (tableView.numberOfSections > section
|
|
|
|
&& indexPath.row == numberOfRowsInSection - 1)
|
|
|
|
{
|
|
|
|
[self->recentsDataSource paginateInSection:section];
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2017-04-14 09:49:14 +00:00
|
|
|
#pragma mark - Override RecentsViewController
|
|
|
|
|
2017-04-11 08:04:52 +00:00
|
|
|
- (void)refreshCurrentSelectedCell:(BOOL)forceVisible
|
|
|
|
{
|
2017-05-03 16:51:09 +00:00
|
|
|
// Check whether the recents data source is correctly configured.
|
2017-06-16 14:55:54 +00:00
|
|
|
if (recentsDataSource.recentsDataSourceMode != RecentsDataSourceModePeople)
|
2017-05-03 16:51:09 +00:00
|
|
|
{
|
2017-06-16 14:55:54 +00:00
|
|
|
return;
|
2017-05-03 16:51:09 +00:00
|
|
|
}
|
2017-06-16 14:55:54 +00:00
|
|
|
|
2021-07-06 15:14:32 +00:00
|
|
|
[super refreshCurrentSelectedCell:forceVisible];
|
2017-04-11 08:04:52 +00:00
|
|
|
}
|
|
|
|
|
2020-09-08 10:09:30 +00:00
|
|
|
- (void)onPlusButtonPressed
|
|
|
|
{
|
2021-08-22 06:23:58 +00:00
|
|
|
if (self.dataSource.currentSpace != nil)
|
|
|
|
{
|
2021-09-14 14:59:32 +00:00
|
|
|
self.spaceMembersCoordinatorBridgePresenter = [[SpaceMembersCoordinatorBridgePresenter alloc] initWithUserSessionsService:[UserSessionsService shared] session:self.mainSession spaceId:self.dataSource.currentSpace.spaceId];
|
2021-09-02 06:34:25 +00:00
|
|
|
self.spaceMembersCoordinatorBridgePresenter.delegate = self;
|
|
|
|
[self.spaceMembersCoordinatorBridgePresenter presentFrom:self animated:YES];
|
2021-08-22 06:23:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[self performSegueWithIdentifier:@"presentStartChat" sender:self];
|
|
|
|
}
|
2020-09-08 10:09:30 +00:00
|
|
|
}
|
|
|
|
|
2017-06-16 14:55:54 +00:00
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
- (void)scrollToNextRoomWithMissedNotifications
|
|
|
|
{
|
|
|
|
// Check whether the recents data source is correctly configured.
|
|
|
|
if (recentsDataSource.recentsDataSourceMode == RecentsDataSourceModePeople)
|
|
|
|
{
|
2021-12-08 11:17:49 +00:00
|
|
|
[self scrollToTheTopTheNextRoomWithMissedNotificationsInSection:recentsDataSource.peopleSection];
|
2017-06-16 14:55:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-26 10:22:55 +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 peopleEmptyViewTitle]
|
|
|
|
informationText:[VectorL10n peopleEmptyViewInformation]];
|
2020-11-26 10:22:55 +00:00
|
|
|
}
|
|
|
|
|
2020-11-30 15:42:47 +00:00
|
|
|
- (UIImage*)emptyViewArtwork
|
|
|
|
{
|
|
|
|
if (ThemeService.shared.isCurrentThemeDark)
|
|
|
|
{
|
2022-02-10 16:13:23 +00:00
|
|
|
return AssetImages.peopleEmptyScreenArtworkDark.image;
|
2020-11-30 15:42:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-02-10 16:13:23 +00:00
|
|
|
return AssetImages.peopleEmptyScreenArtwork.image;
|
2020-11-30 15:42:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-02 06:34:25 +00:00
|
|
|
#pragma mark - SpaceMembersCoordinatorBridgePresenterDelegate
|
2021-08-22 06:23:58 +00:00
|
|
|
|
2021-09-02 06:34:25 +00:00
|
|
|
- (void)spaceMembersCoordinatorBridgePresenterDelegateDidComplete:(SpaceMembersCoordinatorBridgePresenter *)coordinatorBridgePresenter
|
2021-08-22 06:23:58 +00:00
|
|
|
{
|
|
|
|
[coordinatorBridgePresenter dismissWithAnimated:YES completion:^{
|
2021-09-02 06:34:25 +00:00
|
|
|
self.spaceMembersCoordinatorBridgePresenter = nil;
|
2021-08-22 06:23:58 +00:00
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2017-04-06 12:27:45 +00:00
|
|
|
@end
|