//
//  XVCategoryTitleCell.m
//  fastservice
//
//  Created by xuning on 2/4/24.
//  Copyright © 2024 FastService. All rights reserved.
//

#import "XVCategoryTitleCell.h"
#import "XVCategoryTitleCellModel.h"

@interface XVCategoryTitleCell()

@property (nonatomic, strong) UIImageView *singleImageView;

@end

@implementation XVCategoryTitleCell


- (void)initializeViews {
    [super initializeViews];

    self.titleLabelCenterX.active = NO;
    self.maskTitleLabelCenterX.active = NO;
    
    self.titleLabelCenterX.active = NO;
    self.maskTitleLabelCenterX.active = NO;



    self.singleImageView = [[UIImageView alloc] init];
    self.singleImageView.contentMode = UIViewContentModeScaleAspectFit;
    self.singleImageView.hidden = YES;
    [self.contentView addSubview:self.singleImageView];
}

- (void)reloadData:(JXCategoryBaseCellModel *)cellModel {
    [super reloadData:cellModel];


    self.singleImageView.hidden = YES;

    XVCategoryTitleCellModel *myCellModel = (XVCategoryTitleCellModel *)cellModel;
    if (myCellModel.uiType == XVCategoryTitleUIType_SingleImage) {
        if(myCellModel.imageLocation == XVCategoryTitleImageLocation_Right) {
            [self.singleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(self.contentView);
                make.left.mas_equalTo(self.titleLabel.mas_right).mas_offset(1);
                make.size.mas_equalTo(CGSizeMake(10, 10));
            }];
        }else{
            
            [self.singleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(self.contentView);
                make.left.mas_equalTo(self.contentView);
                make.size.mas_equalTo(CGSizeMake(16, 16));
            }];
            [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.mas_equalTo(self.contentView);
                make.left.mas_equalTo(self.singleImageView.mas_right).mas_offset(1);
            }];


        }
        self.singleImageView.hidden = NO;
        self.singleImageView.image = myCellModel.singleImage;
    }

}


@end
