//
// HotelSearchListSmallCell.m
// Project
//
// Created by Ziv on 15/12/11.
//
//

#import "HotelSearchListSmallCell.h"
#import "SDK.h"
#import "CocoaUtils.h"
#import "ImageUtils.h"
#import "UIConstants.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import "DiscountTipTool.h"
#import "Vars.h"

@interface HotelSearchListSmallCell ()
@property (nonatomic, weak) IBOutlet NSLayoutConstraint *widthConstraint;
@property (nonatomic, strong) UILabel *ribandLabel;
@end

@implementation HotelSearchListSmallCell

- (void)awakeFromNib {
	[super awakeFromNib];
	
	self.ribandLabel = [DiscountTipTool labelForDealsWithText:IMLocalizedString(@"Exclusive Deals") font:[UIFont preferredFontForTextStyle:UIFontTextStyleCaption2]];
	[self.hotelImageView addSubview:self.ribandLabel];
	self.hotelImageView.clipsToBounds = YES;
}

#pragma mark - Property

#pragma mark - Public

- (void)showRiband:(BOOL)isShow {
	self.ribandLabel.hidden = !isShow;
}

- (void)setTripAdvisorImageWithURLString:(NSString *)urlString {
	[self.tripadvisorImgView sd_setImageWithURL:urlString completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
		self.widthConstraint.constant = image ? ceil(CGRectGetHeight(self.tripadvisorImgView.frame) * image.size.width / image.size.height) : 0;
	}];
}

@end
