270 lines
8.0 KiB
Objective-C
270 lines
8.0 KiB
Objective-C
//
|
|
// XPMinePersonalCenterCell.m
|
|
// YuMi
|
|
//
|
|
// Created by YuMi on 2023/6/30.
|
|
//
|
|
|
|
#import "XPMinePersonalCenterCell.h"
|
|
@interface XPMinePersonalCenterCell()
|
|
|
|
///背景
|
|
@property (nonatomic,strong) UIView *bgView;
|
|
/// 标题
|
|
@property (nonatomic,strong) UILabel *titleView;
|
|
///我的房间
|
|
@property (nonatomic,strong) XPMinePersonalCenterItemView *myRoomView;
|
|
///收益记录
|
|
@property (nonatomic,strong) XPMinePersonalCenterItemView *earningsRecordView;
|
|
///赠送钻石
|
|
@property (nonatomic,strong) XPMinePersonalCenterItemView *giveDiamondView;
|
|
|
|
|
|
|
|
@end
|
|
|
|
@implementation XPMinePersonalCenterCell
|
|
|
|
- (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.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
self.backgroundColor = [UIColor clearColor];
|
|
[self.contentView addSubview:self.bgView];
|
|
[self.bgView addSubview:self.titleView];
|
|
[self.bgView addSubview:self.myRoomView];
|
|
[self.bgView addSubview:self.earningsRecordView];
|
|
[self.bgView addSubview:self.giveDiamondView];
|
|
self.giveDiamondView.hidden = YES;
|
|
}
|
|
- (void)initSubViewConstraints {
|
|
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(15);
|
|
make.trailing.mas_offset(-15);
|
|
make.top.bottom.equalTo(self.contentView);
|
|
}];
|
|
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(12);
|
|
make.top.mas_equalTo(14);
|
|
}];
|
|
|
|
[self.myRoomView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(35);
|
|
make.width.mas_greaterThanOrEqualTo(104);
|
|
make.height.equalTo(@38);
|
|
make.top.mas_equalTo(44);
|
|
}];
|
|
[self.earningsRecordView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.height.width.equalTo(self.myRoomView);
|
|
make.trailing.mas_equalTo(-35);
|
|
}];
|
|
[self.giveDiamondView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.height.width.equalTo(self.myRoomView);
|
|
make.trailing.mas_equalTo(0);
|
|
}];
|
|
}
|
|
-(void)setIsHaveGiveDiamond:(BOOL)isHaveGiveDiamond{
|
|
_isHaveGiveDiamond = isHaveGiveDiamond;
|
|
self.myRoomView.isHaveGiveDiamond = _isHaveGiveDiamond;
|
|
self.earningsRecordView.isHaveGiveDiamond = _isHaveGiveDiamond;
|
|
self.giveDiamondView.isHaveGiveDiamond = _isHaveGiveDiamond;
|
|
CGFloat width = (KScreenWidth - 30) / 3;
|
|
if(_isHaveGiveDiamond == YES){
|
|
self.giveDiamondView.hidden = NO;
|
|
[self.myRoomView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(0);
|
|
make.width.mas_greaterThanOrEqualTo(width);
|
|
make.height.equalTo(@68);
|
|
}];
|
|
[self.earningsRecordView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.trailing.mas_equalTo(-width);
|
|
}];
|
|
return;
|
|
}
|
|
self.giveDiamondView.hidden = YES;
|
|
[self.myRoomView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(35);
|
|
make.width.mas_greaterThanOrEqualTo(104);
|
|
make.height.equalTo(@38);
|
|
}];
|
|
[self.earningsRecordView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.trailing.mas_equalTo(-35);
|
|
}];
|
|
|
|
}
|
|
-(void)clickMyRoomAction{
|
|
if (self.clickAction){
|
|
self.clickAction(0);
|
|
}
|
|
}
|
|
-(void)clickEarningsRecordAction{
|
|
if (self.clickAction){
|
|
self.clickAction(1);
|
|
}
|
|
}
|
|
-(void)clickGiveDiamondAction{
|
|
if (self.clickAction){
|
|
self.clickAction(2);
|
|
}
|
|
}
|
|
- (UIView *)bgView{
|
|
if(!_bgView){
|
|
_bgView = [UIView new];
|
|
_bgView.backgroundColor = [UIColor whiteColor];
|
|
_bgView.layer.cornerRadius = 10;
|
|
_bgView.layer.masksToBounds = YES;
|
|
}
|
|
return _bgView;
|
|
}
|
|
-(UILabel *)titleView{
|
|
if(!_titleView){
|
|
_titleView = [UILabel new];
|
|
_titleView.textColor = UIColorFromRGB(0x1F1A4E);
|
|
_titleView.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
|
|
_titleView.text = YMLocalizedString(@"XPMinePersonalCenterCell0");
|
|
}
|
|
|
|
return _titleView;
|
|
}
|
|
- (XPMinePersonalCenterItemView *)myRoomView{
|
|
if(!_myRoomView){
|
|
_myRoomView = [[XPMinePersonalCenterItemView alloc]initWithFrame:CGRectZero];
|
|
[_myRoomView setTitle:YMLocalizedString(@"XPMinePersonalCenterCell1")];
|
|
[_myRoomView setImage:@"mine_personal_centermy_room"];
|
|
UITapGestureRecognizer *myRoomViewTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickMyRoomAction)];
|
|
[_myRoomView addGestureRecognizer:myRoomViewTap];
|
|
return _myRoomView;
|
|
}
|
|
return _myRoomView;
|
|
}
|
|
-(XPMinePersonalCenterItemView *)earningsRecordView{
|
|
if(!_earningsRecordView){
|
|
_earningsRecordView = [[XPMinePersonalCenterItemView alloc]initWithFrame:CGRectZero];
|
|
[_earningsRecordView setTitle:YMLocalizedString(@"XPMinePersonalCenterCell2")];
|
|
[_earningsRecordView setImage:@"mine_earnings_record"];
|
|
UITapGestureRecognizer *earningsRecordTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickEarningsRecordAction)];
|
|
[_earningsRecordView addGestureRecognizer:earningsRecordTap];
|
|
}
|
|
return _earningsRecordView;
|
|
}
|
|
- (XPMinePersonalCenterItemView *)giveDiamondView{
|
|
if (!_giveDiamondView){
|
|
_giveDiamondView = [[XPMinePersonalCenterItemView alloc]initWithFrame:CGRectZero];
|
|
[_giveDiamondView setTitle:YMLocalizedString(@"XPMinePersonalCenterCell3")];
|
|
[_giveDiamondView setImage:@"mine_me_give"];
|
|
UITapGestureRecognizer *earningsRecordTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickGiveDiamondAction)];
|
|
[_giveDiamondView addGestureRecognizer:earningsRecordTap];
|
|
}
|
|
return _giveDiamondView;
|
|
}
|
|
|
|
- (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
|
|
|
|
|
|
|
|
/***************************************************************华丽分割线****************************************************************************/
|
|
|
|
@interface XPMinePersonalCenterItemView()
|
|
@property (nonatomic,strong) UIImageView *iconView;
|
|
@property (nonatomic,strong) UILabel* titleVeiw;
|
|
|
|
@end
|
|
|
|
|
|
@implementation XPMinePersonalCenterItemView
|
|
|
|
|
|
-(instancetype)initWithFrame:(CGRect)frame{
|
|
self = [super initWithFrame:frame];
|
|
if(self){
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
[self addSubview:self.iconView];
|
|
[self addSubview:self.titleVeiw];
|
|
}
|
|
- (void)initSubViewConstraints {
|
|
[self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.height.mas_equalTo(38);
|
|
make.leading.mas_equalTo(0);
|
|
make.top.equalTo(self);
|
|
}];
|
|
[self.titleVeiw mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(48);
|
|
make.top.equalTo(self.iconView.mas_top).mas_offset(9);
|
|
make.trailing.equalTo(self);
|
|
}];
|
|
}
|
|
-(void)setTitle:(NSString *)title{
|
|
self.titleVeiw.text = title;
|
|
|
|
}
|
|
-(void)setIsHaveGiveDiamond:(BOOL)isHaveGiveDiamond{
|
|
_isHaveGiveDiamond = isHaveGiveDiamond;
|
|
|
|
if(_isHaveGiveDiamond){
|
|
[self.titleVeiw mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(0);
|
|
make.top.equalTo(self.iconView.mas_top).mas_offset(48);
|
|
}];
|
|
CGFloat left = (((KScreenWidth - 30) / 3) - 38) / 2;
|
|
[self.iconView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(left);
|
|
}];
|
|
_titleVeiw.textAlignment = NSTextAlignmentCenter;
|
|
return;
|
|
}
|
|
[self.titleVeiw mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(48);
|
|
make.top.equalTo(self.iconView.mas_top).mas_offset(9);
|
|
}];
|
|
[self.iconView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(0);
|
|
}];
|
|
_titleVeiw.textAlignment = NSTextAlignmentLeft;
|
|
|
|
}
|
|
-(void)setImage:(NSString *)imageName{
|
|
self.iconView.image = [UIImage imageNamed:imageName];
|
|
}
|
|
-(UIImageView *)iconView{
|
|
if(!_iconView){
|
|
_iconView = [UIImageView new];
|
|
_iconView.userInteractionEnabled = YES;
|
|
}
|
|
return _iconView;
|
|
}
|
|
-(UILabel *)titleVeiw{
|
|
if(!_titleVeiw){
|
|
_titleVeiw = [UILabel new];
|
|
_titleVeiw.font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
|
|
_titleVeiw.textColor = UIColorFromRGB(0x1F1A4E);
|
|
|
|
}
|
|
return _titleVeiw;
|
|
}
|
|
@end
|