mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-05-22 23:52:11 +02:00
Public rooms search: PublicRoomTableViewCell: Show room avatar and display the room name as expected in Vector
This commit is contained in:
@@ -178,7 +178,7 @@ double const kPublicRoomsDirectoryDataExpiration = 10;
|
||||
publicRoomCell = [[PublicRoomTableViewCell alloc] init];
|
||||
}
|
||||
|
||||
[publicRoomCell render:_filteredRooms[indexPath.row]];
|
||||
[publicRoomCell render:_filteredRooms[indexPath.row] withMatrixSession:self.mxSession];
|
||||
|
||||
return publicRoomCell;
|
||||
}
|
||||
|
||||
@@ -18,4 +18,13 @@
|
||||
|
||||
@interface PublicRoomTableViewCell : MXKPublicRoomTableViewCell
|
||||
|
||||
/**
|
||||
Configure the cell in order to display the public room.
|
||||
|
||||
@param publicRoom the public room to render.
|
||||
*/
|
||||
- (void)render:(MXPublicRoom*)publicRoom withMatrixSession:(MXSession*)mxSession;
|
||||
|
||||
@property (weak, nonatomic) IBOutlet MXKImageView *roomAvatar;
|
||||
|
||||
@end
|
||||
|
||||
@@ -16,6 +16,50 @@
|
||||
|
||||
#import "PublicRoomTableViewCell.h"
|
||||
|
||||
#import "AvatarGenerator.h"
|
||||
#import "MXKImageView.h"
|
||||
|
||||
@implementation PublicRoomTableViewCell
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
[super awakeFromNib];
|
||||
|
||||
// Round image view
|
||||
[_roomAvatar.layer setCornerRadius:_roomAvatar.frame.size.width / 2];
|
||||
_roomAvatar.clipsToBounds = YES;
|
||||
}
|
||||
|
||||
- (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
|
||||
UIImage* avatarImage = [AvatarGenerator generateRoomAvatar:publicRoom.roomId andDisplayName:self.roomDisplayName.text];
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
_roomAvatar.contentMode = UIViewContentModeScaleAspectFill;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
<constraint firstAttribute="height" constant="42" id="WPC-tL-hnM"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" misplaced="YES" text="RoomTitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lg1-xQ-AGn">
|
||||
<rect key="frame" x="69" y="14" width="430" height="21"/>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" verticalHuggingPriority="251" text="RoomTitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Lg1-xQ-AGn">
|
||||
<rect key="frame" x="69" y="14" width="437" height="21"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="21" id="vCd-fx-d5z"/>
|
||||
</constraints>
|
||||
@@ -48,8 +48,8 @@
|
||||
<color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" misplaced="YES" text="x users" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="360-Go-RcG">
|
||||
<rect key="frame" x="503" y="16" width="87" height="18"/>
|
||||
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="x users" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="360-Go-RcG">
|
||||
<rect key="frame" x="510" y="16" width="80" height="18"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="80" id="uOj-6w-G8q"/>
|
||||
</constraints>
|
||||
@@ -76,6 +76,7 @@
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<connections>
|
||||
<outlet property="memberCount" destination="360-Go-RcG" id="odP-CD-Cz7"/>
|
||||
<outlet property="roomAvatar" destination="RX5-eD-c3c" id="XZm-X0-ep1"/>
|
||||
<outlet property="roomDisplayName" destination="Lg1-xQ-AGn" id="xsu-y3-L5l"/>
|
||||
<outlet property="roomTopic" destination="dQt-mN-T6b" id="xz7-Kr-2Fu"/>
|
||||
</connections>
|
||||
|
||||
Reference in New Issue
Block a user