123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- //
- // KWMineHomeOrderListCell.m
- // westkissMob
- //
- // Created by iOS on 2022/9/15.
- //
- #import "KWMineHomeOrderListCell.h"
- #import "KWMineHomeOrderSubView.h"
- @interface KWMineHomeOrderListCell ()
- @property (nonatomic, strong) UIStackView *prodStackV;
- @property (nonatomic, strong) UIView *bgV;
- @property (nonatomic, strong) UILabel *orderNoNameLB;
- @property (nonatomic, strong) UILabel *orderNoLB;
- @property (nonatomic, strong) UILabel *timeLB;
- @property (nonatomic, strong) UIButton *viewBt;
- @property (nonatomic, strong) KWMineHomeOrderModel *m;
- @end
- @implementation KWMineHomeOrderListCell
- - (void)setData:(KWMineHomeOrderModel *)model {
- self.m = model;
- self.timeLB.text = model.created_at;
- self.orderNoLB.text = model.increment_id;
- for (UIView*item in self.prodStackV.arrangedSubviews) {
- if (item.superview) {
- [item removeFromSuperview];
- }
- }
- for (KWMineOrderProInfoModel *info in model.items) {
- KWMineHomeOrderSubView *subV = [[KWMineHomeOrderSubView alloc] init];
- [subV setData:info canEdit:false];
- [self.prodStackV addArrangedSubview:subV];
- }
- }
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- [self configSubV];
- }
- return self;
- }
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- - (void)configSubV {
- self.selectionStyle = UITableViewCellSelectionStyleNone;
-
- self.contentView.backgroundColor = Col_FFF;
- self.bgV = [UIView new];
- self.bgV.layer.cornerRadius = 4;
- self.bgV.layer.masksToBounds = true;
- self.bgV.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
-
- [self.contentView addSubview:self.bgV];
- [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(10);
- make.right.equalTo(self.contentView).offset(-10);
- make.top.equalTo(self.contentView).offset(0);
- make.bottom.equalTo(self.contentView).offset(-10);
- }];
-
- self.prodStackV = [[UIStackView alloc] init];
- self.prodStackV.axis = UILayoutConstraintAxisVertical;
- self.prodStackV.spacing = 20;
- self.prodStackV.distribution = UIStackViewDistributionFillEqually;
- self.prodStackV.alignment = UIStackViewAlignmentFill;
-
- [self.bgV addSubview:self.prodStackV];
-
- [self.prodStackV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.bgV).offset(20);
- make.left.equalTo(self.bgV).offset(10);
- make.right.equalTo(self.bgV).offset(-15);
- }];
-
- [self.bgV addSubview:self.orderNoNameLB];
- [self.bgV addSubview:self.orderNoLB];
- [self.bgV addSubview:self.timeLB];
- [self.bgV addSubview:self.viewBt];
-
-
-
-
- [self.orderNoNameLB mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.prodStackV.mas_left);
- make.top.equalTo(self.prodStackV.mas_bottom).offset(21);
- make.height.equalTo(@16);
- }];
- [self.orderNoNameLB setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- [self.orderNoLB mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.orderNoNameLB);
- make.left.equalTo(self.orderNoNameLB.mas_right);
- make.right.equalTo(self.prodStackV.mas_right);
- make.height.equalTo(@16);
- }];
-
- [self.timeLB mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.prodStackV);
- make.top.equalTo(self.orderNoNameLB.mas_bottom).offset(5);
- make.height.equalTo(@14);
- make.bottom.equalTo(self.bgV.mas_bottom).offset(-20);
- }];
-
- [self.viewBt mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.timeLB.mas_right).offset(10);
- make.right.equalTo(self.prodStackV);
- make.bottom.equalTo(self.bgV.mas_bottom).offset(-20);
- make.height.equalTo(@17);
- make.width.equalTo(@75);
- }];
-
-
- }
- - (UILabel *)orderNoNameLB {
- if (!_orderNoNameLB) {
- UILabel *lb = [[UILabel alloc] init];
- lb.font = [UIFont fontWithName:Rob_Regular size:12];
- lb.textColor = [UIColor colorWithHexString:@"#666666"];
- lb.backgroundColor = [UIColor clearColor];
- lb.textAlignment = NSTextAlignmentLeft;
- lb.text = @"Order Number:";
- _orderNoNameLB = lb;
- }
- return _orderNoNameLB;
- }
- - (UILabel *)orderNoLB {
- if (!_orderNoLB) {
- UILabel *lb = [[UILabel alloc] init];
- lb.font = [UIFont fontWithName:Rob_Regular size:12];
- lb.textColor = [UIColor colorWithHexString:@"#666666"];
- lb.backgroundColor = [UIColor clearColor];
- _orderNoLB = lb;
- }
- return _orderNoLB;
- }
- - (UILabel *)timeLB {
- if (!_timeLB) {
- UILabel *lb = [[UILabel alloc] init];
- lb.font = [UIFont fontWithName:Rob_Regular size:12];
- lb.textColor = [UIColor colorWithHexString:@"#666666"];
- lb.backgroundColor = [UIColor clearColor];
- lb.textAlignment = NSTextAlignmentLeft;
- _timeLB = lb;
- }
- return _timeLB;
- }
- - (UIButton *)viewBt {
- if (!_viewBt) {
- UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
- NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:@"View Order"];
- [attStr addAttributes:@{
- NSFontAttributeName:[UIFont fontWithName:Rob_Regular size:14],
- NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle),
- NSUnderlineColorAttributeName:[UIColor colorWithHexString:@"#000000"],
- NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#000000"],
- } range:NSMakeRange(0, attStr.length)];
-
- [bt setAttributedTitle:attStr forState:UIControlStateNormal];
- [bt addTarget:self action:@selector(viewBtAction) forControlEvents:UIControlEventTouchUpInside];
- _viewBt = bt;
- }
- return _viewBt;
- }
- -(void)viewBtAction {
-
- if (self.viewOrderCall) {
- self.viewOrderCall(0, self.m);
- }
-
- }
- @end
|