107 lines
3.4 KiB
Objective-C
107 lines
3.4 KiB
Objective-C
//
|
|
// XPSessionMessageGameInfoView.m
|
|
// xplan-ios
|
|
//
|
|
// Created by duoban on 2023/8/25.
|
|
//
|
|
|
|
#import "XPSessionMessageGameInfoView.h"
|
|
@interface XPSessionMessageGameInfoView()
|
|
@property(nonatomic,strong) UIButton *tapBtn;
|
|
@property(nonatomic,strong) UIView *bgView;
|
|
@property(nonatomic,strong) NetImageView *headView;
|
|
@property(nonatomic,strong) UILabel *nameView;
|
|
@property(nonatomic,strong) UIImageView *arrowView;
|
|
@end
|
|
@implementation XPSessionMessageGameInfoView
|
|
|
|
-(instancetype)initWithFrame:(CGRect)frame{
|
|
self = [super initWithFrame:frame];
|
|
if(self){
|
|
[self installUI];
|
|
[self installConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
-(void)installUI{
|
|
[self addSubview:self.bgView];
|
|
[self.bgView addSubview:self.headView];
|
|
[self.bgView addSubview:self.nameView];
|
|
[self.bgView addSubview:self.arrowView];
|
|
[self.bgView addSubview:self.tapBtn];
|
|
}
|
|
-(void)installConstraints{
|
|
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(kGetScaleWidth(88));
|
|
make.height.mas_equalTo(kGetScaleWidth(76));
|
|
make.top.leading.equalTo(self);
|
|
}];
|
|
[self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(kGetScaleWidth(11));
|
|
make.width.height.mas_equalTo(kGetScaleWidth(34));
|
|
make.centerX.equalTo(self.bgView);
|
|
}];
|
|
[self.arrowView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.trailing.mas_equalTo(-kGetScaleWidth(5));
|
|
make.top.equalTo(self.headView.mas_bottom).mas_offset(kGetScaleWidth(9));
|
|
make.width.height.mas_equalTo(kGetScaleWidth(10));
|
|
}];
|
|
[self.nameView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.equalTo(self.arrowView);
|
|
make.trailing.equalTo(self.arrowView.mas_leading).mas_offset(-kGetScaleWidth(0));
|
|
}];
|
|
[self.tapBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.bgView);
|
|
}];
|
|
}
|
|
-(void)setHeadUrl:(NSString *)headUrl{
|
|
_headUrl = headUrl;
|
|
_headView.imageUrl = _headUrl;
|
|
}
|
|
-(void)tapAction{
|
|
if(self.delegate && [self.delegate respondsToSelector:@selector(clicTokMineUserInfo)]){
|
|
[self.delegate clicTokMineUserInfo];
|
|
}
|
|
}
|
|
#pragma mark - 懒加载
|
|
- (UIView *)bgView{
|
|
if(!_bgView){
|
|
_bgView = [UIView new];
|
|
_bgView.backgroundColor = [UIColor whiteColor];
|
|
_bgView.layer.cornerRadius = kGetScaleWidth(10);
|
|
_bgView.layer.masksToBounds = YES;
|
|
}
|
|
return _bgView;
|
|
}
|
|
-(NetImageView *)headView{
|
|
if(!_headView){
|
|
NetImageConfig *config = [[NetImageConfig alloc]init];
|
|
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
|
|
_headView = [[NetImageView alloc]initWithConfig:config];
|
|
_headView.layer.cornerRadius = kGetScaleWidth(34)/2;
|
|
_headView.layer.masksToBounds = YES;
|
|
}
|
|
return _headView;
|
|
}
|
|
-(UILabel *)nameView{
|
|
if(!_nameView){
|
|
_nameView = [UILabel labelInitWithText:@"去TA的主页" font:kFontRegular(12) textColor:UIColorFromRGB(0x2B2D33)];
|
|
}
|
|
return _nameView;
|
|
}
|
|
-(UIImageView *)arrowView{
|
|
if(!_arrowView){
|
|
_arrowView = [UIImageView new];
|
|
_arrowView.image = kImage(@"Session_Message_Game_InfoView_arrow");
|
|
}
|
|
return _arrowView;
|
|
}
|
|
- (UIButton *)tapBtn{
|
|
if(!_tapBtn){
|
|
_tapBtn = [UIButton new];
|
|
[_tapBtn addTarget:self action:@selector(tapAction) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _tapBtn;
|
|
}
|
|
@end
|