187 lines
5.9 KiB
Objective-C
187 lines
5.9 KiB
Objective-C
//
|
|
// YMRoomRedPacketPwdView.m
|
|
// YUMI
|
|
//
|
|
// Created by YUMI on 2022/8/31.
|
|
//
|
|
|
|
#import "XPRoomRedPacketPwdView.h"
|
|
#import "LoginVerifCodeView.h"
|
|
#import "DJDKMIMOMColor.h"
|
|
#import <Masonry/Masonry.h>
|
|
#import <ReactiveObjC/ReactiveObjC.h>
|
|
#import "TTPopUp.h"
|
|
|
|
@interface XPRoomRedPacketPwdView()
|
|
|
|
@property (nonatomic, strong) UIView *diamondContentView;
|
|
@property (nonatomic, strong) UIButton *closeBtn;
|
|
@property (nonatomic, strong) UILabel *titleLabel;
|
|
@property (nonatomic, strong) UIImageView *diamondImage;
|
|
@property (nonatomic, strong) UILabel *diamondLabel;
|
|
@property (nonatomic, strong) LoginVerifCodeView *codeView;
|
|
@property (nonatomic, strong) UIButton *forgetBtn;
|
|
|
|
@end
|
|
|
|
@implementation XPRoomRedPacketPwdView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
if (self = [super initWithFrame:frame]) {
|
|
[self initSubViews];
|
|
[self initSubViewConstraints];
|
|
[self initEvents];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - Private Method
|
|
- (void)initSubViews {
|
|
self.backgroundColor = [DJDKMIMOMColor appBackgroundColor];
|
|
self.layer.cornerRadius = 8;
|
|
self.layer.masksToBounds = YES;
|
|
[self addSubview:self.closeBtn];
|
|
[self addSubview:self.titleLabel];
|
|
[self addSubview:self.diamondContentView];
|
|
[self.diamondContentView addSubview:self.diamondImage];
|
|
[self.diamondContentView addSubview:self.diamondLabel];
|
|
[self addSubview:self.codeView];
|
|
[self addSubview:self.forgetBtn];
|
|
}
|
|
|
|
- (void)initSubViewConstraints {
|
|
[self mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(360);
|
|
make.height.mas_equalTo(200);
|
|
}];
|
|
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(16);
|
|
make.top.mas_equalTo(16);
|
|
make.height.width.mas_equalTo(30);
|
|
}];
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self);
|
|
make.top.mas_equalTo(20);
|
|
make.height.mas_equalTo(16);
|
|
}];
|
|
[self.diamondContentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self);
|
|
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(16);
|
|
make.height.mas_equalTo(30);
|
|
}];
|
|
[self.diamondImage mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(0);
|
|
make.centerY.mas_equalTo(self.diamondContentView);
|
|
make.width.height.mas_equalTo(24);
|
|
}];
|
|
[self.diamondLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.leading.mas_equalTo(self.diamondImage.mas_trailing).mas_offset(7.5);
|
|
make.centerY.mas_equalTo(self.diamondContentView);
|
|
make.trailing.mas_equalTo(0);
|
|
}];
|
|
[self.codeView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.mas_equalTo(self);
|
|
make.top.mas_equalTo(self.diamondContentView.mas_bottom).mas_offset(16);
|
|
}];
|
|
[self.forgetBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.trailing.mas_equalTo(-12);
|
|
make.top.mas_equalTo(self.codeView.mas_bottom).mas_offset(8);
|
|
}];
|
|
|
|
}
|
|
|
|
- (void)initEvents {
|
|
@weakify(self);
|
|
self.codeView.textFieldChangeBlock = ^(NSString * _Nonnull code) {
|
|
@strongify(self);
|
|
if (code.length == 6) {
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomRedPacketPwdViewPwdComplete:)]) {
|
|
[self.delegate xPRoomRedPacketPwdViewPwdComplete:code];
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
- (void)onCloseButtonClick:(UIButton *)sender {
|
|
[TTPopup dismiss];
|
|
}
|
|
|
|
- (void)onFogetButtonClick:(UIButton *)sender {
|
|
[TTPopup dismiss];
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(xPRoomRedPacketPwdViewPwdForgetBtnClick)]) {
|
|
[self.delegate xPRoomRedPacketPwdViewPwdForgetBtnClick];
|
|
}
|
|
}
|
|
|
|
- (void)setDiamonCount:(NSString *)diamonCount {
|
|
self.diamondLabel.text = diamonCount;
|
|
}
|
|
|
|
- (UIView *)diamondContentView {
|
|
if (!_diamondContentView) {
|
|
_diamondContentView = [[UIView alloc] init];
|
|
}
|
|
return _diamondContentView;
|
|
}
|
|
|
|
- (UILabel *)titleLabel {
|
|
if (!_titleLabel) {
|
|
UILabel *label = [[UILabel alloc] init];
|
|
label.text = YMLocalizedString(@"XPRoomRedPacketPwdView0");
|
|
label.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
|
|
label.textColor = [DJDKMIMOMColor mainTextColor];
|
|
_titleLabel = label;
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
|
|
- (UIImageView *)diamondImage {
|
|
if (!_diamondImage) {
|
|
_diamondImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"moli_money_icon"]];
|
|
}
|
|
return _diamondImage;
|
|
}
|
|
|
|
- (UILabel *)diamondLabel {
|
|
if (!_diamondLabel) {
|
|
UILabel *label = [[UILabel alloc] init];
|
|
label.text = @"";
|
|
label.font = [UIFont systemFontOfSize:28 weight:UIFontWeightMedium];
|
|
label.textColor = [DJDKMIMOMColor mainTextColor];
|
|
_diamondLabel = label;
|
|
}
|
|
return _diamondLabel;
|
|
}
|
|
|
|
- (UIButton *)closeBtn {
|
|
if (!_closeBtn) {
|
|
_closeBtn = [[UIButton alloc] init];
|
|
[_closeBtn setImage:[UIImage imageNamed:@"send_redPacket_cancel"] forState:UIControlStateNormal];
|
|
[_closeBtn addTarget:self action:@selector(onCloseButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _closeBtn;
|
|
}
|
|
|
|
- (LoginVerifCodeView *)codeView {
|
|
if (!_codeView) {
|
|
_codeView= [[LoginVerifCodeView alloc] init];
|
|
_codeView.number = 6;
|
|
_codeView.shouldBeSecurity = YES;
|
|
}
|
|
return _codeView;
|
|
}
|
|
|
|
- (UIButton *)forgetBtn {
|
|
if (!_forgetBtn) {
|
|
_forgetBtn = [[UIButton alloc] init];
|
|
[_forgetBtn addTarget:self action:@selector(onFogetButtonClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
[_forgetBtn setTitle:YMLocalizedString(@"XPRoomRedPacketPwdView1") forState:UIControlStateNormal];
|
|
[_forgetBtn setTitleColor:UIColorFromRGB(0xEA3B36) forState:UIControlStateNormal];
|
|
_forgetBtn.titleLabel.font = [UIFont systemFontOfSize:13];
|
|
}
|
|
return _forgetBtn;
|
|
}
|
|
|
|
@end
|