Files
peko-ios/YuMi/Modules/YMRoom/View/MenuContainerView/MSRoomMenuGameCell.m
2024-06-06 17:10:28 +08:00

78 lines
2.4 KiB
Objective-C

//
// MSRoomMenuGameCell.m
// YuMi
//
// Created by duoban on 2024/4/29.
//
#import "MSRoomMenuGameCell.h"
@interface MSRoomMenuGameCell()
@property(nonatomic,strong) NetImageView *gameView;
@property(nonatomic,strong) UILabel *textView;
@end
@implementation MSRoomMenuGameCell
-(instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if(self){
[self installUI];
[self installConstraints];
}
return self;
}
-(void)installUI{
[self.contentView addSubview:self.gameView];
[self.contentView addSubview:self.textView];
}
-(void)installConstraints{
[self.gameView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(kGetScaleWidth(20));
make.width.height.mas_equalTo(kGetScaleWidth(56));
make.centerX.equalTo(self.contentView);
}];
[self.textView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.gameView.mas_bottom).mas_offset(kGetScaleWidth(10));
make.leading.trailing.equalTo(self.contentView).inset(kGetScaleWidth(5));
}];
}
- (void)setModel:(ActivityInfoModel *)model{
_model = model;
_gameView.image = nil;
[_gameView loadImageWithUrl:_model.icon completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
self.gameView.image = image;
}];
_textView.text = _model.name;
}
- (void)setLittleGameModel:(LittleGameInfoModel *)littleGameModel{
_littleGameModel = littleGameModel;
_gameView.image = nil;
[_gameView loadImageWithUrl:littleGameModel.pic2 completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
self.gameView.image = image;
}];
_textView.text = littleGameModel.name;
}
#pragma mark - 懒加载
- (NetImageView *)gameView{
if(!_gameView){
NetImageConfig *config = [NetImageConfig new];
config.placeHolder = [UIImageConstant defaultEmptyAvatarPlaceholder];
_gameView = [[NetImageView alloc]initWithConfig:config];
_gameView.layer.cornerRadius = kGetScaleWidth(6);
_gameView.layer.masksToBounds = YES;
}
return _gameView;
}
- (UILabel *)textView{
if(!_textView){
_textView = [UILabel labelInitWithText:@"" font:kFontRegular(12) textColor:[UIColor whiteColor]];
_textView.textAlignment = NSTextAlignmentCenter;
_textView.numberOfLines = 2;
_textView.hidden = YES;
}
return _textView;
}
@end