//
// HotelSearchDetailRichCell.m
// Project
//
// Created by haibara on 1/8/16.
//
//

#import "HotelSearchDetailRichCell.h"
#import "SDK.h"
#import "CocoaUtils.h"
#import <DTCoreText/DTCoreText.h>

@interface HotelSearchDetailRichCell () {
	NSUInteger _restorationHash;
}
@property (nonatomic, weak) IBOutlet DTAttributedTextContentView *contentLabel;
@end

@implementation HotelSearchDetailRichCell

- (void)awakeFromNib {
	[super awakeFromNib];
	// Initialization code
	_restorationHash = -1;
	self.titleLabel.text = nil;
	self.contentLabel.shouldDrawImages = NO;

	[CocoaUtils fillSeparatorOfCell:self];
}

#pragma mark - Property

- (void)setAdditionalPaddingAtBottom:(CGFloat)additionalPaddingAtBottom {
	self.contentLabel.edgeInsets = UIEdgeInsetsMake(0, 0, additionalPaddingAtBottom, 0);
}

- (CGFloat)additionalPaddingAtBottom {
	return self.contentLabel.edgeInsets.bottom;
}

#pragma mark - Public

- (void)setHTMLString:(NSString *)html options:(NSDictionary *)options {
	NSUInteger newHash = html.hash;
	if (newHash != _restorationHash) {
		NSAttributedString *attributedString = [[NSAttributedString alloc] initWithHTMLData:[html dataUsingEncoding:NSUTF8StringEncoding] options:options documentAttributes:NULL];
		self.contentLabel.attributedString = attributedString;
		//
		_restorationHash = newHash;
	}
}

- (void)ready {
}

@end
