|
@@ -0,0 +1,316 @@
|
|
|
+//
|
|
|
+// ASCouponListCell.m
|
|
|
+// Asteria
|
|
|
+//
|
|
|
+// Created by iOS on 2023/6/25.
|
|
|
+//
|
|
|
+
|
|
|
+#import "ASCouponListCell.h"
|
|
|
+
|
|
|
+@interface ASCouponListCell ()
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIView *bgV;
|
|
|
+@property (nonatomic, strong) UIImageView *bg1;
|
|
|
+@property (nonatomic, strong) UIImageView *bg2;
|
|
|
+@property (nonatomic, strong) UIImageView *ln1;
|
|
|
+@property (nonatomic, strong) UIImageView *ln2;
|
|
|
+@property (nonatomic, strong) UIImageView *sep;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UILabel *titleLb;
|
|
|
+@property (nonatomic, strong) UILabel *ruleLb;
|
|
|
+@property (nonatomic, strong) UILabel *dateLb;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UILabel *cpLb;
|
|
|
+@property (nonatomic, strong) UILabel *codeTitleLb;
|
|
|
+@property (nonatomic, strong) UILabel *codeLb;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIButton *cpBt;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIImageView *usedTopV;
|
|
|
+
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation ASCouponListCell
|
|
|
+
|
|
|
+- (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
|
|
|
+}
|
|
|
+
|
|
|
+- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
|
|
|
+ self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
|
|
|
+ if (self)
|
|
|
+ {
|
|
|
+ [self loadSubVs];
|
|
|
+ [self setDemoData];
|
|
|
+ }
|
|
|
+ return self;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)setDemoData {
|
|
|
+ self.titleLb.text = @"$10 off";
|
|
|
+ self.ruleLb.text = @"For Order ≥ $99";
|
|
|
+ self.dateLb.text = @"DTAE:2022/09/01-2022/09/30";
|
|
|
+
|
|
|
+ self.codeLb.text = @"3VIP55";
|
|
|
+}
|
|
|
+
|
|
|
+- (void)loadSubVs {
|
|
|
+ self.backgroundColor = UIColor.clearColor;
|
|
|
+ self.contentView.backgroundColor = UIColor.clearColor;
|
|
|
+ self.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
|
+ [self.contentView addSubview:self.bgV];
|
|
|
+ [self.bgV addSubview:self.bg1];
|
|
|
+ [self.bgV addSubview:self.bg2];
|
|
|
+ [self.bgV addSubview:self.ln1];
|
|
|
+ [self.bgV addSubview:self.ln2];
|
|
|
+ [self.bgV addSubview:self.sep];
|
|
|
+ //229/106
|
|
|
+ [self.bgV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.equalTo(@100);
|
|
|
+ make.leading.equalTo(self.contentView).offset(20);
|
|
|
+ make.trailing.equalTo(self.contentView).offset(-20);
|
|
|
+ make.top.equalTo(self.contentView).offset(15);
|
|
|
+ make.bottom.equalTo(self.contentView).offset(-5);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.bg1 mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.edges.equalTo(self.bgV);
|
|
|
+ }];
|
|
|
+ [self.bg2 mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.bottom.trailing.equalTo(self.bgV);
|
|
|
+ make.width.equalTo(self.bgV).multipliedBy(106.0/(229+106));
|
|
|
+ }];
|
|
|
+ [self.sep mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.width.equalTo(@1);
|
|
|
+ make.top.bottom.equalTo(self.bgV);
|
|
|
+ make.centerX.equalTo(self.bg2.mas_leading);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.ln1 mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.edges.equalTo(self.bgV);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.ln2 mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.leading.equalTo(self.bgV).offset(5);
|
|
|
+ make.trailing.equalTo(self.bgV).offset(-5);
|
|
|
+ make.top.equalTo(self.bgV).offset(5);
|
|
|
+ make.bottom.equalTo(self.bgV).offset(-5);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.bgV addSubview:self.titleLb];
|
|
|
+ [self.bgV addSubview:self.ruleLb];
|
|
|
+ [self.bgV addSubview:self.dateLb];
|
|
|
+
|
|
|
+ UIStackView *st = [UIStackView baseStackV:true];
|
|
|
+ st.spacing = 0;
|
|
|
+ st.distribution = UIStackViewDistributionFill;
|
|
|
+ [self.bgV addSubview:st];
|
|
|
+
|
|
|
+ [st addArrangedSubview:self.cpLb];
|
|
|
+ [st addArrangedSubview:self.codeTitleLb];
|
|
|
+ [st addArrangedSubview:self.codeLb];
|
|
|
+
|
|
|
+ [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.bgV).offset(16);
|
|
|
+ make.leading.equalTo(self.bgV).offset(30);
|
|
|
+ make.trailing.equalTo(self.sep.mas_leading).offset(-8);
|
|
|
+ make.height.equalTo(@34);
|
|
|
+ }];
|
|
|
+ [self.ruleLb mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.titleLb.mas_bottom);
|
|
|
+ make.leading.trailing.equalTo(self.titleLb);
|
|
|
+ make.height.equalTo(@14);
|
|
|
+ }];
|
|
|
+ [self.dateLb mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.ruleLb.mas_bottom).offset(6);
|
|
|
+ make.leading.trailing.equalTo(self.titleLb);
|
|
|
+ make.height.equalTo(@14);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [st mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.centerY.equalTo(self.bg2);
|
|
|
+ make.centerX.equalTo(self.bg2).offset(-8);
|
|
|
+ make.width.equalTo(@80);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.cpLb mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.equalTo(@34);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.codeTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.equalTo(@17);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.codeLb mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.equalTo(@17);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.bg2 addSubview:self.cpBt];
|
|
|
+ [self.cpBt mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.edges.equalTo(self.bg2);
|
|
|
+ }];
|
|
|
+
|
|
|
+ st.transform = CGAffineTransformRotate(st.transform, -M_PI/2.0);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (UIView *)bgV {
|
|
|
+ if (!_bgV) {
|
|
|
+ UIView *v = [UIView baseV];
|
|
|
+ v.backgroundColor = UIColor.clearColor;
|
|
|
+ v.clipsToBounds = true;
|
|
|
+ _bgV = v;
|
|
|
+ }
|
|
|
+ return _bgV;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIImageView *)bg1 {
|
|
|
+ if (!_bg1) {
|
|
|
+ UIImageView *v = [UIImageView baseImgV];
|
|
|
+ v.contentMode = UIViewContentModeScaleToFill;
|
|
|
+ v.clipsToBounds = true;
|
|
|
+ v.image = [UIImage imageNamed:@"uc_coupon_colorBg1"];
|
|
|
+ _bg1 = v;
|
|
|
+ }
|
|
|
+ return _bg1;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIImageView *)bg2 {
|
|
|
+ if (!_bg2) {
|
|
|
+ UIImageView *v = [UIImageView baseImgV];
|
|
|
+ v.contentMode = UIViewContentModeScaleToFill;
|
|
|
+ v.userInteractionEnabled = true;
|
|
|
+ v.clipsToBounds = true;
|
|
|
+ v.image = [UIImage imageNamed:@"uc_coupon_colorBg2"];
|
|
|
+ _bg2 = v;
|
|
|
+ }
|
|
|
+ return _bg2;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIImageView *)ln1 {
|
|
|
+ if (!_ln1) {
|
|
|
+ UIImageView *v = [UIImageView baseImgV];
|
|
|
+ v.contentMode = UIViewContentModeScaleToFill;
|
|
|
+ v.clipsToBounds = true;
|
|
|
+ v.image = [UIImage imageNamed:@"uc_coupon_line1"];
|
|
|
+ _ln1 = v;
|
|
|
+ }
|
|
|
+ return _ln1;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIImageView *)ln2 {
|
|
|
+ if (!_ln2) {
|
|
|
+ UIImageView *v = [UIImageView baseImgV];
|
|
|
+ v.contentMode = UIViewContentModeScaleToFill;
|
|
|
+ v.clipsToBounds = true;
|
|
|
+ v.image = [UIImage imageNamed:@"uc_coupon_line2"];
|
|
|
+ _ln2 = v;
|
|
|
+ }
|
|
|
+ return _ln2;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIImageView *)sep {
|
|
|
+ if (!_sep) {
|
|
|
+ UIImageView *v = [UIImageView baseImgV];
|
|
|
+ v.contentMode = UIViewContentModeScaleAspectFill;
|
|
|
+ v.clipsToBounds = true;
|
|
|
+ v.image = [UIImage imageNamed:@"uc_coupon_sep"];
|
|
|
+ _sep = v;
|
|
|
+ }
|
|
|
+ return _sep;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)titleLb {
|
|
|
+ if (!_titleLb) {
|
|
|
+ UILabel *lb = [UILabel baseLb];
|
|
|
+ lb.font = [UIFont fontWithName:Rob_BlackItalic size:28];
|
|
|
+ lb.textColor = Col_000;
|
|
|
+ _titleLb = lb;
|
|
|
+ }
|
|
|
+ return _titleLb;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)ruleLb {
|
|
|
+ if (!_ruleLb) {
|
|
|
+ UILabel *lb = [UILabel baseLb];
|
|
|
+ lb.font = [UIFont fontWithName:Rob_Regular size:12];
|
|
|
+ lb.textColor = _043632;
|
|
|
+ _ruleLb = lb;
|
|
|
+ }
|
|
|
+ return _ruleLb;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)dateLb {
|
|
|
+ if (!_dateLb) {
|
|
|
+ UILabel *lb = [UILabel baseLb];
|
|
|
+ lb.font = [UIFont fontWithName:Rob_Regular size:12];
|
|
|
+ lb.textColor = _128273;
|
|
|
+ _dateLb = lb;
|
|
|
+ }
|
|
|
+ return _dateLb;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)cpLb {
|
|
|
+ if (!_cpLb) {
|
|
|
+ UILabel *lb = [UILabel baseLb];
|
|
|
+ lb.font = [UIFont fontWithName:Rob_Black size:28];
|
|
|
+ lb.textColor = Col_FFF;
|
|
|
+ lb.text = @"COPY";
|
|
|
+ lb.textAlignment = NSTextAlignmentCenter;
|
|
|
+ _cpLb = lb;
|
|
|
+ }
|
|
|
+ return _cpLb;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)codeTitleLb {
|
|
|
+ if (!_codeTitleLb) {
|
|
|
+ UILabel *lb = [UILabel baseLb];
|
|
|
+ lb.font = [UIFont fontWithName:Rob_Regular size:14];
|
|
|
+ lb.textAlignment = NSTextAlignmentCenter;
|
|
|
+ lb.textColor = _043632;
|
|
|
+ lb.text = @"CODE";
|
|
|
+ _codeTitleLb = lb;
|
|
|
+ }
|
|
|
+ return _codeTitleLb;
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)codeLb {
|
|
|
+ if (!_codeLb) {
|
|
|
+ UILabel *lb = [UILabel baseLb];
|
|
|
+ lb.textAlignment = NSTextAlignmentCenter;
|
|
|
+ lb.font = [UIFont fontWithName:Rob_Regular size:14];
|
|
|
+ lb.textColor = _043632;
|
|
|
+ _codeLb = lb;
|
|
|
+ }
|
|
|
+ return _codeLb;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIButton *)cpBt {
|
|
|
+ if (!_cpBt) {
|
|
|
+ UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ [bt addTarget: self action:@selector(copyAction) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ _cpBt = bt;
|
|
|
+ }
|
|
|
+ return _cpBt;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)copyAction {
|
|
|
+ if (!self.codeLb.text.isEmpty) {
|
|
|
+ UIPasteboard.generalPasteboard.string = self.codeLb.text;
|
|
|
+ if (self.copyCallBack){
|
|
|
+ self.copyCallBack();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+@end
|