Files
peko-ios/YuMi/Modules/YMMine/View/Cell/MineInfo/XPMineUserInfoTableViewCell.m
2023-08-04 11:47:43 +08:00

168 lines
5.0 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// YMMineInfoTableViewCell.m
// YUMI
//
// Created by YUMI on 2021/9/23.
//
#import "XPMineUserInfoTableViewCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "DJDKMIMOMColor.h"
///Model
#import "UserInfoModel.h"
@interface XPMineUserInfoTableViewCell ()
///背景
@property (nonatomic,strong) UIView * backView;
///名字
@property (nonatomic,strong) UILabel *nameLabel;
///sex
@property (nonatomic,strong) UIImageView *sexImageView;
///id
@property (nonatomic,strong) UILabel *idLabel;
///签名
@property (nonatomic,strong) UILabel *signLabel;
///正在直播中
@property (nonatomic,strong) UIButton *onlineButton;
@end
@implementation XPMineUserInfoTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor clearColor];
self.selectionStyle = UITableViewCellSelectionStyleNone;
[self.contentView addSubview:self.backView];
[self.backView addSubview:self.nameLabel];
[self.backView addSubview:self.sexImageView];
[self.backView addSubview:self.idLabel];
[self.backView addSubview:self.signLabel];
[self.backView addSubview:self.onlineButton];
}
- (void)initSubViewConstraints {
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self.contentView).inset(15);
make.top.bottom.mas_equalTo(self.contentView);
}];
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.backView).offset(15);
make.top.mas_equalTo(self.backView).offset(15);
}];
[self.sexImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nameLabel.mas_right).offset(5);
make.centerY.mas_equalTo(self.nameLabel);
}];
[self.idLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nameLabel);
make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(10);
}];
[self.signLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(self.nameLabel);
make.top.mas_equalTo(self.idLabel.mas_bottom).offset(18);
}];
[self.onlineButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(55, 18));
make.right.mas_equalTo(self.backView).offset(-15);
make.top.mas_equalTo(self.backView).offset(10);
}];
}
#pragma mark - Getters And Setters
- (void)setUserInfo:(UserInfoModel *)userInfo {
_userInfo = userInfo;
if (_userInfo) {
self.nameLabel.text = _userInfo.nick;
self.idLabel.text = [NSString stringWithFormat:@"%@%@%ld",AppName,YMLocalizedString(@"App_Common_hao"), (long)_userInfo.erbanNo];
self.signLabel.text = _userInfo.userDesc.length > 0 ? _userInfo.userDesc : YMLocalizedString(@"XPMineUserInfoTableViewCell1");
NSString * sexStr;
if (_userInfo.gender == GenderType_Male) {
sexStr = @"common_male";
} else {
sexStr = @"common_female";
}
self.sexImageView.image = [UIImage imageNamed:sexStr];
}
}
- (UIView *)backView {
if (!_backView) {
_backView = [[UIView alloc] init];
_backView.backgroundColor = [DJDKMIMOMColor appCellBackgroundColor];
_backView.layer.masksToBounds = YES;
_backView.layer.cornerRadius = 12;
}
return _backView;
}
- (UILabel *)nameLabel {
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] init];
_nameLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:15];
_nameLabel.textColor = [DJDKMIMOMColor mainTextColor];
}
return _nameLabel;
}
- (UIImageView *)sexImageView {
if (!_sexImageView) {
_sexImageView = [[UIImageView alloc] init];
_sexImageView.userInteractionEnabled = YES;
}
return _sexImageView;
}
- (UILabel *)idLabel {
if (!_idLabel) {
_idLabel = [[UILabel alloc] init];
_idLabel.font = [UIFont systemFontOfSize:11];
_idLabel.textColor = [DJDKMIMOMColor textThirdColor];
}
return _idLabel;
}
- (UILabel *)signLabel {
if (!_signLabel) {
_signLabel = [[UILabel alloc] init];
_signLabel.font = [UIFont systemFontOfSize:11];;
_signLabel.textColor = [DJDKMIMOMColor secondTextColor];
}
return _signLabel;
}
- (UIButton *)onlineButton {
if (!_onlineButton) {
_onlineButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_onlineButton setTitle:YMLocalizedString(@"XPMineUserInfoTableViewCell2") forState:UIControlStateNormal];
[_onlineButton setImage:[UIImage imageNamed:@"home_search_user_online"] forState:UIControlStateNormal];
[_onlineButton setTitleColor:[DJDKMIMOMColor appEmphasizeColor] forState:UIControlStateNormal];
_onlineButton.backgroundColor = [UIColor clearColor];
_onlineButton.titleLabel.font = [UIFont systemFontOfSize:10];
_onlineButton.layer.masksToBounds = YES;
_onlineButton.layer.cornerRadius = 18/2;
_onlineButton.layer.borderColor = [DJDKMIMOMColor appEmphasizeColor].CGColor;
_onlineButton.layer.borderWidth = 1;
[_onlineButton addTarget:self action:@selector(onlineButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _onlineButton;
}
@end