|
//
// reTopicCell.m
// ThePaperHD
//
// Created by YoungLee on 15/6/9.
// Copyright (c) 2015年 scar1900. All rights reserved.
//
#import "reTopicCell.h"
#import "AsyncImageView.h"
@interface reTopicCell(){
CGFloat contentHeight;
}
@property(nonatomic, strong)UIView *backView;
@property(nonatomic, strong)UILabel *type;
@property(nonatomic, strong)UILabel *content;
@property(nonatomic, strong)AsyncImageView *userImg;
@property(nonatomic, strong)UIImageView *vImg;
@property(nonatomic, strong)UILabel *userName;
@property(nonatomic, strong)UIImageView *praiseImg;
@property(nonatomic, strong)UILabel *praiseNum;
@property(nonatomic, strong)UILabel *status;
@property(nonatomic, strong)UIButton *gotoInfo;
@end
@implementation reTopicCell
@synthesize topic = _topic;
- (void)awakeFromNib {
// Initialization code
}
//54 6E A5
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
[self.contentView addSubview:self.backView];
[self.backView addSubview:self.type];
[self.backView addSubview:self.content];
[self.backView addSubview:self.userImg];
[self.backView addSubview:self.vImg];
[self.backView addSubview:self.userName];
[self.backView addSubview:self.praiseImg];
[self.backView addSubview:self.praiseNum];
[self.backView addSubview:self.status];
[self.backView addSubview:self.gotoInfo];
}
return self;
}
-(UIView *)backView{
if (!_backView) {
_backView = [[UIView alloc] initWithFrame:CGRectZero];
_backView.backgroundColor = [UIColor colorWithHexString:@"0x425784"];
}
return _backView;
}
-(UILabel *)type{
if (!_type) {
_type = [[UILabel alloc] initWithFrame:CGRectZero];
_type.font = appFont(15, NO);
_type.layer.borderWidth = 1;
_type.layer.borderColor = [UIColor whiteColor].CGColor;
_type.textColor = [UIColor whiteColor];
_type.backgroundColor = [UIColor colorWithHexString:@"0x252F45"];
_type.textAlignment = NSTextAlignmentCenter;
}
return _type;
}
-(UILabel *)content{
if (!_content) {
_content = [[UILabel alloc] initWithFrame:CGRectZero];
_content.textColor = [UIColor whiteColor];
_content.font = appFont(30,NO);
_content.numberOfLines = 0;
}
return _content;
}
-(AsyncImageView *)userImg{
if (!_userImg) {
_userImg = [[AsyncImageView alloc] initWithFrame:CGRectZero];
_userImg.layer.borderColor = [UIColor whiteColor].CGColor;
_userImg.layer.borderWidth = 1;
_userImg.layer.cornerRadius = 15;
_userImg.clipsToBounds = YES;
}
return _userImg;
}
-(UIImageView *)vImg{
if (!_vImg) {
_vImg = [[UIImageView alloc] initWithFrame:CGRectZero];
_vImg.image = Image(@"topic/vipIcon.png");
}
return _vImg;
}
-(UILabel *)userName{
if (!_userName) {
_userName = [[UILabel alloc] initWithFrame:CGRectZero];
_userName.font = appFont(11, NO);
_userName.textColor = [UIColor whiteColor];
_userName.textAlignment = NSTextAlignmentCenter;
_userName.lineBreakMode = NSLineBreakByWordWrapping;
_userName.numberOfLines = 0;
}
return _userName;
}
-(UIImageView *)praiseImg{
if (!_praiseImg) {
_praiseImg = [[UIImageView alloc]initWithFrame:CGRectZero];
_praiseImg.image = Image(@"topic/topicPraiseIcon.png");
_praiseImg.userInteractionEnabled = YES;
}
return _praiseImg;
}
-(UILabel *)praiseNum{
if (!_praiseNum) {
_praiseNum = [[UILabel alloc] initWithFrame:CGRectZero];
_praiseNum.font = appFont(11, NO);
_praiseNum.textColor = [UIColor whiteColor];
_praiseNum.lineBreakMode = NSLineBreakByWordWrapping;
}
return _praiseNum;
}
-(UILabel *)status{
if (!_status) {
_status = [[UILabel alloc] initWithFrame:CGRectZero];
_status.font = appFont(11, NO);
_status.textColor = [UIColor whiteColor];
}
return _status;
}
-(UIButton *)gotoInfo{
if (!_gotoInfo) {
_gotoInfo = [UIButton buttonWithType:UIButtonTypeCustom];
_gotoInfo.titleLabel.font = appFont(11, NO);
_gotoInfo.layer.cornerRadius = 5;
_gotoInfo.backgroundColor = [UIColor whiteColor];
_gotoInfo.userInteractionEnabled = NO;
[_gotoInfo setTitle:@"查看话题详情" forState:UIControlStateNormal];
[_gotoInfo setTitleColor:[UIColor colorWithHexString:BLUECOLOR] forState:UIControlStateNormal];
}
return _gotoInfo;
}
-(void)setTopic:(TopicInfoBO *)topicInfo{
_topic = topicInfo;
self.type.text = _topic.categoryName;
self.content.text = _topic.title;
userBO *user = setJsonDicToDataModel(_topic.userInfo, [userBO class]);
self.userImg.imageUrl = user.pic;
if ([user.isAuth integerValue] == 0) {
self.vImg.hidden = YES;
}else{
self.vImg.hidden = NO;
}
self.userName.text = user.sname;
self.praiseNum.text = _topic.praiseTimes;
self.status.text = [self statuName:_topic];
[self layoutSubviews];
}
//状态:0- 已提交待审核;1- 进行中;2- 审核不通过;3- 关闭
-(NSString *)statuName:(TopicInfoBO *)topic{
NSString *str;
if ([topic.status integerValue] ==0) {
str = @"待审核";
}else if ([topic.status integerValue] ==1) {
if ([topic.replyedNum integerValue] <=0) {//【需求】话题:增加提问征集中的状态(bug:4323)
str = @"提问征集中";
}else{
str = @"进行中...";
}
}else if ([topic.status integerValue] ==2) {
str = @"未通过";
}else if ([topic.status integerValue] ==3) {
str = @"已关闭提问";
}
return str;
}
-(void)layoutSubviews{
[super layoutSubviews];
contentHeight = heightForString(_topic.title, self.content.font,CGRectGetWidth(self.backView.frame)-100 , self.content.lineBreakMode);
self.backView.frame = CGRectMake(CGRectGetWidth(self.contentView.bounds)/2 - 1320/4 - 27/2, 0, 1320/2, 235);
self.type.frame = CGRectMake(CGRectGetWidth(self.backView.frame)/2 - 87/2, 18, 87, 35);
self.userImg.frame = CGRectMake(50, CGRectGetHeight(self.backView.frame)-49, 30, 30);
self.vImg.frame = CGRectMake(CGRectGetMaxX(self.userImg.frame)-10, CGRectGetMaxY(self.userImg.frame)-11, 11, 11);
self.userName.frame = CGRectMake(CGRectGetMaxX(self.vImg.frame)+10, CGRectGetMinY(self.userImg.frame), widthForString(self.userName.text, self.userName.font, 30, self.userName.lineBreakMode), 30);
self.praiseImg.frame = CGRectMake(CGRectGetMaxX(self.userName.frame)+10, CGRectGetMinY(self.userImg.frame)+19/2, 11, 11);
self.praiseNum.frame = CGRectMake(CGRectGetMaxX(self.praiseImg.frame)+5, CGRectGetMinY(self.userImg.frame), widthForString(self.praiseNum.text, self.praiseNum.font, 30, self.praiseNum.lineBreakMode), 30);
self.status.frame= CGRectMake(CGRectGetMaxX(self.praiseNum.frame)+10, CGRectGetMinY(self.userImg.frame), widthForString(self.status.text, self.status.font, 30, self.status.lineBreakMode), 30);
self.content.frame = CGRectMake(CGRectGetMinX(self.userImg.frame),CGRectGetMinY(self.userImg.frame)-contentHeight-10, CGRectGetWidth(self.backView.frame)-100, contentHeight);
self.gotoInfo.frame = CGRectMake(CGRectGetWidth(self.backView.frame)-100, CGRectGetMaxY(self.backView.frame)-45, 85, 30);
}
@end
|