1057 lines
42 KiB
Objective-C
1057 lines
42 KiB
Objective-C
//
|
|
// QXSendGiftView.m
|
|
// QXLive
|
|
//
|
|
// Created by 启星 on 2025/5/29.
|
|
//
|
|
#import <QuartzCore/QuartzCore.h>
|
|
#import "QXSendGiftView.h"
|
|
#import "QXGiftCell.h"
|
|
#import "UIButton+QX.h"
|
|
#import "QXGiveGiftListView.h"
|
|
#import "QXMenuPopView.h"
|
|
#import "QXRechargeViewcController.h"
|
|
#import "QXRechargeView.h"
|
|
#import "QXPayTypeModel.h"
|
|
#import "QXMineNetwork.h"
|
|
#import "QXDynamicNetwork.h"
|
|
|
|
|
|
@interface QXSendGiftView()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate,QXMenuPopViewDelegate,UIGestureRecognizerDelegate>
|
|
/// 趣味
|
|
@property (nonatomic,strong)UIView *funnyView;
|
|
@property (nonatomic,strong)UIImageView *funnyBgImageView;
|
|
@property (nonatomic,strong)UILabel *titleLabel;
|
|
@property (nonatomic,strong)UILabel *subTitleLabel;
|
|
@property (nonatomic,strong)UIButton *introduceBtn;
|
|
|
|
@property (nonatomic,strong)UIView *bgView;
|
|
|
|
@property (nonatomic,strong)JXCategoryTitleView *categoryView;
|
|
@property (nonatomic,strong)JXCategoryListContainerView *containerView;
|
|
|
|
/// 打赏用户列表
|
|
@property (nonatomic,strong)QXSendGiftUserView *userListView;
|
|
/// 麦位用户列表
|
|
@property (nonatomic,strong)QXSendGiftPitUserView *pitUserListView;
|
|
|
|
@property (nonatomic,strong)UIImageView *bgImageView;
|
|
|
|
@property (nonatomic,strong)UIImageView *cornImageView;
|
|
@property (nonatomic,strong)UILabel *cornLabel;
|
|
@property (nonatomic,strong)UIButton *rechargeBtn;
|
|
|
|
@property (nonatomic,strong)UIView *sendBgView;
|
|
@property (nonatomic,strong)UIButton *countBtn;
|
|
@property (nonatomic,strong)UIButton *sendBtn;
|
|
|
|
/// 被选中的礼物
|
|
@property (nonatomic,strong)QXGiftModel *giftModel;
|
|
@property (nonatomic,strong)NSString *giftCount;
|
|
|
|
@end
|
|
|
|
@implementation QXSendGiftView
|
|
|
|
-(void)showInView:(UIView *)view{
|
|
self.bgView.y = SCREEN_HEIGHT;
|
|
[view addSubview:self];
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(429)-kSafeAreaBottom;
|
|
}];
|
|
}
|
|
-(void)hide{
|
|
[UIView animateWithDuration:0.3 animations:^{
|
|
self.bgView.y = SCREEN_HEIGHT;
|
|
} completion:^(BOOL finished) {
|
|
[self removeFromSuperview];
|
|
}];
|
|
}
|
|
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
|
return touch.view == self;
|
|
}
|
|
-(instancetype)initWithType:(QXSendGiftViewType)type{
|
|
self = [super init];
|
|
if (self) {
|
|
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
|
|
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
|
|
self.giftCount = @"1";
|
|
[self initSubviews];
|
|
[self setType:type];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)setType:(QXSendGiftViewType)type{
|
|
_type = type;
|
|
switch (type) {
|
|
case QXSendGiftViewTypeFind:{
|
|
if (_pitUserListView) {
|
|
[_pitUserListView removeFromSuperview];
|
|
_pitUserListView = nil;
|
|
}
|
|
self.bgView.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(429)+kSafeAreaBottom);
|
|
self.bgView.backgroundColor = [UIColor whiteColor];
|
|
self.bgImageView.hidden = YES;
|
|
[self.bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
|
|
[self initUserListView];
|
|
self.categoryView.frame = CGRectMake(16, self.categoryView.bottom+ScaleWidth(8), SCREEN_WIDTH-32, ScaleWidth(44));
|
|
self.containerView.frame = CGRectMake(0, self.categoryView.bottom, SCREEN_WIDTH, self.bgView.height-self.categoryView.bottom-ScaleWidth(63)-kSafeAreaBottom);
|
|
}
|
|
break;
|
|
case QXSendGiftViewTypeRoom:
|
|
case QXSendGiftViewTypeAuction:{
|
|
if (_userListView) {
|
|
[_userListView removeFromSuperview];
|
|
_userListView = nil;
|
|
}
|
|
self.bgView.frame = CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(429)+kSafeAreaBottom);
|
|
self.bgView.backgroundColor = [UIColor clearColor];
|
|
self.bgImageView.frame = self.bounds;
|
|
self.bgImageView.hidden = NO;
|
|
self.categoryView.titleSelectedColor = [UIColor colorWithHexString:@"#FFFFFF"];
|
|
self.categoryView.titleColor = [UIColor colorWithHexString:@"#E9E9E9"];
|
|
[self.bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
|
|
[self initPitUserListView];
|
|
self.categoryView.frame = CGRectMake(16, ScaleWidth(44)+ScaleWidth(8), SCREEN_WIDTH-32, ScaleWidth(44));
|
|
self.containerView.frame = CGRectMake(0, self.categoryView.bottom, SCREEN_WIDTH, self.bgView.height-self.categoryView.bottom-ScaleWidth(63)-kSafeAreaBottom);
|
|
}
|
|
break;
|
|
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
-(void)initSubviews{
|
|
|
|
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
|
|
tap.delegate = self;
|
|
[self addGestureRecognizer:tap];
|
|
|
|
|
|
self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(429)+kSafeAreaBottom)];
|
|
[self.bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
|
|
[self addSubview:self.bgView];
|
|
|
|
self.bgImageView = [[UIImageView alloc] initWithFrame:self.bounds];
|
|
self.bgImageView.image = [UIImage imageNamed:@"room_sound_bg"];
|
|
[self.bgView addSubview:self.bgImageView];
|
|
|
|
self.funnyView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT- self.bgView.height - 12 -ScaleWidth(60), SCREEN_WIDTH, ScaleWidth(60))];
|
|
self.funnyView.hidden = YES;
|
|
[self addSubview:self.funnyView];
|
|
|
|
self.funnyBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gift_funny_bg"]];
|
|
self.funnyBgImageView.frame = self.funnyView.bounds;
|
|
[self.funnyView addSubview:self.funnyBgImageView];
|
|
|
|
self.introduceBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-16-75, 10, 75, ScaleWidth(22))];
|
|
self.introduceBtn.titleLabel.font =[UIFont systemFontOfSize:12];
|
|
[self.introduceBtn setTitleColor:UIColor.whiteColor forState:(UIControlStateNormal)];
|
|
[self.introduceBtn setTitle:@"玩法介绍" forState:(UIControlStateNormal)];
|
|
self.introduceBtn.backgroundColor = RGB16(0x333333);
|
|
[self.introduceBtn addRoundedCornersWithRadius:ScaleWidth(11)];
|
|
[self.introduceBtn addTarget:self action:@selector(introduceAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self.funnyView addSubview:self.introduceBtn];
|
|
|
|
|
|
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(22, 10, self.introduceBtn.left-5-22, ScaleWidth(22))];
|
|
self.titleLabel.font =[UIFont systemFontOfSize:14];
|
|
self.titleLabel.textColor = RGB16(0x333333);
|
|
[self.funnyView addSubview:self.titleLabel];
|
|
|
|
self.subTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(22, self.titleLabel.bottom, self.funnyView.width-22*2, ScaleWidth(18))];
|
|
self.subTitleLabel.font =[UIFont systemFontOfSize:12];
|
|
self.titleLabel.textColor = RGB16(0x666666);
|
|
[self.funnyView addSubview:self.subTitleLabel];
|
|
|
|
self.categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(16, ScaleWidth(8), SCREEN_WIDTH-32, ScaleWidth(44))];
|
|
|
|
self.categoryView.delegate = self;
|
|
self.categoryView.titles = self.titles;
|
|
self.categoryView.titleSelectedColor = [UIColor colorWithHexString:@"#333333"];
|
|
self.categoryView.titleColor = [UIColor colorWithHexString:@"#666666"];
|
|
self.categoryView.cellWidth = JXCategoryViewAutomaticDimension;
|
|
self.categoryView.contentEdgeInsetLeft = 0;
|
|
self.categoryView.cellSpacing = 13;
|
|
self.categoryView.contentEdgeInsetLeft = 5;
|
|
self.categoryView.titleLabelZoomEnabled = YES;
|
|
self.categoryView.titleFont = [UIFont boldSystemFontOfSize:14];
|
|
self.categoryView.titleSelectedFont = [UIFont boldSystemFontOfSize:16];
|
|
self.categoryView.averageCellSpacingEnabled = NO;
|
|
self.containerView = [[JXCategoryListContainerView alloc] initWithType:(JXCategoryListContainerType_ScrollView) delegate:self];
|
|
self.containerView.frame = CGRectMake(0, self.categoryView.bottom, SCREEN_WIDTH, self.height-self.categoryView.bottom-ScaleWidth(63));
|
|
[self.bgView addSubview:self.categoryView];
|
|
[self.bgView addSubview:self.containerView];
|
|
self.categoryView.listContainer = self.containerView;
|
|
|
|
|
|
self.cornImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mine_live_gift_corn"]];
|
|
self.cornImageView.frame = CGRectMake(16, self.height-21, 14, 14);
|
|
[self.bgView addSubview:self.cornImageView];
|
|
[self.cornImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(16);
|
|
make.size.mas_equalTo(CGSizeMake(14, 14));
|
|
make.bottom.mas_equalTo(-(21+kSafeAreaBottom));
|
|
}];
|
|
|
|
self.cornLabel = [[UILabel alloc] init];
|
|
self.cornLabel.font = [UIFont systemFontOfSize:14];
|
|
self.cornLabel.textColor = QXConfig.textColor;
|
|
self.cornLabel.text = @"0";
|
|
[self.bgView addSubview:self.cornLabel];
|
|
[self.cornLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(self.cornImageView.mas_right).offset(3);
|
|
make.height.mas_equalTo(20);
|
|
make.centerY.equalTo(self.cornImageView);
|
|
}];
|
|
|
|
self.rechargeBtn = [[UIButton alloc] init];
|
|
[self.rechargeBtn setTitle:QXText(@"去充值") forState:(UIControlStateNormal)];
|
|
self.rechargeBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
|
self.rechargeBtn.hidden = YES;
|
|
[self.rechargeBtn setTitleColor:QXConfig.themeColor forState:(UIControlStateNormal)];
|
|
[self.rechargeBtn addTarget:self action:@selector(rechargeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self.bgView addSubview:self.rechargeBtn];
|
|
[self.rechargeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.equalTo(self.cornLabel.mas_right).offset(18);
|
|
make.height.mas_equalTo(40);
|
|
make.width.mas_equalTo(45);
|
|
make.centerY.equalTo(self.cornImageView);
|
|
}];
|
|
|
|
self.sendBgView = [[UIView alloc] init];
|
|
[self.sendBgView addRoundedCornersWithRadius:17.5];
|
|
self.sendBgView.layer.borderColor = QXConfig.themeColor.CGColor;
|
|
self.sendBgView.layer.borderWidth = 1;
|
|
[self.bgView addSubview:self.sendBgView];
|
|
[self.sendBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(-16);
|
|
make.width.mas_equalTo(120);
|
|
make.height.mas_equalTo(35);
|
|
make.centerY.equalTo(self.cornImageView);
|
|
}];
|
|
|
|
|
|
self.countBtn = [[UIButton alloc] init];
|
|
[self.countBtn setTitle:@"X1" forState:(UIControlStateNormal)];
|
|
[self.countBtn setTitleColor:RGB16(0x333333) forState:(UIControlStateNormal)];
|
|
self.countBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
|
[self.countBtn addTarget:self action:@selector(selectedCount:) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self.sendBgView addSubview:self.countBtn];
|
|
[self.countBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.top.bottom.equalTo(self.sendBgView);
|
|
make.width.equalTo(self.sendBgView.mas_width).multipliedBy(0.5);
|
|
}];
|
|
|
|
self.sendBtn = [[UIButton alloc] init];
|
|
[self.sendBtn setTitle:QXText(@"赠送") forState:(UIControlStateNormal)];
|
|
[self.sendBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
|
self.sendBtn.backgroundColor = QXConfig.themeColor;
|
|
self.sendBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
|
[self.sendBtn addTarget:self action:@selector(sendAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self.sendBgView addSubview:self.sendBtn];
|
|
[self.sendBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.top.bottom.equalTo(self.sendBgView);
|
|
make.width.equalTo(self.sendBgView.mas_width).multipliedBy(0.5);
|
|
}];
|
|
}
|
|
-(void)introduceAction{
|
|
QXBaseWebViewController *vc = [[QXBaseWebViewController alloc] init];
|
|
vc.urlStr = self.giftModel.rule_url;
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
}
|
|
-(void)selectedCount:(UIButton*)sender{
|
|
QXMenuPopView *popView = [[QXMenuPopView alloc] initWithPoint:CGPointMake(SCREEN_WIDTH-16-60-30, SCREEN_HEIGHT-kSafeAreaBottom-50-225) width:88 height:225];
|
|
popView.type = QXMenuPopViewTypeArrowBottom;
|
|
popView.dataArray = @[@"X99",@"X66",@"X30",@"10",@"5",@"3",@"1"];
|
|
popView.delegate = self;
|
|
[popView showInView:KEYWINDOW];
|
|
}
|
|
|
|
-(void)didSelectedIndex:(NSInteger)index menuTitle:(NSString *)menuTitle{
|
|
[self.countBtn setTitle:menuTitle forState:(UIControlStateNormal)];
|
|
NSCharacterSet* nonDigits =[[NSCharacterSet decimalDigitCharacterSet] invertedSet];
|
|
NSInteger count =[[menuTitle stringByTrimmingCharactersInSet:nonDigits] integerValue];
|
|
QXLOG(@"选择了%ld个",count);
|
|
self.giftCount = [NSString stringWithFormat:@"%ld",count];
|
|
}
|
|
-(void)setDynamicId:(NSString *)dynamicId{
|
|
_dynamicId = dynamicId;
|
|
self.userListView.dynamicId = dynamicId;
|
|
self.rechargeBtn.hidden = !QXGlobal.shareGlobal.isOpenRecharge;
|
|
}
|
|
/// 发送礼物
|
|
-(void)sendAction{
|
|
MJWeakSelf
|
|
if (self.type == QXSendGiftViewTypeRoom) {
|
|
if (self.giftModel==nil) {
|
|
showToast(@"请选择礼物");
|
|
return;
|
|
}
|
|
if (self.pitUserListView.selectedArray.count == 0) {
|
|
showToast(@"请选择送礼对象");
|
|
return;
|
|
}
|
|
/// 2为背包
|
|
NSString *userId = [self.pitUserListView.selectedArray componentsJoinedByString:@","];
|
|
NSString *type = self.categoryView.selectedIndex==0?@"2":@"1";
|
|
[QXMineNetwork roomSendGiftWithRoomId:self.roomId gift_id:self.giftModel.gift_id gift_num:self.giftCount to_uid:userId type:type pit_number:@"" successBlock:^(NSDictionary * _Nonnull dict) {
|
|
[weakSelf hide];
|
|
if (weakSelf.roomSendSuccessBlock) {
|
|
weakSelf.roomSendSuccessBlock(NO,weakSelf.giftModel,userId,@"");
|
|
}
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
showToast(msg)
|
|
}];
|
|
}else if (self.type == QXSendGiftViewTypeAuction) {
|
|
/// 2为背包
|
|
NSString *type = self.categoryView.selectedIndex==0?@"2":@"1";
|
|
[QXMineNetwork roomAuctionJoinWithAuctionId:self.auctionId user_id:[QXGlobal shareGlobal].loginModel.user_id gift_id:self.giftModel.gift_id num:self.giftCount type:type successBlock:^(NSDictionary * _Nonnull dict) {
|
|
[weakSelf hide];
|
|
if (weakSelf.roomSendSuccessBlock) {
|
|
weakSelf.roomSendSuccessBlock(YES,weakSelf.giftModel,[QXGlobal shareGlobal].loginModel.user_id,weakSelf.auctionId);
|
|
}
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
showToast(msg);
|
|
}];
|
|
}else{
|
|
/// 2为背包
|
|
NSString *type = self.categoryView.selectedIndex==0?@"2":@"1";
|
|
[QXDynamicNetwork dynamicGiveGiftWithId:self.dynamicId
|
|
gift_id:self.giftModel.gift_id
|
|
num:self.giftCount
|
|
is_pack:type
|
|
successBlock:^(NSDictionary * _Nonnull dict) {
|
|
showToast(@"打赏成功");
|
|
if (weakSelf.sendSuccessBlock) {
|
|
weakSelf.sendSuccessBlock(weakSelf.dynamicId);
|
|
}
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
showToast(msg);
|
|
}];
|
|
}
|
|
|
|
}
|
|
|
|
|
|
-(void)rechargeAction{
|
|
MJWeakSelf
|
|
switch (self.type) {
|
|
case QXSendGiftViewTypeFind:{
|
|
[self.viewController dismissViewControllerAnimated:YES completion:^{
|
|
QXRechargeViewcController *vc = [[QXRechargeViewcController alloc] init];
|
|
[weakSelf.vc.navigationController pushViewController:vc animated:YES];
|
|
}];
|
|
}
|
|
break;
|
|
case QXSendGiftViewTypeRoom:{
|
|
// [[QXGlobal shareGlobal] hideViewBlock:^{
|
|
// QXRechargeView *recharge = [[QXRechargeView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
|
|
// recharge.isPop = YES;
|
|
// [recharge showInView:weakSelf.vc.view];
|
|
// }];
|
|
[self hide];
|
|
QXRechargeView *recharge = [[QXRechargeView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
|
|
recharge.isPop = YES;
|
|
[recharge showInView:weakSelf.vc.view];
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
-(void)setPitUsers:(NSArray *)pitUsers{
|
|
_pitUsers = pitUsers;
|
|
self.pitUserListView.isSingle = NO;
|
|
[self.pitUserListView.selectedArray removeAllObjects];
|
|
self.pitUserListView.users = pitUsers;
|
|
[self getMyWallet];
|
|
}
|
|
-(void)setUserModel:(QXRoomPitModel *)userModel{
|
|
_userModel = userModel;
|
|
userModel.isSelected = YES;
|
|
self.pitUserListView.isSingle = YES;
|
|
[self.pitUserListView.selectedArray removeAllObjects];
|
|
[self.pitUserListView.selectedArray addObject:userModel.user_id];
|
|
self.pitUserListView.users = @[userModel];
|
|
[self getMyWallet];
|
|
}
|
|
|
|
-(void)initUserListView{
|
|
[self.bgView addSubview:self.userListView];
|
|
}
|
|
|
|
-(void)initPitUserListView{
|
|
[self.bgView addSubview:self.pitUserListView];
|
|
}
|
|
-(void)getCategoryList{
|
|
|
|
MJWeakSelf
|
|
[QXMineNetwork giftLabelSuccessBlock:^(NSArray<QXGiftLabelModel *> * _Nonnull list) {
|
|
[weakSelf.titles removeAllObjects];
|
|
[weakSelf.titles addObjectsFromArray:list];
|
|
QXGiftLabelModel *md = [[QXGiftLabelModel alloc] init];
|
|
md.name = @"背包";
|
|
md.id = @"-10";
|
|
[weakSelf.titles insertObject:md atIndex:0];
|
|
NSMutableArray *arr = [NSMutableArray array];
|
|
for (QXGiftLabelModel*md in weakSelf.titles) {
|
|
[arr addObject:md.name];
|
|
}
|
|
weakSelf.categoryView.titles = arr;
|
|
[weakSelf.categoryView setDefaultSelectedIndex:1];
|
|
[weakSelf.categoryView reloadData];
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
}];
|
|
}
|
|
-(void)reloadData{
|
|
[self getCategoryList];
|
|
[self getMyWallet];
|
|
}
|
|
-(void)getMyWallet{
|
|
MJWeakSelf
|
|
[QXMineNetwork getWalletInfoSuccessBlock:^(NSString * _Nonnull coin, NSString * _Nonnull earnings, NSString * _Nonnull title, NSString * _Nonnull url) {
|
|
weakSelf.cornLabel.text = coin;
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
}];
|
|
self.rechargeBtn.hidden = !QXGlobal.shareGlobal.isOpenRecharge;
|
|
}
|
|
|
|
|
|
-(void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
|
|
// QXGiftLabelModel *model = self.titles[index];
|
|
// if ([model.id isEqualToString:@"2"]) {
|
|
// self.funnyView.hidden = NO;
|
|
// }else{
|
|
// self.funnyView.hidden = YES;
|
|
// }
|
|
}
|
|
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
|
|
return self.titles.count;
|
|
}
|
|
|
|
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
|
|
QXSendGiftCollectionView *subGiftView = [[QXSendGiftCollectionView alloc] initWithFrame:listContainerView.bounds];
|
|
QXGiftLabelModel *md = self.titles[index];
|
|
subGiftView.giftLabelId = md.id;
|
|
MJWeakSelf
|
|
subGiftView.selectetGiftBlock = ^(QXGiftModel * _Nonnull gift) {
|
|
weakSelf.giftModel = gift;
|
|
if (gift.gift_bag_name.length > 0) {
|
|
weakSelf.funnyView.hidden = NO;
|
|
weakSelf.titleLabel.text = gift.gift_bag_name;
|
|
weakSelf.subTitleLabel.text = gift.rule;
|
|
}else{
|
|
weakSelf.funnyView.hidden = YES;
|
|
weakSelf.titleLabel.text = @"";
|
|
weakSelf.subTitleLabel.text = @"";
|
|
}
|
|
};
|
|
return subGiftView;
|
|
}
|
|
|
|
-(NSMutableArray *)titles{
|
|
if (!_titles) {
|
|
_titles = [NSMutableArray array];
|
|
}
|
|
return _titles;
|
|
}
|
|
-(QXSendGiftPitUserView *)pitUserListView{
|
|
if (!_pitUserListView) {
|
|
_pitUserListView = [[QXSendGiftPitUserView alloc] initWithFrame:CGRectMake(0, 0, self.width, ScaleWidth(63))];
|
|
}
|
|
return _pitUserListView;
|
|
}
|
|
-(QXSendGiftUserView *)userListView{
|
|
if (!_userListView) {
|
|
_userListView = [[QXSendGiftUserView alloc] initWithFrame:CGRectMake(0, 0, self.width, ScaleWidth(63))];
|
|
MJWeakSelf
|
|
[_userListView addTapBlock:^(id _Nonnull obj) {
|
|
if (weakSelf.userListView.dataArray.count == 0) {
|
|
return;
|
|
}else{
|
|
QXAlertViewController *al = (QXAlertViewController *)weakSelf.viewController;
|
|
[al hideViewFinishBlock:^{
|
|
QXGiveGiftListView *listView = [[QXGiveGiftListView alloc] init];
|
|
listView.dynamicId = weakSelf.dynamicId;
|
|
listView.vc = weakSelf.vc;
|
|
[listView showInView:KEYWINDOW];
|
|
}];
|
|
}
|
|
}];
|
|
}
|
|
return _userListView;
|
|
}
|
|
|
|
|
|
@end
|
|
|
|
@implementation QXSendGiftCollectionView
|
|
-(UIView *)listView{
|
|
return self;
|
|
}
|
|
-(void)listWillAppear{
|
|
if ([self.giftLabelId isEqualToString:@"-10"]) {
|
|
[self getBagList];
|
|
}
|
|
self.selectedIndex = -1;
|
|
[self.collectionView reloadData];
|
|
}
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)initSubviews{
|
|
self.selectedIndex = -1;
|
|
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
|
layout.itemSize = CGSizeMake((SCREEN_WIDTH-16*2-12*3)/4, ScaleWidth(119));
|
|
layout.minimumLineSpacing = 12;
|
|
layout.minimumInteritemSpacing = 12;
|
|
layout.sectionInset = UIEdgeInsetsMake(0, 16, 0, 16);
|
|
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
|
|
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height) collectionViewLayout:layout];
|
|
[self.collectionView registerNib:[UINib nibWithNibName:@"QXGiftCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"QXGiftCell"];
|
|
self.collectionView.delegate = self;
|
|
self.collectionView.dataSource = self;
|
|
self.collectionView.showsHorizontalScrollIndicator = NO;
|
|
self.collectionView.bounces = NO;
|
|
self.collectionView.backgroundColor = [UIColor clearColor];
|
|
[self addSubview:self.collectionView];
|
|
|
|
}
|
|
-(void)setGiftLabelId:(NSString *)giftLabelId{
|
|
_giftLabelId = giftLabelId;
|
|
if ([giftLabelId isEqualToString:@"-10"]) {
|
|
[self getBagList];
|
|
}else{
|
|
[self getGiftListWithLabel:self.giftLabelId];
|
|
}
|
|
}
|
|
-(void)getGiftListWithLabel:(NSString*)label{
|
|
MJWeakSelf
|
|
self.selectedIndex = -1;
|
|
[QXMineNetwork giftListWithLabel:label successBlock:^(NSArray<QXGiftModel *> * _Nonnull list) {
|
|
[weakSelf.dataArray removeAllObjects];
|
|
[weakSelf.dataArray addObjectsFromArray:list];
|
|
[weakSelf.collectionView reloadData];
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
}];
|
|
}
|
|
-(void)getBagList{
|
|
self.selectedIndex = -1;
|
|
MJWeakSelf
|
|
[QXMineNetwork getBagListSuccessBlock:^(NSArray * _Nonnull list) {
|
|
[weakSelf.dataArray removeAllObjects];
|
|
[weakSelf.dataArray addObjectsFromArray:list];
|
|
[weakSelf.collectionView reloadData];
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
}];
|
|
}
|
|
|
|
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
|
return self.dataArray.count;
|
|
}
|
|
|
|
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
|
QXGiftCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXGiftCell" forIndexPath:indexPath];
|
|
cell.cellType = QXGiftCellTypeLive;
|
|
cell.roomGiftModel = self.dataArray[indexPath.row];
|
|
if (self.selectedIndex == indexPath.row) {
|
|
cell.selecteBtn.selected = YES;
|
|
}else{
|
|
cell.selecteBtn.selected = NO;
|
|
}
|
|
return cell;
|
|
}
|
|
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
|
if (indexPath.row == self.selectedIndex) {
|
|
return;
|
|
}
|
|
self.selectedIndex = indexPath.row;
|
|
QXGiftModel *model = self.dataArray[indexPath.row];
|
|
if (self.selectetGiftBlock) {
|
|
self.selectetGiftBlock(model);
|
|
}
|
|
[collectionView reloadData];
|
|
}
|
|
|
|
-(NSMutableArray *)dataArray{
|
|
if (!_dataArray) {
|
|
_dataArray = [NSMutableArray array] ;
|
|
}
|
|
return _dataArray;
|
|
}
|
|
@end
|
|
|
|
|
|
|
|
@implementation QXSendGiftUserView
|
|
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)initSubviews{
|
|
MJWeakSelf
|
|
self.titltLabel = [[UILabel alloc] init];
|
|
self.titltLabel.font = [UIFont systemFontOfSize:14];
|
|
self.titltLabel.textColor = RGB16(0x666666);
|
|
self.titltLabel.text = QXText(@"还没有人打赏,快来当第一个打赏的人吧!");
|
|
[self addSubview:self.titltLabel];
|
|
[self.titltLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(16);
|
|
make.right.mas_equalTo(-16);
|
|
make.top.mas_equalTo(ScaleWidth(29));
|
|
make.height.mas_equalTo(ScaleWidth(20));
|
|
}];
|
|
|
|
self.detailBtn = [[UIButton alloc] init];
|
|
self.detailBtn.hidden = YES;
|
|
self.detailBtn.userInteractionEnabled = NO;
|
|
[self.detailBtn setTitle:[NSString localizedStringWithFormat:QXText(@"已有%@个人打赏"),@"0"] forState:(UIControlStateNormal)];
|
|
self.detailBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
[self.detailBtn setImage:[UIImage imageNamed:@"arrowRight"] forState:(UIControlStateNormal)];
|
|
[self.detailBtn setTitleColor:RGB16(0x666666) forState:(UIControlStateNormal)];
|
|
[self addSubview:self.detailBtn];
|
|
[self.detailBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(-16);
|
|
make.top.mas_equalTo(ScaleWidth(29));
|
|
make.height.mas_equalTo(ScaleWidth(20));
|
|
make.width.mas_equalTo(135);
|
|
}];
|
|
self.detailBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentTrailing;
|
|
[self.detailBtn qx_layoutButtonNOSizeToFitWithEdgeInsetsStyle:(QXButtonEdgeInsetsStyleRight) imageTitleSpace:0];
|
|
|
|
self.lineView = [[UIView alloc] init];
|
|
self.lineView.backgroundColor = RGB16(0xE2E2E2);
|
|
[self addSubview:self.lineView];
|
|
[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(16);
|
|
make.right.mas_equalTo(-16);
|
|
make.bottom.equalTo(self.mas_bottom);
|
|
make.height.mas_equalTo(1);
|
|
}];
|
|
|
|
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
|
layout.minimumLineSpacing = 2;
|
|
layout.itemSize = CGSizeMake(ScaleWidth(22), ScaleWidth(22));
|
|
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
|
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
|
self.collectionView.dataSource = self;
|
|
self.collectionView.delegate = self;
|
|
self.collectionView.showsHorizontalScrollIndicator = NO;
|
|
[self.collectionView registerClass:[QXSendGiftUserCell class] forCellWithReuseIdentifier:@"QXSendGiftUserCell"];
|
|
[self addSubview:self.collectionView];
|
|
self.collectionView.hidden = YES;
|
|
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(16);
|
|
make.right.equalTo(self.detailBtn.mas_left).offset(-16);
|
|
make.height.mas_equalTo(ScaleWidth(22));
|
|
make.centerY.equalTo(self.detailBtn);
|
|
}];
|
|
|
|
|
|
}
|
|
-(void)setDynamicId:(NSString *)dynamicId{
|
|
_dynamicId = dynamicId;
|
|
[self getUsers];
|
|
}
|
|
-(void)getUsers{
|
|
MJWeakSelf
|
|
[QXDynamicNetwork dynamicGiveGiftListWithId:self.dynamicId successBlock:^(NSArray<QXUserHomeModel *> * _Nonnull list) {
|
|
[weakSelf.dataArray removeAllObjects];
|
|
[weakSelf.dataArray addObjectsFromArray:list];
|
|
if (weakSelf.dataArray.count == 0) {
|
|
weakSelf.titltLabel.hidden = NO;
|
|
weakSelf.collectionView.hidden = YES;
|
|
weakSelf.detailBtn.hidden = YES;
|
|
}else{
|
|
weakSelf.titltLabel.hidden = YES;
|
|
weakSelf.collectionView.hidden = NO;
|
|
weakSelf.detailBtn.hidden = NO;
|
|
}
|
|
NSString *count = [NSString stringWithFormat:@"%ld",weakSelf.dataArray.count];
|
|
[weakSelf.detailBtn setTitle:[NSString localizedStringWithFormat:QXText(@"已有%@个人打赏"),count] forState:(UIControlStateNormal)];
|
|
[weakSelf.detailBtn qx_layoutButtonNOSizeToFitWithEdgeInsetsStyle:(QXButtonEdgeInsetsStyleRight) imageTitleSpace:0];
|
|
[weakSelf.collectionView reloadData];
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
|
if (self.dataArray.count > 5) {
|
|
return 5;
|
|
}else{
|
|
return self.dataArray.count;
|
|
}
|
|
}
|
|
|
|
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
|
QXSendGiftUserCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXSendGiftUserCell" forIndexPath:indexPath];
|
|
QXUserHomeModel *model = self.dataArray[indexPath.row];
|
|
cell.sendUserModel = model;
|
|
return cell;
|
|
}
|
|
|
|
|
|
-(NSMutableArray *)dataArray{
|
|
if (!_dataArray) {
|
|
_dataArray = [NSMutableArray array];
|
|
}
|
|
return _dataArray;
|
|
}
|
|
@end
|
|
|
|
|
|
@implementation QXSendGiftUserCell
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
-(void)initSubviews{
|
|
self.imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"user_header_placehoulder"]];
|
|
[self.imageView addRoundedCornersWithRadius:ScaleWidth(11)];
|
|
self.imageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
[self.contentView addSubview:self.imageView];
|
|
[self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.contentView);
|
|
}];
|
|
}
|
|
-(void)setSendUserModel:(QXUserHomeModel *)sendUserModel{
|
|
_sendUserModel = sendUserModel;
|
|
[self.imageView sd_setImageWithURL:[NSURL URLWithString:sendUserModel.avatar]];
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
@implementation QXSendGiftPitUserView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
-(void)initSubviews{
|
|
self.isPitUser = YES;
|
|
self.allBtn = [[UIButton alloc] init];
|
|
[self.allBtn setTitle:QXText(@"全麦") forState:(UIControlStateNormal)];
|
|
self.allBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
|
[self.allBtn setTitleColor:QXConfig.themeColor forState:(UIControlStateNormal)];
|
|
[self.allBtn setTitleColor:UIColor.whiteColor forState:(UIControlStateSelected)];
|
|
[self.allBtn setBackgroundImage:[UIImage imageWithColor:[UIColor clearColor]] forState:UIControlStateNormal];
|
|
[self.allBtn setBackgroundImage:[UIImage imageWithColor:QXConfig.themeColor] forState:UIControlStateSelected];
|
|
[self.allBtn addRoundedCornersWithRadius:15];
|
|
self.allBtn.layer.borderColor = QXConfig.themeColor.CGColor;
|
|
self.allBtn.layer.borderWidth = 1;
|
|
[self.allBtn addTarget:self action:@selector(selectedAll:) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self addSubview:self.allBtn];
|
|
[self.allBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.mas_equalTo(-16);
|
|
make.size.mas_equalTo(CGSizeMake(72, 30));
|
|
make.centerY.equalTo(self);
|
|
}];
|
|
|
|
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
|
layout.minimumLineSpacing = 10;
|
|
layout.itemSize = CGSizeMake(ScaleWidth(50), ScaleWidth(50));
|
|
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
|
|
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
|
self.collectionView.dataSource = self;
|
|
self.collectionView.delegate = self;
|
|
self.collectionView.showsHorizontalScrollIndicator = NO;
|
|
self.collectionView.backgroundColor = [UIColor clearColor];
|
|
[self.collectionView registerClass:[QXSendGiftUserCell class] forCellWithReuseIdentifier:@"QXSendGiftUserCell"];
|
|
[self.collectionView registerClass:[QXSendGiftPitUserCell class] forCellWithReuseIdentifier:@"QXSendGiftPitUserCell"];
|
|
[self addSubview:self.collectionView];
|
|
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(16);
|
|
make.right.equalTo(self.allBtn.mas_left).offset(-16);
|
|
make.height.mas_equalTo(ScaleWidth(50));
|
|
make.centerY.equalTo(self);
|
|
}];
|
|
}
|
|
-(void)setIsSingle:(BOOL)isSingle{
|
|
_isSingle = isSingle;
|
|
self.allBtn.hidden = isSingle;
|
|
}
|
|
-(void)selectedAll:(UIButton*)sender{
|
|
sender.selected = !sender.selected;
|
|
[self.selectedArray removeAllObjects];
|
|
for (QXRoomPitModel *md in self.users) {
|
|
md.isSelected = sender.selected;
|
|
sender.selected?[self.selectedArray addObject:md.user_id]:[self.selectedArray removeObject:md.user_id];
|
|
[self.collectionView reloadData];
|
|
}
|
|
}
|
|
-(void)setUsers:(NSArray *)users{
|
|
_users = users;
|
|
// [self.selectedArray removeAllObjects];
|
|
[self.collectionView reloadData];
|
|
}
|
|
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
|
|
return self.users.count;
|
|
}
|
|
|
|
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
|
|
// if (self.isPitUser) {
|
|
QXSendGiftPitUserCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXSendGiftPitUserCell" forIndexPath:indexPath];
|
|
cell.pitModel = self.users[indexPath.row];
|
|
return cell;
|
|
// }else{
|
|
// QXSendGiftUserCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXSendGiftUserCell" forIndexPath:indexPath];
|
|
// cell.pitModel = self.users[indexPath.row];
|
|
// return cell;
|
|
// }
|
|
}
|
|
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
|
|
if (self.isSingle) {
|
|
return;
|
|
}
|
|
QXRoomPitModel *model = self.users[indexPath.row];
|
|
model.isSelected = !model.isSelected;
|
|
[collectionView reloadData];
|
|
model.isSelected?[self.selectedArray addObject:model.user_id]:[self.selectedArray removeObject:model.user_id];
|
|
if (self.selectedArray.count == self.users.count) {
|
|
self.allBtn.selected = YES;
|
|
}else{
|
|
self.allBtn.selected = NO;
|
|
}
|
|
}
|
|
-(NSMutableArray *)selectedArray{
|
|
if (!_selectedArray) {
|
|
_selectedArray = [NSMutableArray array];
|
|
}
|
|
return _selectedArray;
|
|
}
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation QXSendGiftPitUserCell
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
[self initSubviews];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(void)initSubviews{
|
|
self.headerImageView = [[UIImageView alloc] init];
|
|
self.headerImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
[self.headerImageView addRoundedCornersWithRadius:ScaleWidth(17.5)];
|
|
self.headerImageView.layer.borderColor = QXConfig.themeColor.CGColor;
|
|
|
|
[self.contentView addSubview:self.headerImageView];
|
|
|
|
self.selectedBtn = [[UIButton alloc] init];
|
|
[self.selectedBtn setTitleColor:QXConfig.textColor forState:(UIControlStateNormal)];
|
|
[self.selectedBtn setBackgroundImage:[UIImage imageWithColor:QXConfig.themeColor] forState:(UIControlStateSelected)];
|
|
[self.selectedBtn setBackgroundImage:[UIImage imageWithColor:UIColor.whiteColor] forState:(UIControlStateNormal)];
|
|
self.selectedBtn.titleLabel.font = [UIFont systemFontOfSize:ScaleWidth(10.0)];
|
|
[self.contentView addSubview:self.selectedBtn];
|
|
self.selectedBtn.userInteractionEnabled = NO;
|
|
[self.selectedBtn addRoundedCornersWithRadius:ScaleWidth(7.5)];
|
|
|
|
[self.headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.size.mas_equalTo(CGSizeMake(ScaleWidth(35), ScaleWidth(35)));
|
|
make.top.equalTo(self.contentView).offset(5);
|
|
make.centerX.equalTo(self.contentView);
|
|
}];
|
|
[self.selectedBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.equalTo(self.contentView);
|
|
make.bottom.equalTo(self.contentView);
|
|
make.height.mas_equalTo(ScaleWidth(15));
|
|
}];
|
|
}
|
|
-(void)setPitModel:(QXRoomPitModel *)pitModel{
|
|
_pitModel = pitModel;
|
|
[self.headerImageView sd_setImageWithURL:[NSURL URLWithString:pitModel.avatar] placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]];
|
|
if (pitModel.pit_number.intValue == 9) {
|
|
[self.selectedBtn setTitle:QXText(@"主持人") forState:(UIControlStateNormal)];
|
|
}else if (pitModel.pit_number.intValue == 10) {
|
|
[self.selectedBtn setTitle:QXText(@"嘉宾") forState:(UIControlStateNormal)];
|
|
}else{
|
|
if (pitModel.pit_number.intValue > 0) {
|
|
if (pitModel.pit_number.longValue == 9999) {
|
|
self.selectedBtn.hidden = NO;
|
|
[self.selectedBtn setTitle:pitModel.nickname forState:(UIControlStateNormal)];
|
|
}else{
|
|
self.selectedBtn.hidden = NO;
|
|
[self.selectedBtn setTitle:[NSString localizedStringWithFormat:QXText(@"%@号麦"),pitModel.pit_number] forState:(UIControlStateNormal)];
|
|
}
|
|
}else{
|
|
self.selectedBtn.hidden = YES;
|
|
}
|
|
|
|
}
|
|
|
|
if (pitModel.isSelected) {
|
|
self.selectedBtn.selected = YES;
|
|
self.headerImageView.layer.borderWidth = 1;
|
|
}else{
|
|
self.selectedBtn.selected = NO;
|
|
self.headerImageView.layer.borderWidth = 0;
|
|
}
|
|
}
|
|
|
|
@end
|
|
|
|
@implementation QXContinuousGiftView
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
|
{
|
|
self = [super initWithFrame:frame];
|
|
if (self) {
|
|
UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
|
|
[self addGestureRecognizer:panRecognizer];
|
|
[self createCircleAnimation];
|
|
}
|
|
return self;
|
|
}
|
|
// 在 UIView 子类或视图控制器中实现
|
|
- (void)createCircleAnimation {
|
|
self.giftImageView = [[UIImageView alloc] init];
|
|
self.giftImageView.frame = self.bounds;
|
|
self.giftImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
[self.giftImageView addRoundedCornersWithRadius:self.height/2];
|
|
[self addSubview:self.giftImageView];
|
|
|
|
self.sendBtn = [[UIButton alloc] initWithFrame:self.giftImageView.bounds];
|
|
[self.sendBtn addTarget:self action:@selector(sendAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
[self addSubview:self.sendBtn];
|
|
// 设置圆环的中心点和半径
|
|
CGPoint center = CGPointMake(self.width/2, self.height/2);
|
|
CGFloat radius = self.bounds.size.height/2;
|
|
|
|
// 创建圆环路径
|
|
UIBezierPath *circlePath = [UIBezierPath bezierPathWithArcCenter:center
|
|
radius:radius
|
|
startAngle:-M_PI_2
|
|
endAngle:3*M_PI_2
|
|
clockwise:YES];
|
|
|
|
// 创建背景圆环(灰色)
|
|
CAShapeLayer *backgroundLayer = [CAShapeLayer layer];
|
|
backgroundLayer.path = circlePath.CGPath;
|
|
backgroundLayer.strokeColor = [UIColor lightGrayColor].CGColor;
|
|
backgroundLayer.fillColor = [UIColor clearColor].CGColor;
|
|
backgroundLayer.lineWidth = 6.0f;
|
|
[self.layer addSublayer:backgroundLayer];
|
|
|
|
// 创建前景圆环(蓝色,用于动画)
|
|
CAShapeLayer *circleLayer = [CAShapeLayer layer];
|
|
circleLayer.path = circlePath.CGPath;
|
|
circleLayer.strokeColor = QXConfig.themeColor.CGColor;
|
|
circleLayer.fillColor = [UIColor clearColor].CGColor;
|
|
circleLayer.lineWidth = 6.0f;
|
|
circleLayer.strokeEnd = 1.0f; // 初始状态不可见
|
|
self.circleLayer = circleLayer;
|
|
|
|
// 添加到视图
|
|
[self.layer addSublayer:circleLayer];
|
|
// 设置动画完成后的状态
|
|
[circleLayer addAnimation:self.animation forKey:@"circleAnimation"];
|
|
circleLayer.strokeEnd = 0.0f;
|
|
|
|
|
|
|
|
}
|
|
-(void)sendAction{
|
|
self.circleLayer.strokeEnd = 1.0f;
|
|
[self.circleLayer removeAllAnimations];
|
|
_animation = nil;
|
|
[self.circleLayer addAnimation:self.animation forKey:@"circleAnimation"];
|
|
[[QXGlobal shareGlobal] vibrationFeedback];
|
|
if (self.isAuction) {
|
|
[QXMineNetwork roomAuctionJoinWithAuctionId:self.auctionId user_id:self.userId gift_id:self.giftModel.gift_id num:@"1" type:@"1" successBlock:^(NSDictionary * _Nonnull dict) {
|
|
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
showToast(msg)
|
|
}];
|
|
}else{
|
|
[QXMineNetwork roomSendGiftWithRoomId:self.roomId gift_id:self.giftModel.gift_id gift_num:@"1" to_uid:self.userId type:@"1" pit_number:@"" successBlock:^(NSDictionary * _Nonnull dict) {
|
|
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
showToast(msg)
|
|
}];
|
|
}
|
|
|
|
}
|
|
-(CABasicAnimation *)animation{
|
|
if (!_animation) {
|
|
_animation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
|
|
_animation.duration = 10.0; // 10秒完成动画
|
|
_animation.fromValue = @1.0f;
|
|
_animation.toValue = @0.0f;
|
|
_animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
|
|
_animation.delegate = self;
|
|
}
|
|
return _animation;
|
|
}
|
|
-(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
|
|
if (flag) {
|
|
if (self.dissMissBlock) {
|
|
self.dissMissBlock(self.giftModel);
|
|
}
|
|
}
|
|
}
|
|
-(void)setGiftModel:(QXGiftModel *)giftModel{
|
|
_giftModel = giftModel;
|
|
[self.giftImageView sd_setImageWithURL:[NSURL URLWithString:giftModel.base_image]];
|
|
self.circleLayer.strokeEnd = 1.0f;
|
|
[self.circleLayer removeAllAnimations];
|
|
_animation = nil;
|
|
[self.circleLayer addAnimation:self.animation forKey:@"circleAnimation"];
|
|
}
|
|
-(void)handlePan:(UIPanGestureRecognizer*)recognizer{
|
|
if (recognizer.state == UIGestureRecognizerStateEnded) {
|
|
NSLog(@"拖动结束");
|
|
}
|
|
CGPoint translation = [recognizer translationInView:self.viewController.view];
|
|
CGPoint panCenter = CGPointMake(recognizer.view.center.x + translation.x,
|
|
recognizer.view.center.y + translation.y);
|
|
if (panCenter.y < kSafeAreaTop || panCenter.y> SCREEN_HEIGHT-kSafeAreaBottom) {
|
|
return;
|
|
}
|
|
|
|
|
|
recognizer.view.center = CGPointMake(SCREEN_WIDTH-ScaleWidth(65)/2,
|
|
recognizer.view.center.y + translation.y);
|
|
[recognizer setTranslation:CGPointZero inView:self.viewController.view];
|
|
}
|
|
@end
|