礼物面板添加个播六五

This commit is contained in:
fengshuo
2022-10-21 19:13:04 +08:00
parent 5df38804e2
commit e7f120f63b
7 changed files with 94 additions and 9 deletions

View File

@@ -18,6 +18,7 @@ typedef NS_ENUM(NSUInteger, GiftType) {
GiftType_Noble = 7, // 贵族礼物 GiftType_Noble = 7, // 贵族礼物
GiftType_WeekStar = 8, //周星礼物 GiftType_WeekStar = 8, //周星礼物
GiftType_Graffiti = 10, //涂鸦礼物 GiftType_Graffiti = 10, //涂鸦礼物
GiftType_Anchor = 11, //个播礼物
}; };
//礼物类型 //礼物类型

View File

@@ -64,6 +64,7 @@
NSArray *normalGift = [GiftInfoModel modelsWithArray:data.data[@"normalGift"]]; // NSArray *normalGift = [GiftInfoModel modelsWithArray:data.data[@"normalGift"]]; //
NSArray *weekStarGift = [GiftInfoModel modelsWithArray:data.data[@"weekStarGift"]]; // NSArray *weekStarGift = [GiftInfoModel modelsWithArray:data.data[@"weekStarGift"]]; //
NSArray *drawGift = [GiftInfoModel modelsWithArray:data.data[@"drawGift"]]; // NSArray *drawGift = [GiftInfoModel modelsWithArray:data.data[@"drawGift"]]; //
NSArray *anchorGift = [GiftInfoModel modelsWithArray:data.data[@"singlePopularGift"]]; //
NSMutableArray *info = [NSMutableArray array]; NSMutableArray *info = [NSMutableArray array];
NSMutableArray *totalInfo = [NSMutableArray array]; NSMutableArray *totalInfo = [NSMutableArray array];
[info addObjectsFromArray:luckyBagGift]; [info addObjectsFromArray:luckyBagGift];
@@ -71,6 +72,7 @@
[info addObjectsFromArray:normalGift]; [info addObjectsFromArray:normalGift];
[info addObjectsFromArray:weekStarGift]; [info addObjectsFromArray:weekStarGift];
[info addObjectsFromArray:drawGift]; [info addObjectsFromArray:drawGift];
[info addObjectsFromArray:anchorGift];
[totalInfo addObjectsFromArray:info]; [totalInfo addObjectsFromArray:info];
[totalInfo addObjectsFromArray:luckyPoolGift]; [totalInfo addObjectsFromArray:luckyPoolGift];
/// ///

View File

@@ -7,6 +7,8 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "XPSendGiftView.h" #import "XPSendGiftView.h"
///Model
#import "RoomInfoModel.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, GiftSegmentType) { typedef NS_ENUM(NSInteger, GiftSegmentType) {
@@ -16,6 +18,7 @@ typedef NS_ENUM(NSInteger, GiftSegmentType) {
GiftSegmentType_WeekStar, ///周星礼物 GiftSegmentType_WeekStar, ///周星礼物
GiftSegmentType_Pack,///背包礼物 GiftSegmentType_Pack,///背包礼物
GiftSegmentType_Graffiti,///涂鸦礼物 GiftSegmentType_Graffiti,///涂鸦礼物
GiftSegmentType_Anchor,///个播
}; };
@@ -51,7 +54,8 @@ typedef NS_ENUM(NSInteger, GiftSegmentType) {
@property (nonatomic, assign) NSInteger curUserNobleLevel; @property (nonatomic, assign) NSInteger curUserNobleLevel;
@property (nonatomic, copy) NSString *defaultSelectGiftId; @property (nonatomic, copy) NSString *defaultSelectGiftId;
///房间类型
@property (nonatomic,assign) RoomType roomType;
///头部礼物类型变更 ///头部礼物类型变更
/// - Parameter headType: 1礼物 2互动 /// - Parameter headType: 1礼物 2互动
- (void)giftHeadTypeHadChange:(NSInteger)headType; - (void)giftHeadTypeHadChange:(NSInteger)headType;

View File

@@ -15,6 +15,7 @@
///Model ///Model
#import "GiftInfoModel.h" #import "GiftInfoModel.h"
#import "GiftReceiveInfoModel.h" #import "GiftReceiveInfoModel.h"
#import "RoomInfoModel.h"
///View ///View
#import "XPGiftItemCollectionViewCell.h" #import "XPGiftItemCollectionViewCell.h"
#import "XPGiftEmptyCollectionViewCell.h" #import "XPGiftEmptyCollectionViewCell.h"
@@ -37,6 +38,8 @@
@property (nonatomic, strong) UIButton *weekStarButton; @property (nonatomic, strong) UIButton *weekStarButton;
/// ///
@property (nonatomic,strong) UIButton *graffitiButton; @property (nonatomic,strong) UIButton *graffitiButton;
///
@property (nonatomic,strong) UIButton *anchorButton;
/// ///
@property (nonatomic,strong) UILabel *totalValueLabel; @property (nonatomic,strong) UILabel *totalValueLabel;
/// ///
@@ -59,6 +62,8 @@
@property (nonatomic,strong) NSArray<GiftInfoModel *> *giftPackArray; @property (nonatomic,strong) NSArray<GiftInfoModel *> *giftPackArray;
/// ///
@property (nonatomic,strong) NSArray<GiftInfoModel *> *giftGraffitiArray; @property (nonatomic,strong) NSArray<GiftInfoModel *> *giftGraffitiArray;
///
@property (nonatomic,strong) NSArray<GiftInfoModel *> *anchorArray;
/// ///
@property (nonatomic,strong) NSAttributedString *totalAttribute; @property (nonatomic,strong) NSAttributedString *totalAttribute;
/// ///
@@ -91,6 +96,7 @@
self.packGiftButton.selected = NO; self.packGiftButton.selected = NO;
self.weekStarButton.selected = NO; self.weekStarButton.selected = NO;
self.graffitiButton.selected = NO; self.graffitiButton.selected = NO;
self.anchorButton.selected = NO;
sender.selected = !sender.selected; sender.selected = !sender.selected;
self.segmentType = sender.tag; self.segmentType = sender.tag;
} }
@@ -112,6 +118,9 @@
[self.segmentStackView addArrangedSubview:self.nobleGiftButton]; [self.segmentStackView addArrangedSubview:self.nobleGiftButton];
[self.segmentStackView addArrangedSubview:self.luckyGiftButton]; [self.segmentStackView addArrangedSubview:self.luckyGiftButton];
[self.segmentStackView addArrangedSubview:self.weekStarButton]; [self.segmentStackView addArrangedSubview:self.weekStarButton];
if(self.roomType == RoomType_Anchor) {
[self didClickGiftSegmentAction:self.anchorButton];
}
if(self.segmentType != GiftSegmentType_Pack) { if(self.segmentType != GiftSegmentType_Pack) {
[self didClickGiftSegmentAction:self.normalGiftButton]; [self didClickGiftSegmentAction:self.normalGiftButton];
} }
@@ -120,6 +129,7 @@
[self.luckyGiftButton removeFromSuperview]; [self.luckyGiftButton removeFromSuperview];
[self.nobleGiftButton removeFromSuperview]; [self.nobleGiftButton removeFromSuperview];
[self.weekStarButton removeFromSuperview]; [self.weekStarButton removeFromSuperview];
[self.anchorButton removeFromSuperview];
[self.segmentStackView addArrangedSubview:self.graffitiButton]; [self.segmentStackView addArrangedSubview:self.graffitiButton];
if(self.segmentType != GiftSegmentType_Pack) { if(self.segmentType != GiftSegmentType_Pack) {
[self didClickGiftSegmentAction:self.graffitiButton]; [self didClickGiftSegmentAction:self.graffitiButton];
@@ -141,6 +151,7 @@
[self.segmentStackView addArrangedSubview:self.nobleGiftButton]; [self.segmentStackView addArrangedSubview:self.nobleGiftButton];
[self.segmentStackView addArrangedSubview:self.luckyGiftButton]; [self.segmentStackView addArrangedSubview:self.luckyGiftButton];
[self.segmentStackView addArrangedSubview:self.weekStarButton]; [self.segmentStackView addArrangedSubview:self.weekStarButton];
[self.segmentStackView addArrangedSubview:self.anchorButton];
/// ///
[self.giftStackView addArrangedSubview:self.giftcollectionView]; [self.giftStackView addArrangedSubview:self.giftcollectionView];
[self.giftStackView addArrangedSubview:self.pageController]; [self.giftStackView addArrangedSubview:self.pageController];
@@ -327,6 +338,14 @@
} }
#pragma mark - Getters And Setters #pragma mark - Getters And Setters
- (void)setRoomType:(RoomType)roomType {
_roomType = roomType;
if (_roomType == RoomType_Anchor) {
self.anchorButton.hidden = NO;
}
}
- (void)setSegmentType:(GiftSegmentType)segmentType { - (void)setSegmentType:(GiftSegmentType)segmentType {
if (segmentType == _segmentType) { if (segmentType == _segmentType) {
return; return;
@@ -339,6 +358,7 @@
[self resetSelectGift:self.giftNobleArray]; [self resetSelectGift:self.giftNobleArray];
[self resetSelectGift:self.giftWeekStarArray]; [self resetSelectGift:self.giftWeekStarArray];
[self resetSelectGift:self.giftGraffitiArray]; [self resetSelectGift:self.giftGraffitiArray];
[self resetSelectGift:self.anchorArray];
self.totalValueLabel.hidden = YES; self.totalValueLabel.hidden = YES;
switch (_segmentType) { switch (_segmentType) {
case GiftSegmentType_Normal: case GiftSegmentType_Normal:
@@ -365,13 +385,16 @@
case GiftSegmentType_Graffiti: case GiftSegmentType_Graffiti:
[self.datasource addObjectsFromArray:self.giftGraffitiArray]; [self.datasource addObjectsFromArray:self.giftGraffitiArray];
break; break;
case GiftSegmentType_Anchor:
[self.datasource addObjectsFromArray:self.anchorArray];
break;
default: default:
[self.datasource addObjectsFromArray:self.giftArray]; [self.datasource addObjectsFromArray:self.giftArray];
break; break;
} }
NSInteger currentPage = 0; NSInteger currentPage = 0;
if (self.datasource.count > 0) { if (self.datasource.count > 0) {
if (self.defaultSelectGiftId.length) { if (self.defaultSelectGiftId.length && (self.segmentType == GiftSegmentType_Normal | self.segmentType == GiftSegmentType_Pack)) {
for (int i = 0 ; i <self.datasource.count; i++) { for (int i = 0 ; i <self.datasource.count; i++) {
GiftInfoModel * gift = [self.datasource objectAtIndex:i]; GiftInfoModel * gift = [self.datasource objectAtIndex:i];
if (gift.giftId == [self.defaultSelectGiftId integerValue]) { if (gift.giftId == [self.defaultSelectGiftId integerValue]) {
@@ -419,24 +442,28 @@
NSMutableArray * nobleArray = [NSMutableArray array]; NSMutableArray * nobleArray = [NSMutableArray array];
NSMutableArray * weekStarArray = [NSMutableArray array]; NSMutableArray * weekStarArray = [NSMutableArray array];
NSMutableArray * graffiti = [NSMutableArray array]; NSMutableArray * graffiti = [NSMutableArray array];
NSMutableArray * anchor = [NSMutableArray array];
[_normalOriginArray enumerateObjectsUsingBlock:^(GiftInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { [_normalOriginArray enumerateObjectsUsingBlock:^(GiftInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (obj.giftType == GiftType_Lucky) { if (obj.giftType == GiftType_Lucky) {
[luckyArray addObject:obj]; [luckyArray addObject:obj];
} else if(obj.giftType == GiftType_Game) { } else if(obj.giftType == GiftType_Game) {
[normaleArray addObject:obj]; [normaleArray addObject:obj];
} else if (obj.giftType == GiftType_Noble) { } else if (obj.giftType == GiftType_Noble) {
[nobleArray addObject:obj]; [nobleArray addObject:obj];
} else if (obj.giftType == GiftType_WeekStar) { } else if (obj.giftType == GiftType_WeekStar) {
[weekStarArray addObject:obj]; [weekStarArray addObject:obj];
} else if (obj.giftType == GiftType_Graffiti) { } else if (obj.giftType == GiftType_Graffiti) {
[graffiti addObject:obj]; [graffiti addObject:obj];
} }else if (obj.giftType == GiftType_Anchor) {
[anchor addObject:obj];
}
}]; }];
self.giftArray = normaleArray; self.giftArray = normaleArray;
self.giftLuckyArray = luckyArray; self.giftLuckyArray = luckyArray;
self.giftNobleArray = nobleArray; self.giftNobleArray = nobleArray;
self.giftWeekStarArray = weekStarArray; self.giftWeekStarArray = weekStarArray;
self.giftGraffitiArray = graffiti; self.giftGraffitiArray = graffiti;
self.anchorArray = anchor;
if (self.defaultSelectGiftId.length) { if (self.defaultSelectGiftId.length) {
for (GiftInfoModel *gift in self.normalOriginArray) { for (GiftInfoModel *gift in self.normalOriginArray) {
if (gift.giftId == [self.defaultSelectGiftId integerValue]) { if (gift.giftId == [self.defaultSelectGiftId integerValue]) {
@@ -469,6 +496,13 @@
break; break;
} }
} }
for (GiftInfoModel *gift in self.anchorArray) {
if (gift.giftId == [self.defaultSelectGiftId integerValue]) {
self.segmentType = GiftSegmentType_Anchor;
break;
}
}
} else { } else {
self.segmentType = GiftSegmentType_Normal; self.segmentType = GiftSegmentType_Normal;
} }
@@ -489,6 +523,7 @@
if (_usingplaceType == SendGiftType_User) { if (_usingplaceType == SendGiftType_User) {
self.luckyGiftButton.hidden = YES; self.luckyGiftButton.hidden = YES;
self.graffitiButton.hidden = YES; self.graffitiButton.hidden = YES;
self.anchorButton.hidden = YES;
} }
} }
@@ -603,6 +638,21 @@
return _graffitiButton; return _graffitiButton;
} }
- (UIButton *)anchorButton {
if (!_anchorButton) {
_anchorButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_anchorButton setTitle:@"个播" forState:UIControlStateNormal];
[_anchorButton setTitleColor:[ThemeColor giftSegmentSelectTitleColor] forState:UIControlStateSelected];
[_anchorButton setTitleColor:[ThemeColor giftSegmentNormalTitleColor] forState:UIControlStateNormal];
_anchorButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold];
_anchorButton.tag = GiftSegmentType_Anchor;
_anchorButton.selected = NO;
_anchorButton.hidden = YES;
[_anchorButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _anchorButton;
}
- (UILabel *)totalValueLabel { - (UILabel *)totalValueLabel {
if (!_totalValueLabel) { if (!_totalValueLabel) {
_totalValueLabel = [[UILabel alloc] init]; _totalValueLabel = [[UILabel alloc] init];

View File

@@ -663,6 +663,13 @@
self.giftInfoView.defaultSelectGiftId = selectGiftId; self.giftInfoView.defaultSelectGiftId = selectGiftId;
} }
- (void)setDelegate:(id<RoomHostDelegate>)delegate {
_delegate = delegate;
if (_delegate) {
self.giftInfoView.roomType = _delegate.getRoomInfo.type;
}
}
- (UIView *)topView { - (UIView *)topView {
if (!_topView) { if (!_topView) {
_topView = [[UIView alloc] init]; _topView = [[UIView alloc] init];

View File

@@ -160,6 +160,7 @@
NSArray *normalGift = [GiftInfoModel modelsWithArray:data.data[@"normalGift"]]; // NSArray *normalGift = [GiftInfoModel modelsWithArray:data.data[@"normalGift"]]; //
NSArray *weekStarGift = [GiftInfoModel modelsWithArray:data.data[@"weekStarGift"]]; // NSArray *weekStarGift = [GiftInfoModel modelsWithArray:data.data[@"weekStarGift"]]; //
NSArray *drawGift = [GiftInfoModel modelsWithArray:data.data[@"drawGift"]]; // NSArray *drawGift = [GiftInfoModel modelsWithArray:data.data[@"drawGift"]]; //
NSArray *anchorGift = [GiftInfoModel modelsWithArray:data.data[@"singlePopularGift"]]; //
//TODO: luckyPoolGift //TODO: luckyPoolGift
NSMutableArray *info = [NSMutableArray array]; NSMutableArray *info = [NSMutableArray array];
NSMutableArray *totalInfo = [NSMutableArray array]; NSMutableArray *totalInfo = [NSMutableArray array];

View File

@@ -1008,12 +1008,16 @@
UserInfoModel * userInfo = microModel.userInfo; UserInfoModel * userInfo = microModel.userInfo;
XPGiftUserInfoModel * userModel = [[XPGiftUserInfoModel alloc] init]; XPGiftUserInfoModel * userModel = [[XPGiftUserInfoModel alloc] init];
userModel.avatar = userInfo.avatar; userModel.avatar = userInfo.avatar;
userModel.vipMic = userInfo.vipMic;
userModel.position = [NSString stringWithFormat:@"%d", microModel.microState.position]; userModel.position = [NSString stringWithFormat:@"%d", microModel.microState.position];
userModel.uid = userInfo.uid; userModel.uid = userInfo.uid;
if (self.delegate.getRoomInfo.type == RoomType_Anchor && microModel.microState.position == -1) {///
continue;
}
[array addObject:userModel]; [array addObject:userModel];
} }
} }
if (self.delegate.getRoomInfo.leaveMode) { if (self.delegate.getRoomInfo.leaveMode) {
RoomInfoModel * roomInfo= self.delegate.getRoomInfo; RoomInfoModel * roomInfo= self.delegate.getRoomInfo;
XPGiftUserInfoModel * userModel = [[XPGiftUserInfoModel alloc] init]; XPGiftUserInfoModel * userModel = [[XPGiftUserInfoModel alloc] init];
@@ -1021,6 +1025,22 @@
userModel.position = @"-1"; userModel.position = @"-1";
userModel.uid = roomInfo.uid; userModel.uid = roomInfo.uid;
[array addObject:userModel]; [array addObject:userModel];
} else if (self.delegate.getRoomInfo.type == RoomType_Anchor) {
RoomInfoModel * roomInfo= self.delegate.getRoomInfo;
BOOL hadContainerOwner = NO;
for (UserInfoModel *userModel in array) {
if (userModel.uid == roomInfo.uid) {
hadContainerOwner = YES;
break;
}
}
if (!hadContainerOwner) {
XPGiftUserInfoModel * userModel = [[XPGiftUserInfoModel alloc] init];
userModel.avatar = roomInfo.avatar;
userModel.position = @"-1";
userModel.uid = roomInfo.uid;
[array addObject:userModel];
}
} }
return array; return array;
} }