修正面板测试问题

This commit is contained in:
eggmanQQQ
2024-08-06 10:38:50 +08:00
parent fb30106c63
commit 5cb36eb8b5
7 changed files with 170 additions and 97 deletions

View File

@@ -141,6 +141,8 @@ typedef NS_ENUM(NSUInteger, RoomSendGiftType) {
@property (nonatomic, copy) NSArray <GiftInfoModel *> *gifts;
- (GiftType)tabGiftType;
@end

View File

@@ -14,4 +14,24 @@ MJCodingImplementation
@implementation GiftPanelTabModel
MJCodingImplementation
- (GiftType)tabGiftType {
if ([self.key isEqualToString:@"normalGift"]) {
return GiftType_Game;
} else if ([self.key isEqualToString:@"luckyBagGift"]) {
return GiftType_Lucky;
} else if ([self.key isEqualToString:@"superLuckyGift"]) {
return GiftType_super;
} else if ([self.key isEqualToString:@"vipGift"]) {
return GiftType_Noble;
} else if ([self.key isEqualToString:@"countryGift"]) {
return GiftType_Country;
} else if ([self.key isEqualToString:@"weekStarGift"]) {
return GiftType_WeekStar;
} else if ([self.key isEqualToString:@"singlePopularGift"]) {
return GiftType_Anchor;
}
return GiftType_Game;
}
@end

View File

@@ -77,10 +77,10 @@
- (void)getTagsAndGifts:(NSString *)roomUid {
CGFloat delayDuration = 0.0;
NSArray * arrary = [[XPGiftStorage shareStorage] getGiftPanelTagsDatasource:roomUid];
if (arrary.count > 0) {
NSArray * array = [[XPGiftStorage shareStorage] getGiftPanelTagsDatasource:roomUid];
if (array.count > 0) {
delayDuration = 1;
[[self getView] getTagsSuccess:arrary];
[[self getView] getTagsSuccess:array];
}
@kWeakify(self);

View File

@@ -196,9 +196,9 @@
self.lockImageView.hidden = YES;
}
_superGiftView.hidden = YES;
if (giftInfo.giftType == GiftType_super){
_superGiftView.hidden = NO;
}
// if (giftInfo.giftType == GiftType_super){
// _superGiftView.hidden = NO;
// }
}
}

View File

@@ -41,8 +41,12 @@
@property (nonatomic,strong)XPGiftInfoView *weekStarVC;
///VIP
@property (nonatomic,strong)XPGiftInfoView *nobleVC;
///
////
@property (nonatomic,strong)XPGiftInfoView *anchorVC;
///
@property (nonatomic,strong)XPGiftInfoView *superLuckyVC;
///
@property (nonatomic,strong)XPGiftInfoView *countryVC;
@property (nonatomic, strong) UIActivityIndicatorView *loadingView;
@@ -99,9 +103,8 @@
}];
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.leading.equalTo(self);
make.trailing.equalTo(self.packGiftButton.mas_leading).offset(-16);
make.height.mas_equalTo(34);
make.width.mas_equalTo(kGetScaleWidth(200));
}];
[self.packGiftButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(-15);
@@ -159,31 +162,77 @@
}
-(XPGiftInfoView *)getListVC:(NSInteger)index{
if(self.usingPlaceType == SendGiftType_User){
return [@[self.normalVC,self.weekStarVC,self.nobleVC] xpSafeObjectAtIndex:index];
GiftPanelTabModel *targetTab = nil;// [self.tagsArray xpSafeObjectAtIndex:index];
for (GiftPanelTabModel *tab in self.tagsArray) {
if (tab.seq-1 == index) {
targetTab = tab;
break;
}
}
if(self.roomType == RoomType_Anchor){
return [@[self.normalVC,self.luckyVC,self.weekStarVC,self.nobleVC,self.anchorVC] xpSafeObjectAtIndex:index];
switch ([targetTab tabGiftType]) {
case GiftType_Game:{
return self.normalVC;
}
break;
case GiftType_Lucky:{
return self.luckyVC;
}
break;
case GiftType_Noble:{
return self.nobleVC;
}
break;
case GiftType_WeekStar:{
return self.weekStarVC;
}
break;
case GiftType_Anchor:{
if (self.roomType == RoomType_Anchor) {
return self.anchorVC;
} else {
return nil;
}
}
break;
case GiftType_super:{
return self.superLuckyVC;
}
break;
case GiftType_Country:{
return self.countryVC;
}
break;
default:
return self.normalVC;
break;
}
return [@[self.normalVC,self.luckyVC,self.weekStarVC,self.nobleVC] xpSafeObjectAtIndex:index];
}
-(NSInteger)getIndex{
if(self.usingPlaceType == SendGiftType_User){
if(self.segmentType == GiftSegmentType_Normal){
return 0;
}else if (self.segmentType == GiftSegmentType_WeekStar){
return 1;
}else{
return 2;
for (int i = 0; i< self.tagsArray.count; i++) {
GiftPanelTabModel *tab = [self.tagsArray xpSafeObjectAtIndex:i];
if ([tab tabGiftType] == GiftType_Game && self.segmentType == GiftSegmentType_Normal) {
return i;
} else if ([tab tabGiftType] == GiftType_Lucky && self.segmentType == GiftSegmentType_Lucky) {
return i;
} else if ([tab tabGiftType] == GiftType_super && self.segmentType == GiftSegmentType_SuperLucky) {
return i;
} else if ([tab tabGiftType] == GiftType_WeekStar && self.segmentType == GiftSegmentType_WeekStar) {
return i;
} else if ([tab tabGiftType] == GiftType_Noble && self.segmentType == GiftSegmentType_Noble) {
return i;
} else if ([tab tabGiftType] == GiftType_Country && self.segmentType == GiftSegmentType_Country) {
return i;
} else if ([tab tabGiftType] == GiftSegmentType_Anchor && self.segmentType == GiftSegmentType_Anchor) {
return i;
}
else if ([tab tabGiftType] == GiftSegmentType_Anchor && self.segmentType == GiftSegmentType_Anchor) {
return i;
}
}
if(self.roomType == RoomType_Anchor){
NSString *index = [@[@"0",@"1",@"2",@"3",@"4"] xpSafeObjectAtIndex:self.segmentType];
return index.integerValue;
}
NSString *index = [@[@"0",@"1",@"2",@"3"] xpSafeObjectAtIndex:self.segmentType];
return index.integerValue;
return 0;
}
-(void)didClickGiftSegmentAction:(UIButton *)sender{
@@ -231,22 +280,50 @@
NSMutableArray *tempGifts = @[].mutableCopy;
for (GiftPanelTabModel *tab in tagsArray) {
// /
if (self.usingPlaceType == SendGiftType_User && ([tab.key isEqualToString:@"luckyBagGift"] || [tab.key isEqualToString:@"superLuckyGift"] || [tab.key isEqualToString:@"singlePopularGift"])) {
if (self.usingPlaceType == SendGiftType_User &&
([tab.key isEqualToString:@"luckyBagGift"] ||
[tab.key isEqualToString:@"superLuckyGift"] ||
[tab.key isEqualToString:@"singlePopularGift"])) {
continue;
} else if (self.roomType != RoomType_Anchor && [tab.key isEqualToString:@"singlePopularGift"]) {
continue;
}
bool canAddGift = false;
if (isMSRTL()) {
[tempTitles addObject:tab.nameMap.ar];
if ([tab.nameMap.ar length] > 0) {
canAddGift = true;
[tempTitles addObject:tab.nameMap.ar];
}
} else if (isMSEN()) {
[tempTitles addObject:tab.nameMap.en];
if ([tab.nameMap.en length] > 0) {
canAddGift = true;
[tempTitles addObject:tab.nameMap.en];
}
} else {
[tempTitles addObject:tab.nameMap.zh];
if ([tab.nameMap.zh length] > 0) {
canAddGift = true;
[tempTitles addObject:tab.nameMap.zh];
}
}
[tempGifts addObject:tab.gifts ? tab.gifts : @[]];
if (canAddGift) {
[tempGifts addObject:tab.gifts ? tab.gifts : @[]];
} else {
[tempGifts addObject:@[]];
}
}
[self.titleView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.leading.equalTo(self);
make.height.mas_equalTo(34);
if (tempTitles.count<5) {
make.width.mas_equalTo(kGetScaleWidth(200));
} else {
make.trailing.equalTo(self.packGiftButton.mas_leading).offset(-16);
}
}];
self.pi_titles = tempTitles.copy;
self.titleView.titles = self.pi_titles;
@@ -264,34 +341,6 @@
- (void)setNormalOriginArray:(NSArray *)normalOriginArray {
[self hideLoading];
_normalOriginArray = normalOriginArray;
// __block NSMutableArray * normalArray = [NSMutableArray array];
// __block NSMutableArray * luckyArray = [NSMutableArray array];
// __block NSMutableArray * weekStarArray = [NSMutableArray array];
// __block NSMutableArray * nobleArray = [NSMutableArray array];
// __block NSMutableArray * anchorArray = [NSMutableArray array];
// [self.normalOriginArray enumerateObjectsUsingBlock:^(GiftInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
// if (obj.giftType == GiftType_Lucky || obj.giftType == GiftType_super) {
// [luckyArray addObject:obj];
// } else if(obj.giftType == GiftType_Game) {
// [normalArray addObject:obj];
// } else if (obj.giftType == GiftType_Noble) {
// [nobleArray addObject:obj];
// } else if (obj.giftType == GiftType_WeekStar) {
// [weekStarArray addObject:obj];
// }else if(obj.giftType == GiftType_Anchor){
// [anchorArray addObject:obj];
// }
// }];
// if (self.usingPlaceType == SendGiftType_User) {
// _giftList = [[NSMutableArray alloc]initWithArray:@[normalArray, weekStarArray, nobleArray]];
// }else{
// _giftList = [[NSMutableArray alloc]initWithArray:@[normalArray, luckyArray, weekStarArray, nobleArray, anchorArray]];
// }
// @kWeakify(self);
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
// @kStrongify(self);
// [self.pi_containerView reloadData];
// });
}
-(void)setPackOriginArray:(NSArray *)packOriginArray{
@@ -308,27 +357,11 @@
}
-(void)setRoomType:(RoomType)roomType{
_roomType = roomType;
// if(_roomType == RoomType_Anchor){
// self.pi_titles = @[YMLocalizedString(@"XPGiftInfoView2"),
// YMLocalizedString(@"XPGiftInfoView3"),
// YMLocalizedString(@"XPGiftInfoView4"),
// YMLocalizedString(@"XPGiftInfoView9"),
// YMLocalizedString(@"XPGiftInfoView8")];
//
// self.titleView.titles = self.pi_titles;
//
// [self.titleView reloadData];
// }
}
- (void)setUsingPlaceType:(SendGiftType)usingPlaceType {
_usingPlaceType = usingPlaceType;
self.packGiftView.usingPlaceType = _usingPlaceType;
if (_usingPlaceType == SendGiftType_User) {
// self.pi_titles = @[YMLocalizedString(@"XPGiftInfoView2"),
// YMLocalizedString(@"XPGiftInfoView4"),
// YMLocalizedString(@"XPGiftInfoView9")];
// self.titleView.titles = self.pi_titles;
// [self.titleView reloadData];
self.titleView.titleColor = [DJDKMIMOMColor secondTextColor];
self.titleView.titleSelectedColor = [DJDKMIMOMColor mainTextColor];
self.segmentBgView.hidden = NO;
@@ -377,7 +410,7 @@
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
_titleView.defaultSelectedIndex = 0;
_titleView.cellSpacing = 0;
_titleView.cellSpacing = 10;
_titleView.cellWidthIncrement = 5;
// _titleView.cellWidth = 30;
_titleView.listContainer = self.pi_containerView;
@@ -437,38 +470,50 @@
- (XPGiftInfoView *)luckyVC{
if(!_luckyVC){
XPGiftInfoView *luckyVC = [[XPGiftInfoView alloc]init];
luckyVC.delegate = self;
luckyVC.segmentType = GiftSegmentType_Lucky;
_luckyVC = luckyVC;
_luckyVC = [[XPGiftInfoView alloc]init];
_luckyVC.delegate = self;
_luckyVC.segmentType = GiftSegmentType_Lucky;
}
return _luckyVC;
}
- (XPGiftInfoView *)weekStarVC{
if(!_weekStarVC){
XPGiftInfoView *weekStarVC = [[XPGiftInfoView alloc]init];
weekStarVC.delegate = self;
weekStarVC.segmentType = GiftSegmentType_WeekStar;
_weekStarVC = weekStarVC;
_weekStarVC = [[XPGiftInfoView alloc]init];
_weekStarVC.delegate = self;
_weekStarVC.segmentType = GiftSegmentType_WeekStar;
}
return _weekStarVC;
}
- (XPGiftInfoView *)nobleVC{
if(!_nobleVC){
XPGiftInfoView *nobleVC = [[XPGiftInfoView alloc]init];
nobleVC.delegate = self;
nobleVC.segmentType = GiftSegmentType_Noble;
_nobleVC = nobleVC;
_nobleVC = [[XPGiftInfoView alloc]init];
_nobleVC.delegate = self;
_nobleVC.segmentType = GiftSegmentType_Noble;
}
return _nobleVC;
}
-(XPGiftInfoView *)anchorVC{
if(!_anchorVC){
XPGiftInfoView *anchorVC = [[XPGiftInfoView alloc]init];
anchorVC.delegate = self;
anchorVC.segmentType = GiftSegmentType_Anchor;
_anchorVC = anchorVC;
_anchorVC = [[XPGiftInfoView alloc]init];
_anchorVC.delegate = self;
_anchorVC.segmentType = GiftSegmentType_Anchor;
}
return _anchorVC;;
return _anchorVC;
}
-(XPGiftInfoView *)superLuckyVC{
if(!_superLuckyVC){
_superLuckyVC = [[XPGiftInfoView alloc]init];
_superLuckyVC.delegate = self;
_superLuckyVC.segmentType = GiftSegmentType_SuperLucky;
}
return _superLuckyVC;
}
-(XPGiftInfoView *)countryVC{
if(!_countryVC){
_countryVC = [[XPGiftInfoView alloc]init];
_countryVC.delegate = self;
_countryVC.segmentType = GiftSegmentType_Country;
}
return _countryVC;
}
@end

View File

@@ -21,6 +21,8 @@ typedef NS_ENUM(NSInteger, GiftSegmentType) {
GiftSegmentType_Pack,///背包礼物
GiftSegmentType_Graffiti,///涂鸦礼物
GiftSegmentType_Punish,///惩罚礼物
GiftSegmentType_SuperLucky,///超级幸运礼物
GiftSegmentType_Country,///国家礼物
};

View File

@@ -156,6 +156,10 @@
return CGSizeMake(KScreenWidth, 105 * 2 + 10);
}
if (self.datasource.count == 0) {
return CGSizeMake(KScreenWidth, 105 * 2 + 10);
}
CGFloat itemWidth = (CGFloat)(KScreenWidth - 15 * 2 - 5 * 3) / (CGFloat)4;
return CGSizeMake(itemWidth, 108);
}
@@ -170,7 +174,7 @@
return 1;
}
return self.datasource.count;
return MAX(1, self.datasource.count);
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
@@ -245,7 +249,7 @@
}
}
}
self.datasource = [[NSMutableArray alloc]initWithArray:_normalOriginArray];
self.datasource = _normalOriginArray.mutableCopy;
NSInteger currentPage = 0;
NSInteger page = 0;
if (self.datasource.count % 8 == 0) { //