Initial commit
This commit is contained in:
+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