Files
midi_ios/QXLive/Tabbar/弹窗/QXInvitePopView.m
2025-08-14 10:07:49 +08:00

118 lines
4.1 KiB
Objective-C

//
// QXInvitePopView.m
// QXLive
//
// Created by 启星 on 2025/5/13.
//
#import "QXInvitePopView.h"
#import "QXSeatHeaderView.h"
#import "QXTimer.h"
@interface QXInvitePopView()
@property (nonatomic,strong)UIImageView *bgImageView;
@property (nonatomic,strong)QXSeatHeaderView *headerView;
@property (nonatomic,strong)UILabel *inviteLabel;
@property (nonatomic,strong)UIButton *agreeBtn;
@property (nonatomic,strong)QXTimer *timer;
@property (nonatomic,strong)UIButton *closeBtn;
@end
@implementation QXInvitePopView
- (instancetype)init
{
self = [super init];
if (self) {
self.frame = CGRectMake(0, 0, ScaleWidth(275), ScaleWidth(200+48));
[self initSubViews];
}
return self;
}
-(void)initSubViews{
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"a_pop_invite"]];
[self addSubview:self.bgImageView];
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.equalTo(self);
make.height.mas_equalTo(ScaleWidth(200));
}];
self.headerView = [[QXSeatHeaderView alloc] init];
[self addSubview:self.headerView];
[self.headerView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(70, 70));
make.centerX.equalTo(self);
make.top.equalTo(self).offset(12);
}];
self.inviteLabel = [[UILabel alloc] init];
self.inviteLabel.font = [UIFont boldSystemFontOfSize:16];
self.inviteLabel.text = QXText(@"邀请你进房陪她聊天");
self.inviteLabel.textColor = RGB16(0x333333);
[self addSubview:self.inviteLabel];
[self.inviteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.top.equalTo(self.headerView.mas_bottom).offset(12);
make.height.mas_equalTo(24);
}];
self.agreeBtn = [[UIButton alloc] init];
[self.agreeBtn addRoundedCornersWithRadius:21];
self.agreeBtn.backgroundColor = QXConfig.themeColor;
[self.agreeBtn setTitle:QXText(@"接收邀请") forState:(UIControlStateNormal)];
[self.agreeBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
self.agreeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
[self.agreeBtn addTarget:self action:@selector(agreeAction) forControlEvents:(UIControlEventTouchUpInside)];
[self addSubview:self.agreeBtn];
[self.agreeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self.bgImageView).offset(-12);
make.height.mas_equalTo(42);
make.width.mas_equalTo(178);
make.centerX.equalTo(self.bgImageView);
}];
self.closeBtn = [[UIButton alloc] init];
[self.closeBtn setBackgroundImage:[UIImage imageNamed:@"home_white_close"] forState:(UIControlStateNormal)];
[self.closeBtn addTarget:self action:@selector(closeAction) forControlEvents:(UIControlEventTouchUpInside)];
[self addSubview:self.closeBtn];
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self);
make.top.equalTo(self.bgImageView.mas_bottom).offset(8);
make.height.width.mas_equalTo(30);
}];
__block int timeCount = 10;
MJWeakSelf
_timer = [QXTimer scheduledTimerWithTimeInterval:1 repeats:YES queue:dispatch_get_main_queue() block:^{
timeCount--;
if (timeCount<=0) {
[weakSelf noAgree];
[self->_agreeBtn setTitle:[NSString stringWithFormat:@"%@(0)",QXText(@"接收邀请")] forState:(UIControlStateNormal)];
[[QXGlobal shareGlobal] hideViewBlock:^{
}];
}
[self->_agreeBtn setTitle:[NSString stringWithFormat:@"%@(%d)",QXText(@"接收邀请"),timeCount] forState:(UIControlStateNormal)];
}];
}
-(void)noAgree{
[self->_timer invalidate];
}
-(void)agreeAction{
MJWeakSelf
[[QXGlobal shareGlobal] hideViewBlock:^{
if (weakSelf.agreeActionBlock) {
weakSelf.agreeActionBlock();
}
}];
}
-(void)closeAction{
[self noAgree];
if (self.closeActionBlock) {
self.closeActionBlock();
}
}
@end