123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- //
- // YMAuthenticationCenterView.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/3/2.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMAuthenticationCenterView.h"
- #import "YMAuthenticationCenterViewModel.h"
- @interface YMAuthenticationCenterView ()
- /// 认证中心VM
- @property (nonatomic, strong) YMAuthenticationCenterViewModel *viewModel;
- /// 示例动作视图
- @property (nonatomic, strong) UIImageView *exampleActionView;
- /// 示例动作提示标签
- @property (nonatomic, strong) UILabel *exampleActionTipsLb;
- /// 本人动作视图
- @property (nonatomic, strong) UIImageView *myActionView;
- /// 本人动作提示标签
- @property (nonatomic, strong) UILabel *myActionTipsLb;
- /// 提示标签
- @property (nonatomic, strong) UILabel *tipsLb;
- /// 按钮视图
- @property (nonatomic, strong) UIView *buttonView;
- /// 立即上传按钮
- @property (nonatomic, strong) UIButton *uploadNowBtn;
- /// 重拍按钮
- @property (nonatomic, strong) UIButton *reshootBtn;
- @end
- @implementation YMAuthenticationCenterView
- - (void)ym_setupViews{
- [self addSubview:self.exampleActionView];
- [self addSubview:self.exampleActionTipsLb];
-
- [self addSubview:self.myActionView];
- [self addSubview:self.myActionTipsLb];
-
- [self addSubview:self.tipsLb];
-
- [self addSubview:self.buttonView];
- [self.buttonView addSubview:self.uploadNowBtn];
- [self.buttonView addSubview:self.reshootBtn];
-
- [self setNeedsUpdateConstraints];
- [self updateConstraintsIfNeeded];
- }
- - (void)updateConstraints {
- [self.exampleActionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(adapt(12));
- make.left.equalTo(self).offset(adapt(12));
- make.width.height.mas_equalTo(adapt(172));
- }];
-
- [self.exampleActionTipsLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.exampleActionView.mas_centerX);
- make.top.equalTo(self.exampleActionView.mas_bottom).offset(adapt(12));
- }];
-
- [self.myActionView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self).offset(adapt(12));
- make.right.equalTo(self).offset(adapt(-12));
- make.width.height.mas_equalTo(adapt(172));
- }];
-
- [self.myActionTipsLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.myActionView.mas_centerX);
- make.top.equalTo(self.myActionView.mas_bottom).offset(adapt(12));
- }];
-
- [self.tipsLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.exampleActionView.mas_bottom).offset(adapt(48));
- make.left.equalTo(self).offset(adapt(10));
- make.right.equalTo(self).offset(adapt(-10));
- }];
-
- [self.buttonView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.tipsLb.mas_bottom).offset(adapt(10));
- make.left.equalTo(self);
- make.right.equalTo(self);
- make.bottom.equalTo(self).offset(adapt(-10)).priorityHigh();
- make.height.mas_equalTo(adapt(100));
- }];
-
- NSArray *btnArr = @[self.uploadNowBtn,self.reshootBtn];
-
- // 实现masonry水平固定控件宽度方法
- // axisType 横排还是竖排
- // fixedSpacing 两个控件间隔
- // leadSpacing 第一个控件与边缘的间隔
- // tailSpacing 最后一个控件与边缘的间隔
- [btnArr mas_distributeViewsAlongAxis:MASAxisTypeVertical withFixedSpacing:adapt(10) leadSpacing:adapt(5) tailSpacing:adapt(5)];
-
- // 设置array的垂直方向的约束
- [btnArr mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.buttonView).offset(adapt(12));
- make.right.equalTo(self.buttonView).offset(adapt(-12));
- }];
-
- [super updateConstraints];
- }
- - (void)ym_bindViewModel:(YMAuthenticationCenterViewModel *)viewModel{
- if (!viewModel) {
- return;
- }
-
- _viewModel = viewModel;
-
- @weakify(self)
- [[[[RACObserve(self.viewModel, samplePhotoUrl) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * samplePhotoUrl) {
- @strongify(self)
- [self.exampleActionView sd_setImageWithURL:[LCTools getImageUrlWithAddress:samplePhotoUrl] placeholderImage:[UIImage new] options:SDWebImageRefreshCached];
- }];
-
- [[[[RACObserve(self.viewModel, photo) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(UIImage * photo) {
- @strongify(self)
- self.myActionView.image = photo;
- }];
-
- }
- - (UIImageView *)exampleActionView{
- if (!_exampleActionView) {
- _exampleActionView = [[UIImageView alloc]init];
- _exampleActionView.contentMode = UIViewContentModeScaleAspectFill;
- _exampleActionView.backgroundColor = HexColorFromRGB(0xF6F6F6);
- _exampleActionView.layer.cornerRadius = adapt(10);
- _exampleActionView.layer.masksToBounds = YES;
- }
- return _exampleActionView;
- }
- - (UILabel *)exampleActionTipsLb{
- if (!_exampleActionTipsLb) {
- _exampleActionTipsLb = [[UILabel alloc]init];
- _exampleActionTipsLb.font = LCFont(14);
- _exampleActionTipsLb.textColor = HexColorFromRGB(0x1B2739);
- _exampleActionTipsLb.textAlignment = NSTextAlignmentCenter;
- _exampleActionTipsLb.text = @"示例动作";
- }
- return _exampleActionTipsLb;
- }
- - (UIImageView *)myActionView{
- if (!_myActionView) {
- _myActionView = [[UIImageView alloc]init];
- _myActionView.contentMode = UIViewContentModeScaleAspectFill;
- _myActionView.backgroundColor = HexColorFromRGB(0xF6F6F6);
- _myActionView.layer.cornerRadius = adapt(10);
- _myActionView.layer.masksToBounds = YES;
- }
- return _myActionView;
- }
- - (UILabel *)myActionTipsLb{
- if (!_myActionTipsLb) {
- _myActionTipsLb = [[UILabel alloc]init];
- _myActionTipsLb.font = LCFont(14);
- _myActionTipsLb.textColor = HexColorFromRGB(0x1B2739);
- _myActionTipsLb.textAlignment = NSTextAlignmentCenter;
- _myActionTipsLb.text = @"本人动作";
- }
- return _myActionTipsLb;
- }
- - (UILabel *)tipsLb{
- if (!_tipsLb) {
- _tipsLb = [[UILabel alloc]init];
- _tipsLb.font = LCFont(14);
- _tipsLb.textColor = HexColorFromRGB(0xFEC01A);
- _tipsLb.textAlignment = NSTextAlignmentCenter;
- _tipsLb.text = @"如未按示例动作拍照,将无法通过审核";
- _tipsLb.numberOfLines = 0;
- }
- return _tipsLb;
- }
- - (UIView *)buttonView{
- if (!_buttonView) {
- _buttonView = [[UIView alloc]init];
- }
- return _buttonView;
- }
- - (UIButton *)uploadNowBtn {
- if(!_uploadNowBtn){
- _uploadNowBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _uploadNowBtn.titleLabel.font = LCBoldFont(15);
- [_uploadNowBtn setTitle:@"立即上传" forState:UIControlStateNormal];
- [_uploadNowBtn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];
- [_uploadNowBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
- _uploadNowBtn.layer.cornerRadius = adapt(10);
- WS(weakSelf)
- [[[_uploadNowBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
- [weakSelf.viewModel uploadAuthenticationPhotoData];
- }];
- }
- return _uploadNowBtn;
- }
- - (UIButton *)reshootBtn {
- if(!_reshootBtn){
- _reshootBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _reshootBtn.titleLabel.font = LCFont(13);
- [_reshootBtn setTitle:@"重拍" forState:UIControlStateNormal];
- [_reshootBtn setTitleColor:HexColorFromRGB(0x666666) forState:UIControlStateNormal];
- WS(weakSelf)
- [[[_reshootBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(__kindof UIButton * _Nullable sender) {
- [weakSelf.viewModel gotoCustomCamera];
- [weakSelf.viewModel.deleteAuditPhotoSubject sendNext:nil];
- weakSelf.myActionView.image = nil;
- }];
- }
- return _reshootBtn;
- }
- @end
|