2017-09-15 15:17:03 +00:00
|
|
|
/*
|
|
|
|
Copyright 2017 Aram Sargsyan
|
|
|
|
|
|
|
|
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 "RecentRoomTableViewCell.h"
|
|
|
|
|
2017-09-29 08:37:54 +00:00
|
|
|
#import "MXRoomSummary+Riot.h"
|
2021-06-29 13:17:49 +00:00
|
|
|
#import "ThemeService.h"
|
2021-10-14 09:05:28 +00:00
|
|
|
|
2021-10-26 15:42:33 +00:00
|
|
|
#import "GeneratedInterface-Swift.h"
|
2017-09-29 08:37:54 +00:00
|
|
|
|
2017-09-15 15:17:03 +00:00
|
|
|
@interface RecentRoomTableViewCell ()
|
|
|
|
|
|
|
|
@property (weak, nonatomic) IBOutlet MXKImageView *avatarImageView;
|
|
|
|
@property (weak, nonatomic) IBOutlet UILabel *roomTitleLabel;
|
|
|
|
@property (weak, nonatomic) IBOutlet UIImageView *encryptedRoomIcon;
|
2021-10-18 13:30:32 +00:00
|
|
|
@property (weak, nonatomic) IBOutlet UIButton *selectionButton;
|
2017-09-15 15:17:03 +00:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation RecentRoomTableViewCell
|
|
|
|
|
|
|
|
#pragma mark - MXKRecentTableViewCell
|
|
|
|
|
|
|
|
+ (UINib *)nib
|
|
|
|
{
|
|
|
|
// Check whether a nib file is available
|
|
|
|
NSBundle *mainBundle = [NSBundle bundleForClass:self.class];
|
|
|
|
|
|
|
|
NSString *path = [mainBundle pathForResource:NSStringFromClass([self class]) ofType:@"nib"];
|
|
|
|
if (path)
|
|
|
|
{
|
|
|
|
return [UINib nibWithNibName:NSStringFromClass([self class]) bundle:mainBundle];
|
|
|
|
}
|
2021-10-28 07:16:22 +00:00
|
|
|
|
2017-09-15 15:17:03 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
2021-06-29 13:17:49 +00:00
|
|
|
- (void)awakeFromNib
|
|
|
|
{
|
|
|
|
[super awakeFromNib];
|
|
|
|
|
|
|
|
self.roomTitleLabel.textColor = ThemeService.shared.theme.textPrimaryColor;
|
|
|
|
self.contentView.backgroundColor = ThemeService.shared.theme.backgroundColor;
|
2021-10-25 10:45:41 +00:00
|
|
|
self.selectionButton.tintColor = ThemeService.shared.theme.tintColor;
|
2021-10-18 13:30:32 +00:00
|
|
|
|
2022-02-10 16:13:23 +00:00
|
|
|
[self.selectionButton setImage:AssetSharedImages.radioButtonDefault.image forState:UIControlStateNormal];
|
|
|
|
[self.selectionButton setImage:AssetSharedImages.radioButtonSelected.image forState:UIControlStateSelected];
|
2021-10-18 13:30:32 +00:00
|
|
|
|
|
|
|
[self.selectionButton setTitle:@"" forState:UIControlStateNormal];
|
|
|
|
[self.selectionButton setTitle:@"" forState:UIControlStateSelected];
|
2021-06-29 13:17:49 +00:00
|
|
|
}
|
|
|
|
|
2017-09-29 08:37:54 +00:00
|
|
|
- (void)layoutSubviews
|
2017-09-15 15:17:03 +00:00
|
|
|
{
|
2017-09-29 08:37:54 +00:00
|
|
|
[super layoutSubviews];
|
2017-09-15 15:17:03 +00:00
|
|
|
|
2017-09-29 08:37:54 +00:00
|
|
|
// Round room avatars
|
|
|
|
[self.avatarImageView.layer setCornerRadius:self.avatarImageView.frame.size.width / 2];
|
|
|
|
self.avatarImageView.clipsToBounds = YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)render:(MXKCellData *)cellData
|
|
|
|
{
|
|
|
|
// Sanity check: accept only object of MXKRecentCellData classes or sub-classes
|
|
|
|
NSParameterAssert([cellData isKindOfClass:[MXKRecentCellData class]]);
|
2017-09-15 15:17:03 +00:00
|
|
|
|
2017-09-29 08:37:54 +00:00
|
|
|
roomCellData = (id<MXKRecentCellDataStoring>)cellData;
|
|
|
|
if (roomCellData)
|
|
|
|
{
|
2021-09-28 14:30:39 +00:00
|
|
|
[self.avatarImageView vc_setRoomAvatarImageWith:roomCellData.avatarUrl
|
2021-10-12 08:49:55 +00:00
|
|
|
roomId:roomCellData.roomIdentifier
|
2021-09-28 14:30:39 +00:00
|
|
|
displayName:roomCellData.roomDisplayname
|
2021-10-29 10:47:06 +00:00
|
|
|
mediaManager:roomCellData.roomSummary.mxSession.mediaManager];
|
2017-09-29 08:37:54 +00:00
|
|
|
|
2021-09-28 14:30:39 +00:00
|
|
|
self.roomTitleLabel.text = roomCellData.roomDisplayname;
|
2017-09-29 08:37:54 +00:00
|
|
|
if (!self.roomTitleLabel.text.length)
|
|
|
|
{
|
2022-03-03 09:32:19 +00:00
|
|
|
self.roomTitleLabel.text = [VectorL10n roomDisplaynameEmptyRoom];
|
2017-09-29 08:37:54 +00:00
|
|
|
}
|
|
|
|
|
2021-03-16 07:59:50 +00:00
|
|
|
self.encryptedRoomIcon.hidden = YES;
|
2017-09-29 08:37:54 +00:00
|
|
|
}
|
2017-09-15 15:17:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+ (CGFloat)cellHeight
|
|
|
|
{
|
|
|
|
return 74;
|
|
|
|
}
|
|
|
|
|
2021-10-18 13:30:32 +00:00
|
|
|
- (void)setCustomSelected:(BOOL)selected animated:(BOOL)animated
|
|
|
|
{
|
|
|
|
[UIView animateWithDuration:(animated ? 0.25f : 0.0f) animations:^{
|
|
|
|
[self.selectionButton setSelected:selected];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2017-09-15 15:17:03 +00:00
|
|
|
@end
|