123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- //
- // ASOrderListCell.m
- // Asteria
- //
- // Created by iOS on 2024/5/14.
- //
- #import "ASOrderListCell.h"
- #import "KWMineHomeOrderSubView.h"
- @interface ASOrderListCell ()
- @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) UIButton *trackBt;
- @property (nonatomic, strong) UIButton *reorderBt;
- @property (nonatomic, strong) UIButton *paynowBt;
- @property (nonatomic, strong) UILabel *statusLb;
- @property (nonatomic, strong) UILabel *totalTiLb;
- @property (nonatomic, strong) UILabel *totalNumLb;
- @property (nonatomic, strong) UIView *lineV;
- @property (nonatomic, strong) KWMineHomeOrderModel *m;
- @end
- @implementation ASOrderListCell
- - (void)setData:(KWMineHomeOrderModel *)model {
- self.m = model;
- self.statusLb.text = model.state;
- self.timeLB.text = [NSString stringWithFormat:@"Date: %@", model.created_at];
- self.orderNoLB.text = model.increment_id;
- self.totalNumLb.text = [NSString stringWithFormat:@"%@%@", model.currency_symbol, model.grand_total];
- 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:true];
- [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 = _F8F8F8;
- self.bgV = [UIView new];
- self.bgV.layer.cornerRadius = 4;
- self.bgV.layer.masksToBounds = true;
- self.bgV.backgroundColor = Col_FFF;
-
- [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.bgV addSubview:self.orderNoNameLB];
- [self.bgV addSubview:self.orderNoLB];
- [self.bgV addSubview:self.timeLB];
- [self.bgV addSubview:self.viewBt];
- [self.bgV addSubview:self.statusLb];
- [self.bgV addSubview:self.totalTiLb];
- [self.bgV addSubview:self.totalNumLb];
- [self.bgV addSubview:self.lineV];
-
- UIStackView *btStv = [[UIStackView alloc] init];
- btStv.axis = UILayoutConstraintAxisHorizontal;
- btStv.spacing = 20;
- btStv.distribution = UIStackViewDistributionFillEqually;
- btStv.alignment = UIStackViewAlignmentFill;
-
- [self.bgV addSubview:btStv];
- // [btStv addArrangedSubview:self.trackBt];
- [btStv addArrangedSubview:self.reorderBt];
- [btStv addArrangedSubview:self.viewBt];
- [btStv addArrangedSubview:self.paynowBt];
-
- [self.statusLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(@10);
- make.right.equalTo(@(-10));
- make.top.equalTo(self.bgV).offset(20);
- make.height.equalTo(@17);
- }];
-
- [self.orderNoNameLB mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.statusLb);
- make.top.equalTo(self.statusLb.mas_bottom).offset(10);
- make.height.equalTo(@16);
- }];
- [self.orderNoLB mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.orderNoNameLB.mas_right);
- make.centerY.equalTo(self.orderNoNameLB);
- make.height.equalTo(@16);
- }];
- [self.orderNoLB setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- [self.orderNoNameLB setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
-
- [self.timeLB mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.orderNoLB.mas_right).offset(10);
- make.centerY.equalTo(self.orderNoNameLB);
- make.height.equalTo(@16);
- make.right.equalTo(self.bgV).offset(-10);
- }];
-
- [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.equalTo(self.statusLb);
- make.height.equalTo(@1);
- make.top.equalTo(self.orderNoNameLB.mas_bottom).offset(10);
- }];
-
-
-
- [self.prodStackV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.lineV.mas_bottom).offset(10);
- make.left.equalTo(self.bgV).offset(10);
- make.right.equalTo(self.bgV).offset(-10);
- }];
-
- [self.totalTiLb 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.totalNumLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
- [self.totalNumLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.totalTiLb);
- make.left.equalTo(self.totalTiLb.mas_right);
- make.right.equalTo(self.prodStackV.mas_right);
- make.height.equalTo(@16);
- }];
-
- [btStv mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.statusLb);
- make.bottom.equalTo(self.bgV.mas_bottom).offset(-30);
- make.height.equalTo(@36);
- make.top.equalTo(self.totalTiLb.mas_bottom).offset(30);
- }];
-
- [self.viewBt mas_makeConstraints:^(MASConstraintMaker *make) {
- make.height.equalTo(@36);
- make.width.equalTo(@76);
- }];
-
-
-
- }
- - (UIView *)lineV {
- if (!_lineV) {
- UIView *v = [UIView baseV];
- v.backgroundColor = _F4F4F4;
- _lineV = v;
- }
- return _lineV;
- }
- - (UILabel *)statusLb {
- if (!_statusLb) {
- UILabel *lb = [[UILabel alloc] init];
- lb.font = [UIFont fontWithName:Rob_Bold size:14];
- lb.textColor = Col_000;
- lb.backgroundColor = [UIColor clearColor];
- _statusLb = lb;
- }
- return _statusLb;
- }
- - (UILabel *)totalTiLb {
- if (!_totalTiLb) {
- UILabel *lb = [[UILabel alloc] init];
- lb.font = [UIFont fontWithName:Rob_Regular size:14];
- lb.textColor = Col_000;
- lb.backgroundColor = [UIColor clearColor];
- lb.textAlignment = NSTextAlignmentRight;
- lb.text = @"Order Total:";
- _totalTiLb = lb;
- }
- return _totalTiLb;
- }
- - (UILabel *)totalNumLb {
- if (!_totalNumLb) {
- UILabel *lb = [[UILabel alloc] init];
- lb.font = [UIFont fontWithName:Rob_Bold size:14];
- lb.textColor = Col_000;
- lb.backgroundColor = [UIColor clearColor];
- _totalNumLb = lb;
- }
- return _totalNumLb;
- }
- - (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.tag = 10000;
- [bt setAttributedTitle:attStr forState:UIControlStateNormal];
- [bt addTarget:self action:@selector(viewBtAction:) forControlEvents:UIControlEventTouchUpInside];
- _viewBt = bt;
- }
- return _viewBt;
- }
- - (UIButton *)trackBt {
- if (!_trackBt) {
- UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
- NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:@"Track 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.tag = 10001;
- [bt setAttributedTitle:attStr forState:UIControlStateNormal];
- [bt addTarget:self action:@selector(viewBtAction:) forControlEvents:UIControlEventTouchUpInside];
- _trackBt = bt;
- }
- return _trackBt;
- }
- - (UIButton *)reorderBt {
- if (!_reorderBt) {
- UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
- NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:@"Reorder"];
- [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.tag = 10002;
- [bt setAttributedTitle:attStr forState:UIControlStateNormal];
- [bt addTarget:self action:@selector(viewBtAction:) forControlEvents:UIControlEventTouchUpInside];
- _reorderBt = bt;
- }
- return _reorderBt;
- }
- - (UIButton *)paynowBt {
- if (!_paynowBt) {
- UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
- bt.tag = 10003;
- bt.hidden = true;
- bt.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
- [bt setTitle:@"Pay Now" forState:UIControlStateNormal];
- [bt addTarget:self action:@selector(viewBtAction:) forControlEvents:UIControlEventTouchUpInside];
- _viewBt = bt;
- }
- return _viewBt;
- }
- -(void)viewBtAction:(UIButton *)bt {
-
- if (self.viewOrderCall) {
- self.viewOrderCall(bt.tag-10000, self.m);
- }
-
- }
- @end
|