//
// msgAskContentBaseCell.m
// ThePaperBase
//
// Created by YoungLee on 15/11/18.
// Copyright © 2015年 scar1900. All rights reserved.
//
#import "msgAskContentCell.h"
@implementation msgAskContentCell
@synthesize commentBO = _commentBO;
@synthesize shadowHidden = _shadowHidden;
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
self.lineView.hidden = YES;
[self.backView removeFromSuperview];
[self.contentView addSubview:self.backView];
[self subLayoutSubViews];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(needrefreshNightMode:) name:REFRESHAFTERNIGHTMODE object:nil];
}
return self;
}
- (void)needrefreshNightMode:(id)sender{
self.backgroundColor = [UIColor colorWithHexString:CELLBACKCOLOR];
self.backView.backgroundColor = [UIColor colorWithHexString:BackGroundColor];
self.askContentLabel.textColor = [UIColor colorWithHexString:TextBlack];
self.lineView.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
[self.askContentLabel setNeedsDisplay];
self.shadowLine.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
}
-(void)setShadowHidden:(BOOL)isHidden{
_shadowHidden = isHidden;
self.shadowLine.hidden = _shadowHidden;
}
- (void)setCommentBO:(commentObjectVO *)data {
_commentBO = data;
if (!_commentBO.parentInfo) {
self.askContentLabel.text = _commentBO.content?_commentBO.content:@"";
}else{
self.askContentLabel.text = _commentBO.parentInfo[@"content"]?_commentBO.parentInfo[@"content"]:@"";
}
if (_commentBO.answerList.count > 0 || _commentBO.parentInfo) {
self.lineView.hidden = NO;
}else{
self.lineView.hidden = YES;
}
if ((!_commentBO.answerList || _commentBO.answerList.count <=0) && !_commentBO.parentInfo) {
self.shadowLine.hidden = NO;
}else{
self.shadowLine.hidden = YES;
}
self.cellHeight = data.labelHeight;
[self reLayoutSubViews];
}
-(UIView *)shadowLine{
if (!_shadowLine) {
_shadowLine = [UIView new];
_shadowLine.backgroundColor = [UIColor colorWithHexString:LINECOLOR];
_shadowLine.hidden = YES;
}
return _shadowLine;
}
- (void)reLayoutSubViews {
__weak typeof(self) weakSelf = self;
[self.askContentLabel remakeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(weakSelf.backView.left).offset(10);
make.top.equalTo(weakSelf.backView);
make.height.mas_equalTo(weakSelf.cellHeight);
make.right.equalTo(weakSelf.backView.right).offset(-10);
}];
}
- (void)subLayoutSubViews {
[self.backView makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.contentView.left).offset(10);
make.right.equalTo(self.contentView.right).offset(-10);
make.top.equalTo(self.contentView.top);
make.bottom.equalTo(self.contentView.bottom);
}];
// [self.backBtn makeConstraints:^(MASConstraintMaker *make) {
// make.edges.equalTo(weakSelf.backView);
// }];
[self.lineView makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.backView.left);
make.right.equalTo(self.backView.right);
make.bottom.equalTo(self.backView.bottom);
make.height.mas_equalTo(0.5);
}];
[self.backView addSubview:self.shadowLine];
[self.shadowLine makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.backView.left);
make.right.equalTo(self.backView.right);
make.top.equalTo(self.backView.bottom).offset(-1);
make.height.mas_equalTo(1);
}];
}
@end
|