| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- //
- // ChangePasswordView.m
- // FunSDKDemo
- //
- // Created by wujiangbo on 2018/10/30.
- // Copyright © 2018年 wujiangbo. All rights reserved.
- //
- #import "ChangePasswordView.h"
- #import "UserInputCell.h"
- #import <Masonry/Masonry.h>
- #import "LoginShowControl.h"
- #import "Header.h"
- @interface ChangePasswordView()<UITableViewDelegate,UITableViewDataSource>
- @end
- @implementation ChangePasswordView
- -(instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
-
- if (self) {
-
- self.backgroundColor = [UIColor whiteColor];
-
- [self addSubview:self.tbPassWord];
- [self addSubview:self.changePwdBtn];
-
- //布局
- [self configSubView];
- }
-
- return self;
- }
- #pragma mark - 控件布局
- -(void)configSubView
- {
- [self.tbPassWord mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(@110);
- make.width.equalTo(self).multipliedBy(0.9);
- make.height.equalTo(@192);
- make.centerX.equalTo(self);
- }];
-
- [self.changePwdBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.tbPassWord.mas_bottom).offset(60);
- make.width.equalTo(self).multipliedBy(0.9);
- make.height.equalTo(@45);
- make.centerX.equalTo(self);
- }];
- }
- #pragma mark - button Event
- //点击密码修改按钮
- -(void)changePwdBtnClicked:(UIButton *)sender
- {
- if (self.changePwdBtnClicked) {
- self.changePwdBtnClicked([[LoginShowControl getInstance] getLoginUserName],self.pwdOldTF.text, self.pwdNewTF.text, self.confrimTF.text);
- }
- }
- //点击空白处隐藏键盘
- -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
- {
- [self endEditing:YES];
- }
- #pragma mark - tableViewDataSource/Delegate
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
-
- return 4;
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- return 48;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-
- UserInputCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UserInputCell"];
- switch (indexPath.row) {
- case 0:
- {
- cell.customTitle.text = TS("UserName");
- cell.customTitle.adjustsFontSizeToFitWidth = YES;
- cell.inputTextField.attributedPlaceholder = [[NSAttributedString alloc]initWithString:@"" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]}];
- cell.inputTextField.text = [[LoginShowControl getInstance] getLoginUserName];
- cell.inputTextField.enabled = NO;
- cell.toggleBtn.hidden = YES;
- }
- break;
- case 1:
- {
- cell.customTitle.text = TS("Old_Password");
- cell.customTitle.adjustsFontSizeToFitWidth = YES;
- cell.inputTextField.attributedPlaceholder = [[NSAttributedString alloc]initWithString:TS("Old_Password") attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]}];
- self.pwdOldTF = cell.inputTextField;
- cell.toggleBtn.hidden = YES;
- }
- break;
-
- case 2:
- {
- cell.customTitle.text = TS("New_Password");
- cell.customTitle.adjustsFontSizeToFitWidth = YES;
- cell.inputTextField.attributedPlaceholder = [[NSAttributedString alloc]initWithString:TS("PwdInputTip") attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]}];
- cell.inputTextField.secureTextEntry = YES;
- self.pwdNewTF = cell.inputTextField;
- cell.toggleBtn.hidden = NO;
- [cell.toggleBtn addTarget:self action:@selector(showPassword) forControlEvents:UIControlEventTouchUpInside];
- }
- break;
-
- default:
- {
- cell.customTitle.text = TS("New_Password");
- cell.inputTextField.attributedPlaceholder =[[NSAttributedString alloc]initWithString:TS("PwdInputTip2") attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]}];
- cell.inputTextField.secureTextEntry = YES;
- cell.customTitle.adjustsFontSizeToFitWidth = YES;
- self.confrimTF = cell.inputTextField;
- cell.toggleBtn.hidden = NO;
- [cell.toggleBtn addTarget:self action:@selector(showPassword) forControlEvents:UIControlEventTouchUpInside];
- }
- break;
- }
- return cell;
- }
- //显示密码
- -(void)showPassword
- {
- self.pwdNewTF.secureTextEntry = !self.pwdNewTF.secureTextEntry;
- UserInputCell *cell1 = [self.tbPassWord cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]];
- cell1.toggleBtn.selected = !cell1.toggleBtn.selected;
-
- self.confrimTF.secureTextEntry = !self.confrimTF.secureTextEntry;
- UserInputCell *cell2 = [self.tbPassWord cellForRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]];
- cell2.toggleBtn.selected = !cell2.toggleBtn.selected;
- }
- #pragma mark - LazyLoad
- -(UITableView *)tbPassWord {
- if (!_tbPassWord) {
- _tbPassWord = [[UITableView alloc] init];
- _tbPassWord.delegate = self;
- _tbPassWord.dataSource = self;
- _tbPassWord.scrollEnabled = NO;
- _tbPassWord.layer.cornerRadius = 4;
- _tbPassWord.allowsSelection = NO;
- [_tbPassWord registerClass:[UserInputCell class] forCellReuseIdentifier:@"UserInputCell"];
- }
-
- return _tbPassWord;
- }
- -(UIButton *)changePwdBtn
- {
- if (!_changePwdBtn) {
- _changePwdBtn = [[UIButton alloc] init];
- [_changePwdBtn setTitle:TS("Modify_pwd") forState:UIControlStateNormal];
- [_changePwdBtn setBackgroundColor:GlobalMainColor];
- [_changePwdBtn.titleLabel setFont:[UIFont systemFontOfSize:16]];
- [_changePwdBtn addTarget:self action:@selector(changePwdBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
- }
-
- return _changePwdBtn;
- }
- @end
|