Merge pull request #372 from vector-im/371

Bug Fix - Room Preview: the room avatar is missing on invited room re…
This commit is contained in:
giomfo 2016-06-06 16:23:36 +02:00
commit 5a56614a76
3 changed files with 30 additions and 15 deletions

View file

@ -879,7 +879,9 @@
[self setRoomTitleViewClass:RoomAvatarTitleView.class];
// Note the avatar title view does not define tap gesture.
roomAvatarView = ((RoomAvatarTitleView*)self.titleView).roomAvatar;
RoomAvatarTitleView *roomAvatarTitleView = (RoomAvatarTitleView*)self.titleView;
roomAvatarView = roomAvatarTitleView.roomAvatar;
roomAvatarView.alpha = 0.0;
shadowImage = [[UIImage alloc] init];
@ -887,12 +889,18 @@
// Set the avatar provided in preview data
if (roomPreviewData.roomAvatarUrl)
{
RoomAvatarTitleView *roomAvatarTitleView = (RoomAvatarTitleView*)self.titleView;
MXKImageView *roomAvatarView = roomAvatarTitleView.roomAvatar;
NSString *roomAvatarUrl = [self.mainSession.matrixRestClient urlOfContentThumbnail:roomPreviewData.roomAvatarUrl toFitViewSize:roomAvatarView.frame.size withMethod:MXThumbnailingMethodCrop];
roomAvatarTitleView.roomAvatarURL = roomAvatarUrl;
}
else if (roomPreviewData.roomId && roomPreviewData.roomName)
{
roomAvatarTitleView.roomAvatarPlaceholder = [AvatarGenerator generateRoomAvatar:roomPreviewData.roomId andDisplayName:roomPreviewData.roomName];
}
else
{
roomAvatarTitleView.roomAvatarPlaceholder = [UIImage imageNamed:@"placeholder"];
}
}
else
{

View file

@ -22,5 +22,6 @@
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *roomAvatarCenterXConstraint;
@property (nonatomic) NSString *roomAvatarURL;
@property (nonatomic) UIImage *roomAvatarPlaceholder;
@end

View file

@ -71,24 +71,23 @@
if (self.mxRoom)
{
[self.mxRoom setRoomAvatarImageIn:self.roomAvatar];
// Round image view for thumbnail
self.roomAvatar.layer.cornerRadius = self.roomAvatar.frame.size.width / 2;
self.roomAvatar.clipsToBounds = YES;
}
else if (self.roomAvatarURL)
{
[self.roomAvatar setImageURL:self.roomAvatarURL withType:nil andImageOrientation:UIImageOrientationUp previewImage:[UIImage imageNamed:@"placeholder"]];
// Round image view for thumbnail
self.roomAvatar.layer.cornerRadius = self.roomAvatar.frame.size.width / 2;
self.roomAvatar.clipsToBounds = YES;
[self.roomAvatar setImageURL:self.roomAvatarURL withType:nil andImageOrientation:UIImageOrientationUp previewImage:[UIImage imageNamed:@"placeholder"]];
}
else if (self.roomAvatarPlaceholder)
{
self.roomAvatar.image = self.roomAvatarPlaceholder;
}
else
{
self.roomAvatar.image = [UIImage imageNamed:@"placeholder"];
}
self.roomAvatar.image = nil;
}
// Round image view for thumbnail
self.roomAvatar.layer.cornerRadius = self.roomAvatar.frame.size.width / 2;
self.roomAvatar.clipsToBounds = YES;
self.roomAvatar.backgroundColor = kVectorColorLightGrey;
}
@ -100,4 +99,11 @@
[self refreshDisplay];
}
- (void)setRoomAvatarPlaceholder:(UIImage *)roomAvatarPlaceholder
{
_roomAvatarPlaceholder = roomAvatarPlaceholder;
[self refreshDisplay];
}
@end