Files
peko-ios/YuMi/Modules/YMMine/View/Guild/View/Cell/Income/PIGuildSingleRoomIncomeCell.m
2024-02-22 15:58:48 +08:00

163 lines
6.1 KiB
Objective-C

//
// PIGuildSingleRoomIncomeCell.m
// YuMi
//
// Created by duoban on 2024/2/21.
//
#import "PIGuildSingleRoomIncomeCell.h"
@interface PIGuildSingleRoomIncomeCell()
@property(nonatomic,strong) NetImageView *headView;
@property(nonatomic,strong) UILabel *nameView;
@property(nonatomic,strong) UILabel *numberView;
@property(nonatomic,strong) UILabel *anchorNumView;
@property(nonatomic,strong) UILabel *roomNumView;
@property(nonatomic,strong) UILabel *timeView;
@property(nonatomic,strong) UIView *lineView;
@end
@implementation PIGuildSingleRoomIncomeCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if(self){
[self installUI];
[self installConstraints];
}
return self;
}
-(void)installUI{
self.backgroundColor = [DJDKMIMOMColor appCellBackgroundColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.headView];
[self.contentView addSubview:self.nameView];
[self.contentView addSubview:self.numberView];
[self.contentView addSubview:self.anchorNumView];
[self.contentView addSubview:self.roomNumView];
[self.contentView addSubview:self.timeView];
[self.contentView addSubview:self.lineView];
}
-(void)installConstraints{
[self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(44));
make.leading.mas_equalTo(kGetScaleWidth(17));
make.centerY.equalTo(self.contentView);
}];
CGFloat width = kGetScaleWidth(242) / 3;
[self.timeView mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(0);
make.width.mas_equalTo(width);
make.centerY.equalTo(self.contentView);
}];
[self.roomNumView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(width);
make.centerY.equalTo(self.contentView);
make.trailing.equalTo(self.timeView.mas_leading).mas_offset(0);
}];
[self.anchorNumView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(width);
make.centerY.equalTo(self.contentView);
make.trailing.equalTo(self.roomNumView.mas_leading).mas_offset(0);
}];
[self.nameView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.headView.mas_top).mas_offset(kGetScaleWidth(4));
make.leading.equalTo(self.headView.mas_trailing).mas_offset(kGetScaleWidth(6));
make.trailing.equalTo(self.anchorNumView.mas_leading).mas_offset((0));
make.height.mas_equalTo(kGetScaleWidth(20));
}];
[self.numberView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.nameView.mas_bottom).mas_offset(kGetScaleWidth(0));
make.leading.equalTo(self.nameView);
make.trailing.equalTo(self.nameView);
}];
}
- (void)setUserInfo:(GuildPersonIncomeUserInfoModel *)userInfo {
_userInfo = userInfo;
if (_userInfo) {
self.headView.image = nil;
[self.headView loadImageWithUrl:_userInfo.avatar completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) {
self.headView.image = image;
}];
self.nameView.text = _userInfo.nick;
self.numberView.text = [NSString stringWithFormat:@"ID:%@",_userInfo.erbanNo];
self.anchorNumView.text = _userInfo.anchorDiamondNum;
self.roomNumView.text = _userInfo.roomDiamondNum;
NSInteger h = _userInfo.timeDuration / 60;
NSInteger min = _userInfo.timeDuration % 60;
if(h <= 0){
self.timeView.text = [NSString stringWithFormat:@"%ldmin",_userInfo.timeDuration];
}else if(min <= 0 && h > 0){
self.timeView.text = [NSString stringWithFormat:@"%ldh",h];
}else{
self.timeView.text = [NSString stringWithFormat:@"%ldh%ldmin",h,min];
}
}
}
#pragma mark - 懒加载
- (NetImageView *)headView{
if(!_headView){
NetImageConfig *config = [NetImageConfig new];
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_headView = [[NetImageView alloc]initWithConfig:config];
_headView.layer.cornerRadius = kGetScaleWidth(44)/2;
_headView.layer.masksToBounds = YES;
}
return _headView;
}
- (UILabel *)nameView{
if(!_nameView){
_nameView = [UILabel labelInitWithText:@"" font:[UIFont systemFontOfSize:14 weight:UIFontWeightMedium] textColor:UIColorFromRGB(0x1F1B4F)];
}
return _nameView;
}
- (UILabel *)numberView{
if(!_numberView){
_numberView = [UILabel labelInitWithText:@"" font:[UIFont systemFontOfSize:11 weight:UIFontWeightRegular] textColor:UIColorFromRGB(0x8A8CAB)];
}
return _numberView;
}
- (UILabel *)anchorNumView{
if(!_anchorNumView){
_anchorNumView = [UILabel labelInitWithText:@"0" font:[UIFont systemFontOfSize:14 weight:UIFontWeightMedium] textColor:UIColorFromRGB(0x1F1B4F)];
_anchorNumView.textAlignment = NSTextAlignmentCenter;
_anchorNumView.numberOfLines = 2;
}
return _anchorNumView;
}
- (UILabel *)roomNumView{
if(!_roomNumView){
_roomNumView = [UILabel labelInitWithText:@"0" font:[UIFont systemFontOfSize:14 weight:UIFontWeightMedium] textColor:UIColorFromRGB(0x1F1B4F)];
_roomNumView.textAlignment = NSTextAlignmentCenter;
_roomNumView.numberOfLines = 2;
}
return _roomNumView;
}
- (UILabel *)timeView{
if(!_timeView){
_timeView = [UILabel labelInitWithText:@"0h0min" font:[UIFont systemFontOfSize:14 weight:UIFontWeightMedium] textColor:UIColorFromRGB(0x1F1B4F)];
_timeView.textAlignment = NSTextAlignmentCenter;
_timeView.numberOfLines = 2;
}
return _timeView;
}
- (UIView *)lineView{
if(!_lineView){
_lineView = [UIView new];
_lineView.backgroundColor = UIColorFromRGB(0xF1F2F2);
}
return _lineView;
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end