//
//  ALShareTopicCardView.m
//  GMAlpha
//
//  Created by Mikasa on 2019/2/25.
//  Copyright © 2019 Gengmei. All rights reserved.
//

#import "ALShareTopicCardView.h"
#import <GMKit/GMFont.h>
#import <GMKit/Constant.h>
#import <GMKit/UIColor+GMTheme.h>
#define kTopicCardViewW    (MAINSCREEN_WIDTH - 30)

@interface ALShareTopicCardView ()


@end

@implementation ALShareTopicCardView
- (GMImageView *)cardImageView {
    if (!_cardImageView) {
        GMImageView *cardImageView = [GMImageView new];
        cardImageView.contentMode = UIViewContentModeScaleAspectFit;
        _cardImageView = cardImageView;
    }
    return _cardImageView;
}

- (GMLabel *)cardTitleLabel {
    if (!_cardTitleLabel) {
        GMLabel *cardTitleLabel = [GMLabel new];
        cardTitleLabel.font = [UIFont gmFont:15];
        cardTitleLabel.textColor = RGBCOLOR_HEX(0x323232);
        cardTitleLabel.numberOfLines = 3;
        _cardTitleLabel = cardTitleLabel;
    }
    return _cardTitleLabel;
}

- (void)setup {
    [super setup];
    
    self.backgroundColor = UIColor.whiteColor;
    [self addSubview:self.cardImageView];
    [self addSubview:self.cardTitleLabel];
    
    [self addSetupContraints];
}

- (void)addSetupContraints {
    CGFloat cardImageViewWH = (kTopicCardViewW - 20);
    [self.cardImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(10);
        make.height.width.mas_equalTo(cardImageViewWH);
    }];
    
    [self.cardTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_cardImageView.mas_bottom).offset(10);
        make.left.mas_equalTo(16);
        make.right.mas_equalTo(-16);
        make.bottom.mas_equalTo(-18);
    }];
}

@end
