mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-29 20:56:57 +02:00
e0ef651074
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.8 KiB
Objective-C
95 lines
2.8 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 "RoomMembershipCollapsedBubbleCell.h"
|
|
|
|
#import "RiotDesignValues.h"
|
|
|
|
#import "RoomBubbleCellData.h"
|
|
|
|
#import "AvatarGenerator.h"
|
|
|
|
@implementation RoomMembershipCollapsedBubbleCell
|
|
|
|
- (void)customizeTableViewCellRendering
|
|
{
|
|
[super customizeTableViewCellRendering];
|
|
|
|
self.messageTextView.tintColor = kRiotColorGreen;
|
|
}
|
|
|
|
- (void)layoutSubviews
|
|
{
|
|
[super layoutSubviews];
|
|
|
|
// Round avatars
|
|
for (UIView *avatarView in self.avatarsView.subviews)
|
|
{
|
|
[avatarView.layer setCornerRadius:avatarView.frame.size.width / 2];
|
|
avatarView.clipsToBounds = YES;
|
|
}
|
|
}
|
|
|
|
- (void)prepareForReuse
|
|
{
|
|
[super prepareForReuse];
|
|
|
|
// Reset avatars
|
|
for (UIView *avatarView in self.avatarsView.subviews)
|
|
{
|
|
[avatarView removeFromSuperview];
|
|
}
|
|
}
|
|
|
|
- (void)render:(MXKCellData *)cellData
|
|
{
|
|
[super render:cellData];
|
|
|
|
// Add up to 5 avatars to self.avatarsView
|
|
RoomBubbleCellData *nextBubbleData = (RoomBubbleCellData*)bubbleData;
|
|
|
|
do
|
|
{
|
|
MXKImageView *avatarView = [[MXKImageView alloc] initWithFrame:CGRectMake(12 * self.avatarsView.subviews.count, 0, 16, 16)];
|
|
|
|
// Handle user's picture by considering it is stored unencrypted on Matrix media repository
|
|
|
|
// Use the Riot style placeholder
|
|
if (!nextBubbleData.senderAvatarPlaceholder)
|
|
{
|
|
nextBubbleData.senderAvatarPlaceholder = [AvatarGenerator generateAvatarForMatrixItem:nextBubbleData.senderId withDisplayName:nextBubbleData.senderDisplayName];
|
|
}
|
|
|
|
avatarView.enableInMemoryCache = YES;
|
|
[avatarView setImageURI:nextBubbleData.senderAvatarUrl
|
|
withType:nil
|
|
andImageOrientation:UIImageOrientationUp
|
|
toFitViewSize:avatarView.frame.size
|
|
withMethod:MXThumbnailingMethodCrop
|
|
previewImage:nextBubbleData.senderAvatarPlaceholder
|
|
mediaManager:nextBubbleData.mxSession.mediaManager];
|
|
|
|
// Clear the default background color of a MXKImageView instance
|
|
avatarView.defaultBackgroundColor = [UIColor clearColor];
|
|
|
|
[self.avatarsView addSubview:avatarView];
|
|
}
|
|
while ((nextBubbleData = nextBubbleData.nextCollapsableCellData) && self.avatarsView.subviews.count < 5);
|
|
}
|
|
|
|
@end
|