APPassForgetNewPassV.m 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. //
  2. // APPassForgetNewPassV.m
  3. // westkissMob
  4. //
  5. // Created by iOS on 2024/4/24.
  6. //
  7. #import "APPassForgetNewPassV.h"
  8. #import "KWTextField.h"
  9. @interface APPassForgetNewPassV ()
  10. @property (nonatomic, strong) KWTextField *passTf;
  11. @property (nonatomic, strong) KWTextField *conPassTf;
  12. @property (nonatomic, strong) UILabel *passTitleLb;
  13. @property (nonatomic, strong) UILabel *conpassTitleLb;
  14. @property (nonatomic, strong) UIButton *commitBtn;
  15. @end
  16. @implementation APPassForgetNewPassV
  17. - (void)clearPass {
  18. self.passTf.text = @"";
  19. self.conPassTf.text = @"";
  20. }
  21. - (void)commitBtnAction:(UIButton *)bt {
  22. [bt sleep:1];
  23. NSString *pass = self.passTf.text;
  24. NSString *conPass = self.conPassTf.text;
  25. if (pass == nil || pass.isEmpty || pass.length < 6) {
  26. [self makeToast:@"The Password Can't Less Than 6 Character"];
  27. return;
  28. }
  29. if (![pass isEqualToString:conPass]) {
  30. [self makeToast:@"The Confirm Password Mast Same to New Password"];
  31. return;
  32. }
  33. if (self.btnClick) {
  34. self.btnClick(pass);
  35. }
  36. }
  37. - (instancetype)initWithFrame:(CGRect)frame
  38. {
  39. self = [super initWithFrame:frame];
  40. if (self) {
  41. [self loadSubV];
  42. }
  43. return self;
  44. }
  45. - (void)loadSubV {
  46. UILabel *titileLab = [UILabel new];
  47. titileLab.text = @"RESET PASSWORD";
  48. titileLab.font = [UIFont boldSystemFontOfSize:16];
  49. titileLab.textAlignment = NSTextAlignmentCenter;
  50. titileLab.textColor = [UIColor colorWithHexString:@"#000000"];
  51. [self addSubview:titileLab];
  52. [titileLab mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.top.equalTo(@30);
  54. make.leading.equalTo(self).offset(30);
  55. make.trailing.equalTo(self).offset(-30);
  56. }];
  57. [self addSubviews:@[self.passTitleLb, self.passTf, self.conpassTitleLb, self.conPassTf, self.commitBtn]];
  58. [self.passTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.top.equalTo(titileLab.mas_bottom).offset(40);
  60. make.height.equalTo(@14);
  61. make.leading.equalTo(@20);
  62. make.trailing.equalTo(@(-20));
  63. }];
  64. [self.passTf mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.top.equalTo(self.passTitleLb.mas_bottom).offset(10);
  66. make.leading.equalTo(@20);
  67. make.trailing.equalTo(@(-20));
  68. make.height.equalTo(@45);
  69. }];
  70. [self.conpassTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  71. make.top.equalTo(self.passTf.mas_bottom).offset(30);
  72. make.height.equalTo(@14);
  73. make.leading.equalTo(@20);
  74. make.trailing.equalTo(@(-20));
  75. }];
  76. [self.conPassTf mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.top.equalTo(self.conpassTitleLb.mas_bottom).offset(10);
  78. make.leading.equalTo(@20);
  79. make.trailing.equalTo(@(-20));
  80. make.height.equalTo(@45);
  81. }];
  82. [self.commitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  83. make.top.equalTo(self.conPassTf.mas_bottom).offset(31);
  84. make.height.equalTo(@45);
  85. make.leading.equalTo(@20);
  86. make.trailing.equalTo(@(-20));
  87. make.bottom.equalTo(self).offset(-30);
  88. }];
  89. }
  90. - (KWTextField *)passTf {
  91. if (!_passTf) {
  92. KWTextField *tf = [[KWTextField alloc] init];
  93. tf.placeholder = @"* Password";
  94. tf.rightView = [self getPassRightBt:800000];
  95. tf.rightViewMode = UITextFieldViewModeAlways;
  96. _passTf = tf;
  97. }
  98. return _passTf;
  99. }
  100. - (KWTextField *)conPassTf {
  101. if (!_conPassTf) {
  102. KWTextField *tf = [[KWTextField alloc] init];
  103. tf.placeholder = @"* Confirm Password";
  104. tf.rightView = [self getPassRightBt:800001];
  105. tf.rightViewMode = UITextFieldViewModeAlways;
  106. _conPassTf = tf;
  107. }
  108. return _conPassTf;
  109. }
  110. - (UILabel *)passTitleLb {
  111. if (!_passTitleLb) {
  112. UILabel *lb = [UILabel baseLb];
  113. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  114. lb.text = @"New Password";
  115. lb.textColor = Col_000;
  116. _passTitleLb = lb;
  117. }
  118. return _passTitleLb;
  119. }
  120. - (UILabel *)conpassTitleLb {
  121. if (!_conpassTitleLb) {
  122. UILabel *lb = [UILabel baseLb];
  123. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  124. lb.text = @"Confirm Password";
  125. lb.textColor = Col_000;
  126. _conpassTitleLb = lb;
  127. }
  128. return _conpassTitleLb;
  129. }
  130. - (UIButton *)commitBtn {
  131. if (!_commitBtn) {
  132. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  133. [bt setTitle:@"SUBMIT" forState:UIControlStateNormal];
  134. bt.titleLabel.font = [UIFont fontWithName:Rob_Regular size:14];
  135. [bt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  136. [bt setBackgroundColor:[UIColor colorWithHexString:@"#000000"]];
  137. bt.layer.cornerRadius = 4;
  138. bt.layer.masksToBounds = true;
  139. [bt addTarget:self action:@selector(commitBtnAction:) forControlEvents:UIControlEventTouchUpInside];
  140. _commitBtn = bt;
  141. }
  142. return _commitBtn;
  143. }
  144. - (UIView *)getPassRightBt:(NSInteger)tag {
  145. UIView *v = [UIView new];
  146. v.backgroundColor = UIColor.clearColor;
  147. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  148. [bt setImage:[UIImage imageNamed:@"login_password_secure"] forState:UIControlStateNormal];
  149. [bt setImage:[UIImage imageNamed:@"login_password_secure_display"] forState:UIControlStateSelected];
  150. [bt addTarget:self action:@selector(tfBtAction:) forControlEvents:UIControlEventTouchUpInside];
  151. bt.tag = tag;
  152. [v addSubview:bt];
  153. [bt mas_makeConstraints:^(MASConstraintMaker *make) {
  154. make.width.height.equalTo(@30);
  155. make.right.equalTo(v).offset(-17);
  156. make.centerY.equalTo(v);
  157. }];
  158. [v mas_makeConstraints:^(MASConstraintMaker *make) {
  159. make.width.equalTo(@50);
  160. make.height.equalTo(@43);
  161. }];
  162. return v;
  163. }
  164. - (void)tfBtAction:(UIButton *)bt {
  165. NSInteger tag = bt.tag - 800000;
  166. bt.selected = !bt.isSelected;
  167. if (tag == 0) {
  168. self.passTf.secureTextEntry = !bt.isSelected;
  169. } else {
  170. self.conPassTf.secureTextEntry = !bt.isSelected;
  171. }
  172. }
  173. @end