// // ASCustomAlertViewController.m // Asteria // // Created by iOS on 2023/12/23. // #import "ASCustomAlertViewController.h" @interface ASCustomAlertViewController () @property (nonatomic, assign) BOOL isMast; @end @implementation ASCustomAlertViewController - (void)viewDidLoad { [super viewDidLoad]; [self configSubV]; } - (void)setMastStatus:(BOOL)isMast { _isMast = isMast; self.cancelBt.hidden = isMast; self.closeBt.hidden = isMast; } - (void)configSubV { self.view.backgroundColor = UIColor.clearColor; [self.view addSubview:self.contentV]; [self.contentV addSubview:self.closeBt]; [self.contentV addSubview:self.conetntLb]; [self.contentV addSubview:self.titleLb]; [self.contentV addSubview:self.sureBt]; [self.contentV addSubview:self.cancelBt]; [self.conetntLb setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisVertical]; [self.contentV mas_makeConstraints:^(MASConstraintMaker *make) { make.center.equalTo(self.view); make.width.equalTo(@310); make.height.greaterThanOrEqualTo(@290); }]; [self.closeBt mas_makeConstraints:^(MASConstraintMaker *make) { make.width.height.equalTo(@40); make.centerX.equalTo(self.contentV); make.top.equalTo(self.contentV).offset(22); }]; [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentV).offset(18); make.right.equalTo(self.contentV).offset(-18); make.top.equalTo(self.closeBt.mas_bottom).offset(13); make.height.equalTo(@50); }]; [self.sureBt mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.contentV); make.width.equalTo(@120); make.height.equalTo(@35); make.bottom.equalTo(self.contentV).offset(-30); }]; [self.cancelBt mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.equalTo(self.sureBt); make.height.equalTo(@35); make.left.equalTo(self.sureBt.mas_right).offset(15); make.right.equalTo(self.contentV).offset(-15); }]; [self.conetntLb mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.contentV).offset(18); make.right.equalTo(self.contentV).offset(-18); make.top.equalTo(self.titleLb.mas_bottom).offset(13); make.bottom.greaterThanOrEqualTo(self.sureBt.mas_top).offset(-30); }]; } -(UIView *)contentV { if (!_contentV) { UIView * v = [[UIView alloc] init]; v.backgroundColor = [UIColor colorWithHexString:@"#FFF5F0"]; _contentV = v; } return _contentV; } - (UIButton *)closeBt { if (!_closeBt) { UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; [btn setImage:[UIImage imageNamed:@"productLsit_filter_close"] forState:UIControlStateNormal]; [btn addTarget:self action:@selector(closeBtAction) forControlEvents:UIControlEventTouchUpInside]; _closeBt = btn; } return _closeBt; } - (UILabel *)conetntLb { if (!_conetntLb) { UILabel *lb = [[UILabel alloc] init]; lb.font = [UIFont fontWithName:Rob_Regular size:14]; lb.textColor = [UIColor blackColor]; lb.numberOfLines = 0; lb.text = @"A New Version Of West Kiss Upgrade Version 1.1.0 Is Available For Your Phone And Is Ready To Install Now!"; lb.textAlignment = NSTextAlignmentCenter; lb.backgroundColor = [UIColor clearColor]; lb.qmui_lineHeight = 24; _conetntLb = lb; } return _conetntLb; } - (UILabel *)titleLb { if (!_titleLb) { UILabel *lb = [[UILabel alloc] init]; lb.font = [UIFont fontWithName:Rob_Bold size:14]; lb.qmui_lineHeight = 24; lb.textColor = [UIColor blackColor]; lb.text = @"Update App?"; lb.textAlignment = NSTextAlignmentCenter; lb.backgroundColor = [UIColor clearColor]; _titleLb = lb; } return _titleLb; } - (UIButton *)sureBt { if (!_sureBt) { UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.backgroundColor = [UIColor blackColor]; [btn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal]; [btn setTitle:@"UPDATE NOW" forState:UIControlStateNormal]; btn.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16]; [btn addTarget:self action:@selector(sureBtAction) forControlEvents:UIControlEventTouchUpInside]; _sureBt = btn; } return _sureBt; } - (UIButton *)cancelBt { if (!_cancelBt) { UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.backgroundColor = [UIColor clearColor]; [btn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal]; NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:@"LATER"]; [attStr setAttributes:@{ NSFontAttributeName:[UIFont fontWithName:Rob_Regular size:16], NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleSingle], NSUnderlineColorAttributeName:[UIColor colorWithHexString:@"#000000"], NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#000000"] } range:NSMakeRange(0, attStr.length)]; [btn setAttributedTitle:attStr forState:UIControlStateNormal]; [btn addTarget:self action:@selector(cancelBtAction) forControlEvents:UIControlEventTouchUpInside]; _cancelBt = btn; } return _cancelBt; } - (void)sureBtAction { if (self.sureAction) { self.sureAction(); } if (!_isMast) { ASWindowManager.share.customW = nil; } } - (void)cancelBtAction { if (self.cancelAction) { self.cancelAction(); } ASWindowManager.share.customW = nil; } - (void)closeBtAction { if (self.closeAction) { self.closeAction(); } ASWindowManager.share.customW = nil; } @end