礼物面板更改
This commit is contained in:
@@ -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 = "<group>"; };
|
||||
23CEFC482AFB8FC100576D89 /* BSDrawLine.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSDrawLine.m; sourceTree = "<group>"; };
|
||||
23CEFC492AFB8FC100576D89 /* BSkObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSkObject.h; sourceTree = "<group>"; };
|
||||
23CEFC662AFCCE7700576D89 /* PIGiftInfoSegmentedView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIGiftInfoSegmentedView.h; sourceTree = "<group>"; };
|
||||
23CEFC672AFCCE7700576D89 /* PIGiftInfoSegmentedView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIGiftInfoSegmentedView.m; sourceTree = "<group>"; };
|
||||
23D321D02ADD0EBC006B259C /* PIRoomPhotoAlbumItemPresenter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIRoomPhotoAlbumItemPresenter.h; sourceTree = "<group>"; };
|
||||
23D321D12ADD0EBC006B259C /* PIRoomPhotoAlbumItemPresenter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIRoomPhotoAlbumItemPresenter.m; sourceTree = "<group>"; };
|
||||
23D321D32ADD0F05006B259C /* Api+PhotoAlbum.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Api+PhotoAlbum.h"; sourceTree = "<group>"; };
|
||||
@@ -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 */,
|
||||
|
@@ -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<NSString *> *)titles {
|
||||
if (!_titles) {
|
||||
|
@@ -0,0 +1,48 @@
|
||||
//
|
||||
// PIGiftInfoSegmentedView.h
|
||||
// YuMi
|
||||
//
|
||||
// Created by duoban on 2023/11/9.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#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 <NSObject>
|
||||
|
||||
///点击了切换不同礼物的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) id<PIGiftInfoSegmentedViewDelegate>delegate;
|
||||
///普通礼物/幸运礼物/贵族礼物
|
||||
@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
|
@@ -0,0 +1,292 @@
|
||||
//
|
||||
// PIGiftInfoSegmentedView.m
|
||||
// YuMi
|
||||
//
|
||||
// Created by duoban on 2023/11/9.
|
||||
//
|
||||
|
||||
#import "PIGiftInfoSegmentedView.h"
|
||||
#import <JXCategoryView/JXCategoryView.h>
|
||||
#import <JXCategoryView/JXCategoryIndicatorBackgroundView.h>
|
||||
#import <JXCategoryView/JXCategoryListContainerView.h>
|
||||
#import "ThemeColor+SendGift.h"
|
||||
#import "XPGiftInfoView.h"
|
||||
@interface PIGiftInfoSegmentedView()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate,XPGiftInfoViewDelegate>
|
||||
///分页标题
|
||||
@property (nonatomic, strong) NSArray<NSString *> *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<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
|
||||
XPGiftInfoView<JXCategoryListContentViewDelegate> * list = (XPGiftInfoView<JXCategoryListContentViewDelegate> *)[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<NSString *> *)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
|
@@ -7,6 +7,7 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "XPSendGiftView.h"
|
||||
#import <JXCategoryView/JXCategoryListContainerView.h>
|
||||
///Model
|
||||
#import "RoomInfoModel.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@@ -28,20 +29,21 @@ typedef NS_ENUM(NSInteger, GiftSegmentType) {
|
||||
@protocol XPGiftInfoViewDelegate <NSObject>
|
||||
|
||||
///点击了切换不同礼物的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<JXCategoryListContentViewDelegate>
|
||||
///使用的地方
|
||||
@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
|
||||
|
@@ -26,68 +26,26 @@
|
||||
#import "XPGiftWeekStarCollectionViewCell.h"
|
||||
#import "XPGiftCollectionViewFlowLayout.h"
|
||||
#import "XPGiftFreeItemCell.h"
|
||||
static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIcon";///是否隐藏惩罚礼物“新”标识
|
||||
|
||||
|
||||
@interface XPGiftInfoView ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, XPGiftWeekStarCollectionViewCellDelegate>
|
||||
///滚动的容器
|
||||
@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 <GiftInfoModel *> *datasource;
|
||||
///普通礼物的数据源
|
||||
@property (nonatomic,strong) NSArray<GiftInfoModel *> *giftArray;
|
||||
/////幸运礼物的数据源
|
||||
@property (nonatomic,strong) NSArray<GiftInfoModel *> *giftLuckyArray;
|
||||
///贵族礼物的数据源
|
||||
@property (nonatomic, strong) NSArray<GiftInfoModel *> *giftNobleArray;
|
||||
///周星礼物的数据源
|
||||
@property (nonatomic, strong) NSArray<GiftInfoModel *> *giftWeekStarArray;
|
||||
/////背包礼物的数据源
|
||||
@property (nonatomic,strong) NSArray<GiftInfoModel *> *giftPackArray;
|
||||
///涂鸦礼物数据源
|
||||
@property (nonatomic,strong) NSArray<GiftInfoModel *> *giftGraffitiArray;
|
||||
///个播礼物数据源
|
||||
@property (nonatomic,strong) NSArray<GiftInfoModel *> *anchorArray;
|
||||
///惩罚礼物数据源
|
||||
@property (nonatomic, strong) NSArray<GiftInfoModel *> *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
|
||||
@@ -101,17 +59,35 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc
|
||||
}
|
||||
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;
|
||||
}
|
||||
@@ -154,105 +130,10 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc
|
||||
[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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#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<GiftInfoModel *> *)array {
|
||||
for (GiftInfoModel * gift in array) {
|
||||
@@ -260,41 +141,6 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc
|
||||
}
|
||||
}
|
||||
|
||||
- (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;
|
||||
@@ -304,6 +150,9 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc
|
||||
giftInfo.sourceType = GiftSourceType_Normal;
|
||||
}
|
||||
giftInfo.isSelected = YES;
|
||||
if(self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoView:dealSelectGift:)]){
|
||||
[self.delegate xPGiftInfoView:self dealSelectGift:giftInfo];
|
||||
}
|
||||
}
|
||||
|
||||
// 根据礼物id查找
|
||||
@@ -368,11 +217,14 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc
|
||||
cell.weekStarGiftList = self.datasource;
|
||||
return cell;
|
||||
}
|
||||
GiftInfoModel * giftInfo;
|
||||
giftInfo= [self.datasource safeObjectAtIndex1:indexPath.item];
|
||||
|
||||
GiftInfoModel * giftInfo = [self.datasource safeObjectAtIndex1:indexPath.item];
|
||||
giftInfo.isSelected = self.lastSelectGift.giftId == giftInfo.giftId;
|
||||
if(self.freeModel != nil && self.segmentType == GiftSegmentType_Pack && giftInfo.giftId == self.freeModel.giftId.integerValue){
|
||||
XPGiftFreeItemCell *itemCell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftFreeItemCell class]) forIndexPath:indexPath];
|
||||
|
||||
itemCell.giftInfo = giftInfo;
|
||||
|
||||
itemCell.freeModel = self.freeModel;
|
||||
return itemCell;
|
||||
|
||||
@@ -409,44 +261,139 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc
|
||||
#pragma mark - Getters And Setters
|
||||
- (void)setRoomType:(RoomType)roomType {
|
||||
_roomType = roomType;
|
||||
if (_roomType == RoomType_Anchor) {
|
||||
self.anchorButton.hidden = NO;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)setSegmentType:(GiftSegmentType)segmentType {
|
||||
if (segmentType == _segmentType) {
|
||||
return;
|
||||
// if (segmentType == _segmentType) {
|
||||
// return;
|
||||
// }
|
||||
// [_datasource removeAllObjects];
|
||||
// _segmentType = segmentType;
|
||||
//
|
||||
//
|
||||
// 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 <self.datasource.count; i++) {
|
||||
//// GiftInfoModel * gift = [self.datasource safeObjectAtIndex1:i];
|
||||
//// if (gift.giftId == [self.defaultSelectGiftId integerValue]) {
|
||||
//// [self dealSelectGift:gift];
|
||||
//// self.selectIndex = [self.datasource indexOfObject:gift];
|
||||
//// NSInteger page = i / 8;
|
||||
//// currentPage = page;
|
||||
//// break;
|
||||
//// }
|
||||
//// }
|
||||
////
|
||||
//// } else {
|
||||
// GiftInfoModel * gift = [self.datasource firstObject];
|
||||
// [self dealSelectGift:gift];
|
||||
//// }
|
||||
// }
|
||||
// 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];;
|
||||
// });
|
||||
}
|
||||
[_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];
|
||||
|
||||
- (void)setNormalOriginArray:(NSArray *)normalOriginArray {
|
||||
_normalOriginArray = normalOriginArray;
|
||||
if(_normalOriginArray.count > 0 && self.lastSelectGift == nil){
|
||||
self.lastSelectGift = _normalOriginArray.firstObject;
|
||||
}
|
||||
break;
|
||||
case GiftSegmentType_WeekStar: {
|
||||
[self.datasource addObjectsFromArray:self.giftWeekStarArray];
|
||||
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;
|
||||
}
|
||||
break;
|
||||
case GiftSegmentType_Pack:
|
||||
{
|
||||
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;
|
||||
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) {
|
||||
@@ -458,189 +405,19 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc
|
||||
}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 <self.datasource.count; i++) {
|
||||
// GiftInfoModel * gift = [self.datasource safeObjectAtIndex1:i];
|
||||
// if (gift.giftId == [self.defaultSelectGiftId integerValue]) {
|
||||
// [self dealSelectGift:gift];
|
||||
// self.selectIndex = [self.datasource indexOfObject:gift];
|
||||
// NSInteger page = i / 8;
|
||||
// currentPage = page;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// } else {
|
||||
GiftInfoModel * gift = [self.datasource firstObject];
|
||||
[self dealSelectGift:gift];
|
||||
// }
|
||||
}
|
||||
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.hidden = page <= 1;
|
||||
[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;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setPackOriginArray:(NSArray *)packOriginArray {
|
||||
_packOriginArray = packOriginArray;
|
||||
[self createPackTotalValueAttribute];
|
||||
}
|
||||
|
||||
- (void)setCurUserNobleLevel:(NSInteger)curUserNobleLevel {
|
||||
@@ -650,163 +427,26 @@ 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];
|
||||
// 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{
|
||||
@@ -845,37 +485,9 @@ static NSString *kSendGiftViewHidePunishNewIcon = @"kSendGiftViewHidePunishNewIc
|
||||
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];
|
||||
}
|
||||
return _nobleGiftButton;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
|
@@ -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,11 +519,12 @@ 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 {
|
||||
#pragma mark - PIGiftInfoSegmentedViewDelegate
|
||||
///点击了切换不同礼物的tabbar
|
||||
- (void)pIGiftInfoSegmentedView:(PIGiftInfoSegmentedView *)view didClickSegment:(GiftSegmentType)type{
|
||||
self.segmentType = type;
|
||||
self.giftBarView.type = type;
|
||||
self.giftBarView.drawGiftCount = 0;
|
||||
@@ -559,7 +560,8 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)xPGiftInfoView:(XPGiftInfoView *)view didClickItem:(GiftInfoModel *)info type:(GiftSegmentType)type {
|
||||
///点击了某个item
|
||||
- (void)pIGiftInfoSegmentedView:(PIGiftInfoSegmentedView *)view didClickItem:(GiftInfoModel *)info type:(GiftSegmentType)type{
|
||||
if (type == GiftSegmentType_Graffiti) {
|
||||
self.giftInfoView.hidden = YES;
|
||||
self.graffitiView.hidden = NO;
|
||||
@@ -581,6 +583,7 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#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<RoomHostDelegate>)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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -33,7 +33,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
* 设置麦位信息和用户信息。
|
||||
*/
|
||||
- (void)configMicroView:(MicroQueueModel *)model;
|
||||
|
||||
///设置pk按钮的状态
|
||||
- (void)configPkBtn:(UserInfoModel *)userInfo;
|
||||
/**
|
||||
* 设置用户信息。
|
||||
*/
|
||||
|
@@ -73,7 +73,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic, weak, readonly) id<RoomHostDelegate> hostDelegate;
|
||||
|
||||
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate;
|
||||
|
||||
-(void)exitRoom;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -162,6 +162,7 @@
|
||||
[[NIMSDK sharedSDK].chatroomManager fetchChatroomQueue:[NSString stringWithFormat:@"%ld", (long)roomInfo.roomId] completion:^(NSError * _Nullable error, NSArray<NSDictionary<NSString *,NSString *> *> * _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;
|
||||
@@ -169,16 +170,32 @@
|
||||
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;
|
||||
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{
|
||||
RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo;
|
||||
@@ -467,10 +484,36 @@
|
||||
[RtcManager instance].localMuted = YES;
|
||||
}
|
||||
}
|
||||
|
||||
if(userInfo.isNoProhibitMic == YES){
|
||||
for (int i = 0; i < self.countOfMircoView; i++) {
|
||||
UIView<MicroViewProtocol> * 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<NSString *,NSString *> * _Nullable element) {
|
||||
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
- (void)handleNIMCustomMessage:(NIMMessage *)message {
|
||||
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||||
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
||||
|
@@ -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 用户信息
|
||||
|
@@ -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) {//个播房,获取下一个房间
|
||||
@@ -1388,8 +1397,25 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出
|
||||
NSDate* date = [NSDate dateWithTimeIntervalSinceNow:0];//获取当前时间0秒后的时间
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user