Initial commit

This commit is contained in:
ifish
2017-08-15 16:59:01 +08:00
commit bdc83e07ef
5766 changed files with 423223 additions and 0 deletions
@@ -0,0 +1,61 @@
//
// UMComChatRecodTableViewCell.h
// UMCommunity
//
// Created by umeng on 16/3/4.
// Copyright © 2016年 Umeng. All rights reserved.
//
#import "UMComTableViewCell.h"
#define UMCom_Forum_Chat_Icon_Width 45
#define UMCom_Forum_Chat_Icon_Edge 10
#define UMCom_Forum_Chat_Message_ShortEdge 15 //聊天内容到背景图片边框的距离
#define UMCom_Forum_Chat_Message_LongEdge 47 //背景图片到Cell边框的距离
#define UMCom_Forum_Chat_DateMessage_Space 0
#define UMCom_Forum_Chat_DateLabel_Height 30
#define UMCom_Forum_Chat_Cell_Space 25
#define UMCom_Forum_Chat_DateString_Font 11
#define UMCom_Forum_Chat_Message_Font 15
#define UMCom_Forum_Chat_Date_TextColor @"#A5A5A5"
#define UMCom_Forum_Chat_Cell_BgColor @"#F5F6FA"
#define UMCom_Forum_Chat_ReceivedMsg_TextColor @"#333333"
#define UMCom_Forum_Chat_SendFrame_LineColor @"#DEDEDE"
#define UMCom_Forum_Chat_SendFrame_bgColor @"#F5F6FA"
#define UMCom_Forum_Chat_SendFrame_TextColor @"#333333"
#define UMCom_Forum_Chat_SendFrame_ViewsSpace 10
#define UMCom_Forum_Chat_SendFrame_Heigt 50
#define UMCom_Forum_Chat_SendButton_Width 70
#define UMCom_Forum_Chat_SendButton_TitleFont 15
#define UMCom_Forum_Chat_SendButton_HighLightColor @"#C7C7C7"
#define UMCom_Forum_Chat_SendButton_NomalColor @"#008BEA"
@class UMComImageView,UMComPrivateMessage,UMComMutiText,UMComMutiStyleTextView;
@interface UMComChatRecodTableViewCell :UITableViewCell
@property (nonatomic, strong) UMComImageView *iconImaeView;
@property (nonatomic, strong) UMComMutiStyleTextView *chatContentView;
@property (nonatomic, strong) UILabel *dateLabel;
@property (nonatomic, strong) UIImageView *bgImageView;
@property (nonatomic, copy) void (^clickOnUser)();
@property (nonatomic, copy) void (^clickOnCell)();
- (void)reloadTabelViewCellWithMessage:(UMComPrivateMessage *)privateMessage mutiText:(UMComMutiText *)mutiText cellSize:(CGSize)size;
@end
@interface UMComChatReceivedTableViewCell : UMComChatRecodTableViewCell
@end
@interface UMComChatSendTableViewCell : UMComChatRecodTableViewCell
@end
@@ -0,0 +1,158 @@
//
// UMComChatRecodTableViewCell.m
// UMCommunity
//
// Created by umeng on 16/3/4.
// Copyright © 2016年 Umeng. All rights reserved.
//
#import "UMComChatRecodTableViewCell.h"
#import <UMComDataStorage/UMComUser.h>
#import "UMComCommentEditView.h"
#import <UMCommunitySDK/UMComSession.h>
#import "UMComImageView.h"
#import "UMComMutiStyleTextView.h"
#import "UMComResouceDefines.h"
#import <UMComDataStorage/UMComImageUrl.h>
#import <UMComDataStorage/UMComPrivateMessage.h>
#import <UMComFoundation/UMComKit+Color.h>
@implementation UMComChatRecodTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.bgImageView = [[UIImageView alloc]init];
[self.contentView addSubview:self.bgImageView];
self.iconImaeView = [[[UMComImageView imageViewClassName] alloc]init];
self.iconImaeView.userInteractionEnabled = YES;
self.iconImaeView.clipsToBounds = YES;
[self.contentView addSubview:self.iconImaeView];
self.chatContentView = [[UMComMutiStyleTextView alloc]init];
self.chatContentView.backgroundColor = [UIColor clearColor];
[self.bgImageView addSubview:self.chatContentView];
self.dateLabel = [[UILabel alloc]init];
self.dateLabel.backgroundColor = [UIColor clearColor];
self.dateLabel.font = UMComFontNotoSansLightWithSafeSize(UMCom_Forum_Chat_DateString_Font);
self.dateLabel.textColor = UMComColorWithHexString(UMCom_Forum_Chat_Date_TextColor);
[self.contentView addSubview:self.dateLabel];
self.contentView.backgroundColor = UMComColorWithHexString(UMCom_Forum_Chat_Cell_BgColor);
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickOnUser:)];
[self.iconImaeView addGestureRecognizer:tap];
self.selectionStyle = UITableViewCellSelectionStyleNone;
}
return self;
}
- (void)clickOnUser:(id)sender
{
if (_clickOnUser) {
_clickOnUser();
}
}
//- (void)clickOnCell:()
- (void)reloadTabelViewCellWithMessage:(UMComPrivateMessage *)privateMessage mutiText:(UMComMutiText *)mutiText cellSize:(CGSize)size
{
[self.iconImaeView setImageURL:privateMessage.creator.icon_url.small_url_string placeHolderImage:UMComImageWithImageName(@"um_forum_user_smile_gray")];
if (privateMessage.create_time) {
self.dateLabel.text = createTimeString(privateMessage.create_time);
}else{
self.dateLabel.text = [[NSDate date] description];
}
[self.chatContentView setMutiStyleTextViewWithMutiText:mutiText];
}
@end
@implementation UMComChatReceivedTableViewCell
{
CGFloat imageLeft;
CGFloat imageWidth;
CGFloat dateLabelHeight;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
imageLeft = UMCom_Forum_Chat_Icon_Edge;
imageWidth = UMCom_Forum_Chat_Icon_Width;
dateLabelHeight = UMCom_Forum_Chat_DateLabel_Height;
UIImage *resizableImage = [UMComImageWithImageName(@"um_forum_chat_bg_white") resizableImageWithCapInsets:UIEdgeInsetsMake(30, 20, 5, 20) resizingMode:UIImageResizingModeStretch];
self.bgImageView.image = resizableImage;
self.dateLabel.textAlignment = NSTextAlignmentLeft;
}
return self;
}
- (void)reloadTabelViewCellWithMessage:(UMComPrivateMessage *)privateMessage mutiText:(UMComMutiText *)mutiText cellSize:(CGSize)size
{
[super reloadTabelViewCellWithMessage:privateMessage mutiText:mutiText cellSize:size];
self.iconImaeView.frame = CGRectMake(imageLeft, imageLeft, imageWidth, imageWidth);
self.iconImaeView.layer.cornerRadius = self.iconImaeView.bounds.size.height/2;
CGFloat commonOriginX = imageLeft + imageLeft/2 + imageWidth;
CGFloat bgChatImageWidth = mutiText.textSize.width + UMCom_Forum_Chat_Message_ShortEdge * 2 + 2;
CGFloat bgImageHeight = mutiText.textSize.height + UMCom_Forum_Chat_Message_ShortEdge * 2;
self.bgImageView.frame = CGRectMake(commonOriginX, imageLeft, bgChatImageWidth, bgImageHeight);
self.chatContentView.frame = CGRectMake(UMCom_Forum_Chat_Message_ShortEdge+3, UMCom_Forum_Chat_Message_ShortEdge, mutiText.textSize.width, mutiText.textSize.height);
self.dateLabel.frame = CGRectMake(self.bgImageView.frame.origin.x + UMCom_Forum_Chat_Message_ShortEdge, self.bgImageView.frame.origin.y + bgImageHeight + UMCom_Forum_Chat_DateMessage_Space, size.width-commonOriginX, dateLabelHeight);
}
@end
@implementation UMComChatSendTableViewCell
{
CGFloat imageRight;
CGFloat imageWidth;
CGFloat dateLabelHeight;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
imageRight = UMCom_Forum_Chat_Icon_Edge;
imageWidth = UMCom_Forum_Chat_Icon_Width;
dateLabelHeight = UMCom_Forum_Chat_DateLabel_Height;
self.dateLabel.textAlignment = NSTextAlignmentRight;
UIImage *resizableImage = [UMComImageWithImageName(@"um_forum_chat_bg_blue") resizableImageWithCapInsets:UIEdgeInsetsMake(30, 20, 5, 20) resizingMode:UIImageResizingModeStretch];
self.bgImageView.image = resizableImage;
self.dateLabel.textAlignment = NSTextAlignmentRight;
}
return self;
}
- (void)reloadTabelViewCellWithMessage:(UMComPrivateMessage *)privateMessage mutiText:(UMComMutiText *)mutiText cellSize:(CGSize)size
{
[super reloadTabelViewCellWithMessage:privateMessage mutiText:mutiText cellSize:size];
self.iconImaeView.frame = CGRectMake(size.width-imageRight-imageWidth, imageRight, imageWidth, imageWidth);
self.iconImaeView.layer.cornerRadius = self.iconImaeView.bounds.size.height/2;
CGFloat bgChatImageWidth = mutiText.textSize.width + UMCom_Forum_Chat_Message_ShortEdge*2 + 2;
CGFloat bgImageHeight = mutiText.textSize.height + UMCom_Forum_Chat_Message_ShortEdge * 2;
CGFloat bgImageRigtEdge = imageRight+ imageRight/2 + imageWidth;
self.bgImageView.frame = CGRectMake(size.width - bgChatImageWidth - bgImageRigtEdge, UMCom_Forum_Chat_Icon_Edge, bgChatImageWidth, bgImageHeight);
self.chatContentView.frame = CGRectMake(UMCom_Forum_Chat_Message_ShortEdge, UMCom_Forum_Chat_Message_ShortEdge, mutiText.textSize.width, mutiText.textSize.height);
CGRect dateFrame = self.dateLabel.frame;
CGFloat rightEdge = UMCom_Forum_Chat_Message_ShortEdge + self.iconImaeView.frame.size.width + imageRight*2;
dateFrame.size.width = size.width - UMCom_Forum_Chat_Message_LongEdge - rightEdge;
dateFrame.origin.x = size.width - rightEdge - dateFrame.size.width;
dateFrame.size.height = UMCom_Forum_Chat_DateLabel_Height;
dateFrame.origin.y = self.bgImageView.frame.origin.y + bgImageHeight + UMCom_Forum_Chat_DateMessage_Space;
self.dateLabel.frame = dateFrame;
}
@end
@@ -0,0 +1,18 @@
//
// UMComForumSysCommentCell.h
// UMCommunity
//
// Created by umeng on 15/12/27.
// Copyright © 2015年 Umeng. All rights reserved.
//
#import "UMComSysCommonTableViewCell.h"
@interface UMComSysCommentCell : UMComSysCommonTableViewCell
@property (nonatomic, strong) UIButton *replyButton;
@property (nonatomic, strong) UMComMutiStyleTextView *commentTextView;
@end
@@ -0,0 +1,310 @@
//
// UMComForumSysCommentCell.m
// UMCommunity
//
// Created by umeng on 15/12/27.
// Copyright © 2015年 Umeng. All rights reserved.
//
#import "UMComSysCommentCell.h"
#import <UMComDataStorage/UMComComment.h>
#import <UMComDataStorage/UMComUser.h>
#import "UMComMutiStyleTextView.h"
#import "UMComImageView.h"
#import "UMComResouceDefines.h"
#import <UMComDataStorage/UMComFeed.h>
#import "UMComClickActionDelegate.h"
#import <UMComFoundation/UMComKit+Color.h>
@interface UMComSysCommentCell () <UMComClickActionDelegate>
@property (nonatomic, strong) UMComComment *comment;
@property (nonatomic, assign) CGSize cellSize;
@property (nonatomic, strong) UMComMutiStyleTextView *feedCreatorView;
@property (nonatomic, strong) UMImageView *feedImgView;
@end
@implementation UMComSysCommentCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier cellSize:(CGSize)cellSize
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier cellSize:cellSize];
if (self) {
_cellSize = cellSize;
self.commentTextView = [[UMComMutiStyleTextView alloc] initWithFrame:CGRectMake(UMCom_SysCommonCell_SubViews_LeftEdge, UMCom_SysCommonCell_Content_TopEdge + self.userNameLabel.frame.size.height+10, cellSize.width-80, 50)];
self.commentTextView.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:self.commentTextView];
self.replyButton = [UIButton buttonWithType:UIButtonTypeCustom];
self.replyButton.frame = CGRectMake(self.commentTextView.frame.size.width+self.commentTextView.frame.origin.x+4, self.commentTextView.frame.origin.y, 16, 16);
[self.replyButton addTarget:self action:@selector(didClickOnReplyButton) forControlEvents:UIControlEventTouchUpInside];
[self.replyButton setBackgroundImage:UMComImageWithImageName(@"um_forum_post_comment_nomal") forState:UIControlStateNormal];
[self.contentView addSubview:self.replyButton];
//创建在feed下面有图片的时候单独创建feed作者控件
self.feedCreatorView = [[UMComMutiStyleTextView alloc] initWithFrame:CGRectMake(UMCom_SysCommonCell_SubViews_LeftEdge, UMCom_SysCommonCell_Content_TopEdge + self.userNameLabel.frame.size.height+10, cellSize.width-80, 50)];
self.feedCreatorView.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:self.feedCreatorView];
self.feedImgView = [[UMImageView alloc]initWithFrame: CGRectMake(68, 188, UMCom_SysCommonCell_Feed_IMGHeight, UMCom_SysCommonCell_Feed_IMGHeight)];
self.feedImgView.hidden = YES;
[self.contentView addSubview:self.feedImgView];
}
return self;
}
- (void)reloadCellWithObj:(id)obj
timeString:(NSString *)timeString
mutiText:(UMComMutiText *)commentMutiText
feedMutiText:(UMComMutiText *)feedMutiText
{
self.comment = (UMComComment *)obj;
UMComUser *user = _comment.creator;
NSString *iconUrl = [user iconUrlStrWithType:UMComIconSmallType];
[self.portrait setImageURL:iconUrl placeHolderImage:[UMComImageView placeHolderImageGender:user.gender.integerValue]];
//计算头像的位置
self.portrait.frame = CGRectMake(UMCom_SysCommonCell_Comment_LeftMargin, UMCom_SysCommonCell_Comment_UserImgTopMargin, UMCom_SysCommonCell_Comment_UserImgWidth, UMCom_SysCommonCell_Comment_UserImgHeight);
self.portrait.layer.cornerRadius = self.portrait.frame.size.width/2;
//设置timeLabel
self.timeLabel.text = timeString;
CGSize timeStringSize = [timeString sizeWithFont:self.timeLabel.font];
CGFloat timeLabelHeight = 0;
if (timeStringSize.height > UMCom_SysCommonCell_Comment_TimerHeight) {
timeLabelHeight = timeStringSize.height + 5;//加5个像素的上下margin
}
else
{
timeLabelHeight = UMCom_SysCommonCell_Comment_TimerHeight + 5;//加5个像素的上下margin
}
self.timeLabel.frame = CGRectMake(_cellSize.width-timeStringSize.width - UMCom_SysCommonCell_Comment_RightMargin, UMCom_SysCommonCell_Comment_TimerTopMargin, timeStringSize.width, timeLabelHeight);
//self.timeLabel.backgroundColor = [UIColor redColor];
//设置用户的名字
self.userNameLabel.text = _comment.creator.name;
CGFloat userNameWidth = _cellSize.width - UMCom_SysCommonCell_Comment_LeftMargin - UMCom_SysCommonCell_Comment_UserImgWidth - UMCom_SysCommonCell_Comment_SpaceBetweenUserImgAndUserName - UMCom_SysCommonCell_Comment_RightMargin - self.timeLabel.bounds.size.width;
CGFloat userNameHeight = UMCom_SysCommonCell_Comment_UserNameHeight + 5;
self.userNameLabel.frame =CGRectMake(UMCom_SysCommonCell_Comment_LeftMargin + UMCom_SysCommonCell_Comment_UserImgWidth + UMCom_SysCommonCell_Comment_SpaceBetweenUserImgAndUserName, UMCom_SysCommonCell_Comment_UserNameTopMargin, userNameWidth, userNameHeight);
//self.userNameLabel.backgroundColor = [UIColor grayColor];
//设置replyButton的位置
if (!self.replyButton.hidden) {
//表明是收到评论的cell,需要布局self.replyButton
CGFloat orgx = _cellSize.width - UMCom_SysCommonCell_Comment_ReplyBtnRightMargin - UMCom_SysCommonCell_Comment_ReplyBtnWidth;
CGFloat orgy = self.timeLabel.frame.origin.y + self.timeLabel.frame.size.height + UMCom_SysCommonCell_Comment_SpaceBetweenReplyBtnAndTimer;
self.replyButton.frame = CGRectMake(orgx, orgy, UMCom_SysCommonCell_Comment_ReplyBtnWidth, UMCom_SysCommonCell_Comment_ReplyBtnHeight);
}
//设置评论内容
//self.commentTextView.backgroundColor = [UIColor purpleColor];
CGRect commentFrame = self.commentTextView.frame;
commentFrame.size.height = commentMutiText.textSize.height;
if (self.replyButton.hidden) {
commentFrame.size.width = self.contentView.bounds.size.width - self.userNameLabel.frame.origin.x - UMCom_SysCommonCell_Comment_RightMargin;
}else{
commentFrame.size.width = self.replyButton.frame.origin.x - self.userNameLabel.frame.origin.x;
}
commentFrame.origin.x = self.userNameLabel.frame.origin.x;
commentFrame.origin.y = self.userNameLabel.frame.origin.y + self.userNameLabel.frame.size.height + UMCom_SysCommonCell_Comment_SpaceBetweenUserNameAndComment;
//判断当前的commentMutiText.text和commentMutiText.attributedText同时为空的时候,提供默认高度
if (!commentMutiText.text && !commentMutiText.attributedText) {
//如果没有内容就加入默认的占位高度
commentFrame.size.height = UMCom_SysCommonCell_Comment_CommentDefaultHeight;
}
self.commentTextView.frame = commentFrame;
[self.commentTextView setMutiStyleTextViewWithMutiText:commentMutiText];
__weak typeof(self) weakSelf = self;
self.commentTextView.clickOnlinkText = ^(UMComMutiStyleTextView *styleView,UMComMutiTextRun *run){
if ([run isKindOfClass:[UMComMutiTextRunClickUser class]]) {
UMComUser *user = weakSelf.comment.reply_user;
[weakSelf turnToUserCenterWithUser:user];
}else if ([run isKindOfClass:[UMComMutiTextRunURL class]]){
[weakSelf turnToWebViewWithUrlString:run.text];
}
};
//设置feed的背景区域
UMComFeed *feed = self.comment.feed;
CGFloat bgimageViewHeight = 0;
if (feed.image_urls && [feed.image_urls count] > 0) {
//有图片的布局
if ([feed.status integerValue] < FeedStatusDeleted)
{
bgimageViewHeight = UMCom_SysCommonCell_FeedWithIMG_Height;
}
else
{
bgimageViewHeight = UMCom_SysCommonCell_FeedWithoutIMG_Height;
}
}
else{
//无图片的布局
bgimageViewHeight = UMCom_SysCommonCell_FeedWithoutIMG_Height;
}
self.bgimageView.frame = CGRectMake(self.userNameLabel.frame.origin.x, self.commentTextView.frame.origin.y + self.commentTextView.frame.size.height + UMCom_SysCommonCell_Comment_CommentBotoom, _cellSize.width - self.userNameLabel.frame.origin.x - UMCom_SysCommonCell_Comment_RightMargin, bgimageViewHeight);
CGRect bgImageFrame = self.bgimageView.frame;
//设置背景中的feed
CGSize userNameSize;
CGFloat userNamelHeight = 0;
NSString* userName = feed.creator.name;
if (feed.image_urls && [feed.image_urls count] > 0)
{
if ([feed.status integerValue] < FeedStatusDeleted)
{
userName = [NSString stringWithFormat:@"@%@",userName];
userNameSize = [userName sizeWithFont:UMComFontNotoSansLightWithSafeSize(14)];
if (userNameSize.width > self.contentView.frame.size.width-80-self.feedImgView.frame.size.width - 12) {
userNameSize.width = self.contentView.frame.size.width-80-self.feedImgView.frame.size.width - 12;
}
//有图片,显示图片,feed的用户,和feedTextView
self.feedImgView.hidden = NO;
self.feedImgView.frame = CGRectMake(bgImageFrame.origin.x + UMCom_SysCommonCell_Feed_IMGLeftMargin, bgImageFrame.origin.y + UMCom_SysCommonCell_Feed_IMGTopMargin, UMCom_SysCommonCell_Feed_IMGWidth, UMCom_SysCommonCell_Feed_IMGHeight);
NSString* urlString = [[feed.image_urls firstObject] valueForKey:@"small_url_string"];
if (urlString) {
self.feedImgView.isAutoStart = YES;
[self.feedImgView setImageURL:[NSURL URLWithString:urlString] placeholderImage:UMComImageWithImageName(@"photox")];
}
//布局有图片的的feedCreatorView
//设置feedCreatorView的位置
if (userNameSize.height > UMCom_SysCommonCell_FeedCreator_DefaultHeight) {
userNamelHeight = userNameSize.height + 5;//加5个margin的距离
}
else
{
userNamelHeight = UMCom_SysCommonCell_FeedCreator_DefaultHeight + 5;//加5个margin的距离
}
self.feedCreatorView.hidden = NO;
//布局有图片的的feedTextView
//self.feedTextView.backgroundColor = [UIColor brownColor];
self.feedCreatorView.frame = CGRectMake(bgImageFrame.origin.x+UMCom_SysCommonCell_FeedCreatorWithImg_LeftMargin, bgImageFrame.origin.y+UMCom_SysCommonCell_FeedCreatorWithImg_TopMargin, userNameSize.width, userNamelHeight);
self.feedTextView.frame = CGRectMake( self.feedCreatorView.frame.origin.x, self.feedCreatorView.frame.origin.y + self.feedCreatorView.frame.size.height + UMCom_SysCommonCell_SpaceBetweenFeedTextWithIMGAndFeedCreator, bgImageFrame.size.width - (self.feedCreatorView.frame.origin.x -bgImageFrame.origin.x), UMCom_SysCommonCell_FeedTextWithIMG_DefaultHeight);
}
else
{
self.feedCreatorView.hidden = YES;
self.feedImgView.hidden = YES;
//self.feedTextView.backgroundColor = [UIColor brownColor];
self.feedTextView.frame = CGRectMake(bgImageFrame.origin.x+UMCom_SysCommonCell_FeedCreator_LeftMargin, bgImageFrame.origin.y+UMCom_SysCommonCell_FeedCreator_TopMargin, bgImageFrame.size.width - UMCom_SysCommonCell_FeedCreator_LeftMargin, bgImageFrame.size.height -UMCom_SysCommonCell_FeedCreator_TopMargin);
}
}
else
{
if ([feed.status integerValue] < FeedStatusDeleted)
{
userName = [NSString stringWithFormat:@"@%@:",userName];
userNameSize = [userName sizeWithFont:UMComFontNotoSansLightWithSafeSize(14)];
if (userNameSize.width > self.contentView.frame.size.width-80) {
userNameSize.width = self.contentView.frame.size.width-80;
}
self.feedImgView.hidden = YES;
self.feedCreatorView.hidden = NO;
//设置feedCreatorView的位置
CGFloat userNamelHeight = 0;
if (userNameSize.height > UMCom_SysCommonCell_FeedCreator_DefaultHeight) {
userNamelHeight = userNameSize.height + 5;//加5个margin的距离
}
else
{
userNamelHeight = UMCom_SysCommonCell_FeedCreator_DefaultHeight + 5;//加5个margin的距离
}
//self.feedCreatorView.backgroundColor = [UIColor orangeColor];
self.feedCreatorView.frame = CGRectMake(bgImageFrame.origin.x+UMCom_SysCommonCell_FeedCreator_LeftMargin, bgImageFrame.origin.y+UMCom_SysCommonCell_FeedCreator_TopMargin, userNameSize.width, userNamelHeight);
//设置feedTextView的位置
//self.feedTextView.backgroundColor = [UIColor brownColor];
self.feedTextView.frame = CGRectMake(self.feedCreatorView.frame.origin.x + self.feedCreatorView.frame.size.width, bgImageFrame.origin.y+UMCom_SysCommonCell_FeedTextWithoutIMG_TopMargin, bgImageFrame.size.width - (self.feedCreatorView.frame.origin.x-bgImageFrame.origin.x + self.feedCreatorView.frame.size.width), userNamelHeight);//此处的高度用feedCreatorView的默认高度来保持和feedCreatorView的高度一致
}
else
{
self.feedImgView.hidden = YES;
self.feedCreatorView.hidden = YES;
//self.feedTextView.backgroundColor = [UIColor brownColor];
self.feedTextView.frame = CGRectMake(bgImageFrame.origin.x+UMCom_SysCommonCell_FeedCreator_LeftMargin, bgImageFrame.origin.y+UMCom_SysCommonCell_FeedCreator_TopMargin, bgImageFrame.size.width - UMCom_SysCommonCell_FeedCreator_LeftMargin, bgImageFrame.size.height -UMCom_SysCommonCell_FeedCreator_TopMargin);
}
}
//设置feedCreatorView的富文本
NSMutableArray* feedCheckWords = [NSMutableArray array];
if(feed.creator.name){
NSString *checkuserName = [NSString stringWithFormat:UserNameString,feed.creator.name];
[feedCheckWords addObject:checkuserName];
}
UMComMutiText *feedCreatorText = [UMComMutiText mutiTextWithSize:CGSizeMake(userNameSize.width, MAXFLOAT) font:UMComFontNotoSansLightWithSafeSize(14) string:userName lineSpace:2 checkWords:feedCheckWords textColor:UMComColorWithHexString(@"#666666") highLightColor:UMComColorWithHexString(@"#4E7CB1")];
[self.feedCreatorView setMutiStyleTextViewWithMutiText:feedCreatorText];
self.feedCreatorView.clickOnlinkText = ^(UMComMutiStyleTextView *styleView,UMComMutiTextRun *run){
UMComMutiTextRunClickUser *userRun = (UMComMutiTextRunClickUser *)run;
UMComUser *user = [weakSelf.comment.feed relatedUserWithUserName:userRun.text];
if (!user) {
//如果为空直接到当前feed的个人中心
user = weakSelf.comment.feed.creator;
}
[weakSelf turnToUserCenterWithUser:user];
};
//设置feedTextView的富文本
[self.feedTextView setMutiStyleTextViewWithMutiText:feedMutiText];
self.feedTextView.clickOnlinkText = ^(UMComMutiStyleTextView *styleView,UMComMutiTextRun *run){
if ([run isKindOfClass:[UMComMutiTextRunClickUser class]]) {
UMComMutiTextRunClickUser *userRun = (UMComMutiTextRunClickUser *)run;
UMComUser *user = [weakSelf.comment.feed relatedUserWithUserName:userRun.text];
if (!user) {
//如果为空直接到当前feed的个人中心
user = weakSelf.comment.feed.creator;
}
[weakSelf turnToUserCenterWithUser:user];
}else if ([run isKindOfClass:[UMComMutiTextRunTopic class]])
{
UMComMutiTextRunTopic *topicRun = (UMComMutiTextRunTopic *)run;
UMComTopic *topic = [weakSelf.comment.feed relatedTopicWithTopicName:topicRun.text];
[weakSelf turnToTopicViewWithTopic:topic];
}else{
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customObj:clickOnFeedText:)]) {
__strong typeof(weakSelf)strongSelf = weakSelf;
[weakSelf.delegate customObj:strongSelf clickOnFeedText:weakSelf.comment.feed];
}
}
};
}
- (void)didClickOnReplyButton
{
if (self.delegate && [self.delegate respondsToSelector:@selector(customObj:clickOnComment:feed:)]) {
[self.delegate customObj:self clickOnComment:self.comment feed:self.comment.feed];
}
}
-(void)handleGesture:(UIGestureRecognizer*)gestureRecognizer
{
if (self.delegate && [self.delegate respondsToSelector:@selector(customObj:clickOnFeedText:)]) {
[self.delegate customObj:self clickOnFeedText:self.comment.feed];
}
}
- (void)didSelectedUser
{
[self turnToUserCenterWithUser:self.comment.creator];
}
@end
@@ -0,0 +1,116 @@
//
// UMComSysCommnTableViewCell.h
// UMCommunity
//
// Created by umeng on 15/12/27.
// Copyright © 2015年 Umeng. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "UMComTableViewCell.h"
#define UMCom_SysCommonCell_SubViews_LeftEdge 50
#define UMCom_SysCommonCell_SubViews_RightEdge 10
#define UMCom_SysCommonCell_FeedText_HorizonEdge 2
#define UMCom_SysCommonCell_FeedText_TopEdge 10
#define UMCom_SysCommonCell_FeedText_BottomEdge 3
#define UMCom_SysCommonCell_NameLabel_Height 30
#define UMCom_SysCommonCell_Content_TopEdge 10
#define UMCom_SysCommonCell_Cell_BottomEdge 25
//评论相关的参数---begin
//#define UMCom_SysCommonCell_Comment_Height 66 //评论的高度(目前不固定,由评论的内容的高度动态变化)
#define UMCom_SysCommonCell_Comment_LeftMargin 10 //评论的左间距
#define UMCom_SysCommonCell_Comment_RightMargin 11 //评论的右间距
#define UMCom_SysCommonCell_Comment_UserImgTopMargin 12 //头像的上间距
#define UMCom_SysCommonCell_Comment_UserImgWidth 38 //评论头像的宽
#define UMCom_SysCommonCell_Comment_UserImgHeight 38 //评论头像的高
#define UMCom_SysCommonCell_Comment_UserNameHeight 14 //评论者的名字
#define UMCom_SysCommonCell_Comment_UserNameTopMargin 17 //评论者的名字到上边缘的距离
#define UMCom_SysCommonCell_Comment_SpaceBetweenUserNameAndComment 10 //评论者的名字和评论内容之间的距离
#define UMCom_SysCommonCell_Comment_TimerHeight 9 //时间的高度
#define UMCom_SysCommonCell_Comment_TimerTopMargin 19 //时间的上边距
#define UMCom_SysCommonCell_Comment_ReplyBtnWidth 16 //回复btn的宽度
#define UMCom_SysCommonCell_Comment_ReplyBtnHeight 16 //回复btn的高度
#define UMCom_SysCommonCell_Comment_ReplyBtnRightMargin 15 //回复btn右边距
#define UMCom_SysCommonCell_Comment_SpaceBetweenReplyBtnAndTimer 14 //回复btn和时间的间距
#define UMCom_SysCommonCell_Comment_CommentDefaultHeight 14 //评论内容的默认高度
#define UMCom_SysCommonCell_Comment_CommentBotoom 11 //评论内容到底部的位置
#define UMCom_SysCommonCell_Comment_SpaceBetweenUserImgAndUserName 10 //评论头像和评论名字之间的间距
#define UMCom_SysCommonCell_Comment_replyBtnWidth 16 //回复评论的按钮宽度
#define UMCom_SysCommonCell_Comment_replyBtnHeight 16 //回复评论的按钮高度
//评论相关的参数---end
//feed相关的参数---begin
#define UMCom_SysCommonCell_FeedWithIMG_Height 92 //评论的带图片feed的高度
#define UMCom_SysCommonCell_FeedWithoutIMG_Height 37 //评论不带图片feed的高度
#define UMCom_SysCommonCell_Feed_IMGHeight 70 //feed的图片的高度
#define UMCom_SysCommonCell_Feed_IMGWidth 70 //feed的图片的宽度
#define UMCom_SysCommonCell_Feed_IMGLeftMargin 11 //feed的图片相对背景的左边距
#define UMCom_SysCommonCell_Feed_IMGTopMargin 11 //feed的图片的相对背景的上边距
#define UMCom_SysCommonCell_Feed_IMGMargin 11 //feed图片的上下左右的margin
#define UMCom_SysCommonCell_FeedCreator_DefaultHeight 15 //feed作者的默认高度
#define UMCom_SysCommonCell_FeedCreator_LeftMargin 11 //feed作者的相对于背景的左边距
#define UMCom_SysCommonCell_FeedCreator_TopMargin 12 //feed作者的相对于背景的上边距
#define UMCom_SysCommonCell_FeedCreatorWithImg_LeftMargin 92 //feed作者的相对于背景的左边距(有图片)
#define UMCom_SysCommonCell_FeedCreatorWithImg_TopMargin 21 //feed作者的相对于背景的上边距(有图片)
#define UMCom_SysCommonCell_FeedTextWithoutIMG_DefaultHeight 12 //feed内容的默认高度(没有图片)
#define UMCom_SysCommonCell_FeedTextWithoutIMG_TopMargin 14 //feed内容的相对于背景的上边距
#define UMCom_SysCommonCell_FeedTextWithIMG_DefaultHeight 28 //feed内容的默认高度(没有图片)
#define UMCom_SysCommonCell_SpaceBetweenFeedTextWithIMGAndFeedCreator 10 //feed内容和FeedCreator的间距
//feed相关的参数---end
#define UMCom_SysCommonCell_BottomMargin 10 //最下面的margin
@class UMComMutiStyleTextView, UMComImageView, UMComMutiText, UMComUser, UMComTopic;
@protocol UMComClickActionDelegate;
@interface UMComSysCommonTableViewCell :UMComTableViewCell
@property (nonatomic, strong) UMComImageView *portrait;
@property (nonatomic, strong) UILabel *userNameLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, weak) id<UMComClickActionDelegate> delegate;
@property (nonatomic, strong) UMComMutiStyleTextView *feedTextView;
@property (nonatomic, strong) UIImageView *bgimageView;
- (instancetype)initWithStyle:(UITableViewCellStyle)style
reuseIdentifier:(NSString *)reuseIdentifier
cellSize:(CGSize)cellSize;
- (void)reloadCellWithObj:(id)obj
timeString:(NSString *)timeString
mutiText:(UMComMutiText *)commentMutiText
feedMutiText:(UMComMutiText *)feedMutiText;
- (void)didSelectedUser;
- (void)turnToUserCenterWithUser:(UMComUser *)user;
- (void)turnToTopicViewWithTopic:(UMComTopic *)topic;
- (void)turnToWebViewWithUrlString:(NSString *)urlString;
@end
@@ -0,0 +1,123 @@
//
// UMComSysCommnTableViewCell.m
// UMCommunity
//
// Created by umeng on 15/12/27.
// Copyright © 2015年 Umeng. All rights reserved.
//
#import "UMComSysCommonTableViewCell.h"
#import "UMComImageView.h"
#import "UMComMutiStyleTextView.h"
#import "UMComResouceDefines.h"
#import "UMComClickActionDelegate.h"
#import <UMComFoundation/UMComKit+Color.h>
@interface UMComSysCommonTableViewCell () <UMComClickActionDelegate>
@property (nonatomic, strong) UMComComment *comment;
@property(nonatomic,strong)UITapGestureRecognizer *bgimageViewTapGesture;
-(void)handleGesture:(UIGestureRecognizer*)gestureRecognizer;
@end
@implementation UMComSysCommonTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier cellSize:(CGSize)cellSize
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
CGFloat textOriginX = UMCom_SysCommonCell_SubViews_LeftEdge;
CGFloat textOriginY = UMCom_SysCommonCell_Content_TopEdge;
self.customSpace = 2.0f;
self.portrait = [[[UMComImageView imageViewClassName] alloc]initWithFrame:CGRectMake(10, textOriginY, 30, 30)];
self.portrait.userInteractionEnabled = YES;
self.portrait.layer.cornerRadius = self.portrait.frame.size.width/2;
self.portrait.clipsToBounds = YES;
[self.contentView addSubview:self.portrait];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didSelectedUser)];
[self.portrait addGestureRecognizer:tap];
self.userNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(textOriginX, textOriginY, cellSize.width-textOriginX-10-120, UMCom_SysCommonCell_NameLabel_Height)];
self.userNameLabel.font = UMComFontNotoSansLightWithSafeSize(14);
self.userNameLabel.textColor = UMComColorWithHexString(@"#333333");
[self.contentView addSubview:self.userNameLabel];
self.timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(textOriginX+self.userNameLabel.frame.size.width, textOriginY, 120, UMCom_SysCommonCell_NameLabel_Height)];
self.timeLabel.textColor = UMComColorWithHexString(@"#A5A5A5");
self.timeLabel.textAlignment = NSTextAlignmentRight;
self.timeLabel.font = UMComFontNotoSansLightWithSafeSize(10);
[self.contentView addSubview:self.timeLabel];
self.bgimageView = [[UIImageView alloc]initWithFrame:CGRectMake(textOriginX, self.userNameLabel.frame.origin.y+self.userNameLabel.frame.size.height, cellSize.width-60, 100)];
//设置背景可点击事件--begin
self.bgimageView.userInteractionEnabled = YES;
self.bgimageViewTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleGesture:)];
[self.bgimageView addGestureRecognizer:self.bgimageViewTapGesture];
//设置背景可点击事件--end
// UIImage *resizableImage = [UMComImageWithImageName(@"origin_image_bg") resizableImageWithCapInsets:UIEdgeInsetsMake(20, 50, 0, 0)];
// self.bgimageView.image = resizableImage;
self.bgimageView.backgroundColor = UMComColorWithHexString(@"#F5F6FA");
[self.contentView addSubview:self.bgimageView];
self.feedTextView = [[UMComMutiStyleTextView alloc] initWithFrame:CGRectMake(textOriginX, self.bgimageView.frame.origin.y+10, cellSize.width-60, 80)];
self.feedTextView.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:self.feedTextView];
self.contentView.backgroundColor = [UIColor whiteColor];
}
return self;
}
- (void)reloadCellWithObj:(id)obj
timeString:(NSString *)timeString
mutiText:(UMComMutiText *)commentMutiText
feedMutiText:(UMComMutiText *)feedMutiText
{
}
-(void)dealloc
{
[self.bgimageView removeGestureRecognizer:self.bgimageViewTapGesture];
}
#pragma mark - action
-(void)handleGesture:(UIGestureRecognizer*)gestureRecognizer
{
}
- (void)didSelectedUser
{
}
- (void)turnToUserCenterWithUser:(UMComUser *)user
{
if (self.delegate && [self.delegate respondsToSelector:@selector(customObj:clickOnUser:)]) {
[self.delegate customObj:self clickOnUser:user];
}
}
- (void)turnToTopicViewWithTopic:(UMComTopic *)topic
{
if (self.delegate && [self.delegate respondsToSelector:@selector(customObj:clickOnTopic:)]) {
[self.delegate customObj:self clickOnTopic:topic];
}
}
- (void)turnToWebViewWithUrlString:(NSString *)urlString
{
if (self.delegate && [self.delegate respondsToSelector:@selector(customObj:clickOnURL:)]) {
[self.delegate customObj:self clickOnURL:urlString];
}
}
@end
@@ -0,0 +1,14 @@
//
// UMComSysLikeTableViewCell.h
// UMCommunity
//
// Created by umeng on 15/12/28.
// Copyright © 2015年 Umeng. All rights reserved.
//
#import "UMComSysCommonTableViewCell.h"
@interface UMComSysLikeTableViewCell : UMComSysCommonTableViewCell
@end
@@ -0,0 +1,285 @@
//
// UMComSysLikeTableViewCell.m
// UMCommunity
//
// Created by umeng on 15/12/28.
// Copyright © 2015年 Umeng. All rights reserved.
//
#import "UMComSysLikeTableViewCell.h"
#import <UMComDataStorage/UMComLike.h>
#import "UMComMutiStyleTextView.h"
#import "UMComImageView.h"
#import "UMComResouceDefines.h"
#import "UMComClickActionDelegate.h"
#import <UMComDataStorage/UMComFeed.h>
#import <UMComDataStorage/UMComUser.h>
#import <UMComFoundation/UMComKit+Color.h>
@interface UMComSysLikeTableViewCell ()
@property (nonatomic, strong) UMComLike *like;
@property (nonatomic, strong) UILabel *commentTextView;
@property (nonatomic, assign) CGSize cellSize;
@property (nonatomic, strong) UMComMutiStyleTextView *feedCreatorView;
@property (nonatomic, strong) UMImageView *feedImgView;
@end
@implementation UMComSysLikeTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier cellSize:(CGSize)cellSize
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier cellSize:cellSize];
if (self) {
_cellSize = cellSize;
self.commentTextView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
[self.contentView addSubview:self.commentTextView];
//创建在feed下面有图片的时候单独创建feed作者控件
self.feedCreatorView = [[UMComMutiStyleTextView alloc] initWithFrame:CGRectMake(UMCom_SysCommonCell_SubViews_LeftEdge, UMCom_SysCommonCell_Content_TopEdge + self.userNameLabel.frame.size.height+10, cellSize.width-80, 50)];
self.feedCreatorView.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:self.feedCreatorView];
self.feedImgView = [[UMImageView alloc]initWithFrame: CGRectMake(68, 188, UMCom_SysCommonCell_Feed_IMGHeight, UMCom_SysCommonCell_Feed_IMGHeight)];
self.feedImgView.hidden = YES;
[self.contentView addSubview:self.feedImgView];
}
return self;
}
- (void)reloadCellWithObj:(id)obj
timeString:(NSString *)timeString
mutiText:(UMComMutiText *)commentMutiText
feedMutiText:(UMComMutiText *)feedMutiText
{
self.like = (UMComLike *)obj;
UMComUser *user = _like.creator;
NSString *iconUrl = [user iconUrlStrWithType:UMComIconSmallType];
[self.portrait setImageURL:iconUrl placeHolderImage:[UMComImageView placeHolderImageGender:user.gender.integerValue]];
//计算头像的位置
self.portrait.frame = CGRectMake(UMCom_SysCommonCell_Comment_LeftMargin, UMCom_SysCommonCell_Comment_UserImgTopMargin, UMCom_SysCommonCell_Comment_UserImgWidth, UMCom_SysCommonCell_Comment_UserImgHeight);
self.portrait.layer.cornerRadius = self.portrait.frame.size.width/2;
//设置timeLabel
self.timeLabel.textColor = UMComColorWithHexString(@"#A5A5A5");
self.timeLabel.textAlignment = NSTextAlignmentRight;
self.timeLabel.font = UMComFontNotoSansLightWithSafeSize(10);
self.timeLabel.text = timeString;
CGSize timeStringSize = [timeString sizeWithFont:UMComFontNotoSansLightWithSafeSize(10)];
CGFloat timeLabelHeight = 0;
if (timeStringSize.height > UMCom_SysCommonCell_Comment_TimerHeight) {
timeLabelHeight = timeStringSize.height + 5;//加5个像素的上下margin
}
else
{
timeLabelHeight = UMCom_SysCommonCell_Comment_TimerHeight + 5;//加5个像素的上下margin
}
self.timeLabel.frame = CGRectMake(_cellSize.width-timeStringSize.width - UMCom_SysCommonCell_Comment_RightMargin, UMCom_SysCommonCell_Comment_TimerTopMargin, timeStringSize.width, timeLabelHeight);
//self.timeLabel.backgroundColor = [UIColor redColor];
//设置用户的名字
self.userNameLabel.font = UMComFontNotoSansLightWithSafeSize(14);
self.userNameLabel.text = self.like.creator.name;
CGFloat userNameWidth = _cellSize.width - UMCom_SysCommonCell_Comment_LeftMargin - UMCom_SysCommonCell_Comment_UserImgWidth - UMCom_SysCommonCell_Comment_SpaceBetweenUserImgAndUserName - UMCom_SysCommonCell_Comment_RightMargin - self.timeLabel.bounds.size.width;
CGFloat userNameHeight = UMCom_SysCommonCell_Comment_UserNameHeight + 5;
self.userNameLabel.frame =CGRectMake(UMCom_SysCommonCell_Comment_LeftMargin + UMCom_SysCommonCell_Comment_UserImgWidth + UMCom_SysCommonCell_Comment_SpaceBetweenUserImgAndUserName, UMCom_SysCommonCell_Comment_UserNameTopMargin, userNameWidth, userNameHeight);
//self.userNameLabel.backgroundColor = [UIColor grayColor];
//设置评论内容
//self.commentTextView.backgroundColor = [UIColor purpleColor];
CGRect commentFrame = self.commentTextView.frame;
commentFrame.size.height = UMCom_SysCommonCell_Comment_CommentDefaultHeight;
commentFrame.size.width = _cellSize.width - self.userNameLabel.frame.origin.x - UMCom_SysCommonCell_Comment_RightMargin;
commentFrame.origin.x = self.userNameLabel.frame.origin.x;
commentFrame.origin.y = self.userNameLabel.frame.origin.y + self.userNameLabel.frame.size.height + UMCom_SysCommonCell_Comment_SpaceBetweenUserNameAndComment;
self.commentTextView.frame = commentFrame;
self.commentTextView.text = UMComLocalizedString(@"um_com_assistCommentText", @"赞了这条评论");
self.commentTextView.textColor = UMComColorWithHexString(@"#A5A5A5");
self.commentTextView.font = UMComFontNotoSansLightWithSafeSize(14);
//设置feed的背景区域
UMComFeed *feed = self.like.feed;
CGFloat bgimageViewHeight = 0;
if (feed.image_urls && [feed.image_urls count] > 0) {
//有图片的布局
if ([feed.status integerValue] < FeedStatusDeleted)
{
bgimageViewHeight = UMCom_SysCommonCell_FeedWithIMG_Height;
}
else
{
bgimageViewHeight = UMCom_SysCommonCell_FeedWithoutIMG_Height;
}
}
else{
//无图片的布局
bgimageViewHeight = UMCom_SysCommonCell_FeedWithoutIMG_Height;
}
self.bgimageView.frame = CGRectMake(self.userNameLabel.frame.origin.x, self.commentTextView.frame.origin.y + self.commentTextView.frame.size.height + UMCom_SysCommonCell_Comment_CommentBotoom, _cellSize.width - self.userNameLabel.frame.origin.x - UMCom_SysCommonCell_Comment_RightMargin, bgimageViewHeight);
CGRect bgImageFrame = self.bgimageView.frame;
//设置背景中的feed
CGSize userNameSize;
CGFloat userNamelHeight = 0;
NSString* userName = feed.creator.name;
if (feed.image_urls && [feed.image_urls count] > 0)
{
if ([feed.status integerValue] < FeedStatusDeleted)
{
userName = [NSString stringWithFormat:@"@%@",userName];
userNameSize = [userName sizeWithFont:UMComFontNotoSansLightWithSafeSize(14)];
if (userNameSize.width > self.contentView.frame.size.width-80-self.feedImgView.frame.size.width - 12) {
userNameSize.width = self.contentView.frame.size.width-80-self.feedImgView.frame.size.width - 12;
}
//有图片,显示图片,feed的用户,和feedTextView
self.feedImgView.hidden = NO;
self.feedImgView.frame = CGRectMake(bgImageFrame.origin.x + UMCom_SysCommonCell_Feed_IMGLeftMargin, bgImageFrame.origin.y + UMCom_SysCommonCell_Feed_IMGTopMargin, UMCom_SysCommonCell_Feed_IMGWidth, UMCom_SysCommonCell_Feed_IMGHeight);
NSString* urlString = [[feed.image_urls firstObject] valueForKey:@"small_url_string"];
if (urlString) {
self.feedImgView.isAutoStart = YES;
[self.feedImgView setImageURL:[NSURL URLWithString:urlString] placeholderImage:UMComImageWithImageName(@"photox")];
}
//布局有图片的的feedCreatorView
//设置feedCreatorView的位置
if (userNameSize.height > UMCom_SysCommonCell_FeedCreator_DefaultHeight) {
userNamelHeight = userNameSize.height + 5;//加5个margin的距离
}
else
{
userNamelHeight = UMCom_SysCommonCell_FeedCreator_DefaultHeight + 5;//加5个margin的距离
}
self.feedCreatorView.hidden = NO;
//布局有图片的的feedTextView
//self.feedTextView.backgroundColor = [UIColor brownColor];
self.feedCreatorView.frame = CGRectMake(bgImageFrame.origin.x+UMCom_SysCommonCell_FeedCreatorWithImg_LeftMargin, bgImageFrame.origin.y+UMCom_SysCommonCell_FeedCreatorWithImg_TopMargin, userNameSize.width, userNamelHeight);
self.feedTextView.frame = CGRectMake( self.feedCreatorView.frame.origin.x, self.feedCreatorView.frame.origin.y + self.feedCreatorView.frame.size.height + UMCom_SysCommonCell_SpaceBetweenFeedTextWithIMGAndFeedCreator, bgImageFrame.size.width - (self.feedCreatorView.frame.origin.x -bgImageFrame.origin.x), UMCom_SysCommonCell_FeedTextWithIMG_DefaultHeight);
}
else
{
self.feedCreatorView.hidden = YES;
self.feedImgView.hidden = YES;
//self.feedTextView.backgroundColor = [UIColor brownColor];
self.feedTextView.frame = CGRectMake(bgImageFrame.origin.x+UMCom_SysCommonCell_FeedCreator_LeftMargin, bgImageFrame.origin.y+UMCom_SysCommonCell_FeedCreator_TopMargin, bgImageFrame.size.width - UMCom_SysCommonCell_FeedCreator_LeftMargin, bgImageFrame.size.height -UMCom_SysCommonCell_FeedCreator_TopMargin);
}
}
else
{
if ([feed.status integerValue] < FeedStatusDeleted)
{
userName = [NSString stringWithFormat:@"@%@:",userName];
userNameSize = [userName sizeWithFont:UMComFontNotoSansLightWithSafeSize(14)];
if (userNameSize.width > self.contentView.frame.size.width-80) {
userNameSize.width = self.contentView.frame.size.width-80;
}
self.feedImgView.hidden = YES;
self.feedCreatorView.hidden = NO;
//设置feedCreatorView的位置
CGFloat userNamelHeight = 0;
if (userNameSize.height > UMCom_SysCommonCell_FeedCreator_DefaultHeight) {
userNamelHeight = userNameSize.height + 5;//加5个margin的距离
}
else
{
userNamelHeight = UMCom_SysCommonCell_FeedCreator_DefaultHeight + 5;//加5个margin的距离
}
//self.feedCreatorView.backgroundColor = [UIColor orangeColor];
self.feedCreatorView.frame = CGRectMake(bgImageFrame.origin.x+UMCom_SysCommonCell_FeedCreator_LeftMargin, bgImageFrame.origin.y+UMCom_SysCommonCell_FeedCreator_TopMargin, userNameSize.width, userNamelHeight);
//设置feedTextView的位置
//self.feedTextView.backgroundColor = [UIColor brownColor];
self.feedTextView.frame = CGRectMake(self.feedCreatorView.frame.origin.x + self.feedCreatorView.frame.size.width, bgImageFrame.origin.y+UMCom_SysCommonCell_FeedTextWithoutIMG_TopMargin, bgImageFrame.size.width - (self.feedCreatorView.frame.origin.x-bgImageFrame.origin.x + self.feedCreatorView.frame.size.width), userNamelHeight);//此处的高度用feedCreatorView的默认高度来保持和feedCreatorView的高度一致
}
else
{
self.feedImgView.hidden = YES;
self.feedCreatorView.hidden = YES;
//self.feedTextView.backgroundColor = [UIColor brownColor];
self.feedTextView.frame = CGRectMake(bgImageFrame.origin.x+UMCom_SysCommonCell_FeedCreator_LeftMargin, bgImageFrame.origin.y+UMCom_SysCommonCell_FeedCreator_TopMargin, bgImageFrame.size.width - UMCom_SysCommonCell_FeedCreator_LeftMargin, bgImageFrame.size.height -UMCom_SysCommonCell_FeedCreator_TopMargin);
}
}
//设置feedCreatorView的富文本
__weak typeof(self) weakSelf = self;
NSMutableArray* feedCheckWords = [NSMutableArray array];
if(feed.creator.name){
NSString *checkuserName = [NSString stringWithFormat:UserNameString,feed.creator.name];
[feedCheckWords addObject:checkuserName];
}
UMComMutiText *feedCreatorText = [UMComMutiText mutiTextWithSize:CGSizeMake(userNameSize.width, MAXFLOAT) font:UMComFontNotoSansLightWithSafeSize(14) string:userName lineSpace:2 checkWords:feedCheckWords];
[self.feedCreatorView setMutiStyleTextViewWithMutiText:feedCreatorText];
self.feedCreatorView.clickOnlinkText = ^(UMComMutiStyleTextView *styleView,UMComMutiTextRun *run){
UMComMutiTextRunClickUser *userRun = (UMComMutiTextRunClickUser *)run;
UMComUser *user = [weakSelf.like.feed relatedUserWithUserName:userRun.text];
if (!user) {
//如果为空直接到当前feed的个人中心
user = weakSelf.like.feed.creator;
}
[weakSelf turnToUserCenterWithUser:user];
};
//设置feedTextView的富文本
[self.feedTextView setMutiStyleTextViewWithMutiText:feedMutiText];
self.feedTextView.clickOnlinkText = ^(UMComMutiStyleTextView *styleView,UMComMutiTextRun *run){
if ([run isKindOfClass:[UMComMutiTextRunClickUser class]]) {
UMComMutiTextRunClickUser *userRun = (UMComMutiTextRunClickUser *)run;
UMComUser *user = [weakSelf.like.feed relatedUserWithUserName:userRun.text];
if (!user) {
//如果为空直接到当前feed的个人中心
user = weakSelf.like.feed.creator;
}
[weakSelf turnToUserCenterWithUser:user];
}else if ([run isKindOfClass:[UMComMutiTextRunTopic class]])
{
UMComMutiTextRunTopic *topicRun = (UMComMutiTextRunTopic *)run;
UMComTopic *topic = [weakSelf.like.feed relatedTopicWithTopicName:topicRun.text];
[weakSelf turnToTopicViewWithTopic:topic];
}else{
if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(customObj:clickOnFeedText:)]) {
__strong typeof(weakSelf)strongSelf = weakSelf;
[weakSelf.delegate customObj:strongSelf clickOnFeedText:weakSelf.like.feed];
}
}
};
}
#pragma mark - override method
//点赞用户头像
- (void)didSelectedUser
{
[self turnToUserCenterWithUser:self.like.creator];
}
-(void)handleGesture:(UIGestureRecognizer*)gestureRecognizer
{
if (self.delegate && [self.delegate respondsToSelector:@selector(customObj:clickOnFeedText:)]) {
[self.delegate customObj:self clickOnFeedText:self.like.feed];
}
}
@end
@@ -0,0 +1,45 @@
//
// UMComSysPrivateLetterCell.h
// UMCommunity
//
// Created by umeng on 16/3/4.
// Copyright © 2016年 Umeng. All rights reserved.
//
#import "UMComTableViewCell.h"
#define UMCom_Forum_LetterList_Cell_Height 64
#define UMCom_Forum_LetterList_IconName_Space 10
#define UMCom_Forum_LetterList_Icon_TopEdge 10
#define UMCom_Forum_LetterList_Icon_LeftEdge 10
#define UMCom_Forum_LetterList_Name_TextFont 16
#define UMCom_Forum_LetterList_Name_TextColor @"#333333"
#define UMCom_Forum_LetterList_Message_TextFont 13
#define UMCom_Forum_LetterList_Message_TextColor @"#999999"
#define UMCom_Forum_LetterList_Date_TextFont 12
#define UMCom_Forum_LetterList_Date_TextColor @"#A5A5A5"
#define UMCom_Forum_LetterList_DateLabel_Width 100
#define UMCom_Forum_LetterList_RedDot_Diameter 20
#define UMCom_Forum_LetterList_RedDot_TextFont 11
#define UMCom_Forum_letterList_RedDot_TextColor @"#FFFFFF"
#define UMCom_Forum_letterList_CellItems_RightEdge 10
@class UMComImageView,UMComPrivateLetter;
@interface UMComSysPrivateLetterCell : UMComTableViewCell
@property (nonatomic, strong) UMComImageView *iconImageView;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *dateLabel;
@property (nonatomic, strong) UILabel *detailLabel;
@property (nonatomic, strong) UILabel *redDotLabel;
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier cellSize:(CGSize)size;
- (void)reloadCellWithPrivateLetter:(UMComPrivateLetter *)privateLetter;
@end
@@ -0,0 +1,92 @@
//
// UMComSysPrivateLetterCell.m
// UMCommunity
//
// Created by umeng on 16/3/4.
// Copyright © 2016年 Umeng. All rights reserved.
//
#import "UMComSysPrivateLetterCell.h"
#import "UMComImageView.h"
#import <UMCommunitySDK/UMComSession.h>
#import <UMComDataStorage/UMComPrivateLetter.h>
#import <UMComDataStorage/UMComPrivateMessage.h>
#import <UMComDataStorage/UMComImageUrl.h>
#import "UMComResouceDefines.h"
#import <UMComFoundation/UMComKit+Color.h>
@implementation UMComSysPrivateLetterCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier cellSize:(CGSize)size
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
CGFloat iconLeftEdge = UMCom_Forum_LetterList_Icon_LeftEdge;
CGFloat icoTopEdge = UMCom_Forum_LetterList_Icon_TopEdge;
CGFloat iconWidth = size.height - icoTopEdge*2;
self.iconImageView = [[[UMComImageView imageViewClassName] alloc]initWithFrame:CGRectMake(iconLeftEdge, icoTopEdge, iconWidth, iconWidth)];
self.iconImageView.clipsToBounds = YES;
self.iconImageView.layer.cornerRadius = iconWidth/2;
[self.contentView addSubview:self.iconImageView];
CGFloat v_ImageWidth = 15;
UIImageView *v_imageView = [[UIImageView alloc]initWithFrame:CGRectMake(iconLeftEdge+iconWidth - v_ImageWidth, iconLeftEdge+iconWidth - v_ImageWidth, v_ImageWidth, v_ImageWidth)];
v_imageView.image = UMComImageWithImageName(@"um_forum_v_blue");
[self.iconImageView addSubview:v_imageView];
CGFloat subViewsRightEdge = UMCom_Forum_letterList_CellItems_RightEdge;
CGFloat dataLabelWidth = UMCom_Forum_LetterList_DateLabel_Width;
CGFloat redDotWidth = UMCom_Forum_LetterList_RedDot_Diameter;
CGFloat nameLabelLeftEdge = iconLeftEdge+iconWidth+UMCom_Forum_LetterList_IconName_Space;
self.nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(nameLabelLeftEdge, UMCom_Forum_LetterList_Icon_TopEdge, size.width-nameLabelLeftEdge-subViewsRightEdge-dataLabelWidth, (size.height - UMCom_Forum_LetterList_Icon_TopEdge)/2)];
self.nameLabel.font = UMComFontNotoSansLightWithSafeSize(UMCom_Forum_LetterList_Name_TextFont);
self.nameLabel.textColor = UMComColorWithHexString(UMCom_Forum_LetterList_Name_TextColor);
[self.contentView addSubview:self.nameLabel];
self.dateLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.nameLabel.frame.size.width+self.nameLabel.frame.origin.x, self.nameLabel.frame.origin.y, dataLabelWidth, self.nameLabel.frame.size.height)];
self.dateLabel.font = UMComFontNotoSansLightWithSafeSize(UMCom_Forum_LetterList_Date_TextFont);
self.dateLabel.numberOfLines = 0;
self.dateLabel.textAlignment = NSTextAlignmentRight;
self.dateLabel.textColor = UMComColorWithHexString(UMCom_Forum_LetterList_Date_TextColor);
[self.contentView addSubview:self.dateLabel];
self.detailLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.nameLabel.frame.origin.x, self.nameLabel.frame.size.height+self.nameLabel.frame.origin.y, size.width-iconWidth-iconLeftEdge*2-redDotWidth-subViewsRightEdge, (size.height - UMCom_Forum_LetterList_Icon_TopEdge*2) - self.nameLabel.frame.size.height)];
self.detailLabel.font = UMComFontNotoSansLightWithSafeSize(UMCom_Forum_LetterList_Message_TextFont);
self.detailLabel.textColor = UMComColorWithHexString(UMCom_Forum_LetterList_Message_TextColor);
[self.contentView addSubview:self.detailLabel];
self.redDotLabel = [[UILabel alloc]initWithFrame:CGRectMake(size.width - redDotWidth - subViewsRightEdge,0, redDotWidth, redDotWidth)];
self.redDotLabel.center = CGPointMake(self.redDotLabel.center.x, self.detailLabel.center.y);
self.redDotLabel.backgroundColor = [UIColor redColor];
self.redDotLabel.layer.cornerRadius = redDotWidth/2;
self.redDotLabel.clipsToBounds = YES;
self.redDotLabel.font = UMComFontNotoSansLightWithSafeSize(UMCom_Forum_LetterList_RedDot_TextFont);
self.redDotLabel.textColor = UMComColorWithHexString(UMCom_Forum_letterList_RedDot_TextColor);
self.redDotLabel.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:self.redDotLabel];
}
return self;
}
- (void)reloadCellWithPrivateLetter:(UMComPrivateLetter *)privateLetter
{
[self.iconImageView setImageURL:privateLetter.user.icon_url.small_url_string placeHolderImage:UMComImageWithImageName(@"um_forum_user_smile_gray")];
self.nameLabel.text = privateLetter.user.name?privateLetter.user.name:UMComLocalizedString(@"um_com_guest", @"无名客");
//self.dateLabel.text = privateLetter.update_time? privateLetter.update_time:[[NSDate date] description];
NSString* dataString = privateLetter.update_time? privateLetter.update_time:[[NSDate date] description];
self.dateLabel.text = createTimeString(dataString);
self.detailLabel.text = privateLetter.last_message.content?privateLetter.last_message.content:UMComLocalizedString(@"um_com_lastMessage", @"这本该是最后一条信息的");
int unreadCount = [privateLetter.unread_count intValue];
if (unreadCount > 0) {
self.redDotLabel.hidden = NO;
NSString *unreadText = [NSString stringWithFormat:@"%d",unreadCount];
self.redDotLabel.text = privateLetter.unread_count?unreadText:@"12";
}else{
self.redDotLabel.hidden = YES;
}
}
@end