Initial commit
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// NTESSessionCustomConfig.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/7/24.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NIMCellConfig.h"
|
||||
|
||||
@interface NTESSessionCustomLayoutConfig : NSObject<NIMCellLayoutConfig>
|
||||
|
||||
+ (BOOL)supportMessage:(NIMMessage *)message;
|
||||
|
||||
@end
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// NTESSessionCustomConfig.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/7/24.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESSessionCustomLayoutConfig.h"
|
||||
#import "NTESCustomAttachmentDefines.h"
|
||||
#import "NTESSessionUtil.h"
|
||||
#import "NTESSessionCustomContentConfig.h"
|
||||
|
||||
@interface NTESSessionCustomLayoutConfig()
|
||||
@property (nonatomic,strong) NTESSessionCustomContentConfig *contentConfig; //所有的自定义消息都使用这个对象,重用
|
||||
@end
|
||||
|
||||
@implementation NTESSessionCustomLayoutConfig
|
||||
|
||||
- (instancetype)init{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_contentConfig = [[NTESSessionCustomContentConfig alloc] init];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (CGSize)contentSize:(NIMMessageModel *)model cellWidth:(CGFloat)width{
|
||||
id<NIMSessionContentConfig> config = [self sessionContentConfig:model.message];
|
||||
return [config contentSize:width message:model.message];
|
||||
}
|
||||
|
||||
- (NSString *)cellContent:(NIMMessageModel *)model{
|
||||
id<NIMSessionContentConfig> config = [self sessionContentConfig:model.message];
|
||||
return [config cellContent:model.message];
|
||||
}
|
||||
|
||||
- (UIEdgeInsets)contentViewInsets:(NIMMessageModel *)model
|
||||
{
|
||||
id<NIMSessionContentConfig> config = [self sessionContentConfig:model.message];
|
||||
return [config contentViewInsets:model.message];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - misc
|
||||
- (id<NIMSessionContentConfig>)sessionContentConfig:(NIMMessage *)message{
|
||||
// self.contentConfig.message = message;
|
||||
return self.contentConfig;
|
||||
}
|
||||
|
||||
#pragma mark - 支持类型配置
|
||||
+ (BOOL)supportMessage:(NIMMessage *)message{
|
||||
NSArray *supportType = [NTESSessionCustomLayoutConfig supportAttachmentType];
|
||||
NIMCustomObject *object = message.messageObject;
|
||||
return [supportType indexOfObject:NSStringFromClass([object.attachment class])] != NSNotFound;
|
||||
}
|
||||
|
||||
+ (NSArray *)supportAttachmentType
|
||||
{
|
||||
static NSArray *types = nil;
|
||||
static dispatch_once_t onceTypeToken;
|
||||
//所对应的contentView只适用于cellClass为NTESSessionChatCell的情况,其他cellClass则需要自己实现布局
|
||||
dispatch_once(&onceTypeToken, ^{
|
||||
types = @[
|
||||
@"NTESJanKenPonAttachment",
|
||||
@"NTESSnapchatAttachment",
|
||||
@"NTESChartletAttachment",
|
||||
@"NTESWhiteboardAttachment"
|
||||
];
|
||||
});
|
||||
return types;
|
||||
}
|
||||
|
||||
@end
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// NTESSessionTipConfig.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 16/1/21.
|
||||
// Copyright © 2016年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NIMCellConfig.h"
|
||||
|
||||
@interface NTESSessionTipConfig : NSObject<NIMCellLayoutConfig>
|
||||
|
||||
@end
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// NTESSessionTipConfig.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 16/1/21.
|
||||
// Copyright © 2016年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESSessionTipConfig.h"
|
||||
|
||||
@implementation NTESSessionTipConfig
|
||||
|
||||
@end
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// NTESSearchCellLayoutConstant.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/7/26.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef NIM_NTESSearchCellLayoutConstant_h
|
||||
#define NIM_NTESSearchCellLayoutConstant_h
|
||||
|
||||
//font
|
||||
extern CGFloat SearchCellTitleFontSize;
|
||||
extern CGFloat SearchCellContentFontSize;
|
||||
extern CGFloat SearchCellTimeFontSize;
|
||||
|
||||
//layout
|
||||
extern CGFloat SearchCellAvatarLeft;
|
||||
extern CGFloat SearchCellAvatarAndTitleSpacing;
|
||||
extern CGFloat SearchCellTitleTop;
|
||||
extern CGFloat SearchCellContentTop;
|
||||
extern CGFloat SearchCellContentBottom;
|
||||
extern CGFloat SearchCellContentMaxWidth;
|
||||
extern CGFloat SearchCellContentMinHeight; //cell的高度是由文本高度决定的。防止没有文本的情况,导致cell的高度过小。
|
||||
extern CGFloat SearchCellTimeRight;
|
||||
extern CGFloat SearchCellTimeTop;
|
||||
|
||||
#endif
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// NTESSearchMessageContentCell.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/7/8.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "NTESSearchLocalHistoryObject.h"
|
||||
|
||||
@interface NTESSearchMessageContentCell : UITableViewCell<NTESSearchObjectRefresh>
|
||||
|
||||
|
||||
@end
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
//
|
||||
// NTESSearchMessageContentCell.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/7/8.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESSearchMessageContentCell.h"
|
||||
#import "NTESSearchLocalHistoryObject.h"
|
||||
#import "NTESSessionUtil.h"
|
||||
#import "UIView+NTES.h"
|
||||
#import "NIMAvatarImageView.h"
|
||||
|
||||
//font
|
||||
CGFloat SearchCellTitleFontSize = 13.f;
|
||||
CGFloat SearchCellContentFontSize = 12.f;
|
||||
CGFloat SearchCellTimeFontSize = 12.f;
|
||||
|
||||
//layout
|
||||
CGFloat SearchCellAvatarLeft = 15.f;
|
||||
CGFloat SearchCellAvatarAndTitleSpacing = 10.f;
|
||||
CGFloat SearchCellTitleTop = 10.f;
|
||||
CGFloat SearchCellTimeRight = 15.f;
|
||||
CGFloat SearchCellTimeTop = 10.f;
|
||||
CGFloat SearchCellContentTop = 30.f;
|
||||
CGFloat SearchCellContentBottom = 8.f;
|
||||
CGFloat SearchCellContentMaxWidth = 260.f;
|
||||
CGFloat SearchCellContentMinHeight = 15.f; //cell的高度是由文本高度决定的。防止没有文本的情况,导致cell的高度过小。
|
||||
|
||||
@interface NTESSearchMessageContentCell()
|
||||
|
||||
@property (nonatomic,strong) NIMAvatarImageView *avatar;
|
||||
|
||||
@property (nonatomic,strong) UILabel *titleLabel;
|
||||
|
||||
@property (nonatomic,strong) UILabel *contentLabel;
|
||||
|
||||
@property (nonatomic,strong) UILabel *timeLabel;
|
||||
|
||||
@property (nonatomic,strong) NTESSearchLocalHistoryObject *object;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESSearchMessageContentCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
_avatar = [[NIMAvatarImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
|
||||
[self addSubview:_avatar];
|
||||
_titleLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:13.f];
|
||||
[self addSubview:_titleLabel];
|
||||
_contentLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
_contentLabel.font = [UIFont systemFontOfSize:12.f];
|
||||
_contentLabel.textColor = [UIColor grayColor];
|
||||
_contentLabel.numberOfLines = 0;
|
||||
[self addSubview:_contentLabel];
|
||||
_timeLabel = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
_timeLabel.font = [UIFont systemFontOfSize:12.f];
|
||||
[self addSubview:_timeLabel];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refresh:(NTESSearchLocalHistoryObject *)object{
|
||||
self.object = object;
|
||||
NIMMessage *message = object.message;
|
||||
NIMKitInfo *info = [[NIMKit sharedKit] infoByUser:message.from];
|
||||
NSURL *avatarURL;
|
||||
if (info.avatarUrlString.length) {
|
||||
avatarURL = [NSURL URLWithString:info.avatarUrlString];
|
||||
}
|
||||
[self.avatar nim_setImageWithURL:avatarURL placeholderImage:info.avatarImage];
|
||||
self.titleLabel.text = info.showName;
|
||||
self.contentLabel.text = message.text;
|
||||
self.timeLabel.text = [NTESSessionUtil showTime:message.timestamp showDetail:YES];
|
||||
[self.titleLabel sizeToFit];
|
||||
self.contentLabel.size = [self.contentLabel sizeThatFits:CGSizeMake(SearchCellContentMaxWidth * UISreenWidthScale, CGFLOAT_MAX)];
|
||||
self.contentLabel.height = MAX(SearchCellContentMinHeight, self.contentLabel.height);
|
||||
[self.timeLabel sizeToFit];
|
||||
}
|
||||
|
||||
|
||||
- (void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
self.avatar.top = SearchCellTitleTop;
|
||||
self.avatar.left = SearchCellAvatarLeft;
|
||||
self.titleLabel.left = self.avatar.right + SearchCellAvatarAndTitleSpacing;
|
||||
self.contentLabel.left = self.titleLabel.left;
|
||||
self.titleLabel.top = SearchCellTitleTop;
|
||||
self.contentLabel.bottom = self.height - SearchCellContentBottom;
|
||||
self.timeLabel.right = self.width - SearchCellTimeRight;
|
||||
self.timeLabel.top = SearchCellTimeTop;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
//
|
||||
// NTESSearchMessageEntraceCell.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/7/8.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "NTESSearchLocalHistoryObject.h"
|
||||
|
||||
@interface NTESSearchMessageEntraceCell : UITableViewCell<NTESSearchObjectRefresh>
|
||||
|
||||
@end
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// NTESSearchMessageEntraceCell.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/7/8.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESSearchMessageEntraceCell.h"
|
||||
#import "UIView+NTES.h"
|
||||
|
||||
@interface NTESSearchMessageEntraceCell()
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESSearchMessageEntraceCell
|
||||
|
||||
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
|
||||
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
||||
if (self) {
|
||||
self.textLabel.textColor = [UIColor blueColor];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refresh:(NTESSearchLocalHistoryObject *)object{
|
||||
self.textLabel.text = object.content;
|
||||
[self.textLabel sizeToFit];
|
||||
}
|
||||
|
||||
|
||||
#define TextLabelLeft 20.f
|
||||
- (void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
self.textLabel.left = TextLabelLeft;
|
||||
self.textLabel.centerY = self.height * .5f;
|
||||
}
|
||||
|
||||
@end
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// NTESSessionChartletContentView.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/7/10.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface NTESSessionChartletContentView : NIMSessionMessageContentView
|
||||
|
||||
@end
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// NTESSessionChartletContentView.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/7/10.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESSessionChartletContentView.h"
|
||||
#import "UIView+NTES.h"
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
#import "NTESChartletAttachment.h"
|
||||
#import "NTESSessionUtil.h"
|
||||
|
||||
@interface NTESSessionChartletContentView()
|
||||
|
||||
@property (nonatomic,strong) UIImageView *imageView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESSessionChartletContentView
|
||||
|
||||
- (instancetype)initSessionMessageContentView{
|
||||
self = [super initSessionMessageContentView];
|
||||
if (self) {
|
||||
self.opaque = YES;
|
||||
_imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
|
||||
self.bubbleImageView.hidden = YES;
|
||||
[self addSubview:_imageView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refresh:(NIMMessageModel *)data{
|
||||
[super refresh:data];
|
||||
NIMCustomObject *customObject = (NIMCustomObject*)data.message.messageObject;
|
||||
id attachment = customObject.attachment;
|
||||
if ([attachment isKindOfClass:[NTESChartletAttachment class]]) {
|
||||
self.imageView.image = [attachment showCoverImage];
|
||||
[self.imageView sizeToFit];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
UIEdgeInsets contentInsets = self.model.contentViewInsets;
|
||||
CGSize contentSize = self.model.contentSize;
|
||||
CGRect imageViewFrame = CGRectMake(contentInsets.left, contentInsets.top, contentSize.width, contentSize.height);
|
||||
self.imageView.frame = imageViewFrame;
|
||||
CALayer *maskLayer = [CALayer layer];
|
||||
maskLayer.cornerRadius = 13.0;
|
||||
maskLayer.backgroundColor = [UIColor blackColor].CGColor;
|
||||
maskLayer.frame = self.imageView.bounds;
|
||||
self.imageView.layer.mask = maskLayer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
//
|
||||
// NTESSessionCustomContentView.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/4/10.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
@interface NTESSessionJankenponContentView : NIMSessionMessageContentView
|
||||
|
||||
@end
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// NTESSessionCustomContentView.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/4/10.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESSessionJankenponContentView.h"
|
||||
#import "UIView+NTES.h"
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
#import "NTESJanKenPonAttachment.h"
|
||||
#import "NTESSessionUtil.h"
|
||||
|
||||
@interface NTESSessionJankenponContentView()
|
||||
|
||||
@property (nonatomic,strong,readwrite) UIImageView *imageView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESSessionJankenponContentView
|
||||
|
||||
- (instancetype)initSessionMessageContentView{
|
||||
self = [super initSessionMessageContentView];
|
||||
if (self) {
|
||||
self.opaque = YES;
|
||||
_imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
|
||||
[self addSubview:_imageView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refresh:(NIMMessageModel *)data{
|
||||
[super refresh:data];
|
||||
NIMCustomObject *customObject = (NIMCustomObject*)data.message.messageObject;
|
||||
id attachment = customObject.attachment;
|
||||
if ([attachment isKindOfClass:[NTESJanKenPonAttachment class]]) {
|
||||
self.imageView.image = [attachment showCoverImage];
|
||||
[self.imageView sizeToFit];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
UIEdgeInsets contentInsets = self.model.contentViewInsets;
|
||||
CGSize contentSize = self.model.contentSize;
|
||||
CGRect imageViewFrame = CGRectMake(contentInsets.left, contentInsets.top, contentSize.width, contentSize.height);
|
||||
self.imageView.frame = imageViewFrame;
|
||||
CALayer *maskLayer = [CALayer layer];
|
||||
maskLayer.cornerRadius = 13.0;
|
||||
maskLayer.backgroundColor = [UIColor blackColor].CGColor;
|
||||
maskLayer.frame = self.imageView.bounds;
|
||||
self.imageView.layer.mask = maskLayer;
|
||||
}
|
||||
|
||||
|
||||
- (UIImage *)chatBubbleImageForState:(UIControlState)state outgoing:(BOOL)outgoing{
|
||||
if (self.model.message.session.sessionType == NIMSessionTypeChatroom) {
|
||||
return nil;
|
||||
}
|
||||
return [super chatBubbleImageForState:state outgoing:outgoing];
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// NTESSessionSnapchatContentView.h
|
||||
// NIM
|
||||
//
|
||||
// Created by amao on 7/2/15.
|
||||
// Copyright (c) 2015 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
extern NSString *const NIMDemoEventNameOpenSnapPicture; //自定义消息阅后即焚,打开阅后即焚预览窗口
|
||||
extern NSString *const NIMDemoEventNameCloseSnapPicture; //自定义消息阅后即焚,关闭阅后即焚预览窗口
|
||||
|
||||
@interface NTESSessionSnapchatContentView : NIMSessionMessageContentView
|
||||
|
||||
@end
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
//
|
||||
// NTESSessionSnapchatContentView.m
|
||||
// NIM
|
||||
//
|
||||
// Created by amao on 7/2/15.
|
||||
// Copyright (c) 2015 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESSessionSnapchatContentView.h"
|
||||
#import "NTESSnapchatAttachment.h"
|
||||
#import "NTESSessionUtil.h"
|
||||
#import "UIView+NTES.h"
|
||||
|
||||
NSString *const NIMDemoEventNameOpenSnapPicture = @"NIMDemoEventNameOpenSnapPicture";
|
||||
NSString *const NIMDemoEventNameCloseSnapPicture = @"NIMDemoEventNameCloseSnapPicture";
|
||||
|
||||
|
||||
@interface NTESSessionSnapchatContentView()
|
||||
|
||||
@property (nonatomic,strong) UIImageView *imageView;
|
||||
|
||||
@property (nonatomic,strong) UILabel *label;
|
||||
|
||||
@property (nonatomic,strong) UILongPressGestureRecognizer *longpressGesture;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESSessionSnapchatContentView
|
||||
|
||||
|
||||
- (instancetype)initSessionMessageContentView{
|
||||
self = [super initSessionMessageContentView];
|
||||
if (self) {
|
||||
_longpressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onLongPressDown:)];
|
||||
[self addGestureRecognizer:_longpressGesture];
|
||||
_imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
|
||||
[self addSubview:_imageView];
|
||||
self.bubbleImageView.hidden = YES;//图片背景自带气泡。。
|
||||
|
||||
_label = [[UILabel alloc] initWithFrame:CGRectZero];
|
||||
_label.font = [UIFont systemFontOfSize:13.f];
|
||||
_label.textColor = [UIColor grayColor];
|
||||
_label.text = @"按住查看";
|
||||
[_label sizeToFit];
|
||||
[self addSubview:_label];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refresh:(NIMMessageModel *)model{
|
||||
[super refresh:model];
|
||||
NIMCustomObject * customObject = (NIMCustomObject*)model.message.messageObject;
|
||||
NTESSnapchatAttachment *attachment = (NTESSnapchatAttachment *)customObject.attachment;
|
||||
self.imageView.image = attachment.showCoverImage;
|
||||
self.label.hidden = attachment.isFired;
|
||||
self.longpressGesture.enabled = !attachment.isFired;
|
||||
}
|
||||
|
||||
- (void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
NIMCustomObject * customObject = (NIMCustomObject*)self.model.message.messageObject;
|
||||
NTESSnapchatAttachment *attachment = (NTESSnapchatAttachment *)customObject.attachment;
|
||||
UIEdgeInsets contentInsets = self.model.contentViewInsets;
|
||||
UIImage *showCoverImage = attachment.showCoverImage;
|
||||
CGRect imageViewFrame = CGRectMake(contentInsets.left, contentInsets.top, showCoverImage.size.width, showCoverImage.size.height);
|
||||
self.imageView.frame = imageViewFrame;
|
||||
|
||||
CGFloat customSnapMessageImageRightToText = .5f;
|
||||
CGFloat customSnapMessageTextBottom = 20.5f;
|
||||
self.label.left = self.model.message.isOutgoingMsg ? self.imageView.left - customSnapMessageImageRightToText - self.label.width : self.imageView.right + customSnapMessageImageRightToText;
|
||||
self.label.bottom = self.imageView.bottom - customSnapMessageTextBottom ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
- (void)onLongPressDown:(UILongPressGestureRecognizer *)recognizer
|
||||
{
|
||||
NIMMessage *message = self.model.message;
|
||||
if (!message.isReceivedMsg && message.deliveryState != NIMMessageDeliveryStateDeliveried) {
|
||||
return;
|
||||
}
|
||||
if (recognizer.state != UIGestureRecognizerStateBegan) {
|
||||
return;
|
||||
}
|
||||
recognizer.enabled = NO;
|
||||
[self goOpen];
|
||||
}
|
||||
|
||||
|
||||
- (void)onTouchUpInside:(id)sender{
|
||||
if (self.presentedView) {
|
||||
[self goClose];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)onTouchUpOutside:(id)sender{
|
||||
if (self.presentedView) {
|
||||
[self goClose];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)goOpen{
|
||||
if ([self.delegate respondsToSelector:@selector(onCatchEvent:)]) {
|
||||
NIMKitEvent *event = [[NIMKitEvent alloc] init];
|
||||
event.eventName = NIMDemoEventNameOpenSnapPicture;
|
||||
event.messageModel = self.model;
|
||||
event.data = self;
|
||||
[self.delegate onCatchEvent:event];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)goClose{
|
||||
if ([self.delegate respondsToSelector:@selector(onCatchEvent:)]) {
|
||||
NIMKitEvent *event = [[NIMKitEvent alloc] init];
|
||||
event.eventName = NIMDemoEventNameCloseSnapPicture;
|
||||
event.messageModel = self.model;
|
||||
event.data = self;
|
||||
[self.delegate onCatchEvent:event];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// NTESSessionWhiteBoardContentView.h
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/8/3.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
@class M80AttributedLabel;
|
||||
|
||||
|
||||
#import "NIMSessionMessageContentView.h"
|
||||
|
||||
@interface NTESSessionWhiteBoardContentView : NIMSessionMessageContentView
|
||||
|
||||
@property (nonatomic, strong) M80AttributedLabel *textLabel;
|
||||
|
||||
@end
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// NTESSessionWhiteBoardContentView.m
|
||||
// NIM
|
||||
//
|
||||
// Created by chris on 15/8/3.
|
||||
// Copyright (c) 2015年 Netease. All rights reserved.
|
||||
//
|
||||
|
||||
#import "NTESSessionWhiteBoardContentView.h"
|
||||
#import "NTESSessionUtil.h"
|
||||
#import "UIView+NTES.h"
|
||||
#import "M80AttributedLabel.h"
|
||||
#import "NIMKitUtil.h"
|
||||
|
||||
@interface NTESSessionWhiteBoardContentView()
|
||||
|
||||
@property (nonatomic,strong) UIImageView *imageView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation NTESSessionWhiteBoardContentView
|
||||
|
||||
-(instancetype)initSessionMessageContentView
|
||||
{
|
||||
if (self = [super initSessionMessageContentView]) {
|
||||
//
|
||||
_textLabel = [[M80AttributedLabel alloc] initWithFrame:CGRectZero];
|
||||
_textLabel.numberOfLines = 0;
|
||||
_textLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
||||
_textLabel.font = [UIFont systemFontOfSize:14.f];
|
||||
_textLabel.backgroundColor = [UIColor clearColor];
|
||||
[self addSubview:_textLabel];
|
||||
|
||||
_imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"icon_whiteboard_session_msg"]];
|
||||
[self addSubview:_imageView];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)refresh:(NIMMessageModel *)data{
|
||||
[super refresh:data];
|
||||
NSString *text = [NIMKitUtil messageTipContent:data.message];
|
||||
[_textLabel setText:text];
|
||||
if (!data.message.isOutgoingMsg) {
|
||||
_textLabel.textColor = [UIColor blackColor];
|
||||
}else{
|
||||
_textLabel.textColor = [UIColor whiteColor];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
UIEdgeInsets contentInsets = self.model.contentViewInsets;
|
||||
CGSize contentSize = self.model.contentSize;
|
||||
self.imageView.left = contentInsets.left;
|
||||
self.imageView.centerY = self.height * .5f;
|
||||
CGFloat customWhiteBorardMessageImageRightToText = 5.f;
|
||||
CGRect labelFrame = CGRectMake(self.imageView.right + customWhiteBorardMessageImageRightToText, contentInsets.top, contentSize.width, contentSize.height);
|
||||
self.textLabel.frame = labelFrame;
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user