diff --git a/YuMi.xcodeproj/project.pbxproj b/YuMi.xcodeproj/project.pbxproj index 55d31612..6fa7fd7f 100644 --- a/YuMi.xcodeproj/project.pbxproj +++ b/YuMi.xcodeproj/project.pbxproj @@ -332,6 +332,7 @@ 23CEFC632AFB8FC100576D89 /* BSRealTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23CEFC442AFB8FC100576D89 /* BSRealTextView.m */; }; 23CEFC642AFB8FC100576D89 /* BSkObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 23CEFC472AFB8FC100576D89 /* BSkObject.m */; }; 23CEFC652AFB8FC100576D89 /* BSDrawLine.m in Sources */ = {isa = PBXBuildFile; fileRef = 23CEFC482AFB8FC100576D89 /* BSDrawLine.m */; }; + 23CEFC682AFCCE7700576D89 /* PIGiftInfoSegmentedView.m in Sources */ = {isa = PBXBuildFile; fileRef = 23CEFC672AFCCE7700576D89 /* PIGiftInfoSegmentedView.m */; }; 23D321D22ADD0EBC006B259C /* PIRoomPhotoAlbumItemPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 23D321D12ADD0EBC006B259C /* PIRoomPhotoAlbumItemPresenter.m */; }; 23D321D52ADD0F05006B259C /* Api+PhotoAlbum.m in Sources */ = {isa = PBXBuildFile; fileRef = 23D321D42ADD0F05006B259C /* Api+PhotoAlbum.m */; }; 23D321D92ADD1B46006B259C /* PIRoomPhotoAlbumItemModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 23D321D82ADD1B46006B259C /* PIRoomPhotoAlbumItemModel.m */; }; @@ -2116,6 +2117,8 @@ 23CEFC472AFB8FC100576D89 /* BSkObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSkObject.m; sourceTree = ""; }; 23CEFC482AFB8FC100576D89 /* BSDrawLine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSDrawLine.m; sourceTree = ""; }; 23CEFC492AFB8FC100576D89 /* BSkObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSkObject.h; sourceTree = ""; }; + 23CEFC662AFCCE7700576D89 /* PIGiftInfoSegmentedView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIGiftInfoSegmentedView.h; sourceTree = ""; }; + 23CEFC672AFCCE7700576D89 /* PIGiftInfoSegmentedView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIGiftInfoSegmentedView.m; sourceTree = ""; }; 23D321D02ADD0EBC006B259C /* PIRoomPhotoAlbumItemPresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIRoomPhotoAlbumItemPresenter.h; sourceTree = ""; }; 23D321D12ADD0EBC006B259C /* PIRoomPhotoAlbumItemPresenter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIRoomPhotoAlbumItemPresenter.m; sourceTree = ""; }; 23D321D32ADD0F05006B259C /* Api+PhotoAlbum.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Api+PhotoAlbum.h"; sourceTree = ""; }; @@ -8722,6 +8725,8 @@ 9B4E91FF28E57A620033419E /* XPGiftHeadTypeView.m */, E8788940273A55AD00BF1D57 /* XPGiftUsersView.h */, E8788941273A55AD00BF1D57 /* XPGiftUsersView.m */, + 23CEFC662AFCCE7700576D89 /* PIGiftInfoSegmentedView.h */, + 23CEFC672AFCCE7700576D89 /* PIGiftInfoSegmentedView.m */, E8788943273A55C200BF1D57 /* XPGiftInfoView.h */, E8788944273A55C200BF1D57 /* XPGiftInfoView.m */, E8788946273A55D000BF1D57 /* XPGiftBarView.h */, @@ -11752,6 +11757,7 @@ E85E7B4B2A4EB0D300B6D00A /* XPMineGuildManagerSetViewController.m in Sources */, 189DD73D26E21C3F00AB55B1 /* YYUtility+Device.m in Sources */, 187EEEDC26E89B32002833B2 /* BaseModel.m in Sources */, + 23CEFC682AFCCE7700576D89 /* PIGiftInfoSegmentedView.m in Sources */, E878B85E283640A500E22DCF /* MonentsUnReadModel.m in Sources */, E81366FC26F0D2980076364C /* UIButton+EnlargeTouchArea.m in Sources */, E85E7BA42A4EC99300B6D00A /* XPMineGiveDiamondCell.m in Sources */, diff --git a/YuMi/Modules/YMMine/View/MineInfo/XPMineSimpleUserInfoHeaderView.m b/YuMi/Modules/YMMine/View/MineInfo/XPMineSimpleUserInfoHeaderView.m index 7b498c73..4f258b73 100644 --- a/YuMi/Modules/YMMine/View/MineInfo/XPMineSimpleUserInfoHeaderView.m +++ b/YuMi/Modules/YMMine/View/MineInfo/XPMineSimpleUserInfoHeaderView.m @@ -393,43 +393,7 @@ return _arrowButton; } -- (JXCategoryTitleView *)titleView { - if (!_titleView) { - _titleView = [[JXCategoryTitleView alloc] init]; - _titleView.delegate = self; - _titleView.titles = self.titles; - _titleView.backgroundColor = [UIColor clearColor]; - _titleView.titleColor = [DJDKMIMOMColor secondTextColor]; - _titleView.titleSelectedColor = [DJDKMIMOMColor appMainColor]; - _titleView.titleFont = [UIFont systemFontOfSize:14]; - _titleView.titleSelectedFont = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium]; - _titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter; - _titleView.contentScrollViewClickTransitionAnimationEnabled = NO; - _titleView.defaultSelectedIndex = 0; - _titleView.cellSpacing = 20; - _titleView.cellWidthIncrement = 5; - _titleView.cellWidth = 60; - _titleView.listContainer = self.pi_containerView; - -// JXCategoryIndicatorImageView *lineView = [[JXCategoryIndicatorImageView alloc] init]; -// lineView.indicatorImageViewSize = CGSizeMake(60, 8); -// lineView.verticalMargin = 6; -// lineView.indicatorImageView.image = [UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFFC000), UIColorFromRGB(0xFFD15A)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(60, 8)]; -// lineView.indicatorImageView.layer.masksToBounds = YES; -// lineView.indicatorImageView.layer.cornerRadius = 6; -// _titleView.indicators = @[lineView]; - } - return _titleView; -} -- (JXCategoryListContainerView *)pi_containerView { - if (!_pi_containerView) { - _pi_containerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self]; - _pi_containerView.defaultSelectedIndex = 0; - _pi_containerView.scrollView.tag = 1009; - } - return _pi_containerView; -} - (NSArray *)titles { if (!_titles) { diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/PIGiftInfoSegmentedView.h b/YuMi/Modules/YMRoom/View/SendGiftView/View/PIGiftInfoSegmentedView.h new file mode 100644 index 00000000..6f01cdf7 --- /dev/null +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/PIGiftInfoSegmentedView.h @@ -0,0 +1,48 @@ +// +// PIGiftInfoSegmentedView.h +// YuMi +// +// Created by duoban on 2023/11/9. +// + +#import +#import "XPFreeGiftModel.h" +#import "GiftInfoModel.h" +#import "RoomInfoModel.h" +#import "XPSendGiftView.h" +#import "XPGiftInfoView.h" +NS_ASSUME_NONNULL_BEGIN +@class GiftInfoModel,PIGiftInfoSegmentedView, GiftReceiveInfoModel; +@protocol PIGiftInfoSegmentedViewDelegate + +///点击了切换不同礼物的tabbar +- (void)pIGiftInfoSegmentedView:(PIGiftInfoSegmentedView *)view didClickSegment:(GiftSegmentType)type; + +///点击了某个item +- (void)pIGiftInfoSegmentedView:(PIGiftInfoSegmentedView *)view didClickItem:(GiftInfoModel *)info type:(GiftSegmentType)type; + +@end + + + +@interface PIGiftInfoSegmentedView : UIView +@property(nonatomic,weak) iddelegate; +///普通礼物/幸运礼物/贵族礼物 +@property (nonatomic,strong) NSArray *normalOriginArray; +///背包礼物 +@property (nonatomic,strong) NSArray *packOriginArray; +///免费礼物 +@property (nonatomic,strong) XPFreeGiftModel *freeModel; +///免费礼物送完删除了,不能出现在背包,防止数据更新时重新加进来 +@property (nonatomic,assign) BOOL isDelFreeGift; +///当前用户贵族等级 +@property (nonatomic, assign) NSInteger curUserNobleLevel; +///最后一次选中的礼物 +@property (nonatomic,strong,readonly) GiftInfoModel *lastSelectGift; +///房间类型 +@property (nonatomic,assign) RoomType roomType; +///送背包礼物更新数据源 +- (void)updatePackSource:(GiftReceiveInfoModel *)giftReceiveInfo numberUser:(NSInteger)numberUser; +@end + +NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/PIGiftInfoSegmentedView.m b/YuMi/Modules/YMRoom/View/SendGiftView/View/PIGiftInfoSegmentedView.m new file mode 100644 index 00000000..3be04ce6 --- /dev/null +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/PIGiftInfoSegmentedView.m @@ -0,0 +1,292 @@ +// +// PIGiftInfoSegmentedView.m +// YuMi +// +// Created by duoban on 2023/11/9. +// + +#import "PIGiftInfoSegmentedView.h" +#import +#import +#import +#import "ThemeColor+SendGift.h" +#import "XPGiftInfoView.h" +@interface PIGiftInfoSegmentedView() +///分页标题 +@property (nonatomic, strong) NSArray *pi_titles; +///导航条背景 +@property (nonatomic,strong) UIImageView *segmentBgView; +///分页控件 +@property (nonatomic, strong) JXCategoryTitleView *titleView; +///分页lineView +@property (nonatomic, strong) JXCategoryListContainerView *pi_containerView; +///背包总价值 +@property (nonatomic,strong) UILabel *totalValueLabel; +///背包礼物 +@property (nonatomic,strong) UIButton *packGiftButton; +///背包礼物面板 +@property(nonatomic,strong) XPGiftInfoView *packGiftView; +///礼物数据 +@property(nonatomic,strong) NSMutableArray *giftList; +///最后一次选中的礼物 +@property (nonatomic,strong) GiftInfoModel *lastSelectGift; +@end +@implementation PIGiftInfoSegmentedView + +-(instancetype)initWithFrame:(CGRect)frame{ + self = [super initWithFrame:frame]; + if(self){ + [self installUI]; + [self installConstraints]; + } + return self; +} +-(void)installUI{ + [self addSubview:self.segmentBgView]; + [self addSubview:self.titleView]; + [self addSubview:self.pi_containerView]; + [self addSubview:self.packGiftButton]; + [self addSubview:self.totalValueLabel]; + [self addSubview:self.packGiftView]; +} +-(void)installConstraints{ + [self mas_makeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(44+108 * 2 + 10 + 10 + 15); + }]; + [self.segmentBgView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.top.equalTo(self); + make.height.mas_equalTo(44); + }]; + [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.leading.equalTo(self); + make.height.mas_equalTo(44); + make.width.mas_equalTo(200); + + }]; + [self.packGiftButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.trailing.mas_equalTo(-15); + make.centerY.height.mas_equalTo(self.titleView); + make.width.mas_equalTo(30); + }]; + [self.totalValueLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.right.mas_equalTo(self.packGiftButton.mas_left).mas_offset(-6); + make.centerY.mas_equalTo(self.packGiftButton); + }]; + [self.pi_containerView mas_makeConstraints:^(MASConstraintMaker *make) { + make.leading.trailing.bottom.equalTo(self); + make.top.equalTo(self.titleView.mas_bottom).mas_offset(kGetScaleWidth(0)); + }]; + [self.packGiftView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.equalTo(self.pi_containerView); + }]; +} +#pragma mark - JXCategoryViewDelegate +- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView { + return self.pi_titles.count; +} + +- (id)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index { + XPGiftInfoView * list = (XPGiftInfoView *)[self.pi_containerView.validListDict objectForKey:[NSNumber numberWithInteger:index]]; + if (list) { + list.normalOriginArray = [self.giftList safeObjectAtIndex1:index]; + return list; + } else { + XPGiftInfoView *vc = [[XPGiftInfoView alloc]init]; + if(index == 0){ + vc.segmentType = GiftSegmentType_Normal; + }else if (index == 1){ + vc.segmentType = GiftSegmentType_Lucky; + }else if (index == 2){ + vc.segmentType = GiftSegmentType_WeekStar; + }else{ + vc.curUserNobleLevel = self.curUserNobleLevel; + vc.segmentType = GiftSegmentType_Noble; + } + vc.delegate = self; + vc.normalOriginArray = [self.giftList safeObjectAtIndex1:index]; + return vc; + } +} +- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{ + self.packGiftView.hidden = YES; + GiftSegmentType type; + if(index == 0){ + type = GiftSegmentType_Normal; + }else if (index == 1){ + type = GiftSegmentType_Lucky; + }else if (index == 2){ + type = GiftSegmentType_WeekStar; + }else{ + type = GiftSegmentType_Noble; + } + if(self.delegate && [self.delegate respondsToSelector:@selector(pIGiftInfoSegmentedView:didClickSegment:)]){ + [self.delegate pIGiftInfoSegmentedView:self didClickSegment:type]; + } +} +-(void)didClickGiftSegmentAction:(UIButton *)sender{ + self.packGiftView.hidden = NO; +} +- (void)createPackTotalValueAttribute { + __block NSInteger giftTotal = 0; + [self.packOriginArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if ([obj isKindOfClass:GiftInfoModel.class]) { + GiftInfoModel *gift = (GiftInfoModel *)obj; + if(gift.giftId != self.freeModel.giftId.integerValue){ + giftTotal += gift.count * gift.goldPrice; + } + } + }]; + NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPGiftInfoView0" ) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10],NSForegroundColorAttributeName:[DJDKMIMOMColor textThirdColor]}]; + [str appendAttributedString:[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",[self countFormatCoinStr:giftTotal]] attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:[DJDKMIMOMColor appMainColor]}]]; + NSTextAttachment *attachImage = [[NSTextAttachment alloc] init]; + attachImage.image = [UIImage imageNamed:@"gift_diamond"]; + attachImage.bounds = CGRectMake(0, 0, 9, 9); + [str appendAttributedString:[[NSMutableAttributedString alloc] initWithAttributedString:[NSAttributedString attributedStringWithAttachment:attachImage]]]; + self.totalValueLabel.attributedText = str; +} +/** + 将数量格式化为字符串 万之后用xx.xxW显示并保留小数点2位,最多显示9999W+; + @param number 数值 + @return 格式化后的字符串 + */ +- (NSString *)countFormatCoinStr:(NSInteger)number { + NSString *numStr = [NSString stringWithFormat:@"%li", number]; + NSInteger num = number; + if (num > 99990000) { + numStr = @"9999W+"; + } else if (num >= 10000) { + CGFloat numF = num / 10000.0; + numStr = [NSString stringWithFormat:@"%.2fW+", numF]; + } + return numStr; +} +- (void)setNormalOriginArray:(NSArray *)normalOriginArray { + _normalOriginArray = normalOriginArray; + NSMutableArray * normaleArray = [NSMutableArray array]; + NSMutableArray * luckyArray = [NSMutableArray array]; + NSMutableArray * weekStarArray = [NSMutableArray array]; + NSMutableArray * nobleArray = [NSMutableArray array]; + [_normalOriginArray enumerateObjectsUsingBlock:^(GiftInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { + if (obj.giftType == GiftType_Lucky) { + [luckyArray addObject:obj]; + } else if(obj.giftType == GiftType_Game) { + [normaleArray addObject:obj]; + } else if (obj.giftType == GiftType_Noble) { + [nobleArray addObject:obj]; + } else if (obj.giftType == GiftType_WeekStar) { + [weekStarArray addObject:obj]; + } + + }]; + _giftList = [[NSMutableArray alloc]initWithArray:@[normaleArray,luckyArray,weekStarArray,nobleArray]]; + +} +-(void)setPackOriginArray:(NSArray *)packOriginArray{ + _packOriginArray = packOriginArray; + self.packGiftView.packOriginArray = packOriginArray; +} +-(void)setFreeModel:(XPFreeGiftModel *)freeModel{ + _freeModel = freeModel; + self.packGiftView.freeModel = freeModel; +} +- (void)setIsDelFreeGift:(BOOL)isDelFreeGift{ + _isDelFreeGift = isDelFreeGift; + self.packGiftView.isDelFreeGift = _isDelFreeGift; +} +//- (void)setPackOriginArray:(NSArray *)packOriginArray { +// _packOriginArray = packOriginArray; +//// [self createPackTotalValueAttribute]; +//} +///送背包礼物更新数据源 +- (void)updatePackSource:(GiftReceiveInfoModel *)giftReceiveInfo numberUser:(NSInteger)numberUser{ + [self.packGiftView updatePackSource:giftReceiveInfo numberUser:numberUser]; +} +#pragma mark- XPGiftInfoViewDelegate +///点击了切换不同礼物的tabbar +- (void)xPGiftInfoView:(XPGiftInfoView *)view dealSelectGift:(GiftInfoModel *)giftInfo{ + self.lastSelectGift = giftInfo; +} + +///点击了某个item +- (void)xPGiftInfoView:(XPGiftInfoView *)view didClickItem:(GiftInfoModel *)info type:(GiftSegmentType)type{ + if(self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoView:didClickItem:type:)]){ + [self.delegate pIGiftInfoSegmentedView:self didClickItem:info type:type]; + } +} +#pragma mark - 懒加载 +- (NSArray *)pi_titles{ + if(!_pi_titles){ + _pi_titles = @[YMLocalizedString(@"XPGiftInfoView2"),YMLocalizedString(@"XPGiftInfoView3"),YMLocalizedString(@"XPGiftInfoView4"),YMLocalizedString(@"XPGiftInfoView9")]; + } + return _pi_titles; +} +- (JXCategoryTitleView *)titleView { + if (!_titleView) { + _titleView = [[JXCategoryTitleView alloc] init]; + _titleView.delegate = self; + _titleView.titles = self.pi_titles; + _titleView.backgroundColor = [UIColor clearColor]; + _titleView.titleColor = [DJDKMIMOMColor giftSegmentNormalTitleColor]; + _titleView.titleSelectedColor = [DJDKMIMOMColor giftSegmentSelectTitleColor]; + _titleView.titleFont = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold]; + _titleView.titleSelectedFont = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold]; + _titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter; + _titleView.contentScrollViewClickTransitionAnimationEnabled = NO; + _titleView.defaultSelectedIndex = 0; + _titleView.cellSpacing = 0; + _titleView.cellWidthIncrement = 5; + _titleView.cellWidth = 30; + _titleView.listContainer = self.pi_containerView; + + } + return _titleView; +} + +- (JXCategoryListContainerView *)pi_containerView { + if (!_pi_containerView) { + _pi_containerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self]; + _pi_containerView.defaultSelectedIndex = 0; + _pi_containerView.scrollView.tag = 1009; + _pi_containerView.scrollView.scrollEnabled = NO; + } + return _pi_containerView; +} +- (UILabel *)totalValueLabel { + if (!_totalValueLabel) { + _totalValueLabel = [[UILabel alloc] init]; + } + return _totalValueLabel; +} +- (UIButton *)packGiftButton { + if (!_packGiftButton) { + _packGiftButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_packGiftButton setTitle:YMLocalizedString(@"XPGiftInfoView5") forState:UIControlStateNormal]; + [_packGiftButton setTitleColor:[DJDKMIMOMColor giftSegmentSelectTitleColor] forState:UIControlStateSelected]; + [_packGiftButton setTitleColor:[DJDKMIMOMColor giftSegmentNormalTitleColor] forState:UIControlStateNormal]; + _packGiftButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold]; + _packGiftButton.tag = GiftSegmentType_Pack; + _packGiftButton.selected = NO; + [_packGiftButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside]; + } + return _packGiftButton; +} +- (XPGiftInfoView *)packGiftView{ + if(!_packGiftView){ + _packGiftView = [[XPGiftInfoView alloc]initWithFrame:CGRectZero]; + _packGiftView.segmentType = GiftSegmentType_Pack; + _packGiftView.hidden = YES; + } + return _packGiftView; +} +- (UIImageView *)segmentBgView { + if (!_segmentBgView) { + _segmentBgView = [[UIImageView alloc] init]; + _segmentBgView.userInteractionEnabled = YES; + _segmentBgView.contentMode = UIViewContentModeScaleAspectFill; + _segmentBgView.image = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor colorWithHexString:@"#E5FFFF"], [DJDKMIMOMColor colorWithHexString:@"#FFFFFF"]] gradientType:GradientTypeTopToBottom imgSize:CGSizeMake(KScreenWidth, 44)]; + _segmentBgView.hidden = YES; + + } + return _segmentBgView; +} +@end diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.h b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.h index 3032ebf7..f07d22a6 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.h +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.h @@ -7,6 +7,7 @@ #import #import "XPSendGiftView.h" +#import ///Model #import "RoomInfoModel.h" NS_ASSUME_NONNULL_BEGIN @@ -28,20 +29,21 @@ typedef NS_ENUM(NSInteger, GiftSegmentType) { @protocol XPGiftInfoViewDelegate ///点击了切换不同礼物的tabbar -- (void)xPGiftInfoView:(XPGiftInfoView *)view didClickSegment:(GiftSegmentType)type; +- (void)xPGiftInfoView:(XPGiftInfoView *)view dealSelectGift:(GiftInfoModel *)giftInfo; ///点击了某个item - (void)xPGiftInfoView:(XPGiftInfoView *)view didClickItem:(GiftInfoModel *)info type:(GiftSegmentType)type; @end -@interface XPGiftInfoView : UIView +@interface XPGiftInfoView : UIView ///使用的地方 @property (nonatomic,assign) SendGiftType usingplaceType; ///普通礼物/幸运礼物/贵族礼物 @property (nonatomic,strong) NSArray *normalOriginArray; ///背包礼物 @property (nonatomic,strong) NSArray *packOriginArray; + ///送背包礼物更新数据源 - (void)updatePackSource:(GiftReceiveInfoModel *)giftReceiveInfo numberUser:(NSInteger)numberUser; ///代理 @@ -51,7 +53,6 @@ typedef NS_ENUM(NSInteger, GiftSegmentType) { ///当前用户贵族等级 @property (nonatomic, assign) NSInteger curUserNobleLevel; -@property (nonatomic, copy) NSString *defaultSelectGiftId; ///房间类型 @property (nonatomic,assign) RoomType roomType; ///免费礼物送完删除了,不能出现在背包,防止数据更新时重新加进来 @@ -59,10 +60,9 @@ typedef NS_ENUM(NSInteger, GiftSegmentType) { ///免费礼物 @property (nonatomic,strong) XPFreeGiftModel *freeModel; -///头部礼物类型变更 -/// - Parameter headType: 1:礼物 2:互动 -- (void)giftHeadTypeHadChange:(NSInteger)headType; +///当前展示的数据的类型 +@property (nonatomic,assign) GiftSegmentType segmentType; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.m b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.m index 34bedbb8..01bf21ac 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPGiftInfoView.m @@ -26,101 +26,77 @@ #import "XPGiftWeekStarCollectionViewCell.h" #import "XPGiftCollectionViewFlowLayout.h" #import "XPGiftFreeItemCell.h" -static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIcon";///是否隐藏惩罚礼物“新”标识 + @interface XPGiftInfoView () -///滚动的容器 -@property (nonatomic,strong) UIScrollView *scrollView; -@property (nonatomic,strong) UIStackView *segmentStackView; -///导航条背景 -@property (nonatomic,strong) UIImageView *segmentBgView; -///普通礼物 -@property (nonatomic,strong) UIButton *normalGiftButton; -///背包礼物 -@property (nonatomic,strong) UIButton *packGiftButton; -///幸运礼物 -@property (nonatomic,strong) UIButton *luckyGiftButton; -///周星礼物 -@property (nonatomic, strong) UIButton *weekStarButton; -///贵族礼物 -@property(nonatomic,strong) UIButton *nobleGiftButton; -///涂鸦礼物 -@property (nonatomic,strong) UIButton *graffitiButton; -///惩罚礼物 -@property (nonatomic, strong) UIButton *punishButton; -///新标识图标 -@property (nonatomic, strong) UIImageView *freshIconImage; -///个播礼物 -@property (nonatomic,strong) UIButton *anchorButton; -///背包总价值 -@property (nonatomic,strong) UILabel *totalValueLabel; -/// -@property (nonatomic,strong) UIStackView *giftStackView; + + + + ///l礼物列表 @property (nonatomic,strong) UICollectionView *giftcollectionView; ///分页控件 @property (nonatomic, strong) UIPageControl *pageController; ///展示的数据源 @property (nonatomic,strong) NSMutableArray *datasource; -///普通礼物的数据源 -@property (nonatomic,strong) NSArray *giftArray; -/////幸运礼物的数据源 -@property (nonatomic,strong) NSArray *giftLuckyArray; -///贵族礼物的数据源 -@property (nonatomic, strong) NSArray *giftNobleArray; -///周星礼物的数据源 -@property (nonatomic, strong) NSArray *giftWeekStarArray; -/////背包礼物的数据源 -@property (nonatomic,strong) NSArray *giftPackArray; -///涂鸦礼物数据源 -@property (nonatomic,strong) NSArray *giftGraffitiArray; -///个播礼物数据源 -@property (nonatomic,strong) NSArray *anchorArray; -///惩罚礼物数据源 -@property (nonatomic, strong) NSArray *punishArray; ///总的价值 @property (nonatomic,strong) NSAttributedString *totalAttribute; -///当前展示的数据的类型 -@property (nonatomic,assign) GiftSegmentType segmentType; + ///最后一次选中的礼物 @property (nonatomic,strong) GiftInfoModel *lastSelectGift; @property (nonatomic, assign) NSInteger selectIndex; -///当前选中的page -@property (nonatomic,assign) NSInteger selectCurrentPage; @end @implementation XPGiftInfoView - (instancetype)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - if (self) { - [self initSubViews]; - [self initSubViewConstraints]; - } - return self; + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; +} +#pragma mark - Private Method +- (void)initSubViews { + + // /礼物 + [self addSubview:self.giftcollectionView]; + [self addSubview:self.pageController]; } +- (void)initSubViewConstraints { + // [self mas_makeConstraints:^(MASConstraintMaker *make) { + // make.height.mas_equalTo(108 * 2 + 10 + 10 + 15); + // }]; + + + + + [self.giftcollectionView mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.equalTo(self); + }]; + + + [self.pageController mas_makeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(10); + make.centerX.equalTo(self); + make.bottom.mas_equalTo(-10); + }]; +} #pragma mark - Response - (void)didClickGiftSegmentAction:(UIButton *)sender { - self.normalGiftButton.selected = NO; - self.luckyGiftButton.selected = NO; - self.packGiftButton.selected = NO; - self.weekStarButton.selected = NO; - self.graffitiButton.selected = NO; - self.anchorButton.selected = NO; - self.punishButton.selected = NO; - self.nobleGiftButton.selected = NO; - sender.selected = !sender.selected; - self.segmentType = sender.tag; + sender.selected = !sender.selected; + self.segmentType = sender.tag; } #pragma mark - Public Method - (void)updatePackSource:(GiftReceiveInfoModel *)giftReceiveInfo numberUser:(NSInteger)numberUser { - GiftInfoModel * giftInfo = [self findGiftInfoByGiftId:giftReceiveInfo.giftId.integerValue]; - giftInfo.count -= giftReceiveInfo.giftNum * numberUser; - if (giftInfo.count == 0) { + GiftInfoModel * giftInfo = [self findGiftInfoByGiftId:giftReceiveInfo.giftId.integerValue]; + giftInfo.count -= giftReceiveInfo.giftNum * numberUser; + if (giftInfo.count == 0) { if(self.freeModel.giftId.integerValue == giftInfo.giftId){ if([CountDownHelper shareHelper].isCountdownFinish == YES){ self.isDelFreeGift = YES; @@ -148,259 +124,135 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc [self dealSelectGift:gift]; } - + } - } - [self.giftcollectionView reloadData]; + } + [self.giftcollectionView reloadData]; } -- (void)giftHeadTypeHadChange:(NSInteger)headType { - if (headType == 1) { - [self.graffitiButton removeFromSuperview]; - [self.punishButton removeFromSuperview]; - [self.freshIconImage removeFromSuperview]; - self.freshIconImage = nil; - [self.segmentStackView addArrangedSubview:self.normalGiftButton]; - [self.segmentStackView addArrangedSubview:self.luckyGiftButton]; - [self.segmentStackView addArrangedSubview:self.weekStarButton]; - if(self.roomType == RoomType_Anchor) { - [self.segmentStackView addArrangedSubview:self.anchorButton]; - [self didClickGiftSegmentAction:self.anchorButton]; - } - if(self.segmentType != GiftSegmentType_Pack) { - [self didClickGiftSegmentAction:self.normalGiftButton]; - } - } else { - [self.normalGiftButton removeFromSuperview]; - [self.luckyGiftButton removeFromSuperview]; - [self.weekStarButton removeFromSuperview]; - [self.anchorButton removeFromSuperview]; - [self.segmentStackView addArrangedSubview:self.graffitiButton]; - [self.segmentStackView addArrangedSubview:self.punishButton]; - BOOL hiden = [[NSUserDefaults standardUserDefaults] boolForKey:kSendGiftViewHidePunishNewIcon]; - if(!hiden) { - [self addSubview:self.freshIconImage]; - [self.freshIconImage mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(self.punishButton.mas_right).mas_offset(-5); - make.bottom.mas_equalTo(self.punishButton.mas_top).mas_offset(5); - make.size.mas_equalTo(CGSizeMake(24, 10)); - }]; - } - if(self.segmentType != GiftSegmentType_Pack) { - [self didClickGiftSegmentAction:self.graffitiButton]; - } + + + + + +- (void)resetSelectGift:(NSArray *)array { + for (GiftInfoModel * gift in array) { + gift.isSelected = NO; } } -#pragma mark - Private Method -- (void)initSubViews { - [self addSubview:self.segmentBgView]; - [self addSubview:self.scrollView]; - [self addSubview:self.giftStackView]; - [self addSubview:self.packGiftButton]; - [self addSubview:self.totalValueLabel]; - [self.scrollView addSubview:self.segmentStackView]; - ///分段控制 - [self.segmentStackView addArrangedSubview:self.normalGiftButton]; - [self.segmentStackView addArrangedSubview:self.luckyGiftButton]; - [self.segmentStackView addArrangedSubview:self.weekStarButton]; - [self.segmentStackView addArrangedSubview:self.nobleGiftButton]; - [self.segmentStackView addArrangedSubview:self.anchorButton]; - ///礼物 - [self.giftStackView addArrangedSubview:self.giftcollectionView]; - [self.giftStackView addArrangedSubview:self.pageController]; -} - -- (void)initSubViewConstraints { - [self mas_makeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(44 + 108 * 2 + 10 + 10 + 15); - }]; - - [self.segmentStackView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.bottom.leading.trailing.height.mas_equalTo(self.scrollView); - }]; - - [self.segmentBgView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.top.mas_equalTo(self); - make.height.mas_equalTo(self.scrollView); - }]; - - [self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(self).mas_offset(15); - make.right.mas_equalTo(self.packGiftButton.mas_left); - make.top.mas_equalTo(self); - make.height.mas_equalTo(44); - }]; - [self.packGiftButton mas_makeConstraints:^(MASConstraintMaker *make) { - make.right.mas_equalTo(-15); - make.centerY.height.mas_equalTo(self.scrollView); - make.width.mas_equalTo(30); - }]; - [self.totalValueLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.right.mas_equalTo(self.packGiftButton.mas_left).mas_offset(-6); - make.centerY.mas_equalTo(self.packGiftButton); - }]; - - [self.giftStackView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self.segmentStackView.mas_bottom).offset(10); - make.left.right.mas_equalTo(self); - make.height.mas_equalTo(108 * 2 + 20); - }]; - - - [self.pageController mas_makeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(10); - }]; -} - -- (void)resetSelectGift:(NSArray *)array { - for (GiftInfoModel * gift in array) { - gift.isSelected = NO; - } -} - -- (void)createPackTotalValueAttribute { - __block NSInteger giftTotal = 0; - [self.packOriginArray enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if ([obj isKindOfClass:GiftInfoModel.class]) { - GiftInfoModel *gift = (GiftInfoModel *)obj; - if(gift.giftId != self.freeModel.giftId.integerValue){ - giftTotal += gift.count * gift.goldPrice; - } - } - }]; - NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:YMLocalizedString(@"XPGiftInfoView0" ) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10],NSForegroundColorAttributeName:[DJDKMIMOMColor textThirdColor]}]; - [str appendAttributedString:[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@",[self countFormatCoinStr:giftTotal]] attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:[DJDKMIMOMColor appMainColor]}]]; - NSTextAttachment *attachImage = [[NSTextAttachment alloc] init]; - attachImage.image = [UIImage imageNamed:@"gift_diamond"]; - attachImage.bounds = CGRectMake(0, 0, 9, 9); - [str appendAttributedString:[[NSMutableAttributedString alloc] initWithAttributedString:[NSAttributedString attributedStringWithAttachment:attachImage]]]; - self.totalAttribute = str; -} - -/** - 将数量格式化为字符串 万之后用xx.xxW显示并保留小数点2位,最多显示9999W+; - @param number 数值 - @return 格式化后的字符串 - */ -- (NSString *)countFormatCoinStr:(NSInteger)number { - NSString *numStr = [NSString stringWithFormat:@"%li", number]; - NSInteger num = number; - if (num > 99990000) { - numStr = @"9999W+"; - } else if (num >= 10000) { - CGFloat numF = num / 10000.0; - numStr = [NSString stringWithFormat:@"%.2fW+", numF]; - } - return numStr; -} - - (void)dealSelectGift:(GiftInfoModel *)giftInfo { - self.lastSelectGift = giftInfo; - if (self.segmentType == GiftSegmentType_Pack) { - giftInfo.sourceType = GiftSourceType_Pack; - } else { - giftInfo.sourceType = GiftSourceType_Normal; - } - giftInfo.isSelected = YES; + self.lastSelectGift = giftInfo; + if (self.segmentType == GiftSegmentType_Pack) { + giftInfo.sourceType = GiftSourceType_Pack; + } else { + giftInfo.sourceType = GiftSourceType_Normal; + } + giftInfo.isSelected = YES; + if(self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoView:dealSelectGift:)]){ + [self.delegate xPGiftInfoView:self dealSelectGift:giftInfo]; + } } // 根据礼物id查找 - (GiftInfoModel *)findGiftInfoByGiftId:(NSInteger)giftId { - for (int i=0; i 0) { - [self resetSelectGift:self.datasource]; - GiftInfoModel * giftInfo= [self.datasource safeObjectAtIndex1:indexPath.item]; - [self dealSelectGift:giftInfo]; - [self.giftcollectionView reloadData]; - if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoView:didClickItem:type:)]) { - [self.delegate xPGiftInfoView:self didClickItem:giftInfo type:self.segmentType]; - } - } + [collectionView deselectItemAtIndexPath:indexPath animated:YES]; + if (self.datasource.count > 0) { + [self resetSelectGift:self.datasource]; + GiftInfoModel * giftInfo= [self.datasource safeObjectAtIndex1:indexPath.item]; + [self dealSelectGift:giftInfo]; + [self.giftcollectionView reloadData]; + if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoView:didClickItem:type:)]) { + [self.delegate xPGiftInfoView:self didClickItem:giftInfo type:self.segmentType]; + } + } } #pragma mark - XPGiftWeekStarCollectionViewCellDelegate - (void)xPGiftWeekStarCollectionViewCell:(XPGiftWeekStarCollectionViewCell *)view didSelectGift:(GiftInfoModel *)giftInfo { - [self dealSelectGift:giftInfo]; + [self dealSelectGift:giftInfo]; if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoView:didClickItem:type:)]) { [self.delegate xPGiftInfoView:self didClickItem:giftInfo type:self.segmentType]; } @@ -408,239 +260,164 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc #pragma mark - Getters And Setters - (void)setRoomType:(RoomType)roomType { - _roomType = roomType; - if (_roomType == RoomType_Anchor) { - self.anchorButton.hidden = NO; - } + _roomType = roomType; } - (void)setSegmentType:(GiftSegmentType)segmentType { - if (segmentType == _segmentType) { - return; - } - [_datasource removeAllObjects]; - _segmentType = segmentType; - [self resetSelectGift:self.giftArray]; - [self resetSelectGift:self.packOriginArray]; - [self resetSelectGift:self.giftLuckyArray]; - [self resetSelectGift:self.giftNobleArray]; - [self resetSelectGift:self.giftWeekStarArray]; - [self resetSelectGift:self.giftGraffitiArray]; - [self resetSelectGift:self.anchorArray]; - [self resetSelectGift:self.punishArray]; - self.totalValueLabel.hidden = YES; - switch (_segmentType) { - case GiftSegmentType_Normal: - [self.datasource addObjectsFromArray:self.giftArray]; - break; - case GiftSegmentType_Lucky: - [self.datasource addObjectsFromArray:self.giftLuckyArray]; - break; - case GiftSegmentType_Noble: { - [self.datasource addObjectsFromArray:self.giftNobleArray]; - } - break; - case GiftSegmentType_WeekStar: { - [self.datasource addObjectsFromArray:self.giftWeekStarArray]; - } - break; - case GiftSegmentType_Pack: - { - if(self.isDelFreeGift == YES){ - NSMutableArray *originArray = [NSMutableArray array]; - for (GiftInfoModel *giftModel in self.packOriginArray) { - if(giftModel.giftId != self.freeModel.giftId.integerValue){ - [originArray addObject:giftModel]; - } - } - [self.datasource addObjectsFromArray:originArray]; - }else{ - [self.datasource addObjectsFromArray:self.packOriginArray]; - } - self.totalValueLabel.hidden = NO; - self.totalValueLabel.attributedText= self.totalAttribute; - } - break; - case GiftSegmentType_Graffiti: - [self.datasource addObjectsFromArray:self.giftGraffitiArray]; - break; - case GiftSegmentType_Anchor: - [self.datasource addObjectsFromArray:self.anchorArray]; - break; - case GiftSegmentType_Punish: - { - [self.datasource addObjectsFromArray:self.punishArray]; - [self.freshIconImage removeFromSuperview]; - self.freshIconImage = nil; - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:kSendGiftViewHidePunishNewIcon]; - [[NSUserDefaults standardUserDefaults] synchronize]; - } - break; - default: - [self.datasource addObjectsFromArray:self.giftArray]; - break; - } - NSInteger currentPage = 0; - if (self.datasource.count > 0) { -// if (self.defaultSelectGiftId.length && (self.segmentType == GiftSegmentType_Normal | self.segmentType == GiftSegmentType_Pack)) { -// for (int i = 0 ; i 0) { + //// if (self.defaultSelectGiftId.length && (self.segmentType == GiftSegmentType_Normal | self.segmentType == GiftSegmentType_Pack)) { + //// for (int i = 0 ; i 0 && self.lastSelectGift == nil){ + self.lastSelectGift = _normalOriginArray.firstObject; + } + self.datasource = [[NSMutableArray alloc]initWithArray:_normalOriginArray]; + NSInteger currentPage = 0; NSInteger page = 0; if (self.datasource.count % 8 == 0) { //刚好满页 page = self.datasource.count / 8; } else { page = self.datasource.count / 8 + 1; } - self.pageController.hidden = page <= 1 || _segmentType == GiftSegmentType_WeekStar; - [self.pageController setNumberOfPages:page]; - self.pageController.currentPage = currentPage; - self.selectCurrentPage = currentPage; - [self.giftcollectionView reloadData]; - if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoView:didClickSegment:)]) { - [self.delegate xPGiftInfoView:self didClickSegment:_segmentType]; - } - - if (self.segmentType != GiftSegmentType_Graffiti && self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoView:didClickItem:type:)]) { - [self.delegate xPGiftInfoView:self didClickItem:self.lastSelectGift type:_segmentType]; - } - - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - [self.giftcollectionView setContentOffset:CGPointMake(self.selectCurrentPage * KScreenWidth, 0) animated:NO];; - }); -} - -- (void)setNormalOriginArray:(NSArray *)normalOriginArray { - _normalOriginArray = normalOriginArray; - NSMutableArray * luckyArray = [NSMutableArray array]; - NSMutableArray * normaleArray = [NSMutableArray array]; - NSMutableArray * nobleArray = [NSMutableArray array]; - NSMutableArray * weekStarArray = [NSMutableArray array]; - NSMutableArray * graffiti = [NSMutableArray array]; - NSMutableArray * anchor = [NSMutableArray array]; - NSMutableArray * punishArray = [NSMutableArray array]; - - - [_normalOriginArray enumerateObjectsUsingBlock:^(GiftInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { - if (obj.giftType == GiftType_Lucky) { - [luckyArray addObject:obj]; - } else if(obj.giftType == GiftType_Game) { - [normaleArray 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_Graffiti) { - [graffiti addObject:obj]; - }else if (obj.giftType == GiftType_Anchor) { - [anchor addObject:obj]; - } else if (obj.giftType == GiftType_Punish) { - [punishArray addObject:obj]; - } - - }]; - self.giftArray = normaleArray; - self.giftLuckyArray = luckyArray; - self.giftNobleArray = nobleArray; - self.giftWeekStarArray = weekStarArray; - self.giftGraffitiArray = graffiti; - self.anchorArray = anchor; - self.punishArray = punishArray; - ///用修复2-3秒后,礼物的类型不对问题 - if(_segmentType == GiftSegmentType_Normal){ - self.lastSelectGift = self.giftArray.count > 0 ? self.giftArray.firstObject : nil; - }else if (_segmentType == GiftSegmentType_Lucky) { - self.lastSelectGift = self.giftLuckyArray.count > 0 ? self.giftLuckyArray.firstObject : nil; - }else if (_segmentType == GiftSegmentType_WeekStar) { - self.lastSelectGift = self.giftWeekStarArray.count > 0 ? self.giftWeekStarArray.firstObject : nil; - }else if (_segmentType == GiftSegmentType_Noble) { - self.lastSelectGift = self.giftNobleArray.count > 0 ? self.giftNobleArray.firstObject : nil; - } - if(self.lastSelectGift){ - self.defaultSelectGiftId = self.defaultSelectGiftId == nil ? @(self.lastSelectGift.giftId).stringValue : self.defaultSelectGiftId; - }else{ - - if(_segmentType == GiftSegmentType_Normal){ - self.segmentType = GiftSegmentType_Normal; - }else if (_segmentType == GiftSegmentType_Lucky) { - self.segmentType = GiftSegmentType_Lucky; - }else if (_segmentType == GiftSegmentType_WeekStar) { - self.segmentType = GiftSegmentType_WeekStar; - }else if (_segmentType == GiftSegmentType_Noble) { - self.segmentType = GiftSegmentType_Noble; - }else{ - self.segmentType = GiftSegmentType_Normal; - } - return; - } - // - if (self.defaultSelectGiftId.length) { - for (GiftInfoModel *gift in self.normalOriginArray) { - if (gift.giftId == [self.defaultSelectGiftId integerValue]) { - self.segmentType = GiftSegmentType_Normal; - break; - } - } - for (GiftInfoModel *gift in self.giftLuckyArray) { - if (gift.giftId == [self.defaultSelectGiftId integerValue]) { - self.segmentType = GiftSegmentType_Lucky; - break; - } - } - for (GiftInfoModel *gift in self.giftNobleArray) { - if (gift.giftId == [self.defaultSelectGiftId integerValue]) { - self.segmentType = GiftSegmentType_Noble; - break; - } - } - for (GiftInfoModel *gift in self.giftWeekStarArray) { - if (gift.giftId == [self.defaultSelectGiftId integerValue]) { - self.segmentType = GiftSegmentType_WeekStar; - break; - } - } - - for (GiftInfoModel *gift in self.giftGraffitiArray) { - if (gift.giftId == [self.defaultSelectGiftId integerValue]) { - self.segmentType = GiftSegmentType_Graffiti; - break; - } - } - - for (GiftInfoModel *gift in self.anchorArray) { - if (gift.giftId == [self.defaultSelectGiftId integerValue]) { - self.segmentType = GiftSegmentType_Anchor; - break; - } - } - for (GiftInfoModel *gift in self.punishArray) { - if (gift.giftId == [self.defaultSelectGiftId integerValue]) { - self.segmentType = GiftSegmentType_Punish; - break; - } - } - } else { - self.segmentType = GiftSegmentType_Normal; - } + self.pageController.hidden = page <= 1 || _segmentType == GiftSegmentType_WeekStar; + [self.pageController setNumberOfPages:page]; + self.pageController.currentPage = currentPage; + + [self.giftcollectionView reloadData]; + + } - (void)setPackOriginArray:(NSArray *)packOriginArray { - _packOriginArray = packOriginArray; - [self createPackTotalValueAttribute]; + _packOriginArray = packOriginArray; + if(_packOriginArray.count > 0 && self.lastSelectGift == nil){ + self.lastSelectGift = _packOriginArray.firstObject; + } + // [self createPackTotalValueAttribute]; + if(self.isDelFreeGift == YES){ + NSMutableArray *originArray = [NSMutableArray array]; + for (GiftInfoModel *giftModel in self.packOriginArray) { + if(giftModel.giftId != self.freeModel.giftId.integerValue){ + [originArray addObject:giftModel]; + } + } + [self.datasource addObjectsFromArray:originArray]; + }else{ + [self.datasource addObjectsFromArray:self.packOriginArray]; + } + NSInteger currentPage = 0; + NSInteger page = 0; + if (self.datasource.count % 8 == 0) { //刚好满页 + page = self.datasource.count / 8; + } else { + page = self.datasource.count / 8 + 1; + } + self.pageController.hidden = page <= 1; + [self.pageController setNumberOfPages:page]; + self.pageController.currentPage = currentPage; + + [self.giftcollectionView reloadData]; + } - (void)setCurUserNobleLevel:(NSInteger)curUserNobleLevel { @@ -649,233 +426,68 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc } - (void)setUsingplaceType:(SendGiftType)usingplaceType { - _usingplaceType = usingplaceType; - if (_usingplaceType == SendGiftType_User) { - self.luckyGiftButton.hidden = YES; - self.graffitiButton.hidden = YES; - self.anchorButton.hidden = YES; - self.punishButton.hidden = YES; - self.segmentBgView.hidden = NO; - - [self.normalGiftButton setTitleColor:[DJDKMIMOMColor mainTextColor] forState:UIControlStateSelected]; - [self.normalGiftButton setTitleColor:[DJDKMIMOMColor secondTextColor] forState:UIControlStateNormal]; - - [self.weekStarButton setTitleColor:[DJDKMIMOMColor mainTextColor] forState:UIControlStateSelected]; - [self.weekStarButton setTitleColor:[DJDKMIMOMColor secondTextColor] forState:UIControlStateNormal]; - - [self.packGiftButton setTitleColor:[DJDKMIMOMColor mainTextColor] forState:UIControlStateSelected]; - [self.packGiftButton setTitleColor:[DJDKMIMOMColor secondTextColor] forState:UIControlStateNormal]; - } + _usingplaceType = usingplaceType; + // if (_usingplaceType == SendGiftType_User) { + // self.luckyGiftButton.hidden = YES; + // self.graffitiButton.hidden = YES; + // self.anchorButton.hidden = YES; + // self.punishButton.hidden = YES; + // self.segmentBgView.hidden = NO; + // + // [self.normalGiftButton setTitleColor:[DJDKMIMOMColor mainTextColor] forState:UIControlStateSelected]; + // [self.normalGiftButton setTitleColor:[DJDKMIMOMColor secondTextColor] forState:UIControlStateNormal]; + // + // [self.weekStarButton setTitleColor:[DJDKMIMOMColor mainTextColor] forState:UIControlStateSelected]; + // [self.weekStarButton setTitleColor:[DJDKMIMOMColor secondTextColor] forState:UIControlStateNormal]; + // + // [self.packGiftButton setTitleColor:[DJDKMIMOMColor mainTextColor] forState:UIControlStateSelected]; + // [self.packGiftButton setTitleColor:[DJDKMIMOMColor secondTextColor] forState:UIControlStateNormal]; + // } } - -- (void)setDefaultSelectGiftId:(NSString *)defaultSelectGiftId { - _defaultSelectGiftId = defaultSelectGiftId; -} - -- (UIStackView *)segmentStackView { - if (!_segmentStackView) { - _segmentStackView = [[UIStackView alloc] init]; - _segmentStackView.axis = UILayoutConstraintAxisHorizontal; - _segmentStackView.distribution = UIStackViewDistributionFill; - _segmentStackView.alignment = UIStackViewAlignmentCenter; - _segmentStackView.spacing = 10; - _segmentStackView.backgroundColor = [UIColor clearColor]; - } - return _segmentStackView; -} - -- (UIStackView *)giftStackView { - if (!_giftStackView) { - _giftStackView = [[UIStackView alloc] init]; - _giftStackView.axis = UILayoutConstraintAxisVertical; - _giftStackView.distribution = UIStackViewDistributionFill; - _giftStackView.alignment = UIStackViewAlignmentFill; - _giftStackView.spacing = 0; - } - return _giftStackView; -} - -- (UIButton *)normalGiftButton { - if (!_normalGiftButton) { - _normalGiftButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_normalGiftButton setTitle:YMLocalizedString(@"XPGiftInfoView2") forState:UIControlStateNormal]; - [_normalGiftButton setTitleColor:[DJDKMIMOMColor giftSegmentSelectTitleColor] forState:UIControlStateSelected]; - [_normalGiftButton setTitleColor:[DJDKMIMOMColor giftSegmentNormalTitleColor] forState:UIControlStateNormal]; - _normalGiftButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold]; - _normalGiftButton.tag = GiftSegmentType_Normal; - _normalGiftButton.selected = YES; - [_normalGiftButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside]; - } - return _normalGiftButton; -} - -- (UIButton *)luckyGiftButton { - if (!_luckyGiftButton) { - _luckyGiftButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_luckyGiftButton setTitle:YMLocalizedString(@"XPGiftInfoView3") forState:UIControlStateNormal]; - [_luckyGiftButton setTitleColor:[DJDKMIMOMColor giftSegmentSelectTitleColor] forState:UIControlStateSelected]; - [_luckyGiftButton setTitleColor:[DJDKMIMOMColor giftSegmentNormalTitleColor] forState:UIControlStateNormal]; - _luckyGiftButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold]; - _luckyGiftButton.tag = GiftSegmentType_Lucky; - _luckyGiftButton.selected = NO; - [_luckyGiftButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside]; - } - return _luckyGiftButton; -} - -- (UIButton *)weekStarButton { - if (!_weekStarButton) { - _weekStarButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_weekStarButton setTitle:YMLocalizedString(@"XPGiftInfoView4") forState:UIControlStateNormal]; - [_weekStarButton setTitleColor:[DJDKMIMOMColor giftSegmentSelectTitleColor] forState:UIControlStateSelected]; - [_weekStarButton setTitleColor:[DJDKMIMOMColor giftSegmentNormalTitleColor] forState:UIControlStateNormal]; - _weekStarButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold]; - _weekStarButton.tag = GiftSegmentType_WeekStar; - _weekStarButton.selected = NO; - [_weekStarButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside]; - } - return _weekStarButton; -} - -- (UIButton *)packGiftButton { - if (!_packGiftButton) { - _packGiftButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_packGiftButton setTitle:YMLocalizedString(@"XPGiftInfoView5") forState:UIControlStateNormal]; - [_packGiftButton setTitleColor:[DJDKMIMOMColor giftSegmentSelectTitleColor] forState:UIControlStateSelected]; - [_packGiftButton setTitleColor:[DJDKMIMOMColor giftSegmentNormalTitleColor] forState:UIControlStateNormal]; - _packGiftButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold]; - _packGiftButton.tag = GiftSegmentType_Pack; - _packGiftButton.selected = NO; - [_packGiftButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside]; - } - return _packGiftButton; -} - -- (UIButton *)graffitiButton { - if (!_graffitiButton) { - _graffitiButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_graffitiButton setTitle:YMLocalizedString(@"XPGiftInfoView6") forState:UIControlStateNormal]; - [_graffitiButton setTitleColor:[DJDKMIMOMColor giftSegmentSelectTitleColor] forState:UIControlStateSelected]; - [_graffitiButton setTitleColor:[DJDKMIMOMColor giftSegmentNormalTitleColor] forState:UIControlStateNormal]; - _graffitiButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold]; - _graffitiButton.tag = GiftSegmentType_Graffiti; - _graffitiButton.selected = NO; - [_graffitiButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside]; - } - return _graffitiButton; -} - -- (UIButton *)punishButton { - if (!_punishButton) { - _punishButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_punishButton setTitle:YMLocalizedString(@"XPGiftInfoView7") forState:UIControlStateNormal]; - [_punishButton setTitleColor:[DJDKMIMOMColor giftSegmentSelectTitleColor] forState:UIControlStateSelected]; - [_punishButton setTitleColor:[DJDKMIMOMColor giftSegmentNormalTitleColor] forState:UIControlStateNormal]; - _punishButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold]; - _punishButton.tag = GiftSegmentType_Punish; - _punishButton.selected = NO; - [_punishButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside]; - } - return _punishButton; -} - -- (UIImageView *)freshIconImage { - if (!_freshIconImage) { - _freshIconImage = [[UIImageView alloc] init]; - _freshIconImage.image = [UIImage imageNamed:@"gift_type_newIcon"]; - } - return _freshIconImage; -} - -- (UIButton *)anchorButton { - if (!_anchorButton) { - _anchorButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_anchorButton setTitle:YMLocalizedString(@"XPGiftInfoView8") forState:UIControlStateNormal]; - [_anchorButton setTitleColor:[DJDKMIMOMColor giftSegmentSelectTitleColor] forState:UIControlStateSelected]; - [_anchorButton setTitleColor:[DJDKMIMOMColor 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]; - } - return _totalValueLabel; +#pragma mark - JXCategoryListContentViewDelegate +- (UIView *)listView { + return self; } - (UICollectionView *)giftcollectionView{ - if (!_giftcollectionView) { - XPGiftCollectionViewFlowLayout *layout = [[XPGiftCollectionViewFlowLayout alloc] init]; - layout.minimumLineSpacing = 5; - layout.minimumInteritemSpacing = 5; - layout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 15); - _giftcollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; - _giftcollectionView.dataSource = self; - _giftcollectionView.delegate = self; - _giftcollectionView.backgroundColor = [UIColor clearColor]; - _giftcollectionView.pagingEnabled = YES; - [_giftcollectionView registerClass:[XPGiftItemCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftItemCollectionViewCell class])]; - [_giftcollectionView registerClass:[XPGiftEmptyCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftEmptyCollectionViewCell class])]; - [_giftcollectionView registerClass:[XPGiftWeekStarCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftWeekStarCollectionViewCell class])]; + if (!_giftcollectionView) { + XPGiftCollectionViewFlowLayout *layout = [[XPGiftCollectionViewFlowLayout alloc] init]; + layout.minimumLineSpacing = 5; + layout.minimumInteritemSpacing = 5; + layout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 15); + _giftcollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; + _giftcollectionView.dataSource = self; + _giftcollectionView.delegate = self; + _giftcollectionView.backgroundColor = [UIColor clearColor]; + _giftcollectionView.pagingEnabled = YES; + [_giftcollectionView registerClass:[XPGiftItemCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftItemCollectionViewCell class])]; + [_giftcollectionView registerClass:[XPGiftEmptyCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftEmptyCollectionViewCell class])]; + [_giftcollectionView registerClass:[XPGiftWeekStarCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftWeekStarCollectionViewCell class])]; [_giftcollectionView registerClass:[XPGiftFreeItemCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftFreeItemCell class])]; _giftcollectionView.showsHorizontalScrollIndicator = NO; - } - return _giftcollectionView; + } + return _giftcollectionView; } - (UIPageControl *)pageController { - if (!_pageController) { - _pageController = [[UIPageControl alloc] init]; - _pageController.currentPageIndicatorTintColor = [DJDKMIMOMColor giftPageIndicatorColor]; - } - return _pageController; + if (!_pageController) { + _pageController = [[UIPageControl alloc] init]; + _pageController.currentPageIndicatorTintColor = [DJDKMIMOMColor giftPageIndicatorColor]; + } + return _pageController; } - (NSMutableArray *)datasource { - if (!_datasource) { - _datasource = [NSMutableArray array]; - } - return _datasource; -} - -- (UIScrollView *)scrollView { - if (!_scrollView) { - _scrollView = [[UIScrollView alloc] init]; - _scrollView.backgroundColor = [UIColor clearColor]; - _scrollView.showsHorizontalScrollIndicator = NO; - } - return _scrollView; -} - -- (UIImageView *)segmentBgView { - if (!_segmentBgView) { - _segmentBgView = [[UIImageView alloc] init]; - _segmentBgView.userInteractionEnabled = YES; - _segmentBgView.contentMode = UIViewContentModeScaleAspectFill; - _segmentBgView.image = [UIImage gradientColorImageFromColors:@[[DJDKMIMOMColor colorWithHexString:@"#E5FFFF"], [DJDKMIMOMColor colorWithHexString:@"#FFFFFF"]] gradientType:GradientTypeTopToBottom imgSize:CGSizeMake(375, 44)]; - _segmentBgView.hidden = YES; - } - return _segmentBgView; -} - -- (UIButton *)nobleGiftButton{ - if(!_nobleGiftButton){ - _nobleGiftButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_nobleGiftButton setTitle:YMLocalizedString(@"XPGiftInfoView9") forState:UIControlStateNormal]; - [_nobleGiftButton setTitleColor:[DJDKMIMOMColor giftSegmentSelectTitleColor] forState:UIControlStateSelected]; - [_nobleGiftButton setTitleColor:[DJDKMIMOMColor giftSegmentNormalTitleColor] forState:UIControlStateNormal]; - _nobleGiftButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold]; - _nobleGiftButton.tag = GiftSegmentType_Noble; - _nobleGiftButton.selected = NO; - [_nobleGiftButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside]; + if (!_datasource) { + _datasource = [NSMutableArray array]; } - return _nobleGiftButton; + return _datasource; } + + + + + + @end diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m index 0edbb268..49f861e9 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/XPSendGiftView.m @@ -32,7 +32,7 @@ #import "XPMessageRemoteExtModel.h" ///View #import "XPGiftUsersView.h" -#import "XPGiftInfoView.h" +#import "PIGiftInfoSegmentedView.h" #import "XPGiftBarView.h" #import "XPRoomHalfWebView.h" #import "XPGraffitiGiftView.h" @@ -49,7 +49,7 @@ UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification; UIKIT_EXTERN NSString * kShowFirstRechargeView; -@interface XPSendGiftView ()< XPGiftBarViewDelegate, XPGiftProtocol, XPGiftInfoViewDelegate, XPGraffitiGiftViewDelegate, XPGiftUsersViewDelegate, XPGiftHeadTypeViewDelegate, XPGiftLuckyGiftBroadcastViewDelegate, XPGiftTwelveStarBroadcastViewDelegate> +@interface XPSendGiftView ()< XPGiftBarViewDelegate, XPGiftProtocol, XPGraffitiGiftViewDelegate, XPGiftUsersViewDelegate, XPGiftHeadTypeViewDelegate, XPGiftLuckyGiftBroadcastViewDelegate, XPGiftTwelveStarBroadcastViewDelegate,PIGiftInfoSegmentedViewDelegate> ///顶部的区域 @property (nonatomic,strong) UIView * topView; ///内容区域 @@ -67,7 +67,7 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; ///送礼物的人 @property (nonatomic,strong) XPGiftUsersView *userView; ///送的什么礼物 -@property (nonatomic,strong) XPGiftInfoView *giftInfoView; +@property (nonatomic,strong) PIGiftInfoSegmentedView *giftInfoView; ///送多少礼物 @property (nonatomic,strong) XPGiftBarView *giftBarView; ///底部的View @@ -506,7 +506,7 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; ///点击了礼物 - (void)xPGiftHeadTypeViewDidClickGift:(XPGiftHeadTypeView *)view { [self.luckyBroadcastView removeFromSuperview]; - [self.giftInfoView giftHeadTypeHadChange:1]; +// [self.giftInfoView giftHeadTypeHadChange:1]; if (!self.graffitiView.hidden) {//清空涂鸦礼物 [self.graffitiView clearData]; [self.graffitiView cratePriceAttribute]; @@ -519,14 +519,15 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; ///点击了互动 - (void)xPGiftHeadTypeViewDidClickInteraction:(XPGiftHeadTypeView *)view { [self.luckyBroadcastView removeFromSuperview]; - [self.giftInfoView giftHeadTypeHadChange:2]; +// [self.giftInfoView giftHeadTypeHadChange:2]; } -#pragma mark - XPGiftInfoViewDelegate -- (void)xPGiftInfoView:(XPGiftInfoView *)view didClickSegment:(GiftSegmentType)type { - self.segmentType = type; - self.giftBarView.type = type; - self.giftBarView.drawGiftCount = 0; +#pragma mark - PIGiftInfoSegmentedViewDelegate +///点击了切换不同礼物的tabbar +- (void)pIGiftInfoSegmentedView:(PIGiftInfoSegmentedView *)view didClickSegment:(GiftSegmentType)type{ + self.segmentType = type; + self.giftBarView.type = type; + self.giftBarView.drawGiftCount = 0; if (type == GiftSegmentType_Lucky) { [self.constellationBanner removeFromSuperview]; if (!self.luckyBroadcastView.superview) { @@ -539,48 +540,50 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; } } else if(type == GiftSegmentType_WeekStar) { [self.luckyBroadcastView removeFromSuperview]; -// if ([ClientConfig shareConfig].configInfo.twelveStarSwitch) { - self.constellationBanner.hidden = NO; - if (!self.constellationBanner.superview) { - [self.view addSubview:self.constellationBanner]; - [self.constellationBanner mas_makeConstraints:^(MASConstraintMaker *make) { - make.bottom.mas_equalTo(self.contentView.mas_top); - make.left.right.mas_equalTo(0); - make.height.mas_equalTo(kGetScaleWidth(56)); - }]; - } +// if ([ClientConfig shareConfig].configInfo.twelveStarSwitch) { + self.constellationBanner.hidden = NO; + if (!self.constellationBanner.superview) { + [self.view addSubview:self.constellationBanner]; + [self.constellationBanner mas_makeConstraints:^(MASConstraintMaker *make) { + make.bottom.mas_equalTo(self.contentView.mas_top); + make.left.right.mas_equalTo(0); + make.height.mas_equalTo(kGetScaleWidth(56)); + }]; + } -// } else { -// self.constellationBanner.hidden = YES; -// } +// } else { +// self.constellationBanner.hidden = YES; +// } } else { [self.luckyBroadcastView removeFromSuperview]; [self.constellationBanner removeFromSuperview]; } } -- (void)xPGiftInfoView:(XPGiftInfoView *)view didClickItem:(GiftInfoModel *)info type:(GiftSegmentType)type { - if (type == GiftSegmentType_Graffiti) { - self.giftInfoView.hidden = YES; - self.graffitiView.hidden = NO; - self.graffitiView.price = info.goldPrice; - self.giftBarView.drawGiftCount = 0; - self.graffitiView.selectUidNumber = self.userView.selectUserArray.count; - [[SDWebImageManager sharedManager] loadImageWithURL:[NSURL URLWithString:info.giftUrl] options:SDWebImageProgressiveLoad progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { - if (error == nil && image) { - self.graffitiView.image = image; - } else { - self.giftInfoView.hidden = NO; - } - }]; +///点击了某个item +- (void)pIGiftInfoSegmentedView:(PIGiftInfoSegmentedView *)view didClickItem:(GiftInfoModel *)info type:(GiftSegmentType)type{ + if (type == GiftSegmentType_Graffiti) { + self.giftInfoView.hidden = YES; + self.graffitiView.hidden = NO; + self.graffitiView.price = info.goldPrice; + self.giftBarView.drawGiftCount = 0; + self.graffitiView.selectUidNumber = self.userView.selectUserArray.count; + [[SDWebImageManager sharedManager] loadImageWithURL:[NSURL URLWithString:info.giftUrl] options:SDWebImageProgressiveLoad progress:nil completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) { + if (error == nil && image) { + self.graffitiView.image = image; + } else { + self.giftInfoView.hidden = NO; + } + }]; }else if(type == GiftSegmentType_WeekStar){ self.constellationBanner.giftInfo = info; } else { - self.giftBarView.drawGiftCount = 10; - } + self.giftBarView.drawGiftCount = 10; + } } + #pragma mark - XPGiftUsersViewDelegate - (void)xPGiftUsersView:(XPGiftUsersView *)view didSelectUsers:(NSArray *)selectUids { self.graffitiView.selectUidNumber = selectUids.count; @@ -690,7 +693,8 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; ///发送涂鸦礼物消息 [self sendGraffitiGiftMessage]; if (self.segmentType == GiftSegmentType_Graffiti) { - NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPSendGiftView3"),self.giftInfoView.lastSelectGift.giftName]; + NSString * title = @""; +// NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPSendGiftView3"),self.giftInfoView.lastSelectGift.giftName]; [self showSuccessToast:title]; [self dismissViewControllerAnimated:YES completion:nil]; } @@ -702,6 +706,7 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; if (code == 31005) {// 余额不足 [self showNotSufficientFundsWithToast:msg]; } else if (code == 8535) {//贵族等级未达到礼物等级 + GiftInfoModel * giftInfo = self.giftInfoView.lastSelectGift; TTAlertConfig *config = [[TTAlertConfig alloc] init]; config.actionStyle = TTAlertActionConfirmStyle; @@ -746,7 +751,7 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; - (void)setUsingplaceType:(SendGiftType)usingplaceType { _usingplaceType = usingplaceType; self.giftBarView.usingplaceType = usingplaceType; - self.giftInfoView.usingplaceType = _usingplaceType; +// self.giftInfoView.usingplaceType = _usingplaceType; self.headTypeView.hidden = _usingplaceType == SendGiftType_User; self.userView.hidden = _usingplaceType == SendGiftType_User; self.effectView.hidden = _usingplaceType == SendGiftType_User; @@ -757,7 +762,7 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; - (void)setSelectGiftId:(NSString *)selectGiftId { _selectGiftId = selectGiftId; - self.giftInfoView.defaultSelectGiftId = selectGiftId; +// self.giftInfoView.defaultSelectGiftId = selectGiftId; } - (void)setDelegate:(id)delegate { @@ -798,9 +803,9 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView; return _userView; } -- (XPGiftInfoView *)giftInfoView { +- (PIGiftInfoSegmentedView *)giftInfoView { if (!_giftInfoView) { - _giftInfoView = [[XPGiftInfoView alloc] init]; + _giftInfoView = [[PIGiftInfoSegmentedView alloc] initWithFrame:CGRectZero]; _giftInfoView.delegate = self; } return _giftInfoView; diff --git a/YuMi/Modules/YMRoom/View/StageView/MicroView/MicroView.m b/YuMi/Modules/YMRoom/View/StageView/MicroView/MicroView.m index e65446eb..ea5501f6 100644 --- a/YuMi/Modules/YMRoom/View/StageView/MicroView/MicroView.m +++ b/YuMi/Modules/YMRoom/View/StageView/MicroView/MicroView.m @@ -501,7 +501,20 @@ } } } - +- (void)configPkBtn:(UserInfoModel *)userInfo{ + self.groupTypeButton.hidden = YES; + if (self.roomInfo.roomModeType == RoomModeType_Open_PK_Mode) { + if (userInfo.groupType == GroupType_Red) { + self.groupTypeButton.hidden = NO; + [self.groupTypeButton setTitle:YMLocalizedString(@"MicroView2") forState:UIControlStateNormal]; + [self.groupTypeButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFC4A95), UIColorFromRGB(0xFE6075)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal]; + } else if(userInfo.groupType == GroupType_Blue) { + self.groupTypeButton.hidden = NO; + [self.groupTypeButton setTitle:YMLocalizedString(@"MicroView3") forState:UIControlStateNormal]; + [self.groupTypeButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x3571FE), UIColorFromRGB(0x7994FC)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal]; + } + } +} - (void)configGiftValue:(long long)giftValue { self.giftValueView.giftValue = giftValue; } diff --git a/YuMi/Modules/YMRoom/View/StageView/MicroView/MicroViewProtocol.h b/YuMi/Modules/YMRoom/View/StageView/MicroView/MicroViewProtocol.h index 047ba68a..37d6a8cc 100644 --- a/YuMi/Modules/YMRoom/View/StageView/MicroView/MicroViewProtocol.h +++ b/YuMi/Modules/YMRoom/View/StageView/MicroView/MicroViewProtocol.h @@ -33,7 +33,8 @@ NS_ASSUME_NONNULL_BEGIN * 设置麦位信息和用户信息。 */ - (void)configMicroView:(MicroQueueModel *)model; - +///设置pk按钮的状态 +- (void)configPkBtn:(UserInfoModel *)userInfo; /** * 设置用户信息。 */ diff --git a/YuMi/Modules/YMRoom/View/StageView/StageView.h b/YuMi/Modules/YMRoom/View/StageView/StageView.h index 42a81c64..7ce872dd 100644 --- a/YuMi/Modules/YMRoom/View/StageView/StageView.h +++ b/YuMi/Modules/YMRoom/View/StageView/StageView.h @@ -73,7 +73,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, weak, readonly) id hostDelegate; - (instancetype)initWithDelegate:(id)delegate; - +-(void)exitRoom; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/StageView/StageView.m b/YuMi/Modules/YMRoom/View/StageView/StageView.m index d86110ee..bfbcfef0 100644 --- a/YuMi/Modules/YMRoom/View/StageView/StageView.m +++ b/YuMi/Modules/YMRoom/View/StageView/StageView.m @@ -142,42 +142,59 @@ } - (void)initNIMMicroQueues { - RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo; - // 获取麦位的状态,并初始化 self.micQueue 。 - [[NIMSDK sharedSDK].chatroomManager fetchChatroomInfo:[NSString stringWithFormat:@"%ld", (long)roomInfo.roomId] completion:^(NSError * _Nullable error, NIMChatroom * _Nullable chatroom) { - if (error) { - return; - } - NSDictionary *info = (NSDictionary *)[chatroom.ext toJSONObject]; - NSDictionary *micState = [info[@"micQueue"] toJSONObject]; - for (NSString *position in micState.allKeys) { - MicroStateModel *state = [MicroStateModel modelWithJSON:micState[position]]; - MicroQueueModel *sequence = [self.micQueue objectForKey:position]; - sequence.microState = state; - } - [self microQueueUpdated: NO]; - }]; + RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo; + // 获取麦位的状态,并初始化 self.micQueue 。 + [[NIMSDK sharedSDK].chatroomManager fetchChatroomInfo:[NSString stringWithFormat:@"%ld", (long)roomInfo.roomId] completion:^(NSError * _Nullable error, NIMChatroom * _Nullable chatroom) { + if (error) { + return; + } + NSDictionary *info = (NSDictionary *)[chatroom.ext toJSONObject]; + NSDictionary *micState = [info[@"micQueue"] toJSONObject]; + for (NSString *position in micState.allKeys) { + MicroStateModel *state = [MicroStateModel modelWithJSON:micState[position]]; + MicroQueueModel *sequence = [self.micQueue objectForKey:position]; + sequence.microState = state; + } + [self microQueueUpdated: NO]; + }]; self.hadGetQueueInfoSuccess = NO; - // 获取麦位的用户,并初始化 self.micQueue 。 - [[NIMSDK sharedSDK].chatroomManager fetchChatroomQueue:[NSString stringWithFormat:@"%ld", (long)roomInfo.roomId] completion:^(NSError * _Nullable error, NSArray *> * _Nullable info) { - if (error) return; - BOOL ownerRTCChange = NO; - for (NSDictionary *item in info) { - UserInfoModel *userInfo = [UserInfoModel modelWithJSON:item.allValues.firstObject]; - NSString *position = item.allKeys.firstObject; - MicroQueueModel *sequence = [self.micQueue objectForKey:position]; - sequence.userInfo = userInfo; - if (userInfo.uid == [AccountInfoStorage instance].getUid.integerValue) { - ownerRTCChange = YES; - } - } - [self microQueueUpdated:ownerRTCChange]; - [self.hostDelegate onMicroQueueUpdate:self.micQueue]; + // 获取麦位的用户,并初始化 self.micQueue 。 + [[NIMSDK sharedSDK].chatroomManager fetchChatroomQueue:[NSString stringWithFormat:@"%ld", (long)roomInfo.roomId] completion:^(NSError * _Nullable error, NSArray *> * _Nullable info) { + if (error) return; + BOOL ownerRTCChange = NO; + MicroQueueModel *meQuence = nil; + for (NSDictionary *item in info) { + UserInfoModel *userInfo = [UserInfoModel modelWithJSON:item.allValues.firstObject]; + NSString *position = item.allKeys.firstObject; + MicroQueueModel *sequence = [self.micQueue objectForKey:position]; + sequence.userInfo = userInfo; + if (userInfo.uid == [AccountInfoStorage instance].getUid.integerValue) { + ownerRTCChange = YES; + meQuence = sequence; + } + } + [self microQueueUpdated:ownerRTCChange]; + [self.hostDelegate onMicroQueueUpdate:self.micQueue]; self.hadGetQueueInfoSuccess = YES; - }]; - - // 拿到麦序后初始化礼物值 - [self initGiftValue]; + if(meQuence != nil){ + [self enterRoomUpMicWith:meQuence]; + } + }]; + + // 拿到麦序后初始化礼物值 + [self initGiftValue]; +} +///进入房间,如果自己在麦上,需要调下上麦,不然,网络不好,会导致人不在麦上,但有声音 +-(void)enterRoomUpMicWith:(MicroQueueModel *)sequence{ + RoomInfoModel * roomInfo =self.hostDelegate.getRoomInfo; + NSString * roomId = [NSString stringWithFormat:@"%ld", roomInfo.uid]; + NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init]; + request.key = @(sequence.microState.position).stringValue; + request.value = [sequence.userInfo toJSONString]; + request.roomId = roomId; + request.transient = YES; + [[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) { + }]; } - (void)initGiftValue{ @@ -467,10 +484,36 @@ [RtcManager instance].localMuted = YES; } } - + if(userInfo.isNoProhibitMic == YES){ + for (int i = 0; i < self.countOfMircoView; i++) { + UIView * view = [self findMicroViewByIndex:i]; + [view configPkBtn:userInfo]; + } + } microQueueChanged = YES; } break; + case NIMChatroomEventTypeEnter: + { + ///进入房间,如果自己在麦上,需要调下上麦,不然,网络不好,会导致人不在麦上,但有声音 + RoomInfoModel * roomInfo =self.hostDelegate.getRoomInfo; + NSString * roomId = [NSString stringWithFormat:@"%ld", roomInfo.uid]; + BOOL isInMic = NO; + for (MicroQueueModel *sequence in self.micQueue.allValues) { + if ([AccountInfoStorage instance].getUid.integerValue == sequence.userInfo.uid) { + isInMic = YES; + NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init]; + request.key = @(sequence.microState.position).stringValue; + request.value = [sequence.userInfo toJSONString]; + request.roomId = roomId; + request.transient = YES; + [[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) { + }]; + + } + } + } + break; case NIMChatroomEventTypeExit: case NIMChatroomEventTypeKicked: { @@ -497,7 +540,23 @@ [self.hostDelegate onMicroQueueUpdate:self.micQueue]; } } - +///自己退出房间,如果在麦上要自己下麦 +-(void)exitRoom{ + RoomInfoModel * roomInfo =self.hostDelegate.getRoomInfo; + NSString * roomId = [NSString stringWithFormat:@"%ld", roomInfo.uid]; + for (MicroQueueModel *sequence in self.micQueue.allValues) { + if ([AccountInfoStorage instance].getUid.integerValue == sequence.userInfo.uid) { + NIMChatroomQueueRemoveRequest *request = [[NIMChatroomQueueRemoveRequest alloc]init]; + request.key = @(sequence.microState.position).stringValue; + request.roomId = roomId; + [[NIMSDK sharedSDK].chatroomManager removeChatroomQueueObject:request completion:^(NSError * _Nullable error, NSDictionary * _Nullable element) { + + }]; + } + } + + +} - (void)handleNIMCustomMessage:(NIMMessage *)message { NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { diff --git a/YuMi/Modules/YMRoom/View/UserCard/Presenter/XPUserCardPresenter.m b/YuMi/Modules/YMRoom/View/UserCard/Presenter/XPUserCardPresenter.m index bb0be8aa..ca59c67c 100644 --- a/YuMi/Modules/YMRoom/View/UserCard/Presenter/XPUserCardPresenter.m +++ b/YuMi/Modules/YMRoom/View/UserCard/Presenter/XPUserCardPresenter.m @@ -449,10 +449,33 @@ request.notifyExt = [@{@"reason":@"kick",@"account":targetUid,@"handleUid":uid} toJSONString]; } [[NIMSDK sharedSDK].chatroomManager kickMember:request completion:^(NSError * _Nullable error) { + if(error == nil){ + [self kickUserFinishWithUid:targetUid roomUid:roomId]; + } + [[self getView] makeKickUserFinish:error]; }]; } +///踢人操作者保存被踢人的id,防止被踢人网络不好时,无法踢出的bug,用于被踢人重连时,判断是否是被踢出房间的,把他踢出房间 +-(void)kickUserFinishWithUid:(NSString *)uid roomUid:(NSString *)roomUid{ + NSDate* date = [NSDate dateWithTimeIntervalSinceNow:0];//获取当前时间0秒后的时间 + NSTimeInterval time = [date timeIntervalSince1970]; + NSString *currentTime = [NSString stringWithFormat:@"%.0f", time]; + NSString *key = [NSString stringWithFormat:@"kManageKickedOutRoom_%@_%@", uid, roomUid]; + NSMutableDictionary *kickedList = [[NSUserDefaults standardUserDefaults]valueForKey:@"kManageKickedOutRoomList"]; + if([kickedList isKindOfClass:[NSString class]]){ + kickedList = nil; + } + if(kickedList == nil){ + kickedList = [NSMutableDictionary dictionary]; + }else{ + kickedList = [[NSMutableDictionary alloc]initWithDictionary:kickedList]; + } + [kickedList setValue:currentTime forKey:key]; + [[NSUserDefaults standardUserDefaults] setObject:kickedList forKey:@"kManageKickedOutRoomList"]; + [[NSUserDefaults standardUserDefaults] synchronize]; +} /// 超管踢管理员 /// @param targetNick 目标用户的昵称 /// @param cardInfo 用户信息 diff --git a/YuMi/Modules/YMRoom/View/XPRoomViewController.m b/YuMi/Modules/YMRoom/View/XPRoomViewController.m index 5dab752a..c0430c3d 100644 --- a/YuMi/Modules/YMRoom/View/XPRoomViewController.m +++ b/YuMi/Modules/YMRoom/View/XPRoomViewController.m @@ -950,10 +950,17 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } ///判断是否被踢出房间 -- (BOOL)isKictOutLatest:(RoomInfoModel *)roomInfo { - NSString *currentUid = [AccountInfoStorage instance].getUid; - NSString *key = [NSString stringWithFormat:@"%@_%ld", currentUid, roomInfo.uid]; - NSString *kictOutTime = [[NSUserDefaults standardUserDefaults] objectForKey:key]; +- (BOOL)isKictOutLatest:(NSString *)key mainKey:(NSString *)mainKey{ + NSMutableDictionary *kickedList = [[NSUserDefaults standardUserDefaults]valueForKey:mainKey]; + if([kickedList isKindOfClass:[NSString class]]){ + kickedList = nil; + } + if(kickedList == nil){ + kickedList = [NSMutableDictionary dictionary]; + }else{ + kickedList = [[NSMutableDictionary alloc]initWithDictionary:kickedList]; + } + NSString *kictOutTime = [kickedList valueForKey:key]; if (kictOutTime) { NSDate* date = [NSDate dateWithTimeIntervalSinceNow:0]; NSTimeInterval time = [date timeIntervalSince1970]; @@ -964,8 +971,6 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 [[NSUserDefaults standardUserDefaults] synchronize]; return NO; } else { - [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPRoomViewController0")]; - [self dismissViewControllerAnimated:YES completion:nil]; return YES; } } else { @@ -1015,7 +1020,11 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 //判断5分钟内是否被踢出过房间 - if ([self isKictOutLatest:roomInfo]) { + NSString *currentUid = [AccountInfoStorage instance].getUid; + NSString *key = [NSString stringWithFormat:@"kKickedOutRoom_%@_%ld", currentUid, roomInfo.uid]; + if ([self isKictOutLatest:key mainKey:@"kKickedOutRoomList"] == YES) { + [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPRoomViewController0")]; + [self dismissViewControllerAnimated:YES completion:nil]; return; } if (roomInfo.type == RoomType_Anchor) {//个播房,获取下一个房间 @@ -1386,10 +1395,27 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 [self showErrorToast:YMLocalizedString(@"XPRoomViewController8")]; ///保存被踢出时的时间 NSDate* date = [NSDate dateWithTimeIntervalSinceNow:0];//获取当前时间0秒后的时间 - NSTimeInterval time=[date timeIntervalSince1970]; + NSTimeInterval time = [date timeIntervalSince1970]; NSString *currentTime = [NSString stringWithFormat:@"%.0f", time]; - NSString *key = [NSString stringWithFormat:@"%@_%ld", [AccountInfoStorage instance].getUid, self.roomInfo.uid]; - [[NSUserDefaults standardUserDefaults] setObject:currentTime forKey:key]; + NSString *key = [NSString stringWithFormat:@"kKickedOutRoom_%@_%ld", [AccountInfoStorage instance].getUid, self.roomInfo.uid]; + + NSMutableDictionary *kickedList = [[NSUserDefaults standardUserDefaults]valueForKey:@"kKickedOutRoomList"]; + if([kickedList isKindOfClass:[NSString class]]){ + kickedList = nil; + } + if(kickedList == nil){ + kickedList = [NSMutableDictionary dictionary]; + }else{ + kickedList = [[NSMutableDictionary alloc]initWithDictionary:kickedList]; + } + NSMutableDictionary *copyList = [[NSMutableDictionary alloc]initWithDictionary:kickedList]; + for (NSString *timeKey in copyList.allKeys) { + if([self isKictOutLatest:timeKey mainKey:@"kKickedOutRoomList"] == NO){ + [kickedList removeObjectForKey:timeKey]; + } + } + [kickedList setValue:currentTime forKey:key]; + [[NSUserDefaults standardUserDefaults] setObject:kickedList forKey:@"kKickedOutRoomList"]; [[NSUserDefaults standardUserDefaults] synchronize]; } else if (result.reason == 5) { [self showErrorToast:YMLocalizedString(@"XPRoomViewController9")]; @@ -1521,6 +1547,23 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } break; case NIMChatroomEventTypeEnter: + { + + NSString *currentUid = content.source.userId; + NSString *key = [NSString stringWithFormat:@"kManageKickedOutRoom_%@_%ld", currentUid, self.roomInfo.roomId]; + if ([self isKictOutLatest:key mainKey:@"kManageKickedOutRoomList"] == YES) { + NSString * uid = [[AccountInfoStorage instance] getUid]; + NIMChatroomMemberKickRequest *request = [[NIMChatroomMemberKickRequest alloc] init]; + request.roomId = [NSString stringWithFormat:@"%ld",self.roomInfo.uid]; + request.userId = currentUid; + if(currentUid != nil && uid != nil){ + request.notifyExt = [@{@"reason":@"kick",@"account":currentUid,@"handleUid":uid} toJSONString]; + } + [[NIMSDK sharedSDK].chatroomManager kickMember:request completion:^(NSError * _Nullable error) { + NSLog(@"%@",error); + }]; + } + if (content.source.userId.integerValue != [AccountInfoStorage instance].getUid.integerValue && self.userInfo.platformRole != 1) { onLineNumber += 1; }else {///如果是自己的话 如果有坐骑的话 @@ -1530,7 +1573,9 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 [self.menuContainerView onRoomUpdate]; } + break; + } case NIMChatroomEventTypeAddBlack: case NIMChatroomEventTypeKicked: case NIMChatroomEventTypeExit: @@ -1796,6 +1841,7 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } - (void)exitRoom { + [self.stageView exitRoom]; [self.menuContainerView menuResignFirstResponder]; [self.animationView resumeTimer]; if (self.roomInfo.roomModeType == RoomModeType_Open_Micro_Mode || self.roomInfo.roomModeType == RoomModeType_Open_Blind) {