273 lines
12 KiB
Objective-C
273 lines
12 KiB
Objective-C
//
|
|
// QXBarAskAlertView.m
|
|
// QXLive
|
|
//
|
|
// Created by 启星 on 2026/1/5.
|
|
//
|
|
|
|
#import "QXBarAskAlertView.h"
|
|
#import "QXMineNetwork.h"
|
|
@interface QXBarAskAlertView()<UIGestureRecognizerDelegate>
|
|
@property (nonatomic,strong)UIView *bgView;
|
|
@property (nonatomic,strong)UIImageView *bgImageView;
|
|
@property (nonatomic,strong)UILabel *titleLabel;
|
|
@property (nonatomic,strong)UIImageView *headerImageView;
|
|
@property (nonatomic,strong)UILabel *nameLabel;
|
|
@property (nonatomic,strong)UIButton *closeBtn;
|
|
|
|
|
|
@property (nonatomic,strong)UIView *contentView;
|
|
@property (nonatomic,strong)UIImageView *contentBgImageView;
|
|
@property (nonatomic,strong)UILabel *contentTitleLabel;
|
|
@property (nonatomic,strong)UIView *giftBgView;
|
|
@property (nonatomic,strong)UIImageView *giftImageView;
|
|
@property (nonatomic,strong)UILabel *giftNameLabel;
|
|
@property (nonatomic,strong)UIButton *giftCoinBtn;
|
|
|
|
@property (nonatomic,strong)UIButton *sendBtn;
|
|
|
|
@property (nonatomic,strong)UIButton *myCoinBtn;
|
|
@property (nonatomic,strong)UIButton *rechargeBtn;
|
|
|
|
@property (nonatomic,strong)QXGiftModel *giftModel;
|
|
@end
|
|
@implementation QXBarAskAlertView
|
|
- (instancetype)init
|
|
{
|
|
self = [super init];
|
|
if (self) {
|
|
self.frame = UIScreen.mainScreen.bounds;
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)initSubviews{
|
|
// UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
|
|
self.backgroundColor = RGB16A(0x000000, 0.3);
|
|
// tap.delegate = self;
|
|
// [self addGestureRecognizer:tap];
|
|
|
|
self.bgView = [[UIView alloc] initWithFrame:CGRectMake((self.width-ScaleWidth(275))/2, 0, ScaleWidth(275), ScaleWidth(275))];
|
|
self.bgView.backgroundColor = RGB16(0xffffff);
|
|
[self.bgView addRoundedCornersWithRadius:16];
|
|
[self addSubview:self.bgView];
|
|
|
|
self.bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.bgView.width, self.bgView.height)];
|
|
self.bgImageView.backgroundColor = RGB16(0x9722D6);
|
|
[self.bgView addSubview:self.bgImageView];
|
|
|
|
|
|
self.titleLabel = [[UILabel alloc] init];
|
|
self.titleLabel.font = [UIFont boldSystemFontOfSize:13];
|
|
self.titleLabel.textColor = RGB16A(0xFFFFFF,0.65);
|
|
self.titleLabel.text = @"送给";
|
|
[self.bgView addSubview:self.titleLabel];
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(16);
|
|
make.height.mas_equalTo(17);
|
|
make.top.mas_equalTo(ScaleWidth(19));
|
|
}];
|
|
|
|
self.headerImageView = [[UIImageView alloc] init];
|
|
[self.bgView addSubview:self.headerImageView];
|
|
self.headerImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
[self.headerImageView addRoundedCornersWithRadius:ScaleWidth(16)];
|
|
[self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(self.titleLabel.mas_right).offset(2);
|
|
make.height.width.mas_equalTo(ScaleWidth(32));
|
|
make.centerY.equalTo(self.titleLabel);
|
|
}];
|
|
|
|
self.nameLabel = [[UILabel alloc] init];
|
|
self.nameLabel.font = [UIFont boldSystemFontOfSize:13];
|
|
self.nameLabel.textColor = RGB16(0xFFFFFF);
|
|
self.nameLabel.text = @"羽声语音";
|
|
[self.bgView addSubview:self.nameLabel];
|
|
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(self.headerImageView.mas_right).offset(2);
|
|
make.height.mas_equalTo(17);
|
|
make.centerY.equalTo(self.titleLabel);
|
|
}];
|
|
|
|
self.closeBtn = [[UIButton alloc] init];
|
|
[self.closeBtn setImage:[[UIImage imageNamed:@"wallet_close"] imageByTintColor:RGB16(0xffffff)] forState:(UIControlStateNormal)];
|
|
[self.closeBtn addTarget:self action:@selector(hide) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self.bgView addSubview:self.closeBtn];
|
|
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.height.mas_equalTo(30);
|
|
make.right.mas_equalTo(-5);
|
|
make.centerY.equalTo(self.titleLabel);
|
|
}];
|
|
|
|
self.myCoinBtn = [[UIButton alloc] init];
|
|
[self.myCoinBtn setImage:[UIImage imageNamed:@"mine_live_gift_corn"] forState:(UIControlStateNormal)];
|
|
[self.myCoinBtn setTitleColor:RGB16(0xF5F24F) forState:(UIControlStateNormal)];
|
|
[self.myCoinBtn setTitle:@"0" forState:(UIControlStateNormal)];
|
|
self.myCoinBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
[self.bgView addSubview:self.myCoinBtn];
|
|
[self.myCoinBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(self.titleLabel);
|
|
make.bottom.equalTo(self.bgView).offset(-8);
|
|
make.height.mas_equalTo(20);
|
|
}];
|
|
|
|
self.rechargeBtn = [[UIButton alloc] init];
|
|
[self.rechargeBtn setTitleColor:RGB16(0xF5F24F) forState:(UIControlStateNormal)];
|
|
[self.rechargeBtn setTitle:@"去充值>" forState:(UIControlStateNormal)];
|
|
self.rechargeBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
[self.rechargeBtn addTarget:self action:@selector(rechargeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self.bgView addSubview:self.rechargeBtn];
|
|
[self.rechargeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(-16);
|
|
make.height.mas_equalTo(30);
|
|
make.centerY.equalTo(self.myCoinBtn);
|
|
}];
|
|
|
|
self.sendBtn = [[UIButton alloc] init];
|
|
[self.sendBtn setTitle:@"赠送并开房" forState:(UIControlStateNormal)];
|
|
[self.sendBtn setTitleColor:RGB16(0xffffff) forState:(UIControlStateNormal)];
|
|
self.sendBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
self.sendBtn.backgroundColor = QXConfig.themeColor;
|
|
[self.sendBtn addRoundedCornersWithRadius:ScaleWidth(16)];
|
|
[self.sendBtn addTarget:self action:@selector(sendAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self.bgView addSubview:self.sendBtn];
|
|
[self.sendBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.equalTo(self.myCoinBtn.mas_top).offset(-5);
|
|
make.width.mas_equalTo(ScaleWidth(104));
|
|
make.height.mas_equalTo(ScaleWidth(32));
|
|
make.centerX.equalTo(self.bgView);
|
|
}];
|
|
|
|
self.contentView = [[UIView alloc] init];
|
|
[self.bgView addRoundedCornersWithRadius:8];
|
|
[self.bgView addSubview:self.contentView];;
|
|
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.headerImageView.mas_bottom).offset(10);
|
|
make.bottom.equalTo(self.sendBtn.mas_top).offset(-12);
|
|
make.left.mas_equalTo(self.titleLabel);
|
|
make.right.mas_equalTo(-16);
|
|
}];
|
|
|
|
self.contentBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"room_bar_ask_bg"]];
|
|
self.contentBgImageView.contentMode = UIViewContentModeScaleToFill;
|
|
[self.contentView addSubview:self.contentBgImageView];
|
|
[self.contentBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(self.titleLabel);
|
|
make.top.equalTo(self.headerImageView.mas_bottom).offset(ScaleWidth(10));
|
|
make.bottom.equalTo(self.sendBtn.mas_top).offset(ScaleWidth(-12));
|
|
make.right.mas_equalTo(-16);
|
|
}];
|
|
|
|
self.contentTitleLabel = [[UILabel alloc] init];
|
|
self.contentTitleLabel.text = @"开启私密房间,一起甜蜜约会吧!";
|
|
self.contentTitleLabel.textColor = RGB16(0xFFD7FE);
|
|
self.contentTitleLabel.textAlignment = NSTextAlignmentCenter;
|
|
self.contentTitleLabel.font = [UIFont systemFontOfSize:ScaleWidth(12)];
|
|
[self.contentView addSubview:self.contentTitleLabel];
|
|
[self.contentTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.equalTo(self.contentView);
|
|
make.top.mas_equalTo(9);
|
|
make.height.mas_equalTo(18);
|
|
}];
|
|
|
|
self.giftBgView = [[UIView alloc] init];
|
|
[self.giftBgView setBackgroundColor:RGB16A(0x000000, 0.65)];
|
|
[self.giftBgView addRoundedCornersWithRadius:12];
|
|
[self.contentView addSubview:self.giftBgView];
|
|
[self.giftBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.contentTitleLabel.mas_bottom).offset(8);
|
|
make.height.width.mas_equalTo(ScaleWidth(72));
|
|
make.centerX.equalTo(self.contentView);
|
|
}];
|
|
|
|
self.giftImageView = [[UIImageView alloc] init];
|
|
[self.giftBgView addSubview:self.giftImageView];
|
|
self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
[self.giftImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.giftBgView);
|
|
}];
|
|
|
|
|
|
self.giftNameLabel = [[UILabel alloc] init];
|
|
self.giftNameLabel.text = @"礼物名称";
|
|
self.giftNameLabel.textColor = RGB16(0xFFD7FE);
|
|
self.giftNameLabel.font = [UIFont systemFontOfSize:ScaleWidth(12)];
|
|
self.giftNameLabel.textAlignment = NSTextAlignmentCenter;
|
|
[self.contentView addSubview:self.giftNameLabel];
|
|
[self.giftNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.equalTo(self.contentView);
|
|
make.top.equalTo(self.giftImageView.mas_bottom).offset(4);
|
|
make.height.mas_equalTo(17);
|
|
}];
|
|
|
|
self.giftCoinBtn = [[UIButton alloc] init];
|
|
[self.giftCoinBtn setImage:[UIImage imageNamed:@"mine_live_gift_corn"] forState:(UIControlStateNormal)];
|
|
[self.giftCoinBtn setTitleColor:RGB16A(0xFFFFFF,0.85) forState:(UIControlStateNormal)];
|
|
[self.giftCoinBtn setTitle:@"0" forState:(UIControlStateNormal)];
|
|
self.giftCoinBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
[self.bgView addSubview:self.giftCoinBtn];
|
|
[self.giftCoinBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.giftNameLabel.mas_bottom);
|
|
make.height.mas_equalTo(20);
|
|
make.centerX.equalTo(self.contentView);
|
|
}];
|
|
|
|
}
|
|
|
|
-(void)setRoomId:(NSString *)roomId{
|
|
_roomId = roomId;
|
|
}
|
|
-(void)setPitModel:(QXRoomPitModel *)pitModel{
|
|
_pitModel = pitModel;
|
|
[self.headerImageView sd_setImageWithURL:[NSURL URLWithString:pitModel.avatar]];
|
|
self.nameLabel.text = pitModel.nickname;
|
|
[self getGiftInfo];
|
|
}
|
|
-(void)getGiftInfo{
|
|
MJWeakSelf
|
|
[QXMineNetwork roomAskUserGiftWithRoomId:self.roomId toUserId:self.pitModel.user_id successBlock:^(QXGiftModel * _Nonnull model) {
|
|
[weakSelf.giftCoinBtn setTitle:model.gift_price forState:(UIControlStateNormal)];
|
|
weakSelf.giftNameLabel.text = model.gift_name;
|
|
[weakSelf.giftImageView sd_setImageWithURL:[NSURL URLWithString:model.base_image]];
|
|
[weakSelf.myCoinBtn setTitle:model.user_wallet_coin forState:(UIControlStateNormal)];
|
|
weakSelf.giftModel = model;
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
showToast(msg);
|
|
}];
|
|
}
|
|
|
|
-(void)rechargeAction{
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(askViewDidRecharge:)]) {
|
|
[self.delegate askViewDidRecharge:self];
|
|
}
|
|
}
|
|
-(void)sendAction{
|
|
if (!self.giftModel) {
|
|
return;
|
|
}
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(askViewDidSend:pitModel:giftInfo:)]) {
|
|
[self.delegate askViewDidSend:self pitModel:self.pitModel giftInfo:self.giftModel];
|
|
}
|
|
}
|
|
|
|
-(void)showInView:(UIView *)view{
|
|
self.bgView.y = -view.height;
|
|
[view addSubview:self];
|
|
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
self.bgView.y = (view.height-self.bgView.height)/2.0;
|
|
} completion:^(BOOL finished) {
|
|
|
|
}];
|
|
}
|
|
|
|
-(void)hide{
|
|
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
|
|
self.bgView.y = SCREEN_HEIGHT;
|
|
} completion:^(BOOL finished) {
|
|
[self removeFromSuperview];
|
|
}];
|
|
}
|
|
|
|
@end
|