KWMNewHomeCell.m 2.5 KB
Newer Older
houweibin committed
1 2 3 4 5 6 7 8 9 10
//
//  KWMNewHomeCell.m
//  iCemarose
//
//  Created by HouWeiBin on 2017/6/2.
//  Copyright © 2017年 kollway. All rights reserved.
//

#import "KWMNewHomeCell.h"
#import "UIView+Prettify.h"
houweibin committed
11 12 13
#import "KWMStringUtil.h"
#import "KWMImageUtil.h"
#import "UIImageView+WebCache.h"
houweibin committed
14 15 16
#import "NSLayoutConstraint+Multiplier.h"
#import "UIColor+SAMAdditions.h"

houweibin committed
17 18 19 20 21 22 23 24 25

@interface KWMNewHomeCell()

@property(nonatomic,weak) IBOutlet UILabel *lbBrand;

@property(nonatomic,weak) IBOutlet UILabel *lbName;

@property(nonatomic,weak) IBOutlet UILabel *lbPrice;

houweibin committed
26 27
@property(nonatomic,weak) IBOutlet UIImageView *ivProduct;

houweibin committed
28 29 30 31 32 33
@property(nonatomic,weak) IBOutlet UIView *vImageContentView;

@property(nonatomic,weak) IBOutlet NSLayoutConstraint *heightDetail;

@property(nonatomic,weak) IBOutlet NSLayoutConstraint *precentOfProductImageView;

houweibin committed
34 35 36 37 38 39 40 41 42
@end

@implementation KWMNewHomeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    [self.vContent initDefaultShadow];
}

houweibin committed
43 44 45
-(void)setSingleShow:(BOOL)singleShow{
    if(singleShow){
        NSTextAlignment textAlignment = NSTextAlignmentCenter;
houweibin committed
46 47 48 49 50
        self.lbBrand.textAlignment = textAlignment;
        self.lbName.textAlignment = textAlignment;
        self.lbPrice.textAlignment = textAlignment;
        self.lbName.numberOfLines = 1;
        self.lbBrand.numberOfLines = 1;
houweibin committed
51 52
//        self.precentOfProductImageView = [self.precentOfProductImageView updateMultiplier:1];
//        self.vImageContentView.backgroundColor = [UIColor sam_colorWithHex:@"F1929A"];
houweibin committed
53 54 55
    }
}

houweibin committed
56

houweibin committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
-(void)setProduct:(BUYProduct *)product{
    _product = product;
    if(product){
        NSString *imageUrl = [KWMImageUtil getProductImageUrl:product ImageSize:SmallImage];
        NSURL *imageURL = [NSURL URLWithString:imageUrl];
        [self.ivProduct sd_setImageWithURL:imageURL placeholderImage:[UIImage imageNamed:@"ic_loading"]];
        self.lbBrand.text = product.vendor;
        self.lbName.text = product.title;
        if(product.variantsArray.count>0){
            BUYProductVariant *variant = product.variantsArray.firstObject;
            self.lbPrice.text = [KWMStringUtil price:variant.price];
        }
    }
}

+(NSInteger)acturlHeight:(BUYProduct *)product width:(NSInteger)width{
    NSInteger lbNameWidth = width - 60;
houweibin committed
74
    UIFont *font = [UIFont systemFontOfSize:9];
houweibin committed
75
    if(SYSTEM_VERSION_LESS_THAN(@"9.0")){
houweibin committed
76
        [UIFont fontWithName:@"PingFang SC" size:9];
houweibin committed
77 78
    }
    NSInteger lbNameHeight = [KWMStringUtil getLabelHeight:product.title labelFont:font textWidth:lbNameWidth].height;
houweibin committed
79
    return width + 50 +lbNameHeight;
houweibin committed
80 81 82
}

@end