// // YMAdolescentModelPopupView.m // MSYOUPAI // // Created by YoMi on 2024/2/22. // Copyright © 2024 MS. All rights reserved. // #import "YMCloseAdolescentModelPopupView.h" @interface YMCloseAdolescentModelPopupView () /// 青少年模式提示图片视图 @property (nonatomic, strong) UIImageView *adolescentModelImageView; /// 青少年模式状态标签 @property (nonatomic, strong) UILabel *adolescentModelStatusLb; /// 开启或关闭青少年模式按钮 @property (nonatomic, strong) UIButton *openOrCloseAdolescentModelBtn; /// 忘记密码按钮 @property (nonatomic, strong) UIButton *forgotPasswordBtn; @end @implementation YMCloseAdolescentModelPopupView - (void)ym_setupViews{ self.backgroundColor = UIColor.whiteColor; [self addSubview:self.adolescentModelImageView]; [self addSubview:self.adolescentModelStatusLb]; [self addSubview:self.openOrCloseAdolescentModelBtn]; [self addSubview:self.forgotPasswordBtn]; [self setNeedsUpdateConstraints]; [self updateConstraintsIfNeeded]; [self configurationAdolescentModel]; } - (void)updateConstraints{ [self.adolescentModelImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.mas_centerX); make.top.equalTo(self).offset(adapt(20)); make.width.mas_equalTo(adapt(220)); make.height.mas_equalTo(adapt(220)); }]; [self.adolescentModelStatusLb mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.adolescentModelImageView.mas_bottom).offset(adapt(15)); make.left.equalTo(self).offset(adapt(15)); make.right.equalTo(self).offset(adapt(-15)); }]; [self.openOrCloseAdolescentModelBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.adolescentModelStatusLb.mas_bottom).offset(adapt(15)); make.left.equalTo(self).offset(adapt(15)); make.right.equalTo(self).offset(adapt(-15)); make.height.mas_equalTo(adapt(50)); }]; [self.forgotPasswordBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.equalTo(self.openOrCloseAdolescentModelBtn.mas_centerX); make.top.equalTo(self.openOrCloseAdolescentModelBtn.mas_bottom).offset(adapt(10)); make.width.mas_equalTo(adapt(90)); make.height.mas_equalTo(adapt(30)); make.bottom.equalTo(self).offset(adapt(-20)); }]; [super updateConstraints]; } - (void)configurationAdolescentModel{ CGFloat adolescentModelImageViewHeight = [self.adolescentModelImageView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height; CGFloat adolescentModelStatusLbHeight = [self.adolescentModelStatusLb systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height; CGFloat openOrCloseAdolescentModelBtnHeight = [self.openOrCloseAdolescentModelBtn systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height; CGFloat forgotPasswordBtnHeight = [self.forgotPasswordBtn systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height; self.frame = CGRectMake(0, 0, kFrameWidth*0.88, adapt(20) + adolescentModelImageViewHeight + adapt(15) + adolescentModelStatusLbHeight + adapt(15) + openOrCloseAdolescentModelBtnHeight + adapt(10) + forgotPasswordBtnHeight + adapt(20)); } - (UIImageView *)adolescentModelImageView{ if (!_adolescentModelImageView) { _adolescentModelImageView = [[UIImageView alloc]init]; _adolescentModelImageView.image = ImageByName(@"ym_common_adolescent_model_tips_two_icon"); } return _adolescentModelImageView; } - (UILabel *)adolescentModelStatusLb{ if (!_adolescentModelStatusLb) { _adolescentModelStatusLb = [[UILabel alloc]init]; _adolescentModelStatusLb.font = LCFont(15); _adolescentModelStatusLb.textColor = HexColorFromRGB(0x333333); _adolescentModelStatusLb.textAlignment = NSTextAlignmentCenter; _adolescentModelStatusLb.text = @"您已开启未成年模式\n所有功能关闭"; _adolescentModelStatusLb.numberOfLines = 0; } return _adolescentModelStatusLb; } - (UIButton *)openOrCloseAdolescentModelBtn{ if (!_openOrCloseAdolescentModelBtn) { _openOrCloseAdolescentModelBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _openOrCloseAdolescentModelBtn.titleLabel.font = LCFont(12); [_openOrCloseAdolescentModelBtn setTitle:@"关闭未成年模式" forState:UIControlStateNormal]; [_openOrCloseAdolescentModelBtn setTitleColor:HexColorFromRGB(0xFFFFFF) forState:UIControlStateNormal]; _openOrCloseAdolescentModelBtn.backgroundColor = HexColorFromRGB(0xfd7bc5); _openOrCloseAdolescentModelBtn.layer.cornerRadius = adapt(8); _openOrCloseAdolescentModelBtn.layer.masksToBounds = YES; WS(weakSelf) [[[_openOrCloseAdolescentModelBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { if (weakSelf.openOrCloseAdolescentModelButtonBlock) { weakSelf.openOrCloseAdolescentModelButtonBlock(); } }]; } return _openOrCloseAdolescentModelBtn; } - (UIButton *)forgotPasswordBtn{ if (!_forgotPasswordBtn) { _forgotPasswordBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _forgotPasswordBtn.titleLabel.font = LCFont(12); [_forgotPasswordBtn setTitle:@"忘记密码" forState:UIControlStateNormal]; [_forgotPasswordBtn setTitleColor:HexColorFromRGB(0x9c9c9c) forState:UIControlStateNormal]; WS(weakSelf) [[[_forgotPasswordBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { if (weakSelf.forgotPasswordBlock) { weakSelf.forgotPasswordBlock(); } }]; } return _forgotPasswordBtn; } @end