Files
peko-ios/YuMi/Modules/YMMessage/View/Session/MSSessionPublicChatHallVC.m

1078 lines
46 KiB
Mathematica
Raw Normal View History

2024-05-07 19:40:21 +08:00
//
// MSSessionPublicChatHallVC.m
// YuMi
//
// Created by duoban on 2024/5/6.
//
#import "MSSessionPublicChatHallVC.h"
#import <IQKeyboardManager/IQKeyboardManager.h>
#import <TZImagePickerController/TZImagePickerController.h>
#import <MJRefresh/MJRefresh.h>
#import <Photos/Photos.h>
///Tool
#import "XCCurrentVCStackManager.h"
#import "NIMMessageMaker.h"
#import "UITableView+NIMScrollToBottom.h"
#import "QEmotionHelper.h"
#import "QKeyboardManager.h"
#import "ClientConfig.h"
///Model
#import "QPhotoImageModel.h"
#import "AttachmentModel.h"
#import "MessageBaseModel.h"
2024-05-10 14:12:47 +08:00
#import "MessageHeadlinesTextModel.h"
2024-05-07 19:40:21 +08:00
#import "MessageAudioModel.h"
#import "MessageTimeModel.h"
#import "MessageImageModel.h"
#import "MessageUnSupportModel.h"
#import "MessageTipsModel.h"
2024-05-10 14:12:47 +08:00
#import "XPMessageRemoteExtModel.h"
#import "MSSessionPublicChatHalImageModel.h"
#import "MSSessionPublicChatHalImageCell.h"
2024-05-17 11:27:36 +08:00
#import "MSSessionPublicChatHalRightTextCell.h"
2024-05-07 19:40:21 +08:00
///View
2024-05-10 14:12:47 +08:00
#import "MSSessionPublicChatHalTextCell.h"
2024-05-07 19:40:21 +08:00
#import "MessageCell.h"
#import "XPMineUserInfoViewController.h"
#import "SessionNavView.h"
#import "QInputBarView.h"
#import "QKeyboardManager.h"
#import "QEmotionBoardView.h"
#import "QinputPhotoView.h"
#import "SessionUserInfoTableViewCell.h"
///P
#import "MessagePresenter.h"
#import "MessageProtocol.h"
#import "Api+Message.h"
#import "XPRoomMessageConstant.h"
2024-05-10 14:12:47 +08:00
#import "MSSessionPublicChatHallHeadView.h"
#import "MSSessionReleaseHeadlinesView.h"
#import "MessageHeadlinesModel.h"
#import "Api+Mine.h"
#import "XPIncomeRecordModel.h"
#import "XPCandyTreeInsufficientBalanceView.h"
#import "XPIAPRechargeViewController.h"
2024-05-11 10:21:48 +08:00
#import "Api+Mine.h"
2024-05-17 11:27:36 +08:00
#import "MSSessionPublicChatHalIRightmageCell.h"
2024-05-10 14:12:47 +08:00
@interface MSSessionPublicChatHallVC ()<SessionNavViewDelegate,MessageProtocol, UITableViewDelegate, UITableViewDataSource, NIMChatManagerDelegate, NIMConversationManagerDelegate, NIMMediaManagerDelegate, MessageCellDelegate, TZImagePickerControllerDelegate, SessionNavViewDelegate, QInputBarViewDelegate, QInputBarViewDataSource,InputBoardDataSource ,InputBoardDelegate , QEmotionBoardViewDelegate, QinputPhotoViewDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate,MSSessionReleaseHeadlinesViewDelegate,XPCandyTreeInsufficientBalanceViewDelegate>
2024-05-07 19:40:21 +08:00
@property (nonatomic, strong) NIMSession * session;
@property (nonatomic, strong) NSMutableArray<MessageBaseModel *> * messages;
@property (nonatomic,strong) SessionNavView *sessionNavView;
@property (nonatomic, strong) UITableView * sessionTableView;
@property (nonatomic,strong) NIMMessage *lastMessage;
@property(nonatomic,strong)QInputBarView *inputBarView;
@property(nonatomic,strong)QKeyboardManager *keyboardManager;
@property (nonatomic, strong) UserInfoModel *userInfo;
2024-05-10 14:12:47 +08:00
@property(nonatomic,strong) MSSessionPublicChatHallHeadView *headView;
2024-05-07 19:40:21 +08:00
///
@property (nonatomic,strong) QinputPhotoView *photoView;
///
@property (nonatomic,strong) NSArray *phototArray;
@property(nonatomic,assign) BOOL isLoadHistoryMessage;
@property(nonatomic,copy) NSString *publicChatMessageRoomId;
2024-05-10 14:12:47 +08:00
@property(nonatomic,copy) NSString *releaseCoins;
@property(nonatomic,copy) NSString *myCoins;
@property(nonatomic,strong) UIButton *sendBtn;
2024-05-07 19:40:21 +08:00
@end
@implementation MSSessionPublicChatHallVC
- (BOOL)isHiddenNavBar {
return YES;
}
- (void)dealloc {
[[NIMSDK sharedSDK].chatManager removeDelegate:self];
[[NSNotificationCenter defaultCenter] removeObserver:self];
2024-05-11 10:21:48 +08:00
2024-05-10 14:12:47 +08:00
[self.presenter exitNIMRoom:self.publicChatMessageRoomId];
2024-05-07 19:40:21 +08:00
}
- (MessagePresenter *)createPresenter {
return [[MessagePresenter alloc] init];
}
2024-05-10 14:12:47 +08:00
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[Api requestRecordIncome:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if(code == 200){
XPIncomeRecordModel *model = [XPIncomeRecordModel modelWithDictionary:data.data];
self.myCoins = @(model.diamonds).stringValue;
}
}];
}
2024-05-07 19:40:21 +08:00
- (void)viewDidLoad {
[super viewDidLoad];
2024-05-10 14:12:47 +08:00
self.view.backgroundColor = [UIColor whiteColor];
2024-05-07 19:40:21 +08:00
self.isLoadHistoryMessage = YES;
[self initViews];
[self initLayout];
[self initHeaderAndFooterRrfresh];
[IQKeyboardManager sharedManager].enable = NO;
[IQKeyboardManager sharedManager].enableAutoToolbar = NO;
2024-07-05 17:15:16 +08:00
2024-05-07 19:40:21 +08:00
[[NIMSDK sharedSDK].chatManager addDelegate:self];
}
- (void)initHeaderAndFooterRrfresh {
[self initData];
}
#pragma mark -
- (void)loadAlbumPhotos {
2024-07-05 17:15:16 +08:00
[YYUtility checkAssetsLibrayAvailable:^{} denied:^{} restriction:^{}];
2024-05-07 19:40:21 +08:00
}
#pragma mark - cell
- (MessageBaseModel *)modeTransformMessage:(NIMMessage *)message {
MessageBaseModel * model;
switch (message.messageType) {
case NIMMessageTypeText:
2024-05-10 14:12:47 +08:00
model = [[MessageHeadlinesTextModel alloc] initWithMessage:message];
2024-05-07 19:40:21 +08:00
break;
case NIMMessageTypeImage:
2024-05-10 14:12:47 +08:00
model = [[MSSessionPublicChatHalImageModel alloc] initWithMessage:message];
2024-05-07 19:40:21 +08:00
break;
2024-05-10 14:12:47 +08:00
case NIMMessageTypeCustom:
model = [self modelTransformCustomMessage:message];
2024-05-07 19:40:21 +08:00
break;
default:
model = [[MessageUnSupportModel alloc] initWithMessage:message];
break;
}
return model;
}
2024-05-10 14:12:47 +08:00
- (MessageBaseModel *)modelTransformCustomMessage:(NIMMessage *)message {
MessageBaseModel * model;
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_Chat_Hall_Headlinesn && attachment.second == Custom_Message_Sub_Chat_Hall_Headlinesn) {
model = [[MessageHeadlinesModel alloc] initWithMessage:message];
MSSessionPublicChatHallTopModel *topModel = [MSSessionPublicChatHallTopModel modelWithDictionary:attachment.data];
2024-07-08 17:06:10 +08:00
[self getPublicChatHallTopTextSuccess:topModel];
2024-05-10 14:12:47 +08:00
}
return model;
}
-(void)setTime:(MSSessionPublicChatHallTopModel *)topModel{
2024-05-11 10:21:48 +08:00
// NSInteger time = topModel.endTime/1000 - topModel.startTime/1000;
// [self performSelector:@selector(setHeadViewData) withObject:nil afterDelay:time];
2024-05-10 14:12:47 +08:00
}
-(void)setHeadViewData{
self.headView.topModel = nil;
}
-(BOOL)isCanAddMsg:(NIMMessage *)message{
BOOL isCanAdd = NO;
2024-05-15 09:54:15 +08:00
NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[self.userInfo.partitionId]];
if(![message.session.sessionId isEqualToString:publicChatRoomId]){
return NO;
}
2024-05-10 14:12:47 +08:00
switch (message.messageType) {
case NIMMessageTypeText:
isCanAdd = YES;
break;
case NIMMessageTypeImage:
isCanAdd = YES;
break;
case NIMMessageTypeCustom:
{
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_Chat_Hall_Headlinesn && attachment.second == Custom_Message_Sub_Chat_Hall_Headlinesn) {
2024-05-11 19:41:06 +08:00
MSSessionPublicChatHallTopModel *topModel = [MSSessionPublicChatHallTopModel modelWithDictionary:attachment.data];
2024-07-08 17:06:10 +08:00
[self getPublicChatHallTopTextSuccess:topModel];
2024-05-11 19:41:06 +08:00
if(topModel.recordStatus == 0){
isCanAdd = YES;
}
2024-05-10 14:12:47 +08:00
}
}
break;
default:
break;
}
return isCanAdd;
}
2024-05-07 19:40:21 +08:00
- (UINavigationController *)getKeyWindowNav {
if ([XCCurrentVCStackManager shareManager].getCurrentVC) {
return [XCCurrentVCStackManager shareManager].getCurrentVC.navigationController;
}
return self.navigationController;
}
- (MessageBaseModel *)createTimeMessage:(NIMMessage *)message {
MessageTimeModel * timeModel = [[MessageTimeModel alloc] initWithMessage:message];
timeModel.time = [self timestrToTimeSecond:[NSString stringWithFormat:@"%f", message.timestamp]];
return timeModel;
}
- (NSString *)timestrToTimeSecond:(NSString *)timeStr {//timestr
NSTimeInterval interval = [timeStr doubleValue];
NSDate *date = [NSDate dateWithTimeIntervalSince1970:interval];
return [NSDate stringFromDate:date];
}
- (void)addTimeMessage:(NIMMessage *)message {
2024-05-10 14:12:47 +08:00
if ([self isCanAddMsg:message] == NO){return;}
2024-05-07 19:40:21 +08:00
if (self.messages.count > 0) {
NIMMessage * lastMessage = self.messages.lastObject.message;
CGFloat dur = message.timestamp - lastMessage.timestamp;
if (dur / 60 > 5) {
NIMMessage * newMessage = [[NIMMessage alloc] init];
newMessage.timestamp = message.timestamp;
[newMessage setValue:self.session forKey:@"session"];
MessageBaseModel * timeModel = [self createTimeMessage:newMessage];
[self.messages addObject:timeModel];
}
}
}
#pragma mark - Private Method
- (void)initInputView {
// frameaddBottomInputBarViewframe
// ViewTextFieldViewController
QInputBarViewConfiguration *inputBarViewConfiguration = [QInputBarViewConfiguration defaultInputBarViewConfiguration];
2024-05-10 14:12:47 +08:00
inputBarViewConfiguration.voiceButtonHidden = YES;//
2024-05-07 19:40:21 +08:00
inputBarViewConfiguration.extendButtonHidden = YES;//
inputBarViewConfiguration.toolHidden = NO;
2024-05-10 14:12:47 +08:00
inputBarViewConfiguration.giftButtonHidden = YES;
2024-05-07 19:40:21 +08:00
inputBarViewConfiguration.cameraButtonHidden = NO;
inputBarViewConfiguration.photoButtonHidden = NO;
_inputBarView = [[QInputBarView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,inputBarViewConfiguration.inputViewHeight)];
2024-05-10 14:12:47 +08:00
2024-05-07 19:40:21 +08:00
[_inputBarView setupWithConfiguration:inputBarViewConfiguration];
_inputBarView.delegate = self;
//keyboard
_keyboardManager = [[QKeyboardManager alloc] initWithViewController:self];
_keyboardManager.dataSource = self;
//addBottomInputBarViewdelegatedelegate
_keyboardManager.delegate = self;
2024-05-10 14:12:47 +08:00
2024-05-07 19:40:21 +08:00
[_keyboardManager addBottomInputBarView:_inputBarView belowViewController:NO];
//
[_keyboardManager bindTextView:_inputBarView.inputTextView];
}
- (void)initViews {
[self.view addSubview:self.sessionNavView];
2024-05-10 14:12:47 +08:00
[self.view addSubview:self.headView];
2024-05-07 19:40:21 +08:00
[self.view addSubview:self.sessionTableView];
2024-05-10 14:12:47 +08:00
[self.view addSubview:self.sendBtn];
2024-05-07 19:40:21 +08:00
[self initInputView];
}
- (void)initLayout {
[self.sessionNavView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(kNavigationHeight);
make.leading.top.trailing.mas_equalTo(self.view);
}];
2024-05-10 14:12:47 +08:00
[self.headView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.sessionNavView.mas_bottom).mas_offset(kGetScaleWidth(0));
make.leading.trailing.equalTo(self.view).inset(kGetScaleWidth(0));
2024-07-08 17:06:10 +08:00
make.height.mas_greaterThanOrEqualTo(kGetScaleWidth(101));
2024-05-10 14:12:47 +08:00
}];
[self.sendBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(kGetScaleWidth(96));
make.height.mas_equalTo(kGetScaleWidth(80));
make.trailing.mas_equalTo(-kGetScaleWidth(0));
make.top.equalTo(self.headView.mas_bottom).mas_offset(kGetScaleWidth(255));
2024-05-10 14:12:47 +08:00
}];
}
-(void)clickReleaseBtnAction{
MSSessionReleaseHeadlinesView *releaseView = [[MSSessionReleaseHeadlinesView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
releaseView.golds = self.releaseCoins;
releaseView.myCoins = self.myCoins;
releaseView.delegate = self;
[TTPopup popupView:releaseView style:TTPopupStyleAlert];
}
-(void)sendHeadlineBtnAction{
[self clickReleaseBtnAction];
2024-05-07 19:40:21 +08:00
}
- (void)viewDidLayoutSubviews{
}
- (void)initData {
2024-05-10 14:12:47 +08:00
self.sessionNavView.title = YMLocalizedString(@"MSSessionPublicChatHallVC0");
[self showLoading];
[self.presenter getUserInfoWithUid:[AccountInfoStorage instance].getUid];
[self.presenter getPublicChatHallTopTextPayMoney];
[self.presenter getPublicChatHallTopText];
2024-05-07 19:40:21 +08:00
}
- (BOOL)isExistMessages:(NIMMessage *)message{
BOOL isExist = NO;
NIMMessage * model;
for (NIMMessage *item in self.messages.reverseObjectEnumerator.allObjects) {
if ([item isKindOfClass:[NIMMessage class]] && [item.messageId isEqualToString:message.messageId]) {
model = item;
isExist = YES;
break;
}
}
if (model) {
model = message;
}
return isExist;
}
2024-05-10 14:12:47 +08:00
- (void)sendPublicChatHallTopTextSuccess{
[Api requestRecordIncome:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if(code == 200){
XPIncomeRecordModel *model = [XPIncomeRecordModel modelWithDictionary:data.data];
self.myCoins = @(model.diamonds).stringValue;
}
}];
}
2024-05-07 19:40:21 +08:00
2024-05-10 14:12:47 +08:00
-(void)getPublicChatHallTopTextPayMoneySuccess:(NSString *)money{
self.releaseCoins = money;
}
- (void)getPublicChatHallTopTextSuccess:(MSSessionPublicChatHallTopModel *)model{
self.headView.topModel = model;
2024-07-08 17:06:10 +08:00
2024-07-11 18:57:34 +08:00
if (model == nil || model.recordStatus == 1) {
2024-07-08 17:06:10 +08:00
[self.headView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.sessionNavView.mas_bottom).mas_offset(kGetScaleWidth(0));
make.leading.trailing.equalTo(self.view).inset(kGetScaleWidth(0));
make.height.mas_equalTo(kGetScaleWidth(101));
}];
} else {
CGFloat height = [UILabel getLabelHeightWithText:model.content
width:KScreenWidth - 29 - 13
font:kFontMedium(14)];
height = height + 47.5 + 13;
[self.headView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.sessionNavView.mas_bottom).mas_offset(kGetScaleWidth(0));
make.leading.trailing.equalTo(self.view).inset(kGetScaleWidth(0));
make.height.mas_equalTo(kGetScaleWidth(height));
}];
}
2024-05-10 14:12:47 +08:00
}
2024-05-07 19:40:21 +08:00
///
2024-05-10 14:12:47 +08:00
- (void)onGetUserInfoSuccess:(UserInfoModel *)userInfo {
2024-05-07 19:40:21 +08:00
_userInfo = userInfo;
self.sessionNavView.userInfo = userInfo;
2024-05-10 14:12:47 +08:00
self.publicChatMessageRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[_userInfo.partitionId]];
2024-05-07 19:40:21 +08:00
if(self.publicChatMessageRoomId.length > 0){
_session = [NIMSession session:self.publicChatMessageRoomId type:NIMSessionTypeChatroom];
[self.presenter enterNIMRoom:self.publicChatMessageRoomId user:userInfo];
2024-05-15 09:54:15 +08:00
}else{
[self hideHUD];
2024-05-07 19:40:21 +08:00
}
}
///
-(void)enterPublicChatHallSuccess:(NIMChatroom *)chatRoom{
[self handleFetchHistoryMessage];
}
///
-(void)enterPublicChatHallFail:(NSInteger)code{
2024-05-15 09:54:15 +08:00
[self hideHUD];
2024-05-07 19:40:21 +08:00
}
- (void)handleFetchHistoryMessage {
NSString *roomId = self.publicChatMessageRoomId;
NIMHistoryMessageSearchOption *option = [[NIMHistoryMessageSearchOption alloc] init];
option.limit = 100;
2024-05-10 14:12:47 +08:00
option.startTime = 0;
2024-05-07 19:40:21 +08:00
option.order = NIMMessageSearchOrderAsc;
2024-05-10 14:12:47 +08:00
option.messageTypes = @[@(NIMMessageTypeText),@(NIMMessageTypeImage)];
2024-05-07 19:40:21 +08:00
[[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId option:option result:^(NSError * _Nullable error, NSArray<NIMMessage *> * _Nullable messages) {
if(error != nil){
2024-07-08 17:06:10 +08:00
self.isLoadHistoryMessage = NO;
2024-05-07 19:40:21 +08:00
}
2024-05-10 14:12:47 +08:00
//50
if (messages.count == 100) {
NIMHistoryMessageSearchOption *option = [[NIMHistoryMessageSearchOption alloc] init];
option.limit = 100;
option.order = NIMMessageSearchOrderDesc;
option.messageTypes = @[@(NIMMessageTypeText),@(NIMMessageTypeImage)];
[[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId option:option result:^(NSError * _Nullable error, NSArray<NIMMessage *> * _Nullable messages) {
if(error != nil){
self.isLoadHistoryMessage = NO;
}
[self hideHUD];
dispatch_async(dispatch_get_main_queue(), ^{///线
if (self.messages.count > kRoomMessageMaxLength) {
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
NSArray *needRemoveMsgArray = [self.messages objectsAtIndexes:set];
[self.messages removeObjectsInArray:needRemoveMsgArray];
}else{
for (NIMMessage *message in messages.reverseObjectEnumerator) {
[self addTimeMessage:message];
if (message.isDeleted) {
continue;
}
if ([self isCanAddMsg:message]){
[self addTimeMessage:message];
MessageBaseModel * model = [self modeTransformMessage:message];
[self.messages addObject:model];
}
}
}
//
[self.sessionTableView reloadData];
//
if(self.messages.count > 0){
NSIndexPath *ip = [NSIndexPath indexPathForRow:self.messages.count-1 inSection:0]; //
[self.sessionTableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionBottom animated:YES]; //
}
});
}];
return;
2024-05-07 19:40:21 +08:00
}
2024-05-11 19:41:06 +08:00
2024-05-07 19:40:21 +08:00
dispatch_async(dispatch_get_main_queue(), ^{///线
2024-05-11 19:41:06 +08:00
[self hideHUD];
2024-05-07 19:40:21 +08:00
if (self.messages.count > kRoomMessageMaxLength) {
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
NSArray *needRemoveMsgArray = [self.messages objectsAtIndexes:set];
[self.messages removeObjectsInArray:needRemoveMsgArray];
}else{
for (NIMMessage *message in messages) {
[self addTimeMessage:message];
if (message.isDeleted) {
continue;
}
2024-05-10 14:12:47 +08:00
if ([self isCanAddMsg:message]){
[self addTimeMessage:message];
MessageBaseModel * model = [self modeTransformMessage:message];
[self.messages addObject:model];
}
2024-05-07 19:40:21 +08:00
}
}
//
[self.sessionTableView reloadData];
//
if(self.messages.count > 0){
NSIndexPath *ip = [NSIndexPath indexPathForRow:self.messages.count-1 inSection:0]; //
[self.sessionTableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionBottom animated:YES]; //
}
});
2024-05-10 14:12:47 +08:00
2024-05-07 19:40:21 +08:00
}];
2024-05-10 14:12:47 +08:00
2024-05-07 19:40:21 +08:00
}
#pragma mark - MessageCellDelegate
- (void)updateMessageSuccess:(NIMMessage *)message {
if ([message.session.sessionId isEqualToString:self.session.sessionId]) {
[self.sessionTableView reloadData];
}
}
- (void)didTapAvatar:(NSString *)uid {
2024-07-08 17:06:10 +08:00
XPMineUserInfoViewController * infoVC = [[XPMineUserInfoViewController alloc] init];
infoVC.uid = uid.integerValue;
[[self getKeyWindowNav] pushViewController:infoVC animated:YES];
2024-05-07 19:40:21 +08:00
}
2024-05-10 14:12:47 +08:00
#pragma mark - MSSessionReleaseHeadlinesViewDelegate
- (void)releaseHeadlinesWithText:(NSString *)text{
if (self.myCoins.integerValue < self.releaseCoins.integerValue){
XPCandyTreeInsufficientBalanceView *balanceView = [[XPCandyTreeInsufficientBalanceView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
balanceView.delegate = self;
[self. view addSubview:balanceView];
return;
}
[self.presenter sendPublicChatHallTopTextWithcontent:text];
}
-(void)payBalanceAction{
XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init];
webVC.type = @"4";
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
}
2024-05-07 19:40:21 +08:00
#pragma mark - SessionNavViewDelegate
- (void)sessionNavView:(SessionNavView *)view didClickBack:(UIButton *)sender {
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
2024-07-05 17:15:16 +08:00
return self.messages.count;
2024-05-07 19:40:21 +08:00
}
- (nonnull UITableViewCell *)tableView:(nonnull UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
2024-07-05 17:15:16 +08:00
MessageBaseModel * message = [self.messages xpSafeObjectAtIndex:indexPath.row];
2024-05-17 11:27:36 +08:00
MessageHeadlinesTextModel * textModel = (MessageHeadlinesTextModel *)message;
2024-07-08 17:06:10 +08:00
switch (message.messageType) {
case SessionMessageType_Text: {
if(textModel.isSelf){
MSSessionPublicChatHalRightTextCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MSSessionPublicChatHalRightTextCell class])
forIndexPath:indexPath];
[cell render:message];
return cell;
} else {
MSSessionPublicChatHalTextCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MSSessionPublicChatHalTextCell class])
forIndexPath:indexPath];
[cell render:message];
return cell;
}
2024-05-17 11:27:36 +08:00
}
2024-07-08 17:06:10 +08:00
break;
case SessionMessageType_Image: {
if(textModel.isSelf){
MSSessionPublicChatHalIRightmageCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MSSessionPublicChatHalIRightmageCell class])
forIndexPath:indexPath];
[cell render:message];
return cell;
} else {
MSSessionPublicChatHalImageCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MSSessionPublicChatHalImageCell class])
forIndexPath:indexPath];
[cell render:message];
return cell;
}
}
break;
default:{
NSString * identifier = [message cellContent:message];
///cell
MessageCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {
/// identifier
[tableView registerClass:[MessageCell class] forCellReuseIdentifier:identifier];
/// cell
cell = [tableView dequeueReusableCellWithIdentifier:identifier];
}
cell.delegate = self;
[cell renderWithMessage:[self.messages xpSafeObjectAtIndex:indexPath.row]];
[cell renderWithMessage:[self.messages xpSafeObjectAtIndex:indexPath.row]];
2024-05-17 11:27:36 +08:00
return cell;
}
2024-07-08 17:06:10 +08:00
break;
2024-07-05 17:15:16 +08:00
}
2024-05-07 19:40:21 +08:00
}
2024-05-17 11:27:36 +08:00
2024-05-10 14:12:47 +08:00
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
MessageBaseModel *m = [self.messages xpSafeObjectAtIndex:indexPath.row];
2024-05-10 14:12:47 +08:00
NSLog(@"%@",m.message.remoteExt);
}
2024-05-07 19:40:21 +08:00
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
[self.keyboardManager hideAllBoardView];
}
#pragma mark - NIMChatManagerDelegate
- (void)onRecvMessages:(NSArray<NIMMessage *> *)messages {
if(!messages.count){
return;
}
2024-07-08 17:06:10 +08:00
2024-05-07 19:40:21 +08:00
if (self.messages.count > kRoomMessageMaxLength) {
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
NSArray *needRemoveMsgArray = [self.messages objectsAtIndexes:set];
[self.messages removeObjectsInArray:needRemoveMsgArray];
}
for (NIMMessage *message in messages) {
2024-05-15 17:35:51 +08:00
if (![self isCanAddMsg:message]){
return;
}
2024-07-08 17:06:10 +08:00
// [self addTimeMessage:message];
2024-05-07 19:40:21 +08:00
if (message.isDeleted) {
continue;
}
2024-05-10 14:12:47 +08:00
if ([self isCanAddMsg:message]){
[self addTimeMessage:message];
MessageBaseModel * model = [self modeTransformMessage:message];
[self.messages addObject:model];
}
2024-05-07 19:40:21 +08:00
}
[self.sessionTableView reloadData];
2024-05-10 14:12:47 +08:00
if(self.messages.count > 0){
2024-07-08 17:06:10 +08:00
NSIndexPath *ip = [NSIndexPath indexPathForRow:self.messages.count-1
inSection:0]; //
[self.sessionTableView scrollToRowAtIndexPath:ip
atScrollPosition:UITableViewScrollPositionBottom
animated:YES]; //
2024-05-10 14:12:47 +08:00
}
2024-05-07 19:40:21 +08:00
}
- (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error {
if (message.session.sessionType != NIMSessionTypeChatroom) {
return;
}
2024-05-15 17:35:51 +08:00
if (![self isCanAddMsg:message]){
return;
}
2024-05-07 19:40:21 +08:00
[self addTimeMessage:message];
2024-05-15 17:35:51 +08:00
2024-05-07 19:40:21 +08:00
if (![self isExistMessages:message]) {
2024-05-10 14:12:47 +08:00
if ([self isCanAddMsg:message]){
[self addTimeMessage:message];
MessageBaseModel * model = [self modeTransformMessage:message];
[self.messages addObject:model];
}
2024-05-07 19:40:21 +08:00
}
2024-07-05 17:15:16 +08:00
2024-05-07 19:40:21 +08:00
if (message.yidunAntiSpamRes) {
NSDictionary * spamRes = message.yidunAntiSpamRes.toJSONObject;
2024-07-05 17:15:16 +08:00
id spamResExt = ((NSString *)spamRes[@"ext"]).toJSONObject;
NSDictionary *antispamDic = nil;
if ([spamResExt isKindOfClass:[NSArray class]]) {
antispamDic = [spamResExt xpSafeObjectAtIndex:0];
} else if ([spamResExt isKindOfClass:[NSDictionary class]]) {
antispamDic = spamResExt[@"antispam"];
}
NSDictionary *realAntiDic = nil;
if ([[antispamDic allKeys] containsObject:@"antispam"]) {
realAntiDic = antispamDic[@"antispam"];;
} else {
realAntiDic = antispamDic;
}
if (realAntiDic) {
NSInteger suggestion = [realAntiDic[@"suggestion"] integerValue];
if (suggestion == 2) {
NSDictionary * dic = @{@"suggestion": @"2"};
message.localExt = dic;
[[NIMSDK sharedSDK].conversationManager updateMessage:message forSession:self.session completion:nil];
[self showErrorToast:YMLocalizedString(@"XPRoomViewController10")];
}
2024-05-07 19:40:21 +08:00
}
}
2024-07-05 17:15:16 +08:00
2024-05-07 19:40:21 +08:00
[self.sessionTableView reloadData];
2024-05-10 14:12:47 +08:00
if(self.messages.count > 0){
NSIndexPath *ip = [NSIndexPath indexPathForRow:self.messages.count-1 inSection:0]; //
[self.sessionTableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionBottom animated:YES]; //
}
2024-05-07 19:40:21 +08:00
}
- (void)sendTextMessage:(NSString *)text {
2024-07-05 17:15:16 +08:00
NIMMessage *message = [NIMMessageMaker msgWithText:text];
message.remoteExt = [self getRemoteExt];
[[[NIMSDK sharedSDK] chatManager] sendMessage:message toSession:self.session error:nil];
2024-05-07 19:40:21 +08:00
}
2024-07-08 17:06:10 +08:00
2024-05-10 14:12:47 +08:00
-(NSDictionary *)getRemoteExt{
UserInfoModel *userInfo = self.userInfo;
XPMessageRemoteExtModel *extModel = [[XPMessageRemoteExtModel alloc] init];
extModel.defUser = userInfo.defUser;
extModel.erbanNo = userInfo.erbanNo;
extModel.carName = userInfo.carName;
extModel.inRoomNameplatePic = userInfo.nameplatePic;
extModel.inRoomNameplateWord = userInfo.nameplateWord;
extModel.isCustomWord = userInfo.isCustomWord;
extModel.charmUrl = userInfo.userLevelVo.charmUrl;
extModel.experLevelSeq = userInfo.userLevelVo.experLevelSeq;
extModel.experUrl = userInfo.userLevelVo.expertUrl;
2024-05-10 14:12:47 +08:00
extModel.newUser = userInfo.newUser;
extModel.vipIcon = userInfo.userVipInfoVO.vipIcon;
extModel.androidBubbleUrl = userInfo.androidBubbleUrl;
extModel.iosBubbleUrl = userInfo.iosBubbleUrl;
extModel.fromSayHelloChannel = userInfo.fromSayHelloChannel;
2024-07-08 17:06:10 +08:00
extModel.avatar = userInfo.avatar;
extModel.nick = userInfo.nick;
extModel.headWearType = [userInfo isHeadWearSVGA] ? 1 : 0;
2024-07-08 17:06:10 +08:00
NSString *headwearUrl= userInfo.headwearEffect.length > 0 ? userInfo.headwearEffect : userInfo.headwearPic;
extModel.headWearUrl = headwearUrl;
2024-05-10 14:12:47 +08:00
NSMutableDictionary *remoteExt = [NSMutableDictionary dictionaryWithObject:extModel.model2dictionary forKey:[AccountInfoStorage instance].getUid];
2024-05-07 19:40:21 +08:00
2024-05-10 14:12:47 +08:00
return remoteExt;
2024-05-07 19:40:21 +08:00
}
2024-05-10 14:12:47 +08:00
2024-05-07 19:40:21 +08:00
#pragma mark - TZImagePickerControllerDelegate
- (void)imagePickerController:(TZImagePickerController *)picker didFinishPickingPhotos:(NSArray<UIImage *> *)photos sourceAssets:(NSArray *)assets isSelectOriginalPhoto:(BOOL)isSelectOriginalPhoto infos:(NSArray<NSDictionary *> *)infos {
2024-07-05 17:15:16 +08:00
@kWeakify(self);
2024-05-07 19:40:21 +08:00
[photos enumerateObjectsUsingBlock:^(UIImage * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
2024-07-05 17:15:16 +08:00
@kStrongify(self);
2024-05-07 19:40:21 +08:00
if (obj) {
2024-07-05 17:15:16 +08:00
NIMMessage * message = [NIMMessageMaker msgWithImage:obj];
message.remoteExt = [self getRemoteExt];
//
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:self.session error:nil];
2024-05-07 19:40:21 +08:00
}
}];
}
#pragma mark - SessionUserInfoTableViewCellDelegate
- (void)sessionUserInfoTableViewCell:(SessionUserInfoTableViewCell *)view showUserInfoVC:(UserInfoModel *)userInfo {
[self didTapAvatar:[NSString stringWithFormat:@"%ld", userInfo.uid]];
}
#pragma mark - InputBoardDataSource
//@return Viewframe
- (UIView *)keyboardManagerExtendBoardView:(QKeyboardManager *)keyboardManager {
UIView *boardView = [UIView new];
boardView.backgroundColor = UIColor.clearColor;
return boardView;
}
//@return Viewframe
- (UIView *)keyboardManagerEmotionBoardView:(QKeyboardManager *)keyboardManager {
QEmotionBoardView *emotionView = [[QEmotionBoardView alloc] init];
QEmotionHelper *faceManager = [QEmotionHelper sharedEmotionHelper];
emotionView.emotions = faceManager.emotionArray;
emotionView.delegate = self;
if (@available(iOS 11.0, *)) {
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
emotionView.backgroundColor = [UIColor colorNamed:@"q_input_extend_bg" inBundle:bundle compatibleWithTraitCollection:nil];
} else {
emotionView.backgroundColor = [UIColor colorWithRed:(246)/255.0f green:(246)/255.0f blue:(246)/255.0f alpha:1];
}
return emotionView;
}
//@return Viewframe
- (UIView *)keyboardManagerPhotoBoardView:(QKeyboardManager *)keyboardManager{
QinputPhotoView *emotionView = [[QinputPhotoView alloc] init];
self.photoView = emotionView;
emotionView.photoList = self.phototArray;
emotionView.delegate = self;
emotionView.backgroundColor = [UIColor colorWithRed:(246)/255.0f green:(246)/255.0f blue:(246)/255.0f alpha:1];
return emotionView;
}
//@return View
- (CGFloat)keyboardManagerEmotionBoardHeight:(QKeyboardManager *)keyboardManager {
return 294;
}
//@return View
- (CGFloat)keyboardManagerExtendBoardHeight:(QKeyboardManager *)keyboardManager {
return 174;
}
- (CGFloat)keyboardManagerPhotoBoardHeight:(QKeyboardManager *)keyboardManager {
return 184 + kSafeAreaBottomHeight;
}
//
- (void)inputBarView:(QInputBarView *)inputBarView onEmotionButtonClick:(UIButton *)emotionSwitchButton {
if (emotionSwitchButton.isSelected) {
[_keyboardManager switchToEmotionBoardKeyboard];
} else {
_inputBarView.inputTextView.text = @"";
[_inputBarView textViewBecomeFirstResponder];
}
}
- (void)inputBarView:(QInputBarView *)inputBarView onVoiceSwitchButtonClick:(UIButton *)voiceSwitchButton {
if (!voiceSwitchButton.isSelected) {
_inputBarView.inputTextView.text = @"";
[_inputBarView textViewBecomeFirstResponder];
} else {
[_keyboardManager hideAllBoardView];
}
}
- (void)inputBarView:(QInputBarView *)inputBarView onGiftButtonClick:(UIButton *)emotionSwitchButton {
[_keyboardManager hideAllBoardView];
}
- (void)inputBarView:(QInputBarView *)inputBarView onCameraButtonClick:(UIButton *)emotionSwitchButton {
[_keyboardManager hideAllBoardView];
@kWeakify(self);
[YYUtility checkCameraAvailable:^{
@kStrongify(self);
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.allowsEditing = YES;
[self presentViewController:imagePicker animated:YES completion:NULL];
} denied:^{
@kStrongify(self);
[self showNotPhoto:YMLocalizedString(@"SessionViewController19") content:YMLocalizedString(@"SessionViewController10")];
} restriction:^{
@kStrongify(self);
[self showNotPhoto:YMLocalizedString(@"SessionViewController19") content:YMLocalizedString(@"SessionViewController12")];
}];
2024-07-05 17:15:16 +08:00
2024-05-07 19:40:21 +08:00
}
- (void)inputBarView:(QInputBarView *)inputBarView onPhototButtonClick:(UIButton *)emotionSwitchButton {
if (emotionSwitchButton.isSelected) {
@kWeakify(self);
[YYUtility checkAssetsLibrayAvailable:^{
@kStrongify(self);
[TZImagePickerConfig sharedInstance].allowPickingImage = YES;
dispatch_async(dispatch_get_global_queue(0, 0), ^{
[[TZImageManager manager] getCameraRollAlbumWithFetchAssets:NO completion:^(TZAlbumModel *model) {
2024-07-05 17:15:16 +08:00
[[TZImageManager manager] getAssetsFromFetchResult:model.result completion:^(NSArray<TZAssetModel *> *models) {
dispatch_async(dispatch_get_main_queue(), ^{
NSMutableArray * array = [NSMutableArray array];
if (models.count > 40) {
for (int i = 0; i < 40; i++) {
TZAssetModel * assets = [models objectAtIndex:i];
QPhotoImageModel * infor = [[QPhotoImageModel alloc] init];
infor.isOrigin = NO;
infor.assetInfo = assets;
[array addObject:infor];
2024-05-07 19:40:21 +08:00
}
2024-07-05 17:15:16 +08:00
} else {
for (int i = 0; i < models.count; i++) {
TZAssetModel * assets = [models objectAtIndex:i];
QPhotoImageModel * infor = [[QPhotoImageModel alloc] init];
infor.isOrigin = NO;
infor.assetInfo = assets;
[array addObject:infor];
2024-05-07 19:40:21 +08:00
}
2024-07-05 17:15:16 +08:00
}
self.phototArray = array;
if (self.phototArray.count > 0) {
self.photoView.photoList = self.phototArray;
[self.keyboardManager switchToPhotoBoardKeyboard];
} else {
TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:self];
imagePickerVc.modalPresentationStyle = UIModalPresentationOverFullScreen;
imagePickerVc.allowPickingVideo = NO;
imagePickerVc.allowTakeVideo = NO;
imagePickerVc.naviBgColor = [DJDKMIMOMColor appCellBackgroundColor];
imagePickerVc.naviTitleColor = [DJDKMIMOMColor mainTextColor];
imagePickerVc.barItemTextColor = [DJDKMIMOMColor mainTextColor];
[self presentViewController:imagePickerVc animated:YES completion:nil];
}
});
}];
2024-05-07 19:40:21 +08:00
}];
});
} denied:^{
@kStrongify(self);
[self showNotPhoto:YMLocalizedString(@"SessionViewController20") content:YMLocalizedString(@"SessionViewController14")];
} restriction:^{
@kStrongify(self);
[self showNotPhoto:YMLocalizedString(@"SessionViewController20") content:YMLocalizedString(@"SessionViewController16")];
}];
} else {
[_keyboardManager hideAllBoardView];
_inputBarView.inputTextView.text = @"";
[_inputBarView textViewResignFirstResponder];
}
2024-07-05 17:15:16 +08:00
2024-05-07 19:40:21 +08:00
}
- (void)showNotPhoto:(NSString *)title content:(NSString *)content {
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.title = title;
config.message = content;
2024-07-05 17:15:16 +08:00
2024-05-07 19:40:21 +08:00
[TTPopup alertWithConfig:config confirmHandler:^{
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
}];
}
} cancelHandler:^{
}];
}
#pragma mark - InputBoardDelegate
- (void)keyboardManager:(QKeyboardManager *)keyboardManager onWholeInputViewHeightDidChange:(CGFloat)wholeInputViewHeight reason:(WholeInputViewHeightDidChangeReason)reason {
[UIView animateWithDuration:0.2 animations:^{
2024-05-10 14:12:47 +08:00
if(self.messages.count > 0){
NSIndexPath *ip = [NSIndexPath indexPathForRow:self.messages.count-1 inSection:0]; //
[self.sessionTableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionBottom animated:NO]; //
}
2024-05-07 19:40:21 +08:00
[self.sessionTableView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.leading.trailing.mas_equalTo(self.view);
2024-05-10 14:12:47 +08:00
make.top.mas_equalTo(self.headView.mas_bottom);
2024-05-07 19:40:21 +08:00
make.bottom.mas_equalTo(self.view).offset(-wholeInputViewHeight - kSafeAreaBottomHeight);
}];
}];
}
#pragma mark - QEmotionBoardViewDelegate
/**
*
* @param index `emotions`
* @param emotion `QMUIEmotion`
*/
- (void)emotionView:(QEmotionBoardView *)emotionView didSelectEmotion:(QEmotion *)emotion atIndex:(NSInteger)index {
//😊
2024-05-17 15:06:46 +08:00
UIFont *font = [UIFont systemFontOfSize:17.5];
NSTextAttachment * emotionAtt = [[NSTextAttachment alloc] init];
UIImage *iconImage = emotion.image;
emotionAtt.bounds = CGRectMake(0, roundf(font.capHeight - emotion.image.size.width)/2.f, emotion.image.size.width, emotion.image.size.height);
emotionAtt.image = iconImage;
emotionAtt.imageName = emotion.displayName;
NSAttributedString *emotionAttribute = [NSMutableAttributedString attributedStringWithAttachment:(NSTextAttachment *)emotionAtt];
2024-07-05 17:15:16 +08:00
2024-05-17 15:06:46 +08:00
[_inputBarView insertEmotionAttributedString:emotionAttribute];
2024-05-07 19:40:21 +08:00
}
//
- (void)emotionViewDidSelectDeleteButton:(QEmotionBoardView *)emotionView {
if (![_inputBarView deleteEmotion]){
//
[_inputBarView.inputTextView deleteBackward];
}
}
//
- (void)emotionViewDidSelectSendButton:(QEmotionBoardView *)emotionView {
[self sendTextMessage:[_inputBarView textViewInputNormalText]];
_inputBarView.inputTextView.text = @"";
[_keyboardManager hideAllBoardView];
2024-07-05 17:15:16 +08:00
2024-05-07 19:40:21 +08:00
}
/**
*
* @param inputNormalText "害~你好啊[微笑]"
*/
- (void)inputBarView:(QInputBarView *)inputBarView onKeyboardSendClick:(NSString *)inputNormalText {
[self sendTextMessage:inputNormalText];
_inputBarView.inputTextView.text = @"";
[_keyboardManager hideAllBoardView];
}
#pragma mark - QinputPhotoViewDelegate
- (void)qinputPhotoView:(QinputPhotoView *)view didClickSend:(NSArray *)photoList {
for (int i = 0; i < photoList.count; i++) {
QPhotoImageModel * imageInfo = [photoList xpSafeObjectAtIndex:i];
2024-05-07 19:40:21 +08:00
UIImage * image;
if (view.isOrigin) {
image = imageInfo.originImage;
} else {
image = imageInfo.compressImage;
}
if (image == nil){
continue;
}
//
NIMMessage * message = [NIMMessageMaker msgWithImage:image];
2024-05-10 14:12:47 +08:00
message.remoteExt = [self getRemoteExt];
2024-05-07 19:40:21 +08:00
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:self.session error:nil];
[view resetChoosePhotos];
}
}
- (void)qinputPhotoView:(QinputPhotoView *)view didClickPhoto:(UIButton *)sender {
TZImagePickerController *imagePickerVc = [[TZImagePickerController alloc] initWithMaxImagesCount:1 delegate:self];
imagePickerVc.modalPresentationStyle = UIModalPresentationOverFullScreen;
imagePickerVc.allowPickingVideo = NO;
imagePickerVc.allowTakeVideo = NO;
imagePickerVc.naviBgColor = [DJDKMIMOMColor appCellBackgroundColor];
imagePickerVc.naviTitleColor = [DJDKMIMOMColor mainTextColor];
imagePickerVc.barItemTextColor = [DJDKMIMOMColor mainTextColor];
[self presentViewController:imagePickerVc animated:YES completion:nil];
}
#pragma mark - UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *selectedPhoto = [info objectForKey:UIImagePickerControllerEditedImage];
if (selectedPhoto) {
if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
UIImageWriteToSavedPhotosAlbum(selectedPhoto, nil, nil, nil);
}
2024-07-05 17:15:16 +08:00
// NIMAntiSpamOption *option = [[NIMAntiSpamOption alloc]init];
// option.yidunEnabled = YES;
// option.businessId = @"e9da8bd5c76da23d5e37f87e5ab1f5e9";
NIMMessage * message = [NIMMessageMaker msgWithImage:selectedPhoto];
message.remoteExt = [self getRemoteExt];
// message.antiSpamOption = option;
//
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:self.session error:nil];
2024-05-07 19:40:21 +08:00
}
[picker dismissViewControllerAnimated:YES completion:^{}];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
[picker dismissViewControllerAnimated:YES completion:^{
}];
}
#pragma mark - Getters And Setters
- (NSArray<MessageBaseModel *> *)messages {
if (!_messages) {
_messages = [[NSMutableArray alloc] init];
}
return _messages;
}
#pragma mark - Event Response
- (void)closeKeyBoard {
[self.view endEditing:YES];
[self.inputBarView textViewResignFirstResponder];
}
- (UITableView *)sessionTableView {
if (!_sessionTableView) {
_sessionTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_sessionTableView.delegate = self;
_sessionTableView.dataSource = self;
_sessionTableView.backgroundColor = UIColor.clearColor;
_sessionTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_sessionTableView.showsVerticalScrollIndicator = NO;
2024-05-10 14:12:47 +08:00
[_sessionTableView registerClass:[MSSessionPublicChatHalTextCell class] forCellReuseIdentifier:NSStringFromClass([MSSessionPublicChatHalTextCell class])];
[_sessionTableView registerClass:[MSSessionPublicChatHalImageCell class] forCellReuseIdentifier:NSStringFromClass([MSSessionPublicChatHalImageCell class])];
2024-05-17 11:27:36 +08:00
[_sessionTableView registerClass:[MSSessionPublicChatHalRightTextCell class] forCellReuseIdentifier:NSStringFromClass([MSSessionPublicChatHalRightTextCell class])];
[_sessionTableView registerClass:[MSSessionPublicChatHalIRightmageCell class] forCellReuseIdentifier:NSStringFromClass([MSSessionPublicChatHalIRightmageCell class])];
2024-05-10 14:12:47 +08:00
2024-05-07 19:40:21 +08:00
if (@available(iOS 11.0, *)) {
_sessionTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
}
return _sessionTableView;
}
- (SessionNavView *)sessionNavView {
if (!_sessionNavView) {
_sessionNavView = [[SessionNavView alloc] init];
_sessionNavView.delegate = self;
_sessionNavView.isPublicChatHall = YES;
}
return _sessionNavView;
}
2024-05-10 14:12:47 +08:00
- (MSSessionPublicChatHallHeadView *)headView{
if(!_headView){
_headView = [[MSSessionPublicChatHallHeadView alloc]initWithFrame:CGRectZero];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickReleaseBtnAction)];
[_headView addGestureRecognizer:tap];
}
return _headView;
}
- (UIButton *)sendBtn{
if(!_sendBtn){
_sendBtn = [UIButton new];
[_sendBtn setBackgroundImage:[UIImage getLanguageImage:@"ms_message_send_headline_bnt"] forState:UIControlStateNormal];
[_sendBtn addTarget:self action:@selector(sendHeadlineBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
return _sendBtn;
}
2024-05-07 19:40:21 +08:00
@end