修复bug

This commit is contained in:
liyuhua
2023-10-31 11:09:04 +08:00
parent a3b6fda673
commit e5ae6d3157
12 changed files with 210 additions and 190 deletions

View File

@@ -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

View File

@@ -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];
});
}

View File

@@ -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]]];
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 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 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);
}];
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<NSAttributedStringKey, id> *)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 {

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -8,6 +8,11 @@
#import <UIKit/UIKit.h>
#import "XPRedPacketModel.h"
@protocol XPReceiveRedPacketViewDelegate <NSObject>
-(void)closeViewAction;
@end
NS_ASSUME_NONNULL_BEGIN
@@ -16,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN
///是否在全服红包的房间内
@property (nonatomic, assign) BOOL inAllPacketRoom;
@property(nonatomic,weak) id<XPReceiveRedPacketViewDelegate>delegate;
@property (nonatomic, strong) XPRedPacketModel *receiveModel;

View File

@@ -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;
}

View File

@@ -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];
}

View File

@@ -87,7 +87,7 @@ UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification;
NSString * const kHadShowAnchorRoomTipKey = @"kHadShowAnchorRoomTipKey";//
NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//退
@interface XPRoomViewController ()<XPRoomProtocol, RoomHostDelegate, NIMChatroomManagerDelegate, NIMChatManagerDelegate, NIMConversationManagerDelegate, NIMLoginManagerDelegate, XPRoomSettingInputViewDelegate, AnchorRoomScrollViewDelegate, XPFirstRechargeViewDelegate,NIMBroadcastManagerDelegate,XPRoomLittleGameContainerViewDelegate,CountDownHelperDelegate,PIRoomEnterRedPacketViewDelegate>
@interface XPRoomViewController ()<XPRoomProtocol, RoomHostDelegate, NIMChatroomManagerDelegate, NIMChatManagerDelegate, NIMConversationManagerDelegate, NIMLoginManagerDelegate, XPRoomSettingInputViewDelegate, AnchorRoomScrollViewDelegate, XPFirstRechargeViewDelegate,NIMBroadcastManagerDelegate,XPRoomLittleGameContainerViewDelegate,CountDownHelperDelegate,PIRoomEnterRedPacketViewDelegate,XPReceiveRedPacketViewDelegate>
///
@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 {