2015-12-22 08:26:08 +00:00
|
|
|
/*
|
|
|
|
Copyright 2015 OpenMarket Ltd
|
2017-08-11 14:56:09 +00:00
|
|
|
Copyright 2017 Vector Creations Ltd
|
2015-12-22 08:26:08 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import "PublicRoomTableViewCell.h"
|
|
|
|
|
2015-12-22 10:49:08 +00:00
|
|
|
#import "AvatarGenerator.h"
|
|
|
|
#import "MXKImageView.h"
|
|
|
|
|
2017-08-11 14:56:09 +00:00
|
|
|
#import "RiotDesignValues.h"
|
|
|
|
|
2015-12-22 08:26:08 +00:00
|
|
|
@implementation PublicRoomTableViewCell
|
|
|
|
|
2015-12-22 10:49:08 +00:00
|
|
|
- (void)awakeFromNib
|
|
|
|
{
|
|
|
|
[super awakeFromNib];
|
|
|
|
|
|
|
|
// Round image view
|
|
|
|
[_roomAvatar.layer setCornerRadius:_roomAvatar.frame.size.width / 2];
|
|
|
|
_roomAvatar.clipsToBounds = YES;
|
|
|
|
}
|
|
|
|
|
2017-08-11 14:56:09 +00:00
|
|
|
- (void)customizeTableViewCellRendering
|
|
|
|
{
|
|
|
|
[super customizeTableViewCellRendering];
|
|
|
|
|
|
|
|
self.roomDisplayName.textColor = kRiotPrimaryTextColor;
|
|
|
|
self.roomTopic.textColor = kRiotSecondaryTextColor;
|
|
|
|
self.memberCount.textColor = kRiotSecondaryTextColor;
|
|
|
|
|
|
|
|
_roomAvatar.backgroundColor = [UIColor clearColor];
|
|
|
|
}
|
|
|
|
|
2015-12-22 10:49:08 +00:00
|
|
|
- (void)render:(MXPublicRoom *)publicRoom withMatrixSession:(MXSession*)mxSession
|
|
|
|
{
|
|
|
|
[super render:publicRoom];
|
|
|
|
|
|
|
|
// Set room display name a la Vector
|
|
|
|
self.roomDisplayName.text = publicRoom.name;
|
|
|
|
if (!self.roomDisplayName.text)
|
|
|
|
{
|
|
|
|
self.roomDisplayName.text = publicRoom.aliases[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the avatar
|
2016-09-09 13:11:12 +00:00
|
|
|
UIImage* avatarImage = [AvatarGenerator generateAvatarForMatrixItem:publicRoom.roomId withDisplayName:self.roomDisplayName.text];
|
2015-12-22 10:49:08 +00:00
|
|
|
|
|
|
|
if (publicRoom.avatarUrl)
|
|
|
|
{
|
|
|
|
_roomAvatar.enableInMemoryCache = YES;
|
|
|
|
|
|
|
|
[_roomAvatar setImageURL:[mxSession.matrixRestClient urlOfContentThumbnail:publicRoom.avatarUrl
|
|
|
|
toFitViewSize:_roomAvatar.frame.size
|
|
|
|
withMethod:MXThumbnailingMethodCrop]
|
|
|
|
withType:nil
|
|
|
|
andImageOrientation:UIImageOrientationUp previewImage:avatarImage];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_roomAvatar.image = avatarImage;
|
|
|
|
}
|
2016-06-02 09:35:29 +00:00
|
|
|
|
2015-12-22 10:49:08 +00:00
|
|
|
_roomAvatar.contentMode = UIViewContentModeScaleAspectFill;
|
|
|
|
}
|
|
|
|
|
2017-04-26 09:10:44 +00:00
|
|
|
+ (CGFloat)cellHeight
|
|
|
|
{
|
|
|
|
return 74;
|
|
|
|
}
|
|
|
|
|
2015-12-22 08:26:08 +00:00
|
|
|
@end
|