Initial commit
This commit is contained in:
+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
|
||||
Reference in New Issue
Block a user