// // ASCheckoutBottomView.m // Asteria // // Created by xingyu on 2024/5/10. // #import "ASCheckoutBottomView.h" @interface ASCheckoutBottomView() @property (nonatomic, strong) UIView *backView; @property (nonatomic, strong) UILabel *titleLab; @property (nonatomic, strong) UIImageView *titleImageView; @end @implementation ASCheckoutBottomView - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { self.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"]; [self addSubview:self.backView]; [self.backView addSubview:self.titleLab]; [self.backView addSubview:self.titleImageView]; [self.backView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.right.mas_equalTo(-10); make.top.mas_equalTo(15); make.height.mas_equalTo(45); }]; [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) { make.center.equalTo(self.backView); }]; [self.titleImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.center.equalTo(self.backView); make.width.mas_equalTo(103); make.height.mas_equalTo(38); }]; self.backView.userInteractionEnabled = YES; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(_payClickAction)]; [self.backView addGestureRecognizer:tap]; } return self; } - (void)setBottomPayStyle:(NSString *)payCode { if ([payCode isEqualToString:@"paypal_express"]) {//paypal self.titleImageView.hidden = NO; self.titleLab.hidden = YES; self.titleImageView.image = [UIImage imageNamed:@"checkout_pay_paypal"]; self.backView.backgroundColor = [UIColor colorWithHexString:@"#FFC43A"]; } // else if ([payCode isEqualToString:@"stripe_payments"]) {//visa // // } else if ([payCode isEqualToString:@"afterpay_payment"]) {//afterpay // // } else if ([payCode isEqualToString:@"klarna_kco"]) {//klarna // // } else { self.titleImageView.hidden = YES; self.titleLab.hidden = NO; self.titleLab.text = @"pay securely now"; self.backView.backgroundColor = [UIColor colorWithHexString:@"#B2000F"]; } } - (void)_payClickAction { if (self.bottomBlock) { self.bottomBlock(); } } - (UIView *)backView { if (!_backView) { _backView = [[UIView alloc] init]; TT_ViewRadius(_backView, 4); } return _backView; } -(UILabel *)titleLab{ if(!_titleLab){ _titleLab = [UILabel labelCreateWithText:@"pay securely now" font:[UIFont fontWithName:Rob_Regular size:16] textColor:Col_FFF]; _titleLab.adjustsFontSizeToFitWidth = YES; } return _titleLab; } - (UIImageView *)titleImageView{ if(!_titleImageView){ _titleImageView = [[UIImageView alloc] init]; _titleImageView.contentMode = UIViewContentModeScaleAspectFit; } return _titleImageView; } @end