123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- //
- // SPSBPurchasersListTableViewCell.m
- // 我的社保
- //
- // Created by shanp on 2021/5/14.
- //
- #import "SPSBPurchasersListTableViewCell.h"
- #import "SPSBUIGeneralHeader.h"
- #import "SPSBPurchasersModel.h"
- @interface SPSBPurchasersListTableViewCell () {
- UIView *_bg;
- UIView *_headerBg;
- UILabel *_iconLabel;
- UILabel *_nameLabel;
- UILabel *_idCardLabel;
-
- UIImageView *_chooseImage;
- }
- @end
- @implementation SPSBPurchasersListTableViewCell
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier type:(SPSBPurchasersListType)type {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (!self) return nil;
-
- self.contentView.backgroundColor = spsb_F5F5F5_color();
- self.selectionStyle = UITableViewCellSelectionStyleNone;
-
- _headerBg = [[UIView alloc] init];
- [self.contentView addSubview:_headerBg];
- [_headerBg makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(0);
- make.trailing.equalTo(0);
- make.top.equalTo(0);
- make.height.equalTo(30);
- }];
-
- _bg = UIView.new;
- _bg.backgroundColor = spsb_FFFFFF_color(1.f);
- [_bg setLayerCornerRadius:4 clipToBounds:false];
- [self.contentView addSubview:_bg];
- [_bg makeConstraints:^(JXHConstraintMaker *make) {
- make.top.equalTo(0);
- make.leading.equalTo(12);
- make.trailing.equalTo(-12);
- make.height.equalTo(100);
- }];
-
- UIView *icon = UIView.new;
- icon.backgroundColor = spsb_28AFF0_color();
- [icon setLayerCornerRadius:24 clipToBounds:false];
- [_bg addSubview:icon];
- [icon makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(20);
- make.centerY.equalTo(self->_bg);
- make.size.equalTo(CGSizeMake(48, 48));
- }];
-
- _iconLabel = [UILabel convenienceWithFont:spsb_semiboldFont(15) text:nil textColor:spsb_FFFFFF_color(1.f) textAlignment:NSTextAlignmentCenter];
- [icon addSubview:_iconLabel];
- [_iconLabel makeConstraints:^(JXHConstraintMaker *make) {
- make.center.equalTo(icon);
- }];
-
- _nameLabel = [UILabel convenienceWithFont:spsb_semiboldFont(17) text:@"" textColor:spsb_333333_color()];
- [_bg addSubview:_nameLabel];
- [_nameLabel makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(icon.trailing).offset(15);
- make.trailing.equalTo(-80);
- make.top.equalTo(30);
- }];
-
- _idCardLabel = [UILabel convenienceWithFont:spsb_font(14) text:@"" textColor:spsb_808080_color()];
- [_bg addSubview:_idCardLabel];
- [_idCardLabel makeConstraints:^(JXHConstraintMaker *make) {
- make.leading.equalTo(self->_nameLabel);
- make.top.equalTo(self->_nameLabel.bottom).offset(10);
- }];
-
- if (type == SPSBPurchasersListTypeManage) {
- [self createButtons];
- } else {
- [self createChooseImage];
- }
-
- return self;
- }
- - (void)createButtons {
- UIButton *deleteButton = [UIButton convenienceWithTarget:self action:@selector(deleteAction)];
- [deleteButton setImage:jxh_getImage(purchasers_delete) state:JXHButtonControlStateNormal];
- [_bg addSubview:deleteButton];
- [deleteButton makeConstraints:^(JXHConstraintMaker *make) {
- make.trailing.equalTo(-6);
- make.centerY.equalTo(self->_bg);
- make.size.equalTo(CGSizeMake(42, 42));
- }];
-
-
- UIButton *editButton = [UIButton convenienceWithTarget:self action:@selector(_editAction)];
- [editButton setImage:jxh_getImage(purchasers_edit) state:JXHButtonControlStateNormal];
- [_bg addSubview:editButton];
- [editButton makeConstraints:^(JXHConstraintMaker *make) {
- make.trailing.equalTo(deleteButton.leading);
- make.centerY.equalTo(self->_bg);
- make.size.equalTo(CGSizeMake(42, 42));
- }];
- }
- - (void)createChooseImage {
- _chooseImage = [[UIImageView alloc] init];
- [_chooseImage setImage:jxh_getImage(filter_n)];
- [_chooseImage setHighlightedImage:jxh_getImage(filter_s)];
- [_bg addSubview:_chooseImage];
- [_chooseImage makeConstraints:^(JXHConstraintMaker *make) {
- make.trailing.equalTo(-20);
- make.centerY.equalTo(self->_bg);
- }];
- }
- - (void)reloadData:(SPSBPurchasersModel *)purchaser isFirstRow:(bool)isFirstRow isChose:(bool)isChose {
- _headerBg.backgroundColor = isFirstRow ? spsb_28AFF0_color() : spsb_F5F5F5_color();
- _iconLabel.text = purchaser.spsba_icon_name;
- _nameLabel.text = purchaser.spsb_user_name;
- _idCardLabel.text = purchaser.spsb_id_card;
- if (_chooseImage) {
- _chooseImage.highlighted = isChose;
- }
- }
- - (void)deleteAction {
- if (_spsb_action) {
- _spsb_action(self, false);
- }
- }
- - (void)_editAction {
- if (_spsb_action) {
- _spsb_action(self, true);
- }
- }
- @end
|