123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- //
- // YMPersonalPageGiftWallCell.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/3/14.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMPersonalPageGiftWallCell.h"
- #import "YMPersonalPageGiftWallCellViewModel.h"
- @interface YMPersonalPageGiftWallCell()
- /// ViewModel
- @property (nonatomic, strong) YMPersonalPageGiftWallCellViewModel *viewModel;
- /// 基础视图
- @property (nonatomic, strong) UIView *baseView;
- /// 礼物图标
- @property (nonatomic, strong) UIImageView *giftIcon;
- /// 礼物名标签
- @property (nonatomic, strong) UILabel *giftNameLb;
- /// 礼物数量标签
- @property (nonatomic, strong) UILabel *giftNumberLb;
- @end
- @implementation YMPersonalPageGiftWallCell
- - (void)ym_setupViews{
-
- [self.contentView addSubview:self.baseView];
- [self.baseView addSubview:self.giftIcon];
- [self.baseView addSubview:self.giftNameLb];
- [self.baseView addSubview:self.giftNumberLb];
-
- [self setNeedsUpdateConstraints];
- [self updateConstraintsIfNeeded];
- }
- - (void)updateConstraints {
- [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.contentView);
- make.left.equalTo(self.contentView);
- make.right.equalTo(self.contentView);
- make.bottom.equalTo(self.contentView);
- }];
-
- [self.giftIcon mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.baseView.mas_centerX);
- make.top.equalTo(self.baseView);
- make.width.height.mas_equalTo(adapt(60));
- }];
-
- [self.giftNameLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.giftIcon.mas_bottom).offset(adapt(5));
- make.left.equalTo(self.baseView);
- make.right.equalTo(self.baseView);
- }];
-
- [self.giftNumberLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.giftNameLb.mas_bottom).offset(adapt(5));
- make.left.equalTo(self.baseView);
- make.right.equalTo(self.baseView);
- make.bottom.equalTo(self.baseView);
- }];
-
- [super updateConstraints];
- }
- - (void)ym_bindViewModel:(YMPersonalPageGiftWallCellViewModel*)viewModel{
- if (!viewModel) {
- return;
- }
- _viewModel = viewModel;
-
- [self.giftIcon sd_setImageWithURL:[LCTools getImageUrlWithAddress:viewModel.giftIcon]];
- self.giftNameLb.text = viewModel.giftName;
- self.giftNumberLb.text = viewModel.giftNumber;
- }
- - (UIView *)baseView{
- if (!_baseView) {
- _baseView = [[UIView alloc]init];
- _baseView.clipsToBounds = YES;
- _baseView.layer.cornerRadius = adapt(8);
- }
- return _baseView;
- }
- - (UIImageView *)giftIcon{
- if (!_giftIcon) {
- _giftIcon = [[UIImageView alloc]init];
- _giftIcon.contentMode = UIViewContentModeScaleAspectFill;
- }
- return _giftIcon;
- }
- - (UILabel *)giftNameLb{
- if (!_giftNameLb) {
- _giftNameLb = [[UILabel alloc]init];
- _giftNameLb.font = LCFont(12);
- _giftNameLb.textColor = HexColorFromRGB(0x737373);
- _giftNameLb.textAlignment = NSTextAlignmentCenter;
- _giftNameLb.text = @"****";
- }
- return _giftNameLb;
- }
- - (UILabel *)giftNumberLb{
- if (!_giftNumberLb) {
- _giftNumberLb = [[UILabel alloc]init];
- _giftNumberLb.font = LCFont(12);
- _giftNumberLb.textColor = HexColorFromRGB(0x333333);
- _giftNumberLb.textAlignment = NSTextAlignmentCenter;
- _giftNumberLb.text = @"****";
- }
- return _giftNumberLb;
- }
- @end
|