|
@@ -0,0 +1,434 @@
|
|
|
+//
|
|
|
+// ASInfomationSetController.m
|
|
|
+// Asteria
|
|
|
+//
|
|
|
+// Created by iOS on 2023/7/5.
|
|
|
+//
|
|
|
+
|
|
|
+#import "ASInfomationSetController.h"
|
|
|
+#import "KWTextField.h"
|
|
|
+#import <BRPickerView/BRPickerView.h>
|
|
|
+
|
|
|
+@interface ASInfomationSetController () <UITextFieldDelegate>
|
|
|
+
|
|
|
+/// 0: 只有邮箱 1: 邮箱加密码 2: 邮箱+验证码+密码 3 邮箱+验证码
|
|
|
+@property (nonatomic,assign) NSInteger showType;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIScrollView *scrollV;
|
|
|
+@property (nonatomic, strong) UIStackView *totalStackV;
|
|
|
+
|
|
|
+@property (nonatomic, strong) KWTextField *lastNTf;
|
|
|
+@property (nonatomic, strong) KWTextField *nameTf;
|
|
|
+@property (nonatomic, strong) KWTextField *birthTf;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIStackView *passStackV;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIButton *changePassBt;
|
|
|
+
|
|
|
+@property (nonatomic, strong) KWTextField *emailTf;
|
|
|
+@property (nonatomic, strong) KWTextField *oldPassTf;
|
|
|
+@property (nonatomic, strong) KWTextField *nPassTf;
|
|
|
+
|
|
|
+@property (nonatomic, strong) UIButton *bottomBt;
|
|
|
+
|
|
|
+
|
|
|
+@property (nonatomic, strong) NSDate *currentDate;
|
|
|
+
|
|
|
+//@property (nonatomic, strong) KWInfoSettingViewModel *vm;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation ASInfomationSetController
|
|
|
+
|
|
|
+- (void)viewDidLoad {
|
|
|
+ [super viewDidLoad];
|
|
|
+// self.vm = [KWInfoSettingViewModel new];
|
|
|
+ self.titleStr = @"Information";
|
|
|
+ [self setNavRightSearch:^{
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ self.statusBgV.backgroundColor = Col_FFF;
|
|
|
+ self.customNavBar.backgroundColor = Col_FFF;
|
|
|
+
|
|
|
+ [self loadSubVs];
|
|
|
+
|
|
|
+ [self setData];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)setData {
|
|
|
+// KWLoginedUserModel *m = [KWLoginedManager.shareInstance getCurrentLoginedUser];
|
|
|
+//// self.userModel = m;
|
|
|
+// self.lastNTf.text = m.lastname;
|
|
|
+// self.nameTf.text = m.firstname;
|
|
|
+// self.currentDate = [NSDate dateWithString:m.dob format:@"yyyy-MM-dd HH:mm:ss"];
|
|
|
+// self.birthTf.text = [self.currentDate stringWithFormat:@"MM/dd/yyyy"];
|
|
|
+
|
|
|
+ self.showType = 0;
|
|
|
+
|
|
|
+// self.emailTf.text = m.email;
|
|
|
+ [self configViewsByShowType];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)loadSubVs {
|
|
|
+
|
|
|
+ [self.view addSubview:self.scrollV];
|
|
|
+
|
|
|
+
|
|
|
+ UIStackView *tStackV = [[UIStackView alloc] init];
|
|
|
+ tStackV.axis = UILayoutConstraintAxisVertical;
|
|
|
+ tStackV.alignment = UIStackViewAlignmentFill;
|
|
|
+ tStackV.distribution = UIStackViewDistributionFill;
|
|
|
+ tStackV.spacing = 20;
|
|
|
+ self.totalStackV = tStackV;
|
|
|
+
|
|
|
+ UIStackView *topStackV = [[UIStackView alloc] init];
|
|
|
+ topStackV.axis = UILayoutConstraintAxisHorizontal;
|
|
|
+ topStackV.alignment = UIStackViewAlignmentFill;
|
|
|
+ topStackV.distribution = UIStackViewDistributionFillEqually;
|
|
|
+ topStackV.spacing = 20;
|
|
|
+ [self.totalStackV addArrangedSubview:topStackV];
|
|
|
+
|
|
|
+ NSArray *titles = @[@"First Name", @"Last Name", @"Date Of Birth"];
|
|
|
+ NSArray *placeHolders = @[@"Pleace Input Name", @"Pleace Input Last Name", @"Pleace Select Date Of Birth"];
|
|
|
+ for (int i = 0; i<titles.count; i++) {
|
|
|
+ UILabel *lb = [[UILabel alloc] init];
|
|
|
+ lb.font = [UIFont fontWithName:Rob_Regular size:12];
|
|
|
+ lb.textColor = UIColor.blackColor;
|
|
|
+ KWTextField *tf = [[KWTextField alloc] init];
|
|
|
+ UIStackView *stackV = [[UIStackView alloc] init];
|
|
|
+ stackV.axis = UILayoutConstraintAxisVertical;
|
|
|
+ stackV.alignment = UIStackViewAlignmentFill;
|
|
|
+ stackV.distribution = UIStackViewDistributionFill;
|
|
|
+ stackV.spacing = 5;
|
|
|
+ [stackV addArrangedSubview:lb];
|
|
|
+ [stackV addArrangedSubview:tf];
|
|
|
+// lb.text = titles[i];
|
|
|
+ tf.placeholder = placeHolders[i];
|
|
|
+ [lb mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.equalTo(@5);
|
|
|
+ }];
|
|
|
+ [tf mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.equalTo(@45);
|
|
|
+ }];
|
|
|
+ if (i == 0 || i == 1) {
|
|
|
+ [topStackV addArrangedSubview:stackV];
|
|
|
+ } else {
|
|
|
+ [self.totalStackV addArrangedSubview:stackV];
|
|
|
+ }
|
|
|
+ switch (i) {
|
|
|
+ case 0: {
|
|
|
+ self.nameTf = tf;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 1: {
|
|
|
+ self.lastNTf = tf;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 2: {
|
|
|
+ self.birthTf = tf;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ UIStackView *pStackV = [[UIStackView alloc] init];
|
|
|
+ pStackV.axis = UILayoutConstraintAxisVertical;
|
|
|
+ pStackV.alignment = UIStackViewAlignmentFill;
|
|
|
+ pStackV.distribution = UIStackViewDistributionFillEqually;
|
|
|
+ pStackV.spacing = 20;
|
|
|
+ self.passStackV = pStackV;
|
|
|
+
|
|
|
+
|
|
|
+ NSArray *titleArr = @[@"Email",@"",@""];
|
|
|
+ NSArray *placeArr = @[@"Place Input Email",@"* OLD Password",@"* New Password"];
|
|
|
+ for (int i=0; i<titleArr.count; i++) {
|
|
|
+ KWTextField *tf = [[KWTextField alloc] init];
|
|
|
+ UIStackView *stackV = [[UIStackView alloc] init];
|
|
|
+ stackV.axis = UILayoutConstraintAxisVertical;
|
|
|
+ stackV.alignment = UIStackViewAlignmentFill;
|
|
|
+ stackV.distribution = UIStackViewDistributionFill;
|
|
|
+ stackV.spacing = 5;
|
|
|
+ if (![titleArr[i] isEqualToString:@""]) {
|
|
|
+ UILabel *lb = [[UILabel alloc] init];
|
|
|
+ lb.font = [UIFont fontWithName:Rob_Regular size:12];
|
|
|
+ lb.textColor = UIColor.blackColor;
|
|
|
+ [stackV addArrangedSubview:lb];
|
|
|
+// lb.text = titleArr[i];
|
|
|
+ [lb mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.equalTo(@5);
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ [stackV addArrangedSubview:tf];
|
|
|
+ tf.placeholder = placeArr[i];
|
|
|
+ [tf mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.equalTo(@45);
|
|
|
+ }];
|
|
|
+ tf.delegate = self;
|
|
|
+ [tf addTarget:self action:@selector(textfieldDidChange:) forControlEvents:UIControlEventEditingChanged];
|
|
|
+ [tf addTarget:self action:@selector(textfieldDidChange:) forControlEvents:UIControlEventValueChanged];
|
|
|
+
|
|
|
+ switch (i) {
|
|
|
+ case 0: {
|
|
|
+ self.emailTf = tf;
|
|
|
+ [self.totalStackV addArrangedSubview:stackV];
|
|
|
+ UIView *v = [UIView new];
|
|
|
+ v.backgroundColor = UIColor.clearColor;
|
|
|
+ [v addSubview:self.changePassBt];
|
|
|
+ [self.totalStackV addArrangedSubview:v];
|
|
|
+ [v mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.height.equalTo(@30);
|
|
|
+ }];
|
|
|
+ [self.changePassBt mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.left.bottom.equalTo(v);
|
|
|
+ }];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 1: {
|
|
|
+ self.oldPassTf = tf;
|
|
|
+ self.oldPassTf.secureTextEntry = true;
|
|
|
+ UIView *lv = [self getPassRightBt:800000];
|
|
|
+ self.oldPassTf.rightView = lv;
|
|
|
+ [lv mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.width.equalTo(@50);
|
|
|
+ make.height.equalTo(@45);
|
|
|
+ }];
|
|
|
+ self.oldPassTf.rightViewMode = UITextFieldViewModeAlways;
|
|
|
+ [self.totalStackV addArrangedSubview:self.passStackV];
|
|
|
+ [self.passStackV addArrangedSubview:stackV];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 2: {
|
|
|
+ self.nPassTf = tf;
|
|
|
+ self.nPassTf.secureTextEntry = true;
|
|
|
+
|
|
|
+ UIView *lv = [self getPassRightBt:800001];
|
|
|
+ lv.frame = CGRectMake(0, 0, 50, 45);
|
|
|
+ self.nPassTf.rightView = lv;
|
|
|
+ [lv mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.width.equalTo(@50);
|
|
|
+ make.height.equalTo(@45);
|
|
|
+ }];
|
|
|
+ self.nPassTf.rightViewMode = UITextFieldViewModeAlways;
|
|
|
+ [self.passStackV addArrangedSubview:stackV];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.passStackV.hidden = true;
|
|
|
+ [self.scrollV addSubview:self.totalStackV];
|
|
|
+ [self.totalStackV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.top.equalTo(self.scrollV).offset(20);
|
|
|
+ make.left.equalTo(self.scrollV).offset(20);
|
|
|
+ make.right.equalTo(self.view).offset(-20);
|
|
|
+ make.bottom.equalTo(self.scrollV).offset(20);
|
|
|
+ make.width.equalTo([NSNumber numberWithFloat:KScreenWidth-40]);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.view addSubview:self.bottomBt];
|
|
|
+ [self.bottomBt mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.equalTo(self.view).offset(20);
|
|
|
+ make.right.equalTo(self.view).offset(-20);
|
|
|
+ make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-20);
|
|
|
+ make.height.equalTo(@45);
|
|
|
+ }];
|
|
|
+
|
|
|
+ [self.scrollV mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.right.equalTo(self.view);
|
|
|
+ make.top.equalTo(self.customNavBar.mas_bottom);
|
|
|
+ make.bottom.equalTo(self.bottomBt.mas_top).offset(-10);
|
|
|
+ }];
|
|
|
+
|
|
|
+ self.birthTf.delegate = self;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (UIScrollView *)scrollV {
|
|
|
+ if (!_scrollV) {
|
|
|
+ UIScrollView *v = [[UIScrollView alloc] init];
|
|
|
+ v.showsVerticalScrollIndicator = false;
|
|
|
+ v.showsHorizontalScrollIndicator = false;
|
|
|
+ v.alwaysBounceVertical = true;
|
|
|
+ v.backgroundColor = [UIColor colorWithHexString:@"#f8f8f8"];
|
|
|
+ _scrollV = v;
|
|
|
+ }
|
|
|
+ return _scrollV;
|
|
|
+}
|
|
|
+
|
|
|
+- (UIButton *)changePassBt {
|
|
|
+ if (!_changePassBt) {
|
|
|
+ UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ [bt setImage:[UIImage imageNamed:@"login_selectRido"] forState:UIControlStateNormal];
|
|
|
+ [bt setImage:[UIImage imageNamed:@"login_selectRido_select"] forState:UIControlStateSelected];
|
|
|
+ [bt setTitle:@" Change Password" forState:UIControlStateNormal];
|
|
|
+ bt.titleLabel.font = [UIFont fontWithName:Rob_Regular size:12];
|
|
|
+ [bt setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
|
|
|
+ [bt addTarget:self action:@selector(changePassTypeChanege) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ _changePassBt = bt;
|
|
|
+ }
|
|
|
+ return _changePassBt;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)changePassTypeChanege {
|
|
|
+ switch (self.showType) {
|
|
|
+ case 0:
|
|
|
+ self.showType = 1;
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ self.showType = 0;
|
|
|
+ break;
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ [self configViewsByShowType];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)configViewsByShowType {
|
|
|
+ switch (self.showType) {
|
|
|
+ case 0:
|
|
|
+ self.changePassBt.selected = false;
|
|
|
+ self.passStackV.hidden = true;
|
|
|
+ [self.bottomBt setTitle:@"SAVE CHANGES" forState:UIControlStateNormal];
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ self.changePassBt.selected = true;
|
|
|
+ self.passStackV.hidden = false;
|
|
|
+ [self.bottomBt setTitle:@"SAVE CHANGES" forState:UIControlStateNormal];
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ [self configBtState];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)configBtState {
|
|
|
+ switch (self.showType) {
|
|
|
+ case 0:
|
|
|
+ self.bottomBt.enabled = !self.emailTf.text.isEmpty && !self.nameTf.text.isEmpty && !self.lastNTf.text.isEmpty && !self.birthTf.text.isEmpty;
|
|
|
+ break;
|
|
|
+ case 1: {
|
|
|
+ BOOL isflag = !self.emailTf.text.isEmpty && !self.oldPassTf.text.isEmpty && !self.nPassTf.text.isEmpty && !self.nameTf.text.isEmpty && !self.lastNTf.text.isEmpty && !self.birthTf.text.isEmpty;
|
|
|
+ self.bottomBt.enabled = isflag;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ self.bottomBt.backgroundColor = self.bottomBt.isEnabled ? [UIColor blackColor] : [UIColor colorWithHexString:@"#ADADAD"];
|
|
|
+}
|
|
|
+
|
|
|
+- (UIView *)getPassRightBt:(NSInteger)tag {
|
|
|
+ UIView *v = [UIView new];
|
|
|
+ v.backgroundColor = UIColor.whiteColor;
|
|
|
+ UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ [bt setImage:[UIImage imageNamed:@"login_password_secure"] forState:UIControlStateNormal];
|
|
|
+ [bt setImage:[UIImage imageNamed:@"login_password_secure_display"] forState:UIControlStateSelected];
|
|
|
+ [bt addTarget:self action:@selector(tfBtAction:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ bt.tag = tag;
|
|
|
+ [v addSubview:bt];
|
|
|
+ [bt mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.width.height.equalTo(@30);
|
|
|
+ make.right.equalTo(v).offset(-17);
|
|
|
+ make.centerY.equalTo(v);
|
|
|
+ }];
|
|
|
+ return v;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)tfBtAction:(UIButton *)bt {
|
|
|
+ NSInteger tag = bt.tag - 800000;
|
|
|
+ bt.selected = !bt.isSelected;
|
|
|
+ if (tag == 0) {
|
|
|
+ self.oldPassTf.secureTextEntry = !bt.isSelected;
|
|
|
+ } else {
|
|
|
+ self.nPassTf.secureTextEntry = !bt.isSelected;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (UIButton *)bottomBt {
|
|
|
+ if (!_bottomBt) {
|
|
|
+ UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
+ [bt setTitle:@"NEXT" forState:UIControlStateNormal];
|
|
|
+ bt.titleLabel.font = [UIFont fontWithName:Rob_Regular size:16];
|
|
|
+ [bt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
|
|
|
+ [bt setBackgroundColor:[UIColor colorWithHexString:@"#ADADAD"]];
|
|
|
+ bt.layer.cornerRadius = 4;
|
|
|
+ bt.layer.masksToBounds = true;
|
|
|
+ bt.enabled = false;
|
|
|
+ [bt addTarget:self action:@selector(bottomBtAction) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ _bottomBt = bt;
|
|
|
+ }
|
|
|
+ return _bottomBt;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)bottomBtAction {
|
|
|
+
|
|
|
+// KWLoginedUserModel *tempInfo = [[KWLoginedUserModel alloc] init];
|
|
|
+// tempInfo.firstname = self.nameTf.text;
|
|
|
+// tempInfo.lastname = self.lastNTf.text;
|
|
|
+// tempInfo.email = self.emailTf.text;
|
|
|
+// tempInfo.dob = self.birthTf.text;
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// [MBProgressHUD showHUDAddedTo:self.view animated:true];
|
|
|
+// @weakify(self);
|
|
|
+// [self.vm editUserInfo:tempInfo changePass:[NSString stringWithFormat:@"%ld", self.showType] oldPass:self.oldPassTf.text nPass:self.nPassTf.text complate:^(BOOL flag, NSString * _Nonnull msg) {
|
|
|
+// [MBProgressHUD hideHUDForView:weak_self.view animated:true];
|
|
|
+// if (!flag) {
|
|
|
+// [weak_self.view makeToast:msg];
|
|
|
+// } else {
|
|
|
+// [weak_self.view makeToast:@"Save Successed"];
|
|
|
+// [weak_self.navigationController popViewControllerAnimated:true];
|
|
|
+// }
|
|
|
+// }];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+- (void)textfieldDidChange:(UITextField *)tf {
|
|
|
+ [self configBtState];
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
|
|
|
+ if ([self.birthTf isEqual:textField]) {
|
|
|
+ BRDatePickerView *datePickerView = [[BRDatePickerView alloc]init];
|
|
|
+ datePickerView.pickerMode = BRDatePickerModeDate;
|
|
|
+ datePickerView.title = @"Please Select The Date Of Birth";
|
|
|
+ datePickerView.selectDate = self.currentDate;
|
|
|
+ datePickerView.minDate = [NSDate br_setYear:1900 month:1 day:1];
|
|
|
+ datePickerView.maxDate = [NSDate date];
|
|
|
+ datePickerView.isAutoSelect = YES;
|
|
|
+ @weakify(self);
|
|
|
+ datePickerView.resultBlock = ^(NSDate *selectDate, NSString *selectValue) {
|
|
|
+ weak_self.currentDate = selectDate;
|
|
|
+ NSDateFormatter *formartter= [[NSDateFormatter alloc]init];
|
|
|
+ [formartter setDateFormat:@"MM/dd/yyyy"];
|
|
|
+ NSString *currentDateStr = [formartter stringFromDate:selectDate];
|
|
|
+ weak_self.birthTf.text = currentDateStr;
|
|
|
+ [weak_self configBtState];
|
|
|
+ NSLog(@"selectValue=%@", selectValue);
|
|
|
+ NSLog(@"selectDate=%@", selectDate);
|
|
|
+ NSLog(@"---------------------------------");
|
|
|
+
|
|
|
+ };
|
|
|
+ [datePickerView show];
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+@end
|