Merge pull request #1209 from vector-im/add_home_tab

Prepare UX Rework:
This commit is contained in:
giomfo 2017-05-05 16:25:00 +02:00 committed by GitHub
commit 3ed3eba908
13 changed files with 629 additions and 30 deletions

View file

@ -21,6 +21,10 @@
F02C1A861E8EB04C0045A404 /* PeopleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F02C1A841E8EB04C0045A404 /* PeopleViewController.m */; };
F05BD79E1E7AEBF800C69941 /* UnifiedSearchViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F05BD79D1E7AEBF800C69941 /* UnifiedSearchViewController.m */; };
F05BD7A11E7C0E4500C69941 /* MasterTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = F05BD7A01E7C0E4500C69941 /* MasterTabBarController.m */; };
F075BED61EBB169C00A7B68A /* RoomCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F075BED41EBB169C00A7B68A /* RoomCollectionViewCell.m */; };
F075BED71EBB169C00A7B68A /* RoomCollectionViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F075BED51EBB169C00A7B68A /* RoomCollectionViewCell.xib */; };
F075BEDB1EBB26F100A7B68A /* TableViewCellWithCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = F075BED91EBB26F100A7B68A /* TableViewCellWithCollectionView.m */; };
F075BEDC1EBB26F100A7B68A /* TableViewCellWithCollectionView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F075BEDA1EBB26F100A7B68A /* TableViewCellWithCollectionView.xib */; };
F083BD1D1E7009ED00A9B29C /* RageShakeManager.m in Sources */ = {isa = PBXBuildFile; fileRef = F083BB0B1E7009EC00A9B29C /* RageShakeManager.m */; };
F083BD1E1E7009ED00A9B29C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F083BB0D1E7009EC00A9B29C /* AppDelegate.m */; };
F083BD1F1E7009ED00A9B29C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = F083BB0F1E7009EC00A9B29C /* InfoPlist.strings */; };
@ -475,6 +479,12 @@
F05BD79D1E7AEBF800C69941 /* UnifiedSearchViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UnifiedSearchViewController.m; sourceTree = "<group>"; };
F05BD79F1E7C0E4500C69941 /* MasterTabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MasterTabBarController.h; sourceTree = "<group>"; };
F05BD7A01E7C0E4500C69941 /* MasterTabBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MasterTabBarController.m; sourceTree = "<group>"; };
F075BED31EBB169C00A7B68A /* RoomCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoomCollectionViewCell.h; sourceTree = "<group>"; };
F075BED41EBB169C00A7B68A /* RoomCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RoomCollectionViewCell.m; sourceTree = "<group>"; };
F075BED51EBB169C00A7B68A /* RoomCollectionViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RoomCollectionViewCell.xib; sourceTree = "<group>"; };
F075BED81EBB26F100A7B68A /* TableViewCellWithCollectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TableViewCellWithCollectionView.h; sourceTree = "<group>"; };
F075BED91EBB26F100A7B68A /* TableViewCellWithCollectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TableViewCellWithCollectionView.m; sourceTree = "<group>"; };
F075BEDA1EBB26F100A7B68A /* TableViewCellWithCollectionView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TableViewCellWithCollectionView.xib; sourceTree = "<group>"; };
F083BB031E7005FD00A9B29C /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
F083BB041E7005FD00A9B29C /* RiotTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RiotTests.m; sourceTree = "<group>"; };
F083BB0A1E7009EC00A9B29C /* RageShakeManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RageShakeManager.h; sourceTree = "<group>"; };
@ -1752,6 +1762,9 @@
F083BCDC1E7009EC00A9B29C /* RoomList */ = {
isa = PBXGroup;
children = (
F075BED31EBB169C00A7B68A /* RoomCollectionViewCell.h */,
F075BED41EBB169C00A7B68A /* RoomCollectionViewCell.m */,
F075BED51EBB169C00A7B68A /* RoomCollectionViewCell.xib */,
F083BCDD1E7009EC00A9B29C /* DirectoryRecentTableViewCell.h */,
F083BCDE1E7009EC00A9B29C /* DirectoryRecentTableViewCell.m */,
F083BCDF1E7009EC00A9B29C /* DirectoryRecentTableViewCell.xib */,
@ -1825,6 +1838,9 @@
F083BD0D1E7009ED00A9B29C /* TableViewCell */ = {
isa = PBXGroup;
children = (
F075BED81EBB26F100A7B68A /* TableViewCellWithCollectionView.h */,
F075BED91EBB26F100A7B68A /* TableViewCellWithCollectionView.m */,
F075BEDA1EBB26F100A7B68A /* TableViewCellWithCollectionView.xib */,
F083BD0E1E7009ED00A9B29C /* TableViewCellWithButton.h */,
F083BD0F1E7009ED00A9B29C /* TableViewCellWithButton.m */,
F083BD101E7009ED00A9B29C /* TableViewCellWithButton.xib */,
@ -2011,6 +2027,7 @@
F083BDA61E7009ED00A9B29C /* notifications@3x.png in Resources */,
F083BD771E7009ED00A9B29C /* e2e_warning.png in Resources */,
F083BDDB1E7009ED00A9B29C /* typing@2x.png in Resources */,
F075BEDC1EBB26F100A7B68A /* TableViewCellWithCollectionView.xib in Resources */,
F083BDE71E7009ED00A9B29C /* callend.mp3 in Resources */,
F083BD231E7009ED00A9B29C /* add_participant@2x.png in Resources */,
F083BDA51E7009ED00A9B29C /* notifications@2x.png in Resources */,
@ -2169,6 +2186,7 @@
F083BD5C1E7009ED00A9B29C /* create_room.png in Resources */,
F083BE871E7009ED00A9B29C /* RoomTableViewCell.xib in Resources */,
F083BD471E7009ED00A9B29C /* call_video_mute_off_icon@3x.png in Resources */,
F075BED71EBB169C00A7B68A /* RoomCollectionViewCell.xib in Resources */,
F083BD941E7009ED00A9B29C /* group@3x.png in Resources */,
F083BD591E7009ED00A9B29C /* chevron.png in Resources */,
F083BDE11E7009ED00A9B29C /* video_icon@2x.png in Resources */,
@ -2422,6 +2440,7 @@
F083BE191E7009ED00A9B29C /* RecentsViewController.m in Sources */,
F083BE351E7009ED00A9B29C /* MediaAlbumTableCell.m in Sources */,
F083BE4C1E7009ED00A9B29C /* RoomOutgoingEncryptedAttachmentWithoutSenderInfoBubbleCell.m in Sources */,
F075BEDB1EBB26F100A7B68A /* TableViewCellWithCollectionView.m in Sources */,
F083BE001E7009ED00A9B29C /* FilesSearchCellData.m in Sources */,
F083BE7A1E7009ED00A9B29C /* RoomInputToolbarView.m in Sources */,
F083BDFF1E7009ED00A9B29C /* RecentsDataSource.m in Sources */,
@ -2461,6 +2480,7 @@
F083BDF91E7009ED00A9B29C /* RoomEmailInvitation.m in Sources */,
F083BE341E7009ED00A9B29C /* EncryptionInfoView.m in Sources */,
F083BE641E7009ED00A9B29C /* RoomIncomingTextMsgWithoutSenderNameBubbleCell.m in Sources */,
F075BED61EBB169C00A7B68A /* RoomCollectionViewCell.m in Sources */,
F0E05A021E963103004B83FB /* FavouritesViewController.m in Sources */,
F083BE941E7009ED00A9B29C /* FilesSearchTableViewCell.m in Sources */,
F083BE921E7009ED00A9B29C /* SimpleRoomTitleView.m in Sources */,

View file

@ -52,6 +52,11 @@ extern NSString *const kRecentsDataSourceTapOnDirectoryServerChange;
@property (nonatomic) NSInteger conversationSection;
@property (nonatomic) NSInteger lowPrioritySection;
@property (nonatomic, readonly) NSArray* invitesCellDataArray;
@property (nonatomic, readonly) NSArray* favoriteCellDataArray;
@property (nonatomic, readonly) NSArray* conversationCellDataArray;
@property (nonatomic, readonly) NSArray* lowPriorityCellDataArray;
/**
Set the delegate by specifying the selected display mode.
*/

View file

@ -56,6 +56,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
@implementation RecentsDataSource
@synthesize directorySection, invitesSection, favoritesSection, conversationSection, lowPrioritySection;
@synthesize hiddenCellIndexPath, droppingCellIndexPath, droppingCellBackGroundView;
@synthesize invitesCellDataArray, favoriteCellDataArray, conversationCellDataArray, lowPriorityCellDataArray;
- (instancetype)init
{
@ -237,7 +238,8 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
favoritesSection = sectionsCount++;
}
if (conversationCellDataArray.count > 0 || (_recentsDataSourceMode == RecentsDataSourceModePeople) || (_recentsDataSourceMode == RecentsDataSourceModeRooms))
// Keep visible the main rooms section even if it is empty, except on favourites screen.
if (_recentsDataSourceMode != RecentsDataSourceModeFavourites)
{
conversationSection = sectionsCount++;
}
@ -702,7 +704,7 @@ NSString *const kRecentsDataSourceTapOnDirectoryServerChange = @"kRecentsDataSou
}
// Check whether a search session is in progress
if (searchPatternsList)
if (self.searchPatternsList)
{
tableViewCell.textLabel.text = NSLocalizedStringFromTable(@"search_no_result", @"Vector", nil);
}

View file

@ -20,6 +20,6 @@
/**
The `HomeViewController` screen is the main app screen.
*/
@interface HomeViewController : RecentsViewController
@interface HomeViewController : RecentsViewController <UITableViewDataSource, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout>
@end

View file

@ -21,6 +21,15 @@
#import "RecentsDataSource.h"
#import "TableViewCellWithCollectionView.h"
#import "RoomCollectionViewCell.h"
@interface HomeViewController ()
{
RecentsDataSource *recentsDataSource;
}
@end
@implementation HomeViewController
- (void)finalizeInit
@ -37,17 +46,14 @@
self.view.accessibilityIdentifier = @"HomeVCView";
self.recentsTableView.accessibilityIdentifier = @"HomeVCTableView";
// TODO: Implement the new home screen.
// Hide the table view FTM.
self.recentsTableView.hidden = YES;
UIImageView *sheltieWaiting = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sheltie-waiting-porch.jpg"]];
sheltieWaiting.frame = self.view.frame;
sheltieWaiting.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin);
sheltieWaiting.contentMode = UIViewContentModeScaleAspectFit;
[self.view addSubview:sheltieWaiting];
// Add room creation button programmatically
[self addRoomCreationButton];
// Register table view cell used for rooms collection.
[self.recentsTableView registerClass:TableViewCellWithCollectionView.class forCellReuseIdentifier:TableViewCellWithCollectionView.defaultReuseIdentifier];
// Change the table data source. It must be the home view controller itself.
self.recentsTableView.dataSource = self;
}
- (void)viewWillAppear:(BOOL)animated
@ -56,11 +62,10 @@
[AppDelegate theDelegate].masterTabBarController.navigationItem.title = NSLocalizedStringFromTable(@"title_home", @"Vector", nil);
if ([self.dataSource isKindOfClass:RecentsDataSource.class])
if (recentsDataSource)
{
// Take the lead on the shared data source.
RecentsDataSource *recentsDataSource = (RecentsDataSource*)self.dataSource;
recentsDataSource.areSectionsShrinkable = YES;
recentsDataSource.areSectionsShrinkable = NO;
[recentsDataSource setDelegate:self andRecentsDataSourceMode:RecentsDataSourceModeHome];
}
}
@ -77,19 +82,30 @@
#pragma mark - Override RecentsViewController
- (void)displayList:(MXKRecentsDataSource *)listDataSource
{
[super displayList:listDataSource];
// Change the table data source. It must be the home view controller itself.
self.recentsTableView.dataSource = self;
// Keep a ref on the recents data source
if ([listDataSource isKindOfClass:RecentsDataSource.class])
{
recentsDataSource = (RecentsDataSource*)listDataSource;
}
}
- (void)refreshCurrentSelectedCell:(BOOL)forceVisible
{
// Check whether the recents data source is correctly configured.
if ([self.dataSource isKindOfClass:RecentsDataSource.class])
if (recentsDataSource.recentsDataSourceMode != RecentsDataSourceModeHome)
{
RecentsDataSource *recentsDataSource = (RecentsDataSource*)self.dataSource;
if (recentsDataSource.recentsDataSourceMode != RecentsDataSourceModeHome)
{
return;
}
return;
}
[super refreshCurrentSelectedCell:forceVisible];
// TODO: refreshCurrentSelectedCell
//[super refreshCurrentSelectedCell:forceVisible];
}
- (void)onRoomCreationButtonPressed
@ -136,4 +152,141 @@
[currentAlert showInViewController:self];
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the actual number of sections prepared in recents dataSource.
return [recentsDataSource numberOfSectionsInTableView:tableView];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Each rooms section is represented by only one collection view.
return 1;
}
- (CGFloat)heightForHeaderInSection:(NSInteger)section
{
// Keep the recents data source informations on the section headers.
return [recentsDataSource heightForHeaderInSection:section];
}
- (NSString *)titleForHeaderInSection:(NSInteger)section
{
// Keep the recents data source informations on the section headers.
return [recentsDataSource titleForHeaderInSection:section];
}
- (UIView *)viewForHeaderInSection:(NSInteger)section withFrame:(CGRect)frame
{
// Keep the recents data source informations on the section headers.
return [recentsDataSource viewForHeaderInSection:section withFrame:frame];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == recentsDataSource.conversationSection && !recentsDataSource.conversationCellDataArray.count)
{
MXKTableViewCell *tableViewCell = [tableView dequeueReusableCellWithIdentifier:[MXKTableViewCell defaultReuseIdentifier]];
if (!tableViewCell)
{
tableViewCell = [[MXKTableViewCell alloc] init];
tableViewCell.textLabel.textColor = kRiotTextColorGray;
tableViewCell.textLabel.font = [UIFont systemFontOfSize:15.0];
tableViewCell.selectionStyle = UITableViewCellSelectionStyleNone;
}
// Check whether a search session is in progress
if (recentsDataSource.searchPatternsList)
{
tableViewCell.textLabel.text = NSLocalizedStringFromTable(@"search_no_result", @"Vector", nil);
}
else
{
tableViewCell.textLabel.text = NSLocalizedStringFromTable(@"room_recents_no_conversation", @"Vector", nil);
}
return tableViewCell;
}
TableViewCellWithCollectionView *collectionViewCell = [tableView dequeueReusableCellWithIdentifier:TableViewCellWithCollectionView.defaultReuseIdentifier forIndexPath:indexPath];
collectionViewCell.collectionView.tag = indexPath.section;
[collectionViewCell.collectionView registerClass:RoomCollectionViewCell.class forCellWithReuseIdentifier:RoomCollectionViewCell.defaultReuseIdentifier];
collectionViewCell.collectionView.delegate = self;
collectionViewCell.collectionView.dataSource = self;
collectionViewCell.selectionStyle = UITableViewCellSelectionStyleNone;
return collectionViewCell;
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
return NO;
}
#pragma mark - UITableView delegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == recentsDataSource.conversationSection && !recentsDataSource.conversationCellDataArray.count)
{
return 50.0;
}
// Return the fixed height of the collection view cell used to display a room.
return [RoomCollectionViewCell defaultCellSize].height;
}
#pragma mark - UICollectionViewDataSource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [recentsDataSource tableView:self.recentsTableView numberOfRowsInSection:collectionView.tag];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
RoomCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:RoomCollectionViewCell.defaultReuseIdentifier
forIndexPath:indexPath];
id<MXKRecentCellDataStoring> cellData = [recentsDataSource cellDataAtIndexPath:[NSIndexPath indexPathForRow:indexPath.item inSection:collectionView.tag]];
if (cellData)
{
[cell render:cellData];
cell.tag = indexPath.item;
//TODO: add long tap gesture recognizer.
// UILongPressGestureRecognizer *cellLongPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onCollectionViewCellLongPress:)];
// [cell addGestureRecognizer:cellLongPressGesture];
}
return cell;
}
#pragma mark - UICollectionViewDelegate
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
if (self.delegate)
{
id<MXKRecentCellDataStoring> cellData = [recentsDataSource cellDataAtIndexPath:[NSIndexPath indexPathForRow:indexPath.item inSection:collectionView.tag]];
[self.delegate recentListViewController:self didSelectRoom:cellData.roomSummary.roomId inMatrixSession:cellData.roomSummary.room.mxSession];
}
// Hide the keyboard when user select a room
// do not hide the searchBar until the view controller disappear
// on tablets / iphone 6+, the user could expect to search again while looking at a room
[self.recentsSearchBar resignFirstResponder];
}
#pragma mark - UICollectionViewDelegateFlowLayout
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
return [RoomCollectionViewCell defaultCellSize];
}
@end

View file

@ -53,6 +53,12 @@
*/
@property (nonatomic) BOOL shouldScrollToTopOnRefresh;
/**
Tell whether the drag and drop option are enabled. NO by default.
This option is used to move a room from a section to another.
*/
@property (nonatomic) BOOL enableDragging;
/**
Tell whether the sticky headers are enabled. NO by default.
*/

View file

@ -41,7 +41,8 @@
// Tell whether a recents refresh is pending (suspended during editing mode).
BOOL isRefreshPending;
// recents drag and drop management
// Recents drag and drop management
UILongPressGestureRecognizer *longPressGestureRecognizer;
UIImageView *cellSnapshot;
NSIndexPath* movingCellPath;
MXRoom* movingRoom;
@ -95,6 +96,8 @@
// Set default screen name
_screenName = @"RecentsScreen";
_enableDragging = NO;
_enableStickyHeaders = NO;
_stickyHeaderHeight = 30.0;
@ -128,9 +131,6 @@
// Register here the customized cell view class used to render recents
[self.recentsTableView registerNib:RecentTableViewCell.nib forCellReuseIdentifier:RecentTableViewCell.defaultReuseIdentifier];
[self.recentsTableView registerNib:InviteRecentTableViewCell.nib forCellReuseIdentifier:InviteRecentTableViewCell.defaultReuseIdentifier];
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onRecentsLongPress:)];
[self.recentsTableView addGestureRecognizer:longPress];
// Hide line separators of empty cells
self.recentsTableView.tableFooterView = [[UIView alloc] init];
@ -150,6 +150,8 @@
- (void)destroy
{
[super destroy];
longPressGestureRecognizer = nil;
if (currentRequest)
{
@ -1238,7 +1240,25 @@
}
}
#pragma mark - recents drag & drop management
#pragma mark - Recents drag & drop management
- (void)setEnableDragging:(BOOL)enableDragging
{
if (_enableDragging != enableDragging)
{
_enableDragging = enableDragging;
if (_enableDragging)
{
longPressGestureRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onRecentsLongPress:)];
[self.recentsTableView addGestureRecognizer:longPressGestureRecognizer];
}
else if (longPressGestureRecognizer)
{
[self.recentsTableView removeGestureRecognizer:longPressGestureRecognizer];
}
}
}
- (void)onRecentsDragEnd
{
@ -1256,6 +1276,11 @@
- (IBAction)onRecentsLongPress:(id)sender
{
if (sender != longPressGestureRecognizer)
{
return;
}
RecentsDataSource* recentsDataSource = nil;
if ([self.dataSource isKindOfClass:[RecentsDataSource class]])
@ -1269,8 +1294,7 @@
return;
}
UILongPressGestureRecognizer *longPress = (UILongPressGestureRecognizer *)sender;
UIGestureRecognizerState state = longPress.state;
UIGestureRecognizerState state = longPressGestureRecognizer.state;
// check if there is a moving cell during the long press managemnt
if ((state != UIGestureRecognizerStateBegan) && !movingCellPath)
@ -1278,7 +1302,7 @@
return;
}
CGPoint location = [longPress locationInView:self.recentsTableView];
CGPoint location = [longPressGestureRecognizer locationInView:self.recentsTableView];
switch (state)
{

View file

@ -0,0 +1,46 @@
/*
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 <MatrixKit/MatrixKit.h>
/**
'RoomCollectionViewCell' class is used to display a room in a collection view.
*/
@interface RoomCollectionViewCell : MXKCollectionViewCell <MXKCellRendering>
{
@protected
/**
The current cell data displayed by the collection view cell
*/
id<MXKRecentCellDataStoring> roomCellData;
}
@property (weak, nonatomic) IBOutlet UILabel *roomTitle;
@property (weak, nonatomic) IBOutlet UIView *directRoomBorderView;
@property (weak, nonatomic) IBOutlet MXKImageView *roomAvatar;
@property (weak, nonatomic) IBOutlet UIImageView *encryptedRoomIcon;
@property (weak, nonatomic) IBOutlet UILabel *missedNotifAndUnreadBadgeLabel;
@property (weak, nonatomic) IBOutlet UIView *missedNotifAndUnreadBadgeBgView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *missedNotifAndUnreadBadgeBgViewWidthConstraint;
/**
The default collection view cell size.
*/
+ (CGSize)defaultCellSize;
@end

View file

@ -0,0 +1,141 @@
/*
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 "RoomCollectionViewCell.h"
#import "AvatarGenerator.h"
#import "RiotDesignValues.h"
#import "MXRoom+Riot.h"
@implementation RoomCollectionViewCell
#pragma mark - Class methods
- (void)awakeFromNib
{
[super awakeFromNib];
// Initialize unread count badge
[_missedNotifAndUnreadBadgeBgView.layer setCornerRadius:10];
_missedNotifAndUnreadBadgeBgViewWidthConstraint.constant = 0;
self.roomTitle.textColor = kRiotTextColorBlack;
self.missedNotifAndUnreadBadgeLabel.textColor = [UIColor whiteColor];
self.directRoomBorderView.backgroundColor = kRiotColorGreen;
self.directRoomBorderView.alpha = 0.75;
[self.directRoomBorderView.layer setCornerRadius:self.directRoomBorderView.frame.size.width / 2];
self.directRoomBorderView.clipsToBounds = YES;
// Disable the user interaction on the room avatar.
self.roomAvatar.userInteractionEnabled = NO;
}
- (void)layoutSubviews
{
[super layoutSubviews];
// Round image view
[_roomAvatar.layer setCornerRadius:_roomAvatar.frame.size.width / 2];
_roomAvatar.clipsToBounds = YES;
}
- (void)render:(MXKCellData *)cellData
{
// Hide by default missed notifications and unread widgets
self.missedNotifAndUnreadBadgeBgView.hidden = YES;
self.missedNotifAndUnreadBadgeBgViewWidthConstraint.constant = 0;
roomCellData = (id<MXKRecentCellDataStoring>)cellData;
if (roomCellData)
{
// Report computed values as is
self.roomTitle.text = roomCellData.roomDisplayname;
// Notify unreads and bing
if (roomCellData.hasUnread)
{
if (0 < roomCellData.notificationCount)
{
self.missedNotifAndUnreadBadgeBgView.hidden = NO;
self.missedNotifAndUnreadBadgeBgView.backgroundColor = roomCellData.highlightCount ? kRiotColorPinkRed : kRiotColorGreen;
self.missedNotifAndUnreadBadgeLabel.text = [NSString stringWithFormat:@"%tu", roomCellData.notificationCount];
[self.missedNotifAndUnreadBadgeLabel sizeToFit];
self.missedNotifAndUnreadBadgeBgViewWidthConstraint.constant = self.missedNotifAndUnreadBadgeLabel.frame.size.width + 18;
}
// Use bold font for the room title
if ([UIFont respondsToSelector:@selector(systemFontOfSize:weight:)])
{
self.roomTitle.font = [UIFont systemFontOfSize:15 weight:UIFontWeightBold];
}
else
{
self.roomTitle.font = [UIFont boldSystemFontOfSize:15];
}
}
else
{
// The room title is not bold anymore
if ([UIFont respondsToSelector:@selector(systemFontOfSize:weight:)])
{
self.roomTitle.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
}
else
{
self.roomTitle.font = [UIFont systemFontOfSize:15];
}
}
self.roomAvatar.backgroundColor = [UIColor clearColor];
self.directRoomBorderView.hidden = !roomCellData.roomSummary.room.isDirect;
self.encryptedRoomIcon.hidden = !roomCellData.roomSummary.isEncrypted;
[roomCellData.roomSummary.room setRoomAvatarImageIn:self.roomAvatar];
}
}
+ (CGFloat)heightForCellData:(MXKCellData *)cellData withMaximumWidth:(CGFloat)maxWidth
{
// The height is fixed
return 110;
}
+ (CGSize)defaultCellSize
{
return CGSizeMake(90, 110);
}
- (void)prepareForReuse
{
[super prepareForReuse];
// Remove all gesture recognizers
while (self.gestureRecognizers.count)
{
[self removeGestureRecognizer:self.gestureRecognizers[0]];
}
self.tag = -1;
}
@end

View file

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="eCk-zY-LXq" customClass="RoomCollectionViewCell">
<rect key="frame" x="0.0" y="0.0" width="90" height="110"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="90" height="110"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="xws-BR-H47">
<rect key="frame" x="10" y="5" width="70" height="70"/>
<color key="backgroundColor" red="0.6886889638" green="1" blue="0.74383144840000004" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="width" constant="70" id="3OW-3y-Rg7"/>
<constraint firstAttribute="width" secondItem="xws-BR-H47" secondAttribute="height" multiplier="1:1" id="bEP-hL-5lg"/>
</constraints>
</view>
<view contentMode="scaleAspectFit" translatesAutoresizingMaskIntoConstraints="NO" id="T1Q-RS-8o6" customClass="MXKImageView">
<rect key="frame" x="15" y="10" width="60" height="60"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="width" constant="60" id="Raw-38-dXN"/>
<constraint firstAttribute="width" secondItem="T1Q-RS-8o6" secondAttribute="height" multiplier="1:1" id="zmb-Nw-TEX"/>
</constraints>
</view>
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Q6g-b0-3sZ">
<rect key="frame" x="90" y="5" width="0.0" height="20"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="2" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ZUZ-tv-dVV">
<rect key="frame" x="-4" y="2" width="9" height="17"/>
<accessibility key="accessibilityConfiguration" identifier="MissedNotifAndUnreadBadge"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="14"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" red="0.0" green="0.72547743060000003" blue="0.0041503219759999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="D9K-B0-riB"/>
<constraint firstItem="ZUZ-tv-dVV" firstAttribute="centerY" secondItem="Q6g-b0-3sZ" secondAttribute="centerY" id="XGQ-9J-nIX"/>
<constraint firstAttribute="width" id="jeX-st-swl"/>
<constraint firstItem="ZUZ-tv-dVV" firstAttribute="centerX" secondItem="Q6g-b0-3sZ" secondAttribute="centerX" id="km0-Wj-nJ0"/>
</constraints>
</view>
<imageView hidden="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="e2e_verified.png" translatesAutoresizingMaskIntoConstraints="NO" id="5Yd-df-HbB">
<rect key="frame" x="63" y="55" width="15" height="18"/>
<constraints>
<constraint firstAttribute="height" constant="18" id="UEZ-5S-KMf"/>
<constraint firstAttribute="width" constant="15" id="bbS-D2-SZi"/>
</constraints>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="RoomTitle" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="oxX-IL-dG4">
<rect key="frame" x="4" y="80" width="82" height="21"/>
<accessibility key="accessibilityConfiguration" identifier="TitleLabel"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="WA1-mL-sFU"/>
</constraints>
<fontDescription key="fontDescription" type="system" weight="medium" pointSize="15"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</view>
<constraints>
<constraint firstAttribute="trailing" secondItem="5Yd-df-HbB" secondAttribute="trailing" constant="12" id="0gr-xn-dfD"/>
<constraint firstAttribute="bottom" secondItem="oxX-IL-dG4" secondAttribute="bottom" constant="9" id="1JB-d1-zb9"/>
<constraint firstItem="oxX-IL-dG4" firstAttribute="leading" secondItem="eCk-zY-LXq" secondAttribute="leading" constant="4" id="6gu-JD-Gb1"/>
<constraint firstItem="xws-BR-H47" firstAttribute="centerX" secondItem="T1Q-RS-8o6" secondAttribute="centerX" id="Lo3-Ov-Bw8"/>
<constraint firstAttribute="trailing" secondItem="Q6g-b0-3sZ" secondAttribute="trailing" id="Mf1-H6-oH4"/>
<constraint firstItem="T1Q-RS-8o6" firstAttribute="top" secondItem="eCk-zY-LXq" secondAttribute="top" constant="10" id="cc7-bg-15Z"/>
<constraint firstItem="xws-BR-H47" firstAttribute="centerY" secondItem="T1Q-RS-8o6" secondAttribute="centerY" id="faX-hg-WfP"/>
<constraint firstItem="5Yd-df-HbB" firstAttribute="top" secondItem="eCk-zY-LXq" secondAttribute="top" constant="55" id="h4R-2d-Xxn"/>
<constraint firstAttribute="trailing" secondItem="oxX-IL-dG4" secondAttribute="trailing" constant="4" id="hDl-X9-M4n"/>
<constraint firstItem="T1Q-RS-8o6" firstAttribute="centerX" secondItem="eCk-zY-LXq" secondAttribute="centerX" id="hmB-fl-oN2"/>
<constraint firstItem="Q6g-b0-3sZ" firstAttribute="top" secondItem="eCk-zY-LXq" secondAttribute="top" constant="5" id="jST-Ic-lsn"/>
</constraints>
<connections>
<outlet property="directRoomBorderView" destination="xws-BR-H47" id="34A-hu-DXq"/>
<outlet property="encryptedRoomIcon" destination="5Yd-df-HbB" id="5pc-Vi-wMZ"/>
<outlet property="missedNotifAndUnreadBadgeBgView" destination="Q6g-b0-3sZ" id="jNG-dA-dfP"/>
<outlet property="missedNotifAndUnreadBadgeBgViewWidthConstraint" destination="jeX-st-swl" id="4sa-wn-bgT"/>
<outlet property="missedNotifAndUnreadBadgeLabel" destination="ZUZ-tv-dVV" id="6IV-rz-s4I"/>
<outlet property="roomAvatar" destination="T1Q-RS-8o6" id="4sR-Wm-jwz"/>
<outlet property="roomTitle" destination="oxX-IL-dG4" id="vff-Fw-AOf"/>
</connections>
</collectionViewCell>
</objects>
<resources>
<image name="e2e_verified.png" width="10" height="12"/>
</resources>
</document>

View file

@ -0,0 +1,23 @@
/*
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 <MatrixKit/MatrixKit.h>
@interface TableViewCellWithCollectionView : MXKTableViewCell
@property (strong, nonatomic) IBOutlet UICollectionView *collectionView;
@end

View file

@ -0,0 +1,31 @@
/*
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 "TableViewCellWithCollectionView.h"
@implementation TableViewCellWithCollectionView
- (void)prepareForReuse
{
[super prepareForReuse];
self.collectionView.tag = -1;
self.collectionView.dataSource = nil;
self.collectionView.delegate = nil;
}
@end

View file

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" id="20U-7H-xmi" customClass="TableViewCellWithCollectionView">
<rect key="frame" x="0.0" y="0.0" width="600" height="110"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="20U-7H-xmi" id="cFw-g7-Cgn">
<rect key="frame" x="0.0" y="0.0" width="600" height="109.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="iXt-1Y-bEu">
<rect key="frame" x="0.0" y="0.0" width="600" height="109.5"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" minimumLineSpacing="10" minimumInteritemSpacing="10" id="zZI-Za-2q1">
<size key="itemSize" width="50" height="50"/>
<size key="headerReferenceSize" width="0.0" height="0.0"/>
<size key="footerReferenceSize" width="0.0" height="0.0"/>
<inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
</collectionViewFlowLayout>
</collectionView>
</subviews>
<constraints>
<constraint firstAttribute="bottom" secondItem="iXt-1Y-bEu" secondAttribute="bottom" id="Rtx-zg-IZA"/>
<constraint firstItem="iXt-1Y-bEu" firstAttribute="top" secondItem="cFw-g7-Cgn" secondAttribute="top" id="eEg-xT-ju4"/>
<constraint firstAttribute="trailing" secondItem="iXt-1Y-bEu" secondAttribute="trailing" id="lAZ-3p-GBF"/>
<constraint firstItem="iXt-1Y-bEu" firstAttribute="leading" secondItem="cFw-g7-Cgn" secondAttribute="leading" id="n3c-tX-orx"/>
</constraints>
</tableViewCellContentView>
<accessibility key="accessibilityConfiguration" identifier="TableViewCell"/>
<connections>
<outlet property="collectionView" destination="iXt-1Y-bEu" id="4ms-f4-dIa"/>
</connections>
</tableViewCell>
</objects>
</document>