礼物面板添加个播六五

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_WeekStar = 8, //周星礼物
GiftType_Graffiti = 10, //涂鸦礼物
GiftType_Anchor = 11, //个播礼物
};
//礼物类型

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1008,8 +1008,12 @@
UserInfoModel * userInfo = microModel.userInfo;
XPGiftUserInfoModel * userModel = [[XPGiftUserInfoModel alloc] init];
userModel.avatar = userInfo.avatar;
userModel.vipMic = userInfo.vipMic;
userModel.position = [NSString stringWithFormat:@"%d", microModel.microState.position];
userModel.uid = userInfo.uid;
if (self.delegate.getRoomInfo.type == RoomType_Anchor && microModel.microState.position == -1) {///
continue;
}
[array addObject:userModel];
}
}
@@ -1021,6 +1025,22 @@
userModel.position = @"-1";
userModel.uid = roomInfo.uid;
[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;
}