公会消息同意拒绝刷新的问题
This commit is contained in:
@@ -368,6 +368,7 @@
|
|||||||
E8395339276A0CC100CF2F24 /* XPMineHeadwearTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E8395338276A0CC100CF2F24 /* XPMineHeadwearTableViewCell.m */; };
|
E8395339276A0CC100CF2F24 /* XPMineHeadwearTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E8395338276A0CC100CF2F24 /* XPMineHeadwearTableViewCell.m */; };
|
||||||
E839533C276A0CCD00CF2F24 /* XPMineCarTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E839533B276A0CCD00CF2F24 /* XPMineCarTableViewCell.m */; };
|
E839533C276A0CCD00CF2F24 /* XPMineCarTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E839533B276A0CCD00CF2F24 /* XPMineCarTableViewCell.m */; };
|
||||||
E839533F276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E839533E276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.m */; };
|
E839533F276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E839533E276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.m */; };
|
||||||
|
E83ABEF6280E9AD800322EE4 /* MessageContentUnSupportView.m in Sources */ = {isa = PBXBuildFile; fileRef = E83ABEF5280E9AD800322EE4 /* MessageContentUnSupportView.m */; };
|
||||||
E83DB47A27462C4500D8CBD1 /* XPGiftBigPrizeModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E83DB47927462C4500D8CBD1 /* XPGiftBigPrizeModel.m */; };
|
E83DB47A27462C4500D8CBD1 /* XPGiftBigPrizeModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E83DB47927462C4500D8CBD1 /* XPGiftBigPrizeModel.m */; };
|
||||||
E83DB47D2746372300D8CBD1 /* XPRoomGiftBannerView.m in Sources */ = {isa = PBXBuildFile; fileRef = E83DB47C2746372300D8CBD1 /* XPRoomGiftBannerView.m */; };
|
E83DB47D2746372300D8CBD1 /* XPRoomGiftBannerView.m in Sources */ = {isa = PBXBuildFile; fileRef = E83DB47C2746372300D8CBD1 /* XPRoomGiftBannerView.m */; };
|
||||||
E83DB481274649FB00D8CBD1 /* XPGiftBannerUserInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E83DB480274649FB00D8CBD1 /* XPGiftBannerUserInfoModel.m */; };
|
E83DB481274649FB00D8CBD1 /* XPGiftBannerUserInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E83DB480274649FB00D8CBD1 /* XPGiftBannerUserInfoModel.m */; };
|
||||||
@@ -1445,6 +1446,8 @@
|
|||||||
E839533B276A0CCD00CF2F24 /* XPMineCarTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineCarTableViewCell.m; sourceTree = "<group>"; };
|
E839533B276A0CCD00CF2F24 /* XPMineCarTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineCarTableViewCell.m; sourceTree = "<group>"; };
|
||||||
E839533D276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineNameplateTableViewCell.h; sourceTree = "<group>"; };
|
E839533D276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineNameplateTableViewCell.h; sourceTree = "<group>"; };
|
||||||
E839533E276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineNameplateTableViewCell.m; sourceTree = "<group>"; };
|
E839533E276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineNameplateTableViewCell.m; sourceTree = "<group>"; };
|
||||||
|
E83ABEF4280E9AD800322EE4 /* MessageContentUnSupportView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageContentUnSupportView.h; sourceTree = "<group>"; };
|
||||||
|
E83ABEF5280E9AD800322EE4 /* MessageContentUnSupportView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MessageContentUnSupportView.m; sourceTree = "<group>"; };
|
||||||
E83DB47827462C4500D8CBD1 /* XPGiftBigPrizeModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPGiftBigPrizeModel.h; sourceTree = "<group>"; };
|
E83DB47827462C4500D8CBD1 /* XPGiftBigPrizeModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPGiftBigPrizeModel.h; sourceTree = "<group>"; };
|
||||||
E83DB47927462C4500D8CBD1 /* XPGiftBigPrizeModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPGiftBigPrizeModel.m; sourceTree = "<group>"; };
|
E83DB47927462C4500D8CBD1 /* XPGiftBigPrizeModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPGiftBigPrizeModel.m; sourceTree = "<group>"; };
|
||||||
E83DB47B2746372300D8CBD1 /* XPRoomGiftBannerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomGiftBannerView.h; sourceTree = "<group>"; };
|
E83DB47B2746372300D8CBD1 /* XPRoomGiftBannerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomGiftBannerView.h; sourceTree = "<group>"; };
|
||||||
@@ -2780,6 +2783,8 @@
|
|||||||
18AAF3EF279EA59300CD7DAD /* MessageContentTextClickable.m */,
|
18AAF3EF279EA59300CD7DAD /* MessageContentTextClickable.m */,
|
||||||
E80B0732280D740600A79F63 /* MessageContentGuildView.h */,
|
E80B0732280D740600A79F63 /* MessageContentGuildView.h */,
|
||||||
E80B0733280D740600A79F63 /* MessageContentGuildView.m */,
|
E80B0733280D740600A79F63 /* MessageContentGuildView.m */,
|
||||||
|
E83ABEF4280E9AD800322EE4 /* MessageContentUnSupportView.h */,
|
||||||
|
E83ABEF5280E9AD800322EE4 /* MessageContentUnSupportView.m */,
|
||||||
);
|
);
|
||||||
path = Content;
|
path = Content;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -6264,6 +6269,7 @@
|
|||||||
9BEE3D142785884A00C83219 /* XPNobleCenterResidueView.m in Sources */,
|
9BEE3D142785884A00C83219 /* XPNobleCenterResidueView.m in Sources */,
|
||||||
E8EEB90C26FC5EBC007C6EBA /* XPMineUserInfoEditModel.m in Sources */,
|
E8EEB90C26FC5EBC007C6EBA /* XPMineUserInfoEditModel.m in Sources */,
|
||||||
18E7B31826F097E00064BC9B /* UserInfoModel.m in Sources */,
|
18E7B31826F097E00064BC9B /* UserInfoModel.m in Sources */,
|
||||||
|
E83ABEF6280E9AD800322EE4 /* MessageContentUnSupportView.m in Sources */,
|
||||||
E8AC721326F46ADD007D6E91 /* XPMineSettingViewController.m in Sources */,
|
E8AC721326F46ADD007D6E91 /* XPMineSettingViewController.m in Sources */,
|
||||||
18E7B32126F098650064BC9B /* UserInfoSkillVo.m in Sources */,
|
18E7B32126F098650064BC9B /* UserInfoSkillVo.m in Sources */,
|
||||||
E8AC722726F482A4007D6E91 /* XPMineFeedbackPresenter.m in Sources */,
|
E8AC722726F482A4007D6E91 /* XPMineFeedbackPresenter.m in Sources */,
|
||||||
|
@@ -10,11 +10,19 @@
|
|||||||
#import "AttachmentModel.h"
|
#import "AttachmentModel.h"
|
||||||
#import "MessageContentProtocol.h"
|
#import "MessageContentProtocol.h"
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@protocol MessageContentCustomViewDelegate <NSObject>
|
||||||
|
|
||||||
|
- (void)updateMessageSuccess:(NIMMessage *)message;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@interface MessageContentCustomView : UIView <MessageContentProtocol>
|
@interface MessageContentCustomView : UIView <MessageContentProtocol>
|
||||||
- (void)initSubViews;
|
- (void)initSubViews;
|
||||||
|
|
||||||
- (void)initSubViewConstraints;
|
- (void)initSubViewConstraints;
|
||||||
|
///代理
|
||||||
|
@property (nonatomic,weak) id<MessageContentCustomViewDelegate> delegate;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
#import "GuildMessageModel.h"
|
#import "GuildMessageModel.h"
|
||||||
#import "NSObject+MJExtension.h"
|
#import "NSObject+MJExtension.h"
|
||||||
#import "ThemeColor.h"
|
#import "ThemeColor.h"
|
||||||
|
#import "XCHUDTool.h"
|
||||||
|
#import "AccountInfoStorage.h"
|
||||||
|
|
||||||
#define MESSAGE_MAX_WIDTH 230
|
#define MESSAGE_MAX_WIDTH 230
|
||||||
#define MESSAGE_TEXT_PADDING 15
|
#define MESSAGE_TEXT_PADDING 15
|
||||||
@@ -36,6 +38,10 @@
|
|||||||
@property (nonatomic,strong) UIButton *resultButton;
|
@property (nonatomic,strong) UIButton *resultButton;
|
||||||
///同意
|
///同意
|
||||||
@property (nonatomic,strong) UIButton *agreeButton;
|
@property (nonatomic,strong) UIButton *agreeButton;
|
||||||
|
///消息的信息
|
||||||
|
@property (nonatomic,strong) GuildMessageModel *messageInfo;
|
||||||
|
@property (nonatomic,strong) AttachmentModel *attachment;
|
||||||
|
@property (nonatomic,strong) NIMMessage *message;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation MessageContentGuildView
|
@implementation MessageContentGuildView
|
||||||
@@ -82,6 +88,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)initSubViews {
|
- (void)initSubViews {
|
||||||
|
[super initSubViews];
|
||||||
[self addSubview:self.backView];
|
[self addSubview:self.backView];
|
||||||
|
|
||||||
[self.backView addSubview:self.stackView];
|
[self.backView addSubview:self.stackView];
|
||||||
@@ -98,6 +105,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)initSubViewConstraints {
|
- (void)initSubViewConstraints {
|
||||||
|
[super initSubViewConstraints];
|
||||||
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.edges.mas_equalTo(self).insets(UIEdgeInsetsMake(0, 0, 0, 0));
|
make.edges.mas_equalTo(self).insets(UIEdgeInsetsMake(0, 0, 0, 0));
|
||||||
make.width.mas_equalTo(MESSAGE_MAX_WIDTH);
|
make.width.mas_equalTo(MESSAGE_MAX_WIDTH);
|
||||||
@@ -141,17 +149,22 @@
|
|||||||
[self.resultButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
[self.resultButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
make.height.mas_equalTo(30);
|
make.height.mas_equalTo(30);
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)render:(NIMMessage *)message {
|
- (void)render:(NIMMessage *)message {
|
||||||
|
self.message = message;
|
||||||
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||||||
AttachmentModel * attach = obj.attachment;
|
AttachmentModel * attach = obj.attachment;
|
||||||
GuildMessageModel * info = [GuildMessageModel modelWithDictionary:attach.data];
|
self.attachment = attach;
|
||||||
|
GuildMessageModel * info;
|
||||||
|
if (message.localExt) {
|
||||||
|
info = [GuildMessageModel modelWithDictionary:message.localExt];
|
||||||
|
} else {
|
||||||
|
info = [GuildMessageModel modelWithDictionary:attach.data];
|
||||||
|
}
|
||||||
|
self.messageInfo = info;
|
||||||
self.titleLabel.text = info.layout.title.content;
|
self.titleLabel.text = info.layout.title.content;
|
||||||
self.titleLabel.font = [UIFont systemFontOfSize:info.layout.title.fontSize weight:info.layout.title.fontBold?UIFontWeightBold:UIFontWeightRegular];
|
self.titleLabel.font = [UIFont systemFontOfSize:info.layout.title.fontSize weight:info.layout.title.fontBold?UIFontWeightBold:UIFontWeightRegular];
|
||||||
|
|
||||||
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]init];
|
NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]init];
|
||||||
GuildMessageLayoutModel *layout = info.layout;
|
GuildMessageLayoutModel *layout = info.layout;
|
||||||
for (GuildMessageLayoutInfoModel *params in layout.contents) {
|
for (GuildMessageLayoutInfoModel *params in layout.contents) {
|
||||||
@@ -224,6 +237,12 @@
|
|||||||
[attr appendAttributedString:[self creatResultAttribute:@"消息已过期" textColor:UIColorRGBAlpha(0x333333, 0.6)]];
|
[attr appendAttributedString:[self creatResultAttribute:@"消息已过期" textColor:UIColorRGBAlpha(0x333333, 0.6)]];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case MessageGuildState_Processed:
|
||||||
|
{
|
||||||
|
self.resultButton.hidden= NO;
|
||||||
|
[attr appendAttributedString:[self creatResultAttribute:@"消息已处理" textColor:UIColorFromRGB(0xC6C6E9)]];
|
||||||
|
}
|
||||||
|
break;
|
||||||
case MessageGuildState_Untreated:
|
case MessageGuildState_Untreated:
|
||||||
{
|
{
|
||||||
self.agreeButton.hidden = NO;
|
self.agreeButton.hidden = NO;
|
||||||
@@ -247,9 +266,67 @@
|
|||||||
return attr;
|
return attr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Event Response
|
|
||||||
- (void)rejectButtonAction:(UIButton *)sender {
|
|
||||||
|
|
||||||
|
#pragma mark - Event Response
|
||||||
|
- (void)controllButtonAction:(UIButton *)sender {
|
||||||
|
NSRange recordRange = [self.messageInfo.url rangeOfString:@"recordId="];
|
||||||
|
NSString *recordId;
|
||||||
|
if (!NSEqualRanges(recordRange, NSMakeRange(NSNotFound, 0))) {
|
||||||
|
if (self.messageInfo.url.length > recordRange.location+recordRange.length) {
|
||||||
|
recordId = [self.messageInfo.url substringFromIndex:recordRange.location+recordRange.length];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (recordId.length > 0) {
|
||||||
|
NSMutableDictionary * params = [NSMutableDictionary dictionary];
|
||||||
|
[params setObject:recordId forKey:@"recordId"];
|
||||||
|
[params setObject:[AccountInfoStorage instance].getUid forKey:@"uid"];
|
||||||
|
///0拒绝 1同意
|
||||||
|
NSString * type = sender.tag == 1000? @"0" : @"1";
|
||||||
|
if (self.attachment.second == Custom_Message_Sub_Hall_Apply_Join || self.attachment.second == Custom_Message_Sub_Hall_Manager_Invite || self.attachment.second == Custom_Message_Sub_Hall_Apply_Exit) {
|
||||||
|
if (self.attachment.second != Custom_Message_Sub_Hall_Apply_Exit) {
|
||||||
|
[params setObject:type forKey:@"type"];
|
||||||
|
}
|
||||||
|
[XCHUDTool showLoading];
|
||||||
|
[HttpRequestHelper POST:self.messageInfo.url params:params success:^(BaseModel * _Nonnull data) {
|
||||||
|
[XCHUDTool hideHUD];
|
||||||
|
NSString *code = [NSString stringWithFormat:@"%@", data.data[@"code"]];
|
||||||
|
BOOL isExpired = [code isEqualToString:@"90121"];
|
||||||
|
BOOL isHandled = [code isEqualToString:@"90122"];
|
||||||
|
MessageGuildState state = MessageGuildState_Untreated;
|
||||||
|
if (isExpired) {
|
||||||
|
state = MessageGuildState_OutData;
|
||||||
|
} else if(isHandled) {
|
||||||
|
state = MessageGuildState_Processed;
|
||||||
|
} else {
|
||||||
|
state = sender.tag == 1000 ? MessageGuildState_Reject : MessageGuildState_Agree;
|
||||||
|
}
|
||||||
|
self.messageInfo.msgStatus = state;
|
||||||
|
self.message.localExt = [self.messageInfo model2dictionary];
|
||||||
|
[[NIMSDK sharedSDK].conversationManager updateMessage:self.message forSession:self.message.session completion:^(NSError * _Nullable error) {
|
||||||
|
if (self.delegate && [self.delegate respondsToSelector:@selector(updateMessageSuccess:)]) {
|
||||||
|
[self.delegate updateMessageSuccess:self.message];
|
||||||
|
}
|
||||||
|
}];
|
||||||
|
} failure:^(NSInteger resCode, NSString * _Nonnull message) {
|
||||||
|
[XCHUDTool hideHUD];
|
||||||
|
[XCHUDTool showErrorWithMessage:message];
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)agreeButtonActon:(UIButton *)sender {
|
||||||
|
NSRange recordRange = [self.messageInfo.url rangeOfString:@"recordId="];
|
||||||
|
NSString *recordId;
|
||||||
|
if (!NSEqualRanges(recordRange, NSMakeRange(NSNotFound, 0))) {
|
||||||
|
if (self.messageInfo.url.length > recordRange.location+recordRange.length) {
|
||||||
|
recordId = [self.messageInfo.url substringFromIndex:recordRange.location+recordRange.length];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recordId.length > 0) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Getters And Setters
|
#pragma mark - Getters And Setters
|
||||||
@@ -322,7 +399,8 @@
|
|||||||
_rejectButton.layer.borderColor = [ThemeColor appMainColor].CGColor;
|
_rejectButton.layer.borderColor = [ThemeColor appMainColor].CGColor;
|
||||||
_rejectButton.layer.borderWidth = 1;
|
_rejectButton.layer.borderWidth = 1;
|
||||||
[_rejectButton setBackgroundColor:[ThemeColor appCellBackgroundColor]];
|
[_rejectButton setBackgroundColor:[ThemeColor appCellBackgroundColor]];
|
||||||
[_rejectButton addTarget:self action:@selector(rejectButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
_rejectButton.tag = 1000;
|
||||||
|
[_rejectButton addTarget:self action:@selector(controllButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||||
}
|
}
|
||||||
return _rejectButton;
|
return _rejectButton;
|
||||||
}
|
}
|
||||||
@@ -330,7 +408,6 @@
|
|||||||
- (UIButton *)resultButton {
|
- (UIButton *)resultButton {
|
||||||
if (!_resultButton) {
|
if (!_resultButton) {
|
||||||
_resultButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
_resultButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||||
[_resultButton addTarget:self action:@selector(rejectButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
||||||
}
|
}
|
||||||
return _resultButton;
|
return _resultButton;
|
||||||
}
|
}
|
||||||
@@ -344,7 +421,8 @@
|
|||||||
_agreeButton.layer.masksToBounds = YES;
|
_agreeButton.layer.masksToBounds = YES;
|
||||||
_agreeButton.layer.cornerRadius = 15;
|
_agreeButton.layer.cornerRadius = 15;
|
||||||
[_agreeButton setBackgroundColor:[ThemeColor appMainColor]];
|
[_agreeButton setBackgroundColor:[ThemeColor appMainColor]];
|
||||||
[_agreeButton addTarget:self action:@selector(rejectButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
_agreeButton.tag = 1001;
|
||||||
|
[_agreeButton addTarget:self action:@selector(controllButtonAction:) forControlEvents:UIControlEventTouchUpInside];
|
||||||
}
|
}
|
||||||
return _agreeButton;
|
return _agreeButton;
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// MessageContentUnSupport.m
|
||||||
|
// xplan-ios
|
||||||
|
//
|
||||||
|
// Created by 冯硕 on 2022/4/19.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "MessageContentUnSupportView.h"
|
||||||
|
|
||||||
|
@implementation MessageContentUnSupportView
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Only override drawRect: if you perform custom drawing.
|
||||||
|
// An empty implementation adversely affects performance during animation.
|
||||||
|
- (void)drawRect:(CGRect)rect {
|
||||||
|
// Drawing code
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
@end
|
@@ -0,0 +1,16 @@
|
|||||||
|
//
|
||||||
|
// MessageContentUnSupport.h
|
||||||
|
// xplan-ios
|
||||||
|
//
|
||||||
|
// Created by 冯硕 on 2022/4/19.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import <UIKit/UIKit.h>
|
||||||
|
#import "MessageContentProtocol.h"
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@interface MessageContentUnSupportView : UIView<MessageContentProtocol>
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,69 @@
|
|||||||
|
//
|
||||||
|
// MessageContentUnSupport.m
|
||||||
|
// xplan-ios
|
||||||
|
//
|
||||||
|
// Created by 冯硕 on 2022/4/19.
|
||||||
|
//
|
||||||
|
|
||||||
|
#import "MessageContentUnSupportView.h"
|
||||||
|
///Third
|
||||||
|
#import <Masonry/Masonry.h>
|
||||||
|
///Tool
|
||||||
|
#import "ThemeColor.h"
|
||||||
|
|
||||||
|
#define MESSAGE_TEXT_PADDING 10
|
||||||
|
|
||||||
|
@interface MessageContentUnSupportView ()
|
||||||
|
///不支持的类型
|
||||||
|
@property (nonatomic,strong) UILabel *unSupportLabel;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation MessageContentUnSupportView
|
||||||
|
|
||||||
|
+ (CGFloat)measureHeight:(NIMMessage *)message {
|
||||||
|
NSString * messageText = @"暂不支持此种类型消息";
|
||||||
|
CGSize dstRect = CGSizeMake(CONTENT_WIDTH_MAX - MESSAGE_TEXT_PADDING * 2, MAXFLOAT);
|
||||||
|
CGFloat msgHeight = [messageText boundingRectWithSize:dstRect options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13]} context:nil].size.height;
|
||||||
|
return msgHeight + MESSAGE_TEXT_PADDING * 2 + CONTENT_PADDING_V_TOTAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)render:(NIMMessage *)message {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
- (instancetype)initWithFrame:(CGRect)frame {
|
||||||
|
self = [super initWithFrame:frame];
|
||||||
|
if (self) {
|
||||||
|
[self initSubViews];
|
||||||
|
[self initSubViewConstraints];
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Private Method
|
||||||
|
- (void)initSubViews {
|
||||||
|
[self addSubview:self.unSupportLabel];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)initSubViewConstraints {
|
||||||
|
[self.unSupportLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||||
|
make.edges.equalTo(self).with.insets(UIEdgeInsetsMake(MESSAGE_TEXT_PADDING, MESSAGE_TEXT_PADDING, MESSAGE_TEXT_PADDING, MESSAGE_TEXT_PADDING));
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Getters And Setters
|
||||||
|
- (UILabel *)unSupportLabel {
|
||||||
|
if (!_unSupportLabel) {
|
||||||
|
_unSupportLabel = [[UILabel alloc]initWithFrame:CGRectZero];
|
||||||
|
_unSupportLabel.preferredMaxLayoutWidth = CONTENT_WIDTH_MAX - MESSAGE_TEXT_PADDING * 2;
|
||||||
|
_unSupportLabel.textColor = ThemeColor.mainTextColor;
|
||||||
|
_unSupportLabel.text = @"暂不支持此种类型消息";
|
||||||
|
_unSupportLabel.textAlignment = NSTextAlignmentCenter;
|
||||||
|
_unSupportLabel.font = [UIFont systemFontOfSize:13];
|
||||||
|
}
|
||||||
|
return _unSupportLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@end
|
@@ -10,11 +10,19 @@
|
|||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
@protocol MessageCellDelegate <NSObject>
|
||||||
|
|
||||||
|
///更新消息成功
|
||||||
|
- (void)updateMessageSuccess:(NIMMessage *)message;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@interface MessageCell : UITableViewCell
|
@interface MessageCell : UITableViewCell
|
||||||
|
|
||||||
+ (CGFloat)measureHeight:(NIMMessage *)message;
|
+ (CGFloat)measureHeight:(NIMMessage *)message;
|
||||||
- (void)renderWithMessage:(NIMMessage *)message;
|
- (void)renderWithMessage:(NIMMessage *)message;
|
||||||
|
///代理
|
||||||
|
@property (nonatomic,weak) id<MessageCellDelegate> delegate;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#import "MessageContentCustomView.h"
|
#import "MessageContentCustomView.h"
|
||||||
#import "MessageContentGiftView.h"
|
#import "MessageContentGiftView.h"
|
||||||
#import "MessageContentGuildView.h"
|
#import "MessageContentGuildView.h"
|
||||||
|
#import "MessageContentUnSupportView.h"
|
||||||
|
|
||||||
#import "AttachmentModel.h"
|
#import "AttachmentModel.h"
|
||||||
#import "NetImageView.h"
|
#import "NetImageView.h"
|
||||||
@@ -21,7 +22,7 @@
|
|||||||
#import "XPMacro.h"
|
#import "XPMacro.h"
|
||||||
#import <Masonry/Masonry.h>
|
#import <Masonry/Masonry.h>
|
||||||
|
|
||||||
@interface MessageCell()
|
@interface MessageCell()<MessageContentCustomViewDelegate>
|
||||||
|
|
||||||
@property (nonatomic, assign) NIMMessageType messageType;
|
@property (nonatomic, assign) NIMMessageType messageType;
|
||||||
|
|
||||||
@@ -88,8 +89,6 @@
|
|||||||
|
|
||||||
- (void)initViews {
|
- (void)initViews {
|
||||||
self.backgroundColor = UIColor.clearColor;
|
self.backgroundColor = UIColor.clearColor;
|
||||||
self.leftAvatar.backgroundColor = UIColor.redColor;
|
|
||||||
self.rightAvatar.backgroundColor = UIColor.blueColor;
|
|
||||||
[self.contentView addSubview:self.leftAvatar];
|
[self.contentView addSubview:self.leftAvatar];
|
||||||
[self.contentView addSubview:self.rightAvatar];
|
[self.contentView addSubview:self.rightAvatar];
|
||||||
[self.contentView addSubview:self.messageBackground];
|
[self.contentView addSubview:self.messageBackground];
|
||||||
@@ -163,52 +162,45 @@
|
|||||||
[self.messageContent render:message];
|
[self.messageContent render:message];
|
||||||
}
|
}
|
||||||
|
|
||||||
///是否支持自定义的消息
|
|
||||||
- (BOOL)isSupportedCustomMessage:(AttachmentModel *)attachment {
|
|
||||||
int first = attachment.first;
|
|
||||||
int second = attachment.second;
|
|
||||||
if (first == CustomMessageType_Gift && second == Custom_Message_Sub_Gift_Send) {
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
return NO;
|
|
||||||
}
|
|
||||||
|
|
||||||
+ (CGFloat)customMessageMeasureHeight:(NIMMessage *)message {
|
+ (CGFloat)customMessageMeasureHeight:(NIMMessage *)message {
|
||||||
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||||||
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
||||||
switch (attachment.first) {
|
if (attachment.first == CustomMessageType_Gift) {
|
||||||
case CustomMessageType_Gift:
|
return [MessageContentGiftView measureHeight:message];
|
||||||
return [MessageContentGiftView measureHeight:message];
|
} else if(attachment.first == CustomMessageType_Secretary) {
|
||||||
break;
|
return [MessageContentTextClickable measureHeight:message];
|
||||||
case CustomMessageType_Secretary:
|
} else if(attachment.first == CustomMessageType_Hall) {
|
||||||
return [MessageContentTextClickable measureHeight:message];
|
return [MessageContentGuildView measureHeight:message];
|
||||||
case CustomMessageType_Hall:
|
} else {
|
||||||
return [MessageContentGuildView measureHeight:message];
|
return [MessageContentUnSupportView measureHeight:message];
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (MessageContentCustomView *)getCustomMessageContentView:(NIMMessage *)message {
|
- (UIView<MessageContentProtocol> *)getCustomMessageContentView:(NIMMessage *)message {
|
||||||
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||||||
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
||||||
switch (attachment.first) {
|
if (attachment.first == CustomMessageType_Gift) {
|
||||||
case CustomMessageType_Gift:
|
return [[MessageContentGiftView alloc] init];
|
||||||
return [[MessageContentGiftView alloc] init];
|
} else if(attachment.first == CustomMessageType_Secretary) {
|
||||||
break;
|
return [[MessageContentTextClickable alloc] init];
|
||||||
case CustomMessageType_Secretary:
|
} else if(attachment.first == CustomMessageType_Hall) {
|
||||||
return [[MessageContentTextClickable alloc] init];
|
MessageContentGuildView * hallView =[[MessageContentGuildView alloc] init];
|
||||||
break;
|
hallView.delegate = self;
|
||||||
case CustomMessageType_Hall:
|
return hallView;
|
||||||
return [[MessageContentGuildView alloc] init];
|
} else {
|
||||||
break;
|
return [[MessageContentUnSupportView alloc] init];
|
||||||
default:
|
|
||||||
return nil;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma mark - MessageContentCustomViewDelegate
|
||||||
|
- (void)updateMessageSuccess:(NIMMessage *)message {
|
||||||
|
if (self.delegate && [self.delegate respondsToSelector:@selector(updateMessageSuccess:)]) {
|
||||||
|
[self.delegate updateMessageSuccess:message];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - Getters And Setters
|
||||||
- (NetImageView *)leftAvatar {
|
- (NetImageView *)leftAvatar {
|
||||||
if (!_leftAvatar) {
|
if (!_leftAvatar) {
|
||||||
NetImageConfig * config = [[NetImageConfig alloc] init];
|
NetImageConfig * config = [[NetImageConfig alloc] init];
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
///Tool
|
///Tool
|
||||||
#import "XCCurrentVCStackManager.h"
|
#import "XCCurrentVCStackManager.h"
|
||||||
|
|
||||||
@interface SessionViewController ()<MessageProtocol, UITableViewDelegate, UITableViewDataSource, NIMChatManagerDelegate, NIMConversationManagerDelegate, NIMMediaManagerDelegate, SendMessageViewDelegate, XPSessionMessageHeadViewDelegate>
|
@interface SessionViewController ()<MessageProtocol, UITableViewDelegate, UITableViewDataSource, NIMChatManagerDelegate, NIMConversationManagerDelegate, NIMMediaManagerDelegate, SendMessageViewDelegate, XPSessionMessageHeadViewDelegate, MessageCellDelegate>
|
||||||
|
|
||||||
@property (nonatomic, strong) NIMSession * session;
|
@property (nonatomic, strong) NIMSession * session;
|
||||||
@property (nonatomic, strong) NSMutableArray<NIMMessage *> * messages;
|
@property (nonatomic, strong) NSMutableArray<NIMMessage *> * messages;
|
||||||
@@ -153,6 +153,12 @@
|
|||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma mark - MessageCellDelegate
|
||||||
|
- (void)updateMessageSuccess:(NIMMessage *)message {
|
||||||
|
if ([message.session.sessionId isEqualToString:self.session.sessionId]) {
|
||||||
|
[self.sessionTableView reloadData];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark - UITableViewDataSource
|
#pragma mark - UITableViewDataSource
|
||||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||||
@@ -168,6 +174,7 @@
|
|||||||
if (cell == nil) {
|
if (cell == nil) {
|
||||||
cell = [[MessageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([MessageCell class])];
|
cell = [[MessageCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([MessageCell class])];
|
||||||
}
|
}
|
||||||
|
cell.delegate = self;
|
||||||
[cell renderWithMessage:[self.messages objectAtIndex:indexPath.row]];
|
[cell renderWithMessage:[self.messages objectAtIndex:indexPath.row]];
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user