From e5ae6d3157d8dfe587e3d1d62022755f571b2294 Mon Sep 17 00:00:00 2001 From: liyuhua <15626451870@163.com> Date: Tue, 31 Oct 2023 11:09:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- YuMi/Global/YUMIMacroUitls.h | 62 +---- .../Content/MessageContentRedPacketView.m | 2 +- .../Session/Content/MessageContentTweetView.m | 239 +++++++++--------- .../Content/SesssionModel/MessageTweetModel.m | 3 +- .../AnimationView/XPRoomGiftBroadcastView.m | 11 + .../View/PIRoomMessagePhotoAlbumView.m | 6 +- .../View/Cell/PIRoomPhotoAlbumItemCell.m | 5 +- .../SendRedPacket/PIRoomEnterRedPacketView.m | 3 +- .../SendRedPacket/XPReceiveRedPacketView.h | 7 +- .../SendRedPacket/XPReceiveRedPacketView.m | 22 +- .../Modules/YMRoom/View/StageView/StageView.m | 6 +- .../YMRoom/View/XPRoomViewController.m | 34 ++- 12 files changed, 210 insertions(+), 190 deletions(-) diff --git a/YuMi/Global/YUMIMacroUitls.h b/YuMi/Global/YUMIMacroUitls.h index 7d77f6e5..593e2197 100644 --- a/YuMi/Global/YUMIMacroUitls.h +++ b/YuMi/Global/YUMIMacroUitls.h @@ -20,64 +20,12 @@ isPhoneXSeries = [[UIApplication sharedApplication] delegate].window.safeAreaIns #define KScreenWidth [[UIScreen mainScreen] bounds].size.width #define KScreenHeight [[UIScreen mainScreen] bounds].size.height -// 状态栏高度 -#define statusbarHeight \ -({\ - CGFloat height = 0.0;\ - if (@available(iOS 11.0, *)) {\ - UIEdgeInsets insets = [UIApplication sharedApplication].delegate.window.safeAreaInsets;\ - height = insets.top;\ - } else {\ - height = 20.0;\ - }\ - height;\ -}) +#define statusbarHeight [[UIApplication sharedApplication] statusBarFrame].size.height #define kStatusBarHeight statusbarHeight -// 安全区域底部高度 -#define kSafeAreaBottomHeight \ -({\ - CGFloat height = 0.0;\ - if (@available(iOS 11.0, *)) {\ - UIEdgeInsets insets = [UIApplication sharedApplication].delegate.window.safeAreaInsets;\ - height = insets.bottom;\ - }\ - height;\ -}) -// 安全区域顶部高度 -#define kSafeAreaTopHeight \ -({\ - CGFloat height = 0.0;\ - if (@available(iOS 11.0, *)) {\ - UIEdgeInsets insets = [UIApplication sharedApplication].delegate.window.safeAreaInsets;\ - height = insets.top;\ - }\ - height;\ -}) - -// 导航栏高度 -#define kNavigationHeight \ -({\ - CGFloat height = 0.0;\ - if (@available(iOS 11.0, *)) {\ - UIEdgeInsets insets = [UIApplication sharedApplication].delegate.window.safeAreaInsets;\ - height = insets.top > 0 ? 44.0 + insets.top : 44.0;\ - } else {\ - height = 64.0;\ - }\ - height;\ -}) -// 标签栏高度 -#define kTabBarHeight \ -({\ - CGFloat height = 0.0;\ - if (@available(iOS 11.0, *)) {\ - UIEdgeInsets insets = [UIApplication sharedApplication].delegate.window.safeAreaInsets;\ - height = insets.bottom > 0 ? 49.0 + insets.bottom : 49.0;\ - } else {\ - height = 49.0;\ - }\ - height;\ -}) +#define kSafeAreaBottomHeight (iPhoneXSeries ? 34 : 0) +#define kSafeAreaTopHeight (iPhoneXSeries ? 24 : 0) +#define kNavigationHeight (kStatusBarHeight + 44) +#define kTabBarHeight (iPhoneXSeries ? 49.0+34.0 : 49.0) #define kScreenScale ((CGFloat)KScreenWidth / (CGFloat)375) #define kScreenHeightScale ((CGFloat)KScreenHeight / (CGFloat)812) #define kHalfScreenHeight KScreenHeight * 0.65 diff --git a/YuMi/Modules/YMMessage/View/Session/Content/MessageContentRedPacketView.m b/YuMi/Modules/YMMessage/View/Session/Content/MessageContentRedPacketView.m index 90c85b0d..24e2081d 100644 --- a/YuMi/Modules/YMMessage/View/Session/Content/MessageContentRedPacketView.m +++ b/YuMi/Modules/YMMessage/View/Session/Content/MessageContentRedPacketView.m @@ -147,7 +147,7 @@ } }]; dispatch_after(1.0, dispatch_get_main_queue(), ^{ - [XPRoomViewController openRoom:self.messageInfo.roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC redEnvelopeId:self.messageInfo.redEnvelopeId]; + [XPRoomViewController openRoom:self.messageInfo.roomUid viewController:kWindow.rootViewController redEnvelopeId:self.messageInfo.redEnvelopeId]; }); } diff --git a/YuMi/Modules/YMMessage/View/Session/Content/MessageContentTweetView.m b/YuMi/Modules/YMMessage/View/Session/Content/MessageContentTweetView.m index 57e0c087..6c42676a 100644 --- a/YuMi/Modules/YMMessage/View/Session/Content/MessageContentTweetView.m +++ b/YuMi/Modules/YMMessage/View/Session/Content/MessageContentTweetView.m @@ -45,106 +45,117 @@ @implementation MessageContentTweetView - (void)render:(MessageBaseModel *)model1 { - MessageTweetModel *obj = (MessageTweetModel *)model1; - ContentTweetModel * model = obj.tweetInfo; - self.tweetModel = model; + MessageTweetModel *obj = (MessageTweetModel *)model1; + ContentTweetModel * model = obj.tweetInfo; + self.tweetModel = model; self.messageId = model1.message.messageId; - self.logoImageView.imageUrl = model.picUrl; - self.titleLabel.attributedText = [[NSMutableAttributedString alloc] initWithString:model.title attributes:[self messageTextAttibutes:[UIFont systemFontOfSize:16] color:[DJDKMIMOMColor mainTextColor]]]; - self.subTitleLabel.attributedText = [[NSMutableAttributedString alloc] initWithString:model.desc attributes:[self messageTextAttibutes:[UIFont systemFontOfSize:13] color:[DJDKMIMOMColor secondTextColor]]]; - - CGFloat oneHeight = [YMLocalizedString(@"MessageContentTweetView0") boundingRectWithSize:CGSizeMake(240, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin - attributes:[self messageTextAttibutes:[UIFont systemFontOfSize:16] color:[DJDKMIMOMColor mainTextColor]] context:nil].size.height + 2.5; - - CGFloat titleHeight = [model.title boundingRectWithSize:CGSizeMake(240, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin - attributes:[self messageTextAttibutes:[UIFont systemFontOfSize:16] color:[DJDKMIMOMColor mainTextColor]] context:nil].size.height; - if (titleHeight <= oneHeight * 2) { - [self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(titleHeight + 5); - }]; - } else{ - [self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(oneHeight * 2); - }]; - } - - - - CGFloat desHeight = [model.desc boundingRectWithSize:CGSizeMake(240, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin - attributes:[self messageTextAttibutes:[UIFont systemFontOfSize:13] color:[DJDKMIMOMColor mainTextColor]] context:nil].size.height; - [self.subTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(desHeight); - }]; + self.logoImageView.imageUrl = model.picUrl; + self.titleLabel.attributedText = [[NSMutableAttributedString alloc] initWithString:model.title attributes:[self messageTextAttibutes:[UIFont systemFontOfSize:16] color:[DJDKMIMOMColor mainTextColor]]]; + self.subTitleLabel.attributedText = [[NSMutableAttributedString alloc] initWithString:model.desc attributes:[self messageTextAttibutes:[UIFont systemFontOfSize:13] color:[DJDKMIMOMColor secondTextColor]]]; + + CGFloat oneHeight = [YMLocalizedString(@"MessageContentTweetView0") boundingRectWithSize:CGSizeMake(240, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin + attributes:[self messageTextAttibutes:[UIFont systemFontOfSize:16] color:[DJDKMIMOMColor mainTextColor]] context:nil].size.height + 2.5; + + CGFloat titleHeight = [model.title boundingRectWithSize:CGSizeMake(240, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin + attributes:[self messageTextAttibutes:[UIFont systemFontOfSize:16] color:[DJDKMIMOMColor mainTextColor]] context:nil].size.height; + if (titleHeight <= oneHeight * 2) { + [self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(titleHeight + 5); + }]; + } else{ + [self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(oneHeight * 2); + }]; + } + + + + CGFloat desHeight = [model.desc boundingRectWithSize:CGSizeMake(240, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin + attributes:[self messageTextAttibutes:[UIFont systemFontOfSize:13] color:[DJDKMIMOMColor mainTextColor]] context:nil].size.height; + [self.subTitleLabel mas_updateConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(desHeight); + }]; NSArray *redPacketHistory = [[NSUserDefaults standardUserDefaults] objectForKey:kTuWenMessageHistory]; - if ([redPacketHistory containsObject: model1.message.messageId]) { + if ( [redPacketHistory containsObject: model1.message.messageId]) { self.isNewImageView.hidden = YES; + [self.isNewImageView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.right.mas_equalTo(self.backView); + make.centerY.equalTo(self.titleLabel); + make.size.mas_equalTo(CGSizeMake(0, 10)); + }]; } else { self.isNewImageView.hidden = NO; + [self.isNewImageView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.right.mas_equalTo(self.backView); + make.centerY.equalTo(self.titleLabel); + make.size.mas_equalTo(CGSizeMake(24, 10)); + }]; } } - (NSDictionary *)messageTextAttibutes:(UIFont *)font color:(UIColor *)color { - NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; - [paragraphStyle setLineSpacing:2.5]; - return @{ - NSFontAttributeName:font, - NSParagraphStyleAttributeName: paragraphStyle, - NSForegroundColorAttributeName:color - }; + NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; + [paragraphStyle setLineSpacing:2.5]; + return @{ + NSFontAttributeName:font, + NSParagraphStyleAttributeName: paragraphStyle, + NSForegroundColorAttributeName:color + }; } - (void)initSubViews { - [super initSubViews]; - [self.backView addSubview:self.titleLabel]; - [self.backView addSubview:self.logoImageView]; - [self.backView addSubview:self.lineView]; - [self.backView addSubview:self.subTitleLabel]; - [self.backView addSubview:self.checkButton]; + [super initSubViews]; + [self.backView addSubview:self.titleLabel]; + [self.backView addSubview:self.logoImageView]; + [self.backView addSubview:self.lineView]; + [self.backView addSubview:self.subTitleLabel]; + [self.backView addSubview:self.checkButton]; [self.backView addSubview:self.isNewImageView]; } - (void)initSubViewConstraints { - [super initSubViewConstraints]; - [self.backView mas_makeConstraints:^(MASConstraintMaker *make) { - make.width.mas_equalTo(280); - make.bottom.mas_equalTo(self.checkButton); - }]; - - [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self.backView); - make.top.mas_equalTo(self.backView); - make.height.mas_equalTo(18); - }]; - - [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self.backView); - make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10); - make.height.mas_equalTo(87); - }]; - - [self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self.backView); - make.top.mas_equalTo(self.logoImageView.mas_bottom).offset(10); - make.height.mas_equalTo(18); - }]; - - [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self.backView); - make.height.mas_equalTo(0.5); - make.top.mas_equalTo(self.subTitleLabel.mas_bottom).offset(5); - }]; - - [self.checkButton mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self.backView); - make.top.mas_equalTo(self.lineView.mas_bottom).offset(10); - make.height.mas_equalTo(20); - }]; + [super initSubViewConstraints]; + [self.backView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(280); + make.bottom.mas_equalTo(self.checkButton); + }]; [self.isNewImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(self.backView); - make.top.mas_equalTo(self.backView).mas_offset(3); + make.centerY.equalTo(self.titleLabel); make.size.mas_equalTo(CGSizeMake(24, 10)); }]; + [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.backView); + make.right.equalTo(self.isNewImageView.mas_left); + make.top.mas_equalTo(self.backView); + make.height.mas_equalTo(18); + }]; + + [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.backView); + make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(10); + make.height.mas_equalTo(87); + }]; + + [self.subTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.backView); + make.top.mas_equalTo(self.logoImageView.mas_bottom).offset(10); + make.height.mas_equalTo(18); + }]; + + [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.backView); + make.height.mas_equalTo(0.5); + make.top.mas_equalTo(self.subTitleLabel.mas_bottom).offset(5); + }]; + + [self.checkButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self.backView); + make.top.mas_equalTo(self.lineView.mas_bottom).offset(10); + make.height.mas_equalTo(20); + }]; + } #pragma mark - Event Response @@ -174,53 +185,53 @@ #pragma mark - Getters And Setters - (NetImageView *)logoImageView { - if (!_logoImageView) { - NetImageConfig * config = [[NetImageConfig alloc]init]; - config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; - _logoImageView = [[NetImageView alloc] initWithConfig:config]; - _logoImageView.layer.masksToBounds = YES; - _logoImageView.layer.cornerRadius = 10; - _logoImageView.contentMode = UIViewContentModeScaleAspectFill; - _logoImageView.layer.masksToBounds = YES; - } - return _logoImageView; + if (!_logoImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _logoImageView = [[NetImageView alloc] initWithConfig:config]; + _logoImageView.layer.masksToBounds = YES; + _logoImageView.layer.cornerRadius = 10; + _logoImageView.contentMode = UIViewContentModeScaleAspectFill; + _logoImageView.layer.masksToBounds = YES; + } + return _logoImageView; } - (UILabel *)titleLabel { - if (!_titleLabel) { - _titleLabel = [[UILabel alloc] init]; - _titleLabel.numberOfLines = 2; - _titleLabel.preferredMaxLayoutWidth = 240; - } - return _titleLabel; + if (!_titleLabel) { + _titleLabel = [[UILabel alloc] init]; + _titleLabel.numberOfLines = 2; + _titleLabel.preferredMaxLayoutWidth = 240; + } + return _titleLabel; } - (UIView *)lineView { - if (!_lineView) { - _lineView = [[UIView alloc] init]; - _lineView.backgroundColor = [DJDKMIMOMColor dividerColor]; - } - return _lineView; + if (!_lineView) { + _lineView = [[UIView alloc] init]; + _lineView.backgroundColor = [DJDKMIMOMColor dividerColor]; + } + return _lineView; } - (UILabel *)subTitleLabel { - if (!_subTitleLabel) { - _subTitleLabel = [[UILabel alloc] init]; - _subTitleLabel.numberOfLines = 0; - _subTitleLabel.preferredMaxLayoutWidth = 240; - } - return _subTitleLabel; + if (!_subTitleLabel) { + _subTitleLabel = [[UILabel alloc] init]; + _subTitleLabel.numberOfLines = 0; + _subTitleLabel.preferredMaxLayoutWidth = 240; + } + return _subTitleLabel; } - (UIButton *)checkButton { - if (!_checkButton) { - _checkButton = [UIButton buttonWithType:UIButtonTypeCustom]; - [_checkButton setTitle:YMLocalizedString(@"MessageContentTweetView1") forState:UIControlStateNormal]; - [_checkButton setTitleColor:UIColorFromRGB(0x4C5AF1) forState:UIControlStateNormal]; - _checkButton.titleLabel.font = [UIFont systemFontOfSize:14]; - [_checkButton addTarget:self action:@selector(checkButtonAction:) forControlEvents:UIControlEventTouchUpInside]; - } - return _checkButton; + if (!_checkButton) { + _checkButton = [UIButton buttonWithType:UIButtonTypeCustom]; + [_checkButton setTitle:YMLocalizedString(@"MessageContentTweetView1") forState:UIControlStateNormal]; + [_checkButton setTitleColor:UIColorFromRGB(0x4C5AF1) forState:UIControlStateNormal]; + _checkButton.titleLabel.font = [UIFont systemFontOfSize:14]; + [_checkButton addTarget:self action:@selector(checkButtonAction:) forControlEvents:UIControlEventTouchUpInside]; + } + return _checkButton; } - (UIImageView *)isNewImageView { diff --git a/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageTweetModel.m b/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageTweetModel.m index ec6646be..26040853 100644 --- a/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageTweetModel.m +++ b/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageTweetModel.m @@ -15,9 +15,10 @@ if (self = [super initWithMessage:message]) { self.messageType = SessionMessageType_Custom; NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; - AttachmentModel * attach = obj.attachment; + AttachmentModel * attach = (AttachmentModel *)obj.attachment; ContentTweetModel * model = [ContentTweetModel modelWithJSON:attach.data]; self.tweetInfo = model; + CGFloat oneHeight = [YMLocalizedString(@"MessageTweetModel0") boundingRectWithSize:CGSizeMake(240, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:[self messageTextAttibutes:[UIFont systemFontOfSize:16]] context:nil].size.height + 2.5; diff --git a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomGiftBroadcastView.m b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomGiftBroadcastView.m index 91f93fed..f05f98c0 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomGiftBroadcastView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomGiftBroadcastView.m @@ -209,6 +209,17 @@ - (void)setBroadcastModel:(GiftReceiveInfoModel *)broadcastModel { _broadcastModel = broadcastModel; if (_broadcastModel) { + _roomNameLabel.hidden = _broadcastModel.roomTitle.length == 0; + _pi_roomIconView.hidden = _broadcastModel.roomTitle.length == 0; + _circuseeBtn.hidden = _broadcastModel.roomTitle.length == 0; + if(_broadcastModel.roomTitle.length == 0){ + [self.pi_contentView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.leading.equalTo(self.senderAvatarView.mas_trailing).mas_offset(kGetScaleWidth(13)); + make.centerY.equalTo(self.backImageView); + make.trailing.mas_equalTo(-kGetScaleWidth(133)); + make.height.mas_equalTo(kGetScaleWidth(14)); + }]; + } NSString *sendUserNick = _broadcastModel.sendUserNick ?: @""; NSString *recvUserNick = _broadcastModel.recvUserNick ?: @""; self.senderAvatarView.imageUrl = _broadcastModel.sendUserAvatar; diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/View/PIRoomMessagePhotoAlbumView.m b/YuMi/Modules/YMRoom/View/MessageContainerView/View/PIRoomMessagePhotoAlbumView.m index a8ff30c5..c3795aad 100644 --- a/YuMi/Modules/YMRoom/View/MessageContainerView/View/PIRoomMessagePhotoAlbumView.m +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/View/PIRoomMessagePhotoAlbumView.m @@ -106,7 +106,11 @@ if(_albumModel.status == 0){ [self.unlockPhotoView loadImageWithUrl:_albumModel.photoUrl completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) { @kStrongify(self); - self.unlockPhotoView.image = [self setBlurImage:image]; + dispatch_async(dispatch_get_main_queue(), ^{ + // UI更新代码 + self.unlockPhotoView.image = [self setBlurImage:image]; + }); + }]; }else{ self.unlockPhotoView.image = nil; diff --git a/YuMi/Modules/YMRoom/View/RoomPhotoAlbum/View/Cell/PIRoomPhotoAlbumItemCell.m b/YuMi/Modules/YMRoom/View/RoomPhotoAlbum/View/Cell/PIRoomPhotoAlbumItemCell.m index b3495c93..fef5e415 100644 --- a/YuMi/Modules/YMRoom/View/RoomPhotoAlbum/View/Cell/PIRoomPhotoAlbumItemCell.m +++ b/YuMi/Modules/YMRoom/View/RoomPhotoAlbum/View/Cell/PIRoomPhotoAlbumItemCell.m @@ -91,7 +91,10 @@ [self.bgImageView loadImageWithUrl:_albumModel.photoUrl completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) { @kStrongify(self); - self.bgImageView.image = [self setBlurImage:image]; + dispatch_async(dispatch_get_main_queue(), ^{ + // UI更新代码 + self.bgImageView.image = [self setBlurImage:image]; + }); }]; }else{ self.bgImageView.image = nil; diff --git a/YuMi/Modules/YMRoom/View/SendRedPacket/PIRoomEnterRedPacketView.m b/YuMi/Modules/YMRoom/View/SendRedPacket/PIRoomEnterRedPacketView.m index e510d969..d11078f0 100644 --- a/YuMi/Modules/YMRoom/View/SendRedPacket/PIRoomEnterRedPacketView.m +++ b/YuMi/Modules/YMRoom/View/SendRedPacket/PIRoomEnterRedPacketView.m @@ -217,8 +217,9 @@ self.redPacketModel = self.redPacketList.firstObject; self.hidden = NO; self.pi_redNum = @(self.redPacketList.count).stringValue; + return; } - return; + } [self.redPacketList replaceObjectAtIndex:[self.redPacketList indexOfObject:self.redPacketModel] withObject:redModel]; self.redPacketModel = redModel; diff --git a/YuMi/Modules/YMRoom/View/SendRedPacket/XPReceiveRedPacketView.h b/YuMi/Modules/YMRoom/View/SendRedPacket/XPReceiveRedPacketView.h index 2b3d243d..09005c75 100644 --- a/YuMi/Modules/YMRoom/View/SendRedPacket/XPReceiveRedPacketView.h +++ b/YuMi/Modules/YMRoom/View/SendRedPacket/XPReceiveRedPacketView.h @@ -8,6 +8,11 @@ #import #import "XPRedPacketModel.h" +@protocol XPReceiveRedPacketViewDelegate + +-(void)closeViewAction; + +@end NS_ASSUME_NONNULL_BEGIN @@ -16,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN ///是否在全服红包的房间内 @property (nonatomic, assign) BOOL inAllPacketRoom; - +@property(nonatomic,weak) iddelegate; @property (nonatomic, strong) XPRedPacketModel *receiveModel; diff --git a/YuMi/Modules/YMRoom/View/SendRedPacket/XPReceiveRedPacketView.m b/YuMi/Modules/YMRoom/View/SendRedPacket/XPReceiveRedPacketView.m index f78d3c0e..704fafba 100644 --- a/YuMi/Modules/YMRoom/View/SendRedPacket/XPReceiveRedPacketView.m +++ b/YuMi/Modules/YMRoom/View/SendRedPacket/XPReceiveRedPacketView.m @@ -317,12 +317,12 @@ } }else if(self.receiveModel.kind == RedPacketConditionsType_Followd){ if(self.isCountDownEnd == NO && self.receiveModel.finish == 0){ - [self removeFromSuperview]; + [self onCloseButtonClick]; [[NSNotificationCenter defaultCenter]postNotificationName:@"kOpenRedPacketNotification" object:nil userInfo:@{@"type":@(RedPacketConditionsType_Followd),@"uid":self.receiveModel.userId ?: @"",@"roomUid":self.receiveModel.roomUId ?: @""}]; return; }else if(self.isCountDownEnd == YES && self.receiveModel.finish == 0){ - [self removeFromSuperview]; + [self onCloseButtonClick]; [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPReceiveRedPacketView18")]; return; @@ -332,12 +332,12 @@ }else if(self.receiveModel.kind == RedPacketConditionsType_Share){ if(self.isCountDownEnd == NO && self.receiveModel.finish == 0){ - [self removeFromSuperview]; + [self onCloseButtonClick]; [[NSNotificationCenter defaultCenter]postNotificationName:@"kOpenRedPacketNotification" object:nil userInfo:@{@"type":@(RedPacketConditionsType_Share),@"uid":self.receiveModel.userId ?: @"",@"roomUid":self.receiveModel.roomUId ?: @""}]; return; }else if(self.isCountDownEnd == YES && self.receiveModel.finish == 0){ - [self removeFromSuperview]; + [self onCloseButtonClick]; [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPReceiveRedPacketView18")]; @@ -347,12 +347,12 @@ } }else if(self.receiveModel.kind == RedPacketConditionsType_Scrolling){ if(self.isCountDownEnd == NO && self.receiveModel.finish == 0){ - [self removeFromSuperview]; + [self onCloseButtonClick]; [[NSNotificationCenter defaultCenter]postNotificationName:@"kOpenRedPacketNotification" object:nil userInfo:@{@"type":@(RedPacketConditionsType_Scrolling),@"uid":self.receiveModel.userId ?: @"",@"roomUid":self.receiveModel.roomUId ?: @"",@"scrolling":self.receiveModel.message ?: @""}]; return; }else if(self.isCountDownEnd == YES && self.receiveModel.finish == 0){ - [self removeFromSuperview]; + [self onCloseButtonClick]; [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPReceiveRedPacketView18")]; return; @@ -394,7 +394,7 @@ [XPRoomViewController openRoom:self.receiveModel.roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC redEnvelopeId:self.receiveModel.redEnvelopeId]; }); } - [self removeFromSuperview]; + [self onCloseButtonClick]; } } } @@ -471,9 +471,11 @@ self.countDownView.text = [NSString stringWithFormat:@"%02d:%02d",minutes,second]; } #pragma mark - action -- (void)onCloseButtonClick:(UIButton *)sender { +- (void)onCloseButtonClick{ [self removeFromSuperview]; - + if(self.delegate && [self.delegate respondsToSelector:@selector(closeViewAction)]){ + [self.delegate closeViewAction]; + } } #pragma mark - getter @@ -550,7 +552,7 @@ if (!_closeBtn) { _closeBtn = [[UIButton alloc] init]; [_closeBtn setImage:[UIImage imageNamed:@"pi_red_packet_receive_colse"] forState:UIControlStateNormal]; - [_closeBtn addTarget:self action:@selector(onCloseButtonClick:) forControlEvents:UIControlEventTouchUpInside]; + [_closeBtn addTarget:self action:@selector(onCloseButtonClick) forControlEvents:UIControlEventTouchUpInside]; } return _closeBtn; } diff --git a/YuMi/Modules/YMRoom/View/StageView/StageView.m b/YuMi/Modules/YMRoom/View/StageView/StageView.m index 9bc2ac21..d86110ee 100644 --- a/YuMi/Modules/YMRoom/View/StageView/StageView.m +++ b/YuMi/Modules/YMRoom/View/StageView/StageView.m @@ -451,10 +451,14 @@ NIMCustomObject *object = [[NIMCustomObject alloc] init]; object.attachment = attachMent; message.messageObject = object; + //构造会话 NSString * sessionId = [NSString stringWithFormat:@"%ld", roomInfo.roomId]; NIMSession *session = [NIMSession session:sessionId type:NIMSessionTypeChatroom]; - [[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil]; + [[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session completion:^(NSError * _Nullable error) { + + }]; + } } roomUid:roomUid micUid:uid position:position uid:uid]; } diff --git a/YuMi/Modules/YMRoom/View/XPRoomViewController.m b/YuMi/Modules/YMRoom/View/XPRoomViewController.m index a8b0baf2..1fd6a7dc 100644 --- a/YuMi/Modules/YMRoom/View/XPRoomViewController.m +++ b/YuMi/Modules/YMRoom/View/XPRoomViewController.m @@ -87,7 +87,7 @@ UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification; NSString * const kHadShowAnchorRoomTipKey = @"kHadShowAnchorRoomTipKey";//是否展示过个播房上划用户引导 NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出过非自己房间 -@interface XPRoomViewController () +@interface XPRoomViewController () ///背景 @property (nonatomic,strong) XPRoomBackContainerView *backContainerView; @@ -153,6 +153,8 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 @property(nonatomic,copy) NSString *redEnvelopeId; ///红包 @property(nonatomic,strong) PIRoomEnterRedPacketView *redPacketView; +///是否正在显示红包弹窗,防止显示多个弹窗 +@property(nonatomic,assign) BOOL isShowRedPacket; @end @implementation XPRoomViewController @@ -387,6 +389,8 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + view.delegate = self; + self.isShowRedPacket = YES; view.receiveModel = redModel; for (UIView *subView in self.view.subviews) { if([subView isKindOfClass:[XPReceiveRedPacketView class]]) { @@ -699,11 +703,17 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 }]; } - +#pragma mark- XPReceiveRedPacketViewDelegate +- (void)closeViewAction{ + self.isShowRedPacket = NO; + +} #pragma mark- PIRoomEnterRedPacketViewDelegate - (void)openRedPacketWtihModel:(XPRedPacketModel *)redModel{ XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; view.receiveModel = redModel; + view.delegate = self; + self.isShowRedPacket = YES; for (UIView *subView in self.view.subviews) { if([subView isKindOfClass:[XPReceiveRedPacketView class]]) { view.alphaView.backgroundColor = [UIColor clearColor]; @@ -1297,6 +1307,8 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } - (void)getRedPacketInftSuccess:(XPRedPacketModel *)redInfo{ XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + view.delegate = self; + self.isShowRedPacket = YES; redInfo.validityType = 0; redInfo.kind = 1; view.receiveModel = redInfo; @@ -1315,9 +1327,14 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 return; } for (XPRedPacketModel *data in list) { + if(data.kind == 0){ + data.kind = 1; + } if((data.validityType == 0 && data.type == RedPacketType_RoomDiamond)|| data.type == RedPacketType_AllDiamond){ XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; view.receiveModel = data; + view.delegate = self; + self.isShowRedPacket = YES; for (UIView *subView in self.view.subviews) { if([subView isKindOfClass:[XPReceiveRedPacketView class]]) { view.alphaView.backgroundColor = [UIColor clearColor]; @@ -1593,6 +1610,8 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 if (attachment.second == Custom_Message_Sub_RoomDiamandRedPacket) { XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; XPRedPacketModel *data = [XPRedPacketModel modelWithJSON:attachment.data]; + view.delegate = self; + self.isShowRedPacket = YES; data.validityType = 0; data.kind = 1; data.redEnvelopeId = attachment.data[@"redEnvelopeId"]; @@ -1605,11 +1624,19 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 } [self.view addSubview:view]; [self.view bringSubviewToFront:view]; + if(self.activityContainerView.redPacketList == nil){ + self.activityContainerView.redPacketList = [NSMutableArray array]; + } + NSMutableArray *redPacketList = [NSMutableArray arrayWithArray:self.activityContainerView.redPacketList]; + [redPacketList insertObject:data atIndex:0]; + self.activityContainerView.redPacketList = redPacketList; }else if(attachment.second == Custom_Message_Sub_NewRoomDiamandRedPacket){ XPRedPacketModel *curData = [XPRedPacketModel modelWithJSON:attachment.data]; curData.redEnvelopeId = attachment.data[@"redEnvelopeId"]; if(curData.validityType == 0){ XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + view.delegate = self; + self.isShowRedPacket = YES; view.receiveModel = curData; for (UIView *subView in self.view.subviews) { if([subView isKindOfClass:[XPReceiveRedPacketView class]]) { @@ -1668,12 +1695,15 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 }else if (attachment.first == CustomMessageType_Tarot && (attachment.second == Custom_Message_Sub_Tarot_Advanced || attachment.second == Custom_Message_Sub_Tarot_Intermediate)){ isHave = YES; }if (attachment.first == CustomMessageType_RedPacket && attachment.second == Custom_Message_Sub_AllDiamandRedPacket) { + if(self.isShowRedPacket == YES)return; XPRedPacketModel *data = [XPRedPacketModel modelWithDictionary:attachment.data]; data.validityType = 0; data.kind = 1; data.redEnvelopeId = attachment.data[@"redEnvelopeId"]; RoomInfoModel *roomInfo = self.roomInfo; XPReceiveRedPacketView *view = [[XPReceiveRedPacketView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + view.delegate = self; + self.isShowRedPacket = YES; if (roomInfo.uid == data.roomUid.integerValue) { view.inAllPacketRoom = YES; } else {