mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-30 08:12:40 +00:00
3258e3abc1
Note - DirectoryServerTableViewCell: Presently the thirdPartyProtocolInstance.icon is not a Matrix Content URI. We could not use here MXKImageView setImageURI method without breaking the instance icon rendering. We use the deprecated interface until this point is fixed on the server side.
95 lines
2.7 KiB
Objective-C
95 lines
2.7 KiB
Objective-C
/*
|
|
Copyright 2017 Vector Creations Ltd
|
|
Copyright 2018 New Vector 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 "GroupRoomTableViewCell.h"
|
|
|
|
#import "AvatarGenerator.h"
|
|
|
|
#import "RiotDesignValues.h"
|
|
|
|
@implementation GroupRoomTableViewCell
|
|
|
|
- (void)awakeFromNib
|
|
{
|
|
[super awakeFromNib];
|
|
|
|
// Round image view
|
|
[_roomAvatar.layer setCornerRadius:_roomAvatar.frame.size.width / 2];
|
|
_roomAvatar.clipsToBounds = YES;
|
|
}
|
|
|
|
- (void)customizeTableViewCellRendering
|
|
{
|
|
[super customizeTableViewCellRendering];
|
|
|
|
self.roomDisplayName.textColor = kRiotPrimaryTextColor;
|
|
self.roomTopic.textColor = kRiotSecondaryTextColor;
|
|
|
|
_roomAvatar.defaultBackgroundColor = [UIColor clearColor];
|
|
}
|
|
|
|
- (void)render:(MXGroupRoom *)groupRoom withMatrixSession:(MXSession*)mxSession
|
|
{
|
|
// Set room display name
|
|
self.roomDisplayName.text = groupRoom.name;
|
|
if (!self.roomDisplayName.text)
|
|
{
|
|
self.roomDisplayName.text = groupRoom.canonicalAlias;
|
|
}
|
|
if (!self.roomDisplayName.text)
|
|
{
|
|
self.roomDisplayName.text = groupRoom.roomId;
|
|
}
|
|
|
|
// Check whether this room has topic
|
|
if (groupRoom.topic)
|
|
{
|
|
_roomTopic.hidden = NO;
|
|
_roomTopic.text = [MXTools stripNewlineCharacters:groupRoom.topic];
|
|
}
|
|
else
|
|
{
|
|
// Hide and fill the label with a fake description to harmonize the height of all the cells.
|
|
// This is a drawback of the self-sizing cell.
|
|
_roomTopic.hidden = YES;
|
|
_roomTopic.text = @"No topic";
|
|
}
|
|
|
|
// Set the avatar
|
|
UIImage* avatarImage = [AvatarGenerator generateAvatarForMatrixItem:groupRoom.roomId withDisplayName:self.roomDisplayName.text];
|
|
|
|
if (groupRoom.avatarUrl)
|
|
{
|
|
_roomAvatar.enableInMemoryCache = YES;
|
|
|
|
[_roomAvatar setImageURI:groupRoom.avatarUrl
|
|
withType:nil
|
|
andImageOrientation:UIImageOrientationUp
|
|
toFitViewSize:_roomAvatar.frame.size
|
|
withMethod:MXThumbnailingMethodCrop
|
|
previewImage:avatarImage
|
|
mediaManager:mxSession.mediaManager];
|
|
}
|
|
else
|
|
{
|
|
_roomAvatar.image = avatarImage;
|
|
}
|
|
|
|
_roomAvatar.contentMode = UIViewContentModeScaleAspectFill;
|
|
}
|
|
|
|
@end
|