|
|
@@ -1,4 +1,4 @@
|
|
|
- //
|
|
|
+//
|
|
|
// MessageViewController.m
|
|
|
// 千模
|
|
|
//
|
|
|
@@ -16,13 +16,13 @@
|
|
|
#import "NIMKitLocationPoint.h"
|
|
|
#import "NIMLocationViewController.h"
|
|
|
|
|
|
-NSString *const NIMDemoEventNameOpenSnapPicture = @"NIMDemoEventNameOpenSnapPicture";
|
|
|
+NSString *const NIMDemoEventNameOpenSnapPicture = @"NIMDemoEventNameOpenSnapPicture";
|
|
|
NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPicture";
|
|
|
|
|
|
-@interface MessageViewController ()<NIMMessageObject>
|
|
|
-@property (nonatomic,strong) NTESSessionConfig *sessionConfig;
|
|
|
-@property (nonatomic,strong) UIView * bgblackView;//黑色背景
|
|
|
-@property (nonatomic,strong) UIView * bgwhiteView;//下拉选项背景
|
|
|
+@interface MessageViewController () <NIMMessageObject>
|
|
|
+@property(nonatomic, strong) NTESSessionConfig *sessionConfig;
|
|
|
+@property(nonatomic, strong) UIView *bgblackView;//黑色背景
|
|
|
+@property(nonatomic, strong) UIView *bgwhiteView;//下拉选项背景
|
|
|
@property(nonatomic, assign) BOOL hideTabBarWhenPop;
|
|
|
|
|
|
@end
|
|
|
@@ -39,54 +39,54 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
[super viewDidLayoutSubviews];
|
|
|
if ([@"system" isEqualToString:self.session.sessionId]) {
|
|
|
self.sessionInputView.hidden = YES;
|
|
|
- [self.tableView setFrame: CGRectMake(0, self.navigationController.navigationBar.frame.size.height, ScreenWidth, self.view.frame.size.height - self.navigationController.navigationBar.frame.size.height)];
|
|
|
+ [self.tableView setFrame:CGRectMake(0, self.navigationController.navigationBar.frame.size.height, ScreenWidth, self.view.frame.size.height - self.navigationController.navigationBar.frame.size.height)];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-- (void)setupNav{
|
|
|
+- (void)setupNav {
|
|
|
[super setUpTitleView];
|
|
|
- if ([UIScreen spt_currentScreenMode]== LESScreenModeIPhoneX){
|
|
|
- self.view.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight+34);
|
|
|
+ if ([UIScreen spt_currentScreenMode] == LESScreenModeIPhoneX) {
|
|
|
+ self.view.frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight + 34);
|
|
|
}
|
|
|
- UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
btn.frame = CGRectMake(0, 0, 40, 40);
|
|
|
[btn setImage:[UIImage imageNamed:@"fanhui2"] forState:UIControlStateNormal];
|
|
|
- btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
|
|
|
+ btn.imageEdgeInsets = UIEdgeInsetsMake(0, -20, 0, 0);
|
|
|
[btn addTarget:self action:@selector(backClick) forControlEvents:UIControlEventTouchUpInside];
|
|
|
UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
|
|
|
- UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
|
|
|
+ UIBarButtonItem *nagetiveSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
|
|
|
nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整
|
|
|
self.navigationItem.leftBarButtonItems = @[nagetiveSpacer, leftItem];
|
|
|
-
|
|
|
+
|
|
|
UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
rightBtn.frame = CGRectMake(0, 0, 40, 40);
|
|
|
[rightBtn setImage:[UIImage imageNamed:@"more"] forState:UIControlStateNormal];
|
|
|
- rightBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, -20);
|
|
|
+ rightBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, -20);
|
|
|
[rightBtn addTarget:self action:@selector(rightBtnClick) forControlEvents:UIControlEventTouchUpInside];
|
|
|
UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
|
|
|
- UIBarButtonItem *nagetiveRightSpacer = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
|
|
|
+ UIBarButtonItem *nagetiveRightSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
|
|
|
// nagetiveSpacer.width = -12;//这个值可以根据自己需要自己调整
|
|
|
self.navigationItem.rightBarButtonItems = @[rightItem, nagetiveRightSpacer];
|
|
|
}
|
|
|
|
|
|
--(void)rightBtnClick{
|
|
|
-
|
|
|
+- (void)rightBtnClick {
|
|
|
+
|
|
|
if (!_bgblackView) {
|
|
|
- _bgblackView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
|
|
|
+ _bgblackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
|
|
|
_bgblackView.backgroundColor = RGBA(0, 0, 0, 0.6);
|
|
|
_bgblackView.hidden = YES;
|
|
|
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickHiddenSiftView)];
|
|
|
+ UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickHiddenSiftView)];
|
|
|
[_bgblackView addGestureRecognizer:tap];
|
|
|
[self.view addSubview:_bgblackView];
|
|
|
-
|
|
|
- self.bgwhiteView = [[UIView alloc]initWithFrame:CGRectMake(ScreenWidth-100, -100, 100, 100)];
|
|
|
+
|
|
|
+ self.bgwhiteView = [[UIView alloc] initWithFrame:CGRectMake(ScreenWidth - 100, -100, 100, 100)];
|
|
|
self.bgwhiteView.backgroundColor = [UIColor whiteColor];
|
|
|
self.bgwhiteView.layer.shadowColor = RGB(200, 200, 200).CGColor;
|
|
|
self.bgwhiteView.layer.shadowOffset = CGSizeMake(0, 1);
|
|
|
self.bgwhiteView.layer.shadowOpacity = 0.5;
|
|
|
[_bgblackView addSubview:self.bgwhiteView];
|
|
|
-
|
|
|
- UIButton *reportButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 100, 50)];
|
|
|
+
|
|
|
+ UIButton *reportButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
|
|
|
reportButton.backgroundColor = [UIColor whiteColor];
|
|
|
[reportButton setImage:[UIImage imageNamed:@"report"] forState:UIControlStateNormal];
|
|
|
[reportButton setTitle:@"举报" forState:UIControlStateNormal];
|
|
|
@@ -97,8 +97,8 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
[reportButton setTitleEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
|
|
|
[reportButton addTarget:self action:@selector(clickReport) forControlEvents:UIControlEventTouchUpInside];
|
|
|
[self.bgwhiteView addSubview:reportButton];
|
|
|
-
|
|
|
- UIButton *screenButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 50, 100, 50)];
|
|
|
+
|
|
|
+ UIButton *screenButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 50, 100, 50)];
|
|
|
screenButton.backgroundColor = [UIColor whiteColor];
|
|
|
[screenButton setImage:[UIImage imageNamed:@"screen"] forState:UIControlStateNormal];
|
|
|
[screenButton setTitle:@"屏蔽" forState:UIControlStateNormal];
|
|
|
@@ -109,79 +109,79 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
[screenButton setTitleEdgeInsets:UIEdgeInsetsMake(10, 10, 10, 10)];
|
|
|
[screenButton addTarget:self action:@selector(clickScreen) forControlEvents:UIControlEventTouchUpInside];
|
|
|
[self.bgwhiteView addSubview:screenButton];
|
|
|
-
|
|
|
- UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 50, 100, 0.5)];
|
|
|
+
|
|
|
+ UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0, 50, 100, 0.5)];
|
|
|
line.backgroundColor = RGB(151, 151, 151);
|
|
|
[self.bgwhiteView addSubview:line];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
_bgblackView.hidden = NO;
|
|
|
-
|
|
|
+
|
|
|
[UIView animateWithDuration:0.25 animations:^{
|
|
|
-
|
|
|
- self.bgwhiteView.frame = CGRectMake(ScreenWidth-100, 64, 100, 100);
|
|
|
- } completion:^(BOOL finished) {
|
|
|
-
|
|
|
+
|
|
|
+ self.bgwhiteView.frame = CGRectMake(ScreenWidth - 100, 64, 100, 100);
|
|
|
+ } completion:^(BOOL finished) {
|
|
|
+
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
//点击隐藏
|
|
|
--(void)clickHiddenSiftView{
|
|
|
-
|
|
|
+- (void)clickHiddenSiftView {
|
|
|
+
|
|
|
[UIView animateWithDuration:0.25 animations:^{
|
|
|
-
|
|
|
- self.bgwhiteView.frame = CGRectMake(ScreenWidth-100, -100, 100, 100);
|
|
|
-
|
|
|
- } completion:^(BOOL finished) {
|
|
|
+
|
|
|
+ self.bgwhiteView.frame = CGRectMake(ScreenWidth - 100, -100, 100, 100);
|
|
|
+
|
|
|
+ } completion:^(BOOL finished) {
|
|
|
_bgblackView.hidden = YES;
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
//举报
|
|
|
--(void)clickReport{
|
|
|
-
|
|
|
+- (void)clickReport {
|
|
|
+
|
|
|
UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:@"是否确定举报该用户" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
|
|
|
- UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
-
|
|
|
+ UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {
|
|
|
+
|
|
|
[self postReport];
|
|
|
}];
|
|
|
[alertVc addAction:cancelAction];
|
|
|
[alertVc addAction:sureAction];
|
|
|
[self presentViewController:alertVc animated:YES completion:nil];
|
|
|
-
|
|
|
+
|
|
|
[self clickHiddenSiftView];
|
|
|
}
|
|
|
|
|
|
-- (void)postReport{
|
|
|
- NSString *str = [NSString stringWithFormat:@"%@/memberInfo?action=report&accuserpk=%@&appelleepk=%@&reason=%@",PublicUrl,[ModelUser user].pk,self.session.sessionId,@""];
|
|
|
- [[AHHttpManager sharedManager]POST:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] parameters:nil success:^(id responseObject) {
|
|
|
-
|
|
|
- if ([[responseObject objectForKey:@"msg"]isEqualToString:@"success"]) {
|
|
|
-
|
|
|
+- (void)postReport {
|
|
|
+ NSString *str = [NSString stringWithFormat:@"%@/memberInfo?action=report&accuserpk=%@&appelleepk=%@&reason=%@", PublicUrl, [ModelUser user].pk, self.session.sessionId, @""];
|
|
|
+ [[AHHttpManager sharedManager] POST:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] parameters:nil success:^(id responseObject) {
|
|
|
+
|
|
|
+ if ([[responseObject objectForKey:@"msg"] isEqualToString:@"success"]) {
|
|
|
+
|
|
|
UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:@"举报成功,我们将会在24小时之内给出回复" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
- UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
-
|
|
|
+ UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {
|
|
|
+
|
|
|
}];
|
|
|
[alertVc addAction:sureAction];
|
|
|
[self presentViewController:alertVc animated:YES completion:nil];
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
[MBProgressHUD showTextHUD:@"超时" inView:self.view hideAfterDelay:1];
|
|
|
}
|
|
|
- } failure:^(NSError *error) {
|
|
|
- NSLog(@"error = %@",error);
|
|
|
+ } failure:^(NSError *error) {
|
|
|
+ NSLog(@"error = %@", error);
|
|
|
[MBProgressHUD showTextHUD:@"超时" inView:self.view hideAfterDelay:1];
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
//屏蔽
|
|
|
--(void)clickScreen{
|
|
|
-
|
|
|
+- (void)clickScreen {
|
|
|
+
|
|
|
UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:@"是否确定屏蔽该用户" preferredStyle:UIAlertControllerStyleAlert];
|
|
|
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
|
|
|
- UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
-
|
|
|
- [[NIMSDK sharedSDK].userManager addToBlackList:self.session.sessionId completion:^(NSError * _Nullable error) {
|
|
|
+ UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) {
|
|
|
+
|
|
|
+ [[NIMSDK sharedSDK].userManager addToBlackList:self.session.sessionId completion:^(NSError *_Nullable error) {
|
|
|
if (!error) {
|
|
|
[MBProgressHUD showTextHUD:@"已屏蔽该用户" inView:self.view hideAfterDelay:1];
|
|
|
}
|
|
|
@@ -190,7 +190,7 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
[alertVc addAction:cancelAction];
|
|
|
[alertVc addAction:sureAction];
|
|
|
[self presentViewController:alertVc animated:YES completion:nil];
|
|
|
-
|
|
|
+
|
|
|
[self clickHiddenSiftView];
|
|
|
}
|
|
|
|
|
|
@@ -233,12 +233,11 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
//}
|
|
|
|
|
|
#pragma mark - Cell事件
|
|
|
-- (BOOL)onTapCell:(NIMKitEvent *)event
|
|
|
-{
|
|
|
+
|
|
|
+- (BOOL)onTapCell:(NIMKitEvent *)event {
|
|
|
BOOL handled = [super onTapCell:event];
|
|
|
NSString *eventName = event.eventName;
|
|
|
- if ([eventName isEqualToString:NIMKitEventNameTapContent])
|
|
|
- {
|
|
|
+ if ([eventName isEqualToString:NIMKitEventNameTapContent]) {
|
|
|
NIMMessage *message = event.messageModel.message;
|
|
|
NSDictionary *actions = [self cellActions];
|
|
|
NSString *value = actions[@(message.messageType)];
|
|
|
@@ -249,15 +248,11 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
handled = YES;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- else if([eventName isEqualToString:NIMKitEventNameTapLabelLink])
|
|
|
- {
|
|
|
+ } else if ([eventName isEqualToString:NIMKitEventNameTapLabelLink]) {
|
|
|
NSString *link = event.data;
|
|
|
[self openSafari:link];
|
|
|
handled = YES;
|
|
|
- }
|
|
|
- else if([eventName isEqualToString:NIMDemoEventNameOpenSnapPicture])
|
|
|
- {
|
|
|
+ } else if ([eventName isEqualToString:NIMDemoEventNameOpenSnapPicture]) {
|
|
|
// NIMCustomObject *object = event.messageModel.message.messageObject;
|
|
|
// NTESSnapchatAttachment *attachment = (NTESSnapchatAttachment *)object.attachment;
|
|
|
// if(attachment.isFired){
|
|
|
@@ -266,9 +261,7 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
// UIView *sender = event.data;
|
|
|
// self.currentSingleSnapView = [NTESGalleryViewController alertSingleSnapViewWithMessage:object.message baseView:sender];
|
|
|
// handled = YES;
|
|
|
- }
|
|
|
- else if([eventName isEqualToString:NIMDemoEventNameCloseSnapPicture])
|
|
|
- {
|
|
|
+ } else if ([eventName isEqualToString:NIMDemoEventNameCloseSnapPicture]) {
|
|
|
// //点击很快的时候可能会触发两次查看,所以这里不管有没有查看过 先强直销毁掉
|
|
|
// NIMCustomObject *object = event.messageModel.message.messageObject;
|
|
|
// UIView *senderView = event.data;
|
|
|
@@ -290,9 +283,7 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
// [[NSFileManager defaultManager] removeItemAtPath:attachment.filepath error:nil];
|
|
|
// self.currentSingleSnapView = nil;
|
|
|
// handled = YES;
|
|
|
- }
|
|
|
- else if([eventName isEqualToString:NIMKitEventNameTapRobotLink])
|
|
|
- {
|
|
|
+ } else if ([eventName isEqualToString:NIMKitEventNameTapRobotLink]) {
|
|
|
NSString *link = event.data;
|
|
|
[self openSafari:link];
|
|
|
handled = YES;
|
|
|
@@ -305,21 +296,21 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
}
|
|
|
|
|
|
#pragma mark - Cell Actions
|
|
|
-- (void)showImage:(NIMMessage *)message
|
|
|
-{
|
|
|
+
|
|
|
+- (void)showImage:(NIMMessage *)message {
|
|
|
NIMImageObject *object = message.messageObject;
|
|
|
NTESGalleryItem *item = [[NTESGalleryItem alloc] init];
|
|
|
- item.thumbPath = [object thumbPath];
|
|
|
- item.imageURL = [object url];
|
|
|
- item.name = [object displayName];
|
|
|
- item.itemId = [message messageId];
|
|
|
- item.size = [object size];
|
|
|
-
|
|
|
- NIMSession *session = [self isMemberOfClass:[MessageViewController class]]? self.session : nil;
|
|
|
-
|
|
|
+ item.thumbPath = [object thumbPath];
|
|
|
+ item.imageURL = [object url];
|
|
|
+ item.name = [object displayName];
|
|
|
+ item.itemId = [message messageId];
|
|
|
+ item.size = [object size];
|
|
|
+
|
|
|
+ NIMSession *session = [self isMemberOfClass:[MessageViewController class]] ? self.session : nil;
|
|
|
+
|
|
|
NTESGalleryViewController *vc = [[NTESGalleryViewController alloc] initWithItem:item session:session];
|
|
|
[self.navigationController pushViewController:vc animated:YES];
|
|
|
- if(![[NSFileManager defaultManager] fileExistsAtPath:object.thumbPath]){
|
|
|
+ if (![[NSFileManager defaultManager] fileExistsAtPath:object.thumbPath]) {
|
|
|
//如果缩略图下跪了,点进看大图的时候再去下一把缩略图
|
|
|
__weak typeof(self) wself = self;
|
|
|
[[NIMSDK sharedSDK].resourceManager download:object.thumbUrl filepath:object.thumbPath progress:nil completion:^(NSError *error) {
|
|
|
@@ -330,20 +321,19 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-- (void)showVideo:(NIMMessage *)message
|
|
|
-{
|
|
|
+- (void)showVideo:(NIMMessage *)message {
|
|
|
NIMVideoObject *object = message.messageObject;
|
|
|
- NIMSession *session = [self isMemberOfClass:[MessageViewController class]]? self.session : nil;
|
|
|
-
|
|
|
+ NIMSession *session = [self isMemberOfClass:[MessageViewController class]] ? self.session : nil;
|
|
|
+
|
|
|
NTESVideoViewItem *item = [[NTESVideoViewItem alloc] init];
|
|
|
item.path = object.path;
|
|
|
- item.url = object.url;
|
|
|
+ item.url = object.url;
|
|
|
item.session = session;
|
|
|
- item.itemId = object.message.messageId;
|
|
|
-
|
|
|
+ item.itemId = object.message.messageId;
|
|
|
+
|
|
|
NTESVideoViewController *playerViewController = [[NTESVideoViewController alloc] initWithVideoViewItem:item];
|
|
|
[self.navigationController pushViewController:playerViewController animated:YES];
|
|
|
- if(![[NSFileManager defaultManager] fileExistsAtPath:object.coverPath]){
|
|
|
+ if (![[NSFileManager defaultManager] fileExistsAtPath:object.coverPath]) {
|
|
|
//如果封面图下跪了,点进视频的时候再去下一把封面图
|
|
|
__weak typeof(self) wself = self;
|
|
|
[[NIMSDK sharedSDK].resourceManager download:object.coverUrl filepath:object.coverPath progress:nil completion:^(NSError *error) {
|
|
|
@@ -354,8 +344,7 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-- (void)showLocation:(NIMMessage *)message
|
|
|
-{
|
|
|
+- (void)showLocation:(NIMMessage *)message {
|
|
|
NIMLocationObject *object = message.messageObject;
|
|
|
NIMKitLocationPoint *locationPoint = [[NIMKitLocationPoint alloc] initWithLocationObject:object];
|
|
|
NIMLocationViewController *vc = [[NIMLocationViewController alloc] initWithLocationPoint:locationPoint];
|
|
|
@@ -369,18 +358,14 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
// [self.navigationController pushViewController:vc animated:YES];
|
|
|
//}
|
|
|
|
|
|
-- (void)showCustom:(NIMMessage *)message
|
|
|
-{
|
|
|
+- (void)showCustom:(NIMMessage *)message {
|
|
|
//普通的自定义消息点击事件可以在这里做哦~
|
|
|
}
|
|
|
|
|
|
-- (void)openSafari:(NSString *)link
|
|
|
-{
|
|
|
+- (void)openSafari:(NSString *)link {
|
|
|
NSURLComponents *components = [[NSURLComponents alloc] initWithString:link];
|
|
|
- if (components)
|
|
|
- {
|
|
|
- if (!components.scheme)
|
|
|
- {
|
|
|
+ if (components) {
|
|
|
+ if (!components.scheme) {
|
|
|
//默认添加 http
|
|
|
components.scheme = @"http";
|
|
|
}
|
|
|
@@ -389,26 +374,24 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
}
|
|
|
|
|
|
|
|
|
-- (NSDictionary *)cellActions
|
|
|
-{
|
|
|
+- (NSDictionary *)cellActions {
|
|
|
static NSDictionary *actions = nil;
|
|
|
static dispatch_once_t onceToken;
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
- actions = @{@(NIMMessageTypeImage) : @"showImage:",
|
|
|
- @(NIMMessageTypeVideo) : @"showVideo:",
|
|
|
- @(NIMMessageTypeLocation) : @"showLocation:",
|
|
|
- @(NIMMessageTypeFile) : @"showFile:",
|
|
|
- @(NIMMessageTypeCustom): @"showCustom:"};
|
|
|
+ actions = @{@(NIMMessageTypeImage): @"showImage:",
|
|
|
+ @(NIMMessageTypeVideo): @"showVideo:",
|
|
|
+ @(NIMMessageTypeLocation): @"showLocation:",
|
|
|
+ @(NIMMessageTypeFile): @"showFile:",
|
|
|
+ @(NIMMessageTypeCustom): @"showCustom:"};
|
|
|
});
|
|
|
return actions;
|
|
|
}
|
|
|
|
|
|
--(void)backClick{
|
|
|
+- (void)backClick {
|
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
|
}
|
|
|
|
|
|
-- (id<NIMSessionConfig>)sessionConfig
|
|
|
-{
|
|
|
+- (id <NIMSessionConfig>)sessionConfig {
|
|
|
if (_sessionConfig == nil) {
|
|
|
_sessionConfig = [[NTESSessionConfig alloc] init];
|
|
|
_sessionConfig.session = self.session;
|
|
|
@@ -416,27 +399,22 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
return _sessionConfig;
|
|
|
}
|
|
|
|
|
|
-- (BOOL)checkRTSCondition
|
|
|
-{
|
|
|
+- (BOOL)checkRTSCondition {
|
|
|
BOOL result = YES;
|
|
|
-
|
|
|
- if (![[Reachability reachabilityForInternetConnection] isReachable])
|
|
|
- {
|
|
|
+
|
|
|
+ if (![[Reachability reachabilityForInternetConnection] isReachable]) {
|
|
|
[self.view makeToast:@"请检查网络" duration:2.0 position:CSToastPositionCenter];
|
|
|
result = NO;
|
|
|
}
|
|
|
NSString *currentAccount = [[NIMSDK sharedSDK].loginManager currentAccount];
|
|
|
- if (self.session.sessionType == NIMSessionTypeP2P && [currentAccount isEqualToString:self.session.sessionId])
|
|
|
- {
|
|
|
+ if (self.session.sessionType == NIMSessionTypeP2P && [currentAccount isEqualToString:self.session.sessionId]) {
|
|
|
[self.view makeToast:@"不能和自己通话哦" duration:2.0 position:CSToastPositionCenter];
|
|
|
result = NO;
|
|
|
}
|
|
|
- if (self.session.sessionType == NIMSessionTypeTeam)
|
|
|
- {
|
|
|
+ if (self.session.sessionType == NIMSessionTypeTeam) {
|
|
|
NIMTeam *team = [[NIMSDK sharedSDK].teamManager teamById:self.session.sessionId];
|
|
|
NSInteger memberNumber = team.memberNumber;
|
|
|
- if (memberNumber < 2)
|
|
|
- {
|
|
|
+ if (memberNumber < 2) {
|
|
|
[self.view makeToast:@"无法发起,群人数少于2人" duration:2.0 position:CSToastPositionCenter];
|
|
|
result = NO;
|
|
|
}
|
|
|
@@ -445,20 +423,12 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
}
|
|
|
|
|
|
#pragma mark - 视频聊天
|
|
|
-- (void)onTapMediaItemVideoChat:(NIMMediaItem *)item
|
|
|
-{
|
|
|
+
|
|
|
+- (void)onTapMediaItemVideoChat:(NIMMediaItem *)item {
|
|
|
if ([self checkRTSCondition]) {
|
|
|
//由于音视频聊天里头有音频和视频聊天界面的切换,直接用present的话页面过渡会不太自然,这里还是用push,然后做出present的效果
|
|
|
NTESVideoChatViewController *vc = [[NTESVideoChatViewController alloc] initWithCallee:self.session.sessionId];
|
|
|
- vc.hidesBottomBarWhenPushed = YES;
|
|
|
- CATransition *transition = [CATransition animation];
|
|
|
- transition.duration = 0.25;
|
|
|
- transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
|
|
|
- transition.type = kCATransitionPush;
|
|
|
- transition.subtype = kCATransitionFromTop;
|
|
|
- [self.navigationController.view.layer addAnimation:transition forKey:nil];
|
|
|
- self.navigationController.navigationBarHidden = YES;
|
|
|
- [self.navigationController pushViewController:vc animated:NO];
|
|
|
+ [self.navigationController presentViewController:vc animated:YES completion:nil];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -477,5 +447,4 @@ NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPi
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
@end
|