2022-05-19 10:39:04 +08:00
|
|
|
//
|
|
|
|
// XPMonentsTopicCollectionViewCell.m
|
|
|
|
// xplan-ios
|
|
|
|
//
|
|
|
|
// Created by 冯硕 on 2022/5/18.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "XPMonentsTopicCollectionViewCell.h"
|
|
|
|
///Third
|
|
|
|
#import <Masonry/Masonry.h>
|
|
|
|
///Tool
|
|
|
|
#import "ThemeColor.h"
|
|
|
|
#import "UIImage+Utils.h"
|
2023-01-04 17:21:42 +08:00
|
|
|
#import "NetImageView.h"
|
2022-05-19 10:39:04 +08:00
|
|
|
///Model
|
|
|
|
#import "MonentsTopicModel.h"
|
|
|
|
|
|
|
|
@interface XPMonentsTopicCollectionViewCell ()
|
|
|
|
|
|
|
|
///背景
|
2023-01-04 17:21:42 +08:00
|
|
|
@property (nonatomic,strong) NetImageView *topicImageView;
|
2022-05-19 10:39:04 +08:00
|
|
|
///显示话题前面的#
|
|
|
|
@property (nonatomic,strong) UIImageView *iconImageView;
|
|
|
|
///显示话题
|
|
|
|
@property (nonatomic,strong) UILabel *topicLabel;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation XPMonentsTopicCollectionViewCell
|
|
|
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
|
|
self = [super initWithFrame:frame];
|
|
|
|
if (self) {
|
|
|
|
[self initSubViews];
|
|
|
|
[self initSubViewConstraints];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
|
|
- (void)initSubViews {
|
|
|
|
[self.contentView addSubview:self.topicImageView];
|
|
|
|
[self.topicImageView addSubview:self.iconImageView];
|
|
|
|
[self.topicImageView addSubview:self.topicLabel];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)initSubViewConstraints {
|
|
|
|
[self.topicImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.edges.mas_equalTo(self.contentView);
|
|
|
|
}];
|
|
|
|
|
|
|
|
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
2023-01-04 17:21:42 +08:00
|
|
|
make.left.right.bottom.mas_equalTo(self.topicImageView);
|
|
|
|
make.height.mas_equalTo(30);
|
2022-05-19 10:39:04 +08:00
|
|
|
}];
|
|
|
|
|
|
|
|
[self.topicLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
2023-01-04 17:21:42 +08:00
|
|
|
make.left.right.mas_equalTo(self.topicImageView).inset(2);
|
|
|
|
make.bottom.mas_equalTo(self.topicImageView.mas_bottom).offset(-6);
|
2022-05-19 10:39:04 +08:00
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Getters And Setters
|
|
|
|
- (void)setTopicInfo:(MonentsTopicModel *)topicInfo {
|
|
|
|
_topicInfo = topicInfo;
|
|
|
|
if (_topicInfo) {
|
2023-01-04 17:21:42 +08:00
|
|
|
self.topicLabel.text = [NSString stringWithFormat:@"#%@", _topicInfo.name];
|
|
|
|
self.topicImageView.imageUrl = _topicInfo.icon;
|
2022-05-19 10:39:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-04 17:21:42 +08:00
|
|
|
- (NetImageView *)topicImageView {
|
2022-05-19 10:39:04 +08:00
|
|
|
if (!_topicImageView) {
|
2023-01-04 17:21:42 +08:00
|
|
|
NetImageConfig * config = [[NetImageConfig alloc]init];
|
|
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
|
|
_topicImageView = [[NetImageView alloc] initWithConfig:config];
|
2022-05-19 10:39:04 +08:00
|
|
|
_topicImageView.layer.masksToBounds = YES;
|
2023-01-04 17:21:42 +08:00
|
|
|
_topicImageView.layer.cornerRadius = 12;
|
|
|
|
_topicImageView.contentMode = UIViewContentModeScaleAspectFill;
|
2022-05-19 10:39:04 +08:00
|
|
|
}
|
|
|
|
return _topicImageView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UIImageView *)iconImageView {
|
|
|
|
if (!_iconImageView) {
|
|
|
|
_iconImageView = [[UIImageView alloc] init];
|
|
|
|
_iconImageView.userInteractionEnabled = YES;
|
2023-01-04 17:21:42 +08:00
|
|
|
_iconImageView.image = [UIImage imageNamed:@"home_room_list_shadow_bg"];
|
2022-05-19 10:39:04 +08:00
|
|
|
}
|
|
|
|
return _iconImageView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (UILabel *)topicLabel {
|
|
|
|
if (!_topicLabel) {
|
|
|
|
_topicLabel = [[UILabel alloc] init];
|
2023-01-04 17:21:42 +08:00
|
|
|
_topicLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightBold];
|
|
|
|
_topicLabel.textColor = [UIColor whiteColor];
|
|
|
|
_topicLabel.textAlignment = NSTextAlignmentCenter;
|
2022-05-19 10:39:04 +08:00
|
|
|
}
|
|
|
|
return _topicLabel;
|
|
|
|
}
|
|
|
|
@end
|