// // QXWalletHomeTopView.m // QXLive // // Created by 启星 on 2025/5/16. // #import "QXWalletHomeTopView.h" @class QXWalletHomeTopSubview; @interface QXWalletHomeTopView() @property (nonatomic,strong)QXWalletHomeTopSubview *leftBgView; @property (nonatomic,strong)QXWalletHomeTopSubview *rightBgView; @end @implementation QXWalletHomeTopView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initSubviews]; } return self; } -(void)initSubviews{ self.leftBgView = [[QXWalletHomeTopSubview alloc] init]; self.leftBgView.isCorn = YES; self.leftBgView.delegate = self; self.leftBgView.btn.hidden = !QXGlobal.shareGlobal.isOpenRecharge; [self addSubview:self.leftBgView]; [self.leftBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(16); make.width.mas_equalTo((SCREEN_WIDTH-16*2-11)/2); make.height.mas_equalTo(ScaleWidth(98)); make.top.equalTo(self).offset(12); }]; self.rightBgView = [[QXWalletHomeTopSubview alloc] init]; self.rightBgView.isCorn = NO; self.rightBgView.delegate = self; [self addSubview:self.rightBgView]; [self.rightBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-16); make.width.mas_equalTo((SCREEN_WIDTH-16*2-11)/2); make.height.mas_equalTo(ScaleWidth(98)); make.top.equalTo(self).offset(12); }]; } -(void)setCoin:(NSString *)coin{ self.leftBgView.priceLabel.text = coin; } - (void)setEarnings:(NSString *)earnings{ _earnings = earnings; self.rightBgView.priceLabel.text = earnings; } -(void)didClickButtonIsRecharge:(BOOL)isRecharge{ if (self.delegate && [self.delegate respondsToSelector:@selector(didClickButtonIsRecharge:)]) { [self.delegate didClickButtonIsRecharge:isRecharge]; } } @end @implementation QXWalletHomeTopSubview - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initSubviews]; } return self; } -(void)setIsCorn:(BOOL)isCorn{ _isCorn = isCorn; self.bgImageView.image = isCorn?[UIImage imageNamed:@"home_top_corn"]:[UIImage imageNamed:@"home_top_diamond"]; self.titleLabel.text = isCorn?QXText(@"金币"):QXText(@"钻石"); [self.btn setBackgroundImage:[UIImage imageNamed:isCorn?@"home_top_recharge":@"home_top_withdraw"] forState:(UIControlStateNormal)]; } -(void)initSubviews{ self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"home_top_corn"]]; [self addSubview:self.bgImageView]; [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.bottom.left.right.equalTo(self); }]; self.titleLabel = [[UILabel alloc] init]; self.titleLabel.font = [UIFont systemFontOfSize:12]; self.titleLabel.textColor = RGB16(0x666666); [self addSubview:self.titleLabel]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.bottom.mas_equalTo(-11); make.size.mas_equalTo(CGSizeMake(50, 18)); }]; self.priceLabel = [[UILabel alloc] init]; self.priceLabel.font = [UIFont boldSystemFontOfSize:16]; self.priceLabel.textColor = RGB16(0x333333); [self addSubview:self.priceLabel]; [self.priceLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.bottom.equalTo(self.titleLabel.mas_top).offset(-4); make.height.mas_equalTo(24); make.right.mas_equalTo(-10); }]; self.btn = [[UIButton alloc] init]; [self.btn addTarget:self action:@selector(btnClick:) forControlEvents:(UIControlEventTouchUpInside)]; [self addSubview:self.btn]; [self.btn mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(-10); make.centerY.equalTo(self.titleLabel); make.size.mas_equalTo(CGSizeMake(74, 28)); }]; } -(void)btnClick:(UIButton*)button{ if (self.delegate && [self.delegate respondsToSelector:@selector(didClickButtonIsRecharge:)]) { [self.delegate didClickButtonIsRecharge:self.isCorn]; } } @end