164 lines
6.3 KiB
Objective-C
164 lines
6.3 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)UIImageView *headerView;
|
|
@property (nonatomic,strong)UILabel *inviteLabel;
|
|
@property (nonatomic,strong)UIButton *commitBtn;
|
|
@property (nonatomic,strong)UIButton *cancelBtn;
|
|
@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 = [[UIImageView alloc] init];
|
|
[self.headerView addRoundedCornersWithRadius:35];
|
|
self.headerView.layer.borderColor = QXConfig.themeColor.CGColor;
|
|
self.headerView.layer.borderWidth = 2;
|
|
self.headerView.contentMode = UIViewContentModeScaleAspectFill;
|
|
[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 = RGB16(0x000000);
|
|
// [self.agreeBtn setTitle:QXText(@"接收邀请") forState:(UIControlStateNormal)];
|
|
// [self.agreeBtn setTitleColor:QXConfig.themeColor 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.commitBtn = [[UIButton alloc] init];
|
|
[self.commitBtn addRoundedCornersWithRadius:21];
|
|
self.commitBtn.backgroundColor = QXConfig.themeColor;
|
|
[self.commitBtn setTitle:QXText(@"接受") forState:(UIControlStateNormal)];
|
|
[self.commitBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
|
self.commitBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
[self.commitBtn addTarget:self action:@selector(agreeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self addSubview:self.commitBtn];
|
|
[self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.equalTo(self.bgImageView).offset(-12);
|
|
make.height.mas_equalTo(42);
|
|
make.width.mas_equalTo(ScaleWidth(110));
|
|
make.right.mas_equalTo(-20);
|
|
}];
|
|
|
|
|
|
self.cancelBtn = [[UIButton alloc] init];
|
|
[self.cancelBtn addRoundedCornersWithRadius:21];
|
|
self.cancelBtn.backgroundColor = RGB16(0xF3F3F3);
|
|
[self.cancelBtn setTitle:QXText(@"拒绝") forState:(UIControlStateNormal)];
|
|
[self.cancelBtn setTitleColor:RGB16(0x999999) forState:(UIControlStateNormal)];
|
|
self.cancelBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
[self.cancelBtn addTarget:self action:@selector(closeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self addSubview:self.cancelBtn];
|
|
[self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.equalTo(self.bgImageView).offset(-12);
|
|
make.height.mas_equalTo(42);
|
|
make.width.mas_equalTo(ScaleWidth(110));
|
|
make.left.mas_equalTo(20);
|
|
}];
|
|
|
|
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;
|
|
__weak typeof(self) weakSelf = self;
|
|
_timer = [QXTimer scheduledTimerWithTimeInterval:1 repeats:YES queue:dispatch_get_main_queue() block:^{
|
|
__strong typeof(weakSelf) strongSelf = weakSelf;
|
|
if (!strongSelf) {
|
|
QXLOG(@"⚠️ self has been deallocated, skipping hide operation");
|
|
return;
|
|
}
|
|
timeCount--;
|
|
if (timeCount<=0) {
|
|
[strongSelf noAgree];
|
|
[strongSelf.cancelBtn setTitle:[NSString stringWithFormat:@"%@(0)",QXText(@"拒绝")] forState:(UIControlStateNormal)];
|
|
[[QXGlobal shareGlobal] hideViewBlock:^{
|
|
|
|
}];
|
|
}
|
|
[strongSelf.cancelBtn setTitle:[NSString stringWithFormat:@"%@(%d)",QXText(@"拒绝"),timeCount] forState:(UIControlStateNormal)];
|
|
}];
|
|
}
|
|
-(void)noAgree{
|
|
[self.timer invalidate];
|
|
}
|
|
|
|
-(void)setModel:(QXRoomListModel *)model{
|
|
_model = model;
|
|
[self.headerView sd_setImageWithURL:[NSURL URLWithString:model.room_cover]];
|
|
}
|
|
|
|
-(void)agreeAction{
|
|
MJWeakSelf
|
|
[[QXGlobal shareGlobal] hideViewBlock:^{
|
|
if (weakSelf.agreeActionBlock) {
|
|
weakSelf.agreeActionBlock();
|
|
}
|
|
}];
|
|
|
|
}
|
|
-(void)closeAction{
|
|
[self noAgree];
|
|
if (self.closeActionBlock) {
|
|
self.closeActionBlock();
|
|
}
|
|
}
|
|
@end
|