2023-07-27 09:20:00 +08:00
|
|
|
//
|
|
|
|
|
// SetLoginUserInfoViewController.m
|
|
|
|
|
// TreeHole
|
|
|
|
|
//
|
|
|
|
|
// Created by 郑创权 on 2022/10/8.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "SetLoginUserInfoViewController.h"
|
|
|
|
|
#import "MTPickerView.h"
|
|
|
|
|
#import "GenderPickerView.h"
|
|
|
|
|
#import "SetNickNameViewController.h"
|
|
|
|
|
@interface SetLoginUserInfoViewController ()<UITextFieldDelegate>
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, strong)UILabel* titleLab;
|
|
|
|
|
@property (nonatomic, strong)UILabel* wantgendersLab;
|
|
|
|
|
@property (nonatomic, strong)UILabel* birthdayLab;
|
|
|
|
|
@property (nonatomic, strong)UILabel* locationLab;
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, strong)UITextField *wantGenderTextField;
|
|
|
|
|
@property (nonatomic, strong)UITextField *birthdayTextField;
|
|
|
|
|
@property (nonatomic, strong)UITextField *locationTextField;
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, strong)UITextField* introductionTF;
|
|
|
|
|
@property (nonatomic, strong)UIButton* nextBtn;
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, strong)NSArray* wantGendersArray;
|
|
|
|
|
@property (nonatomic, strong)NSString* province;
|
|
|
|
|
@property (nonatomic, strong)NSString* city;
|
|
|
|
|
@property (nonatomic, strong)NSString* district;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation SetLoginUserInfoViewController
|
|
|
|
|
|
|
|
|
|
- (BOOL)mt_nagationBarTransparent {
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
// Do any additional setup after loading the view.
|
|
|
|
|
self.cardView.backgroundColor = COLOR_WITH_RGB(0x16112F);
|
|
|
|
|
[self.cardView addSubview:self.titleLab];
|
|
|
|
|
NSArray* functionArray = @[@"想认识的人",@"所在地",@"生日"];
|
|
|
|
|
for (NSInteger i = 0; i < functionArray.count; i++) {
|
|
|
|
|
UIButton* functionBtn = [[UIButton alloc]initWithFrame:CGRectMake(0, _titleLab.bottom+22 + 50*i, SCREEN_WIDTH, 50)];
|
|
|
|
|
[functionBtn setTitle:functionArray[i] forState:UIControlStateNormal];
|
|
|
|
|
[functionBtn setTitleColor:COLOR_WITH_RGB_A(0xFFFFFF, 0) forState:UIControlStateNormal];
|
|
|
|
|
[functionBtn addTarget:self action:@selector(functionBtnClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
[self.cardView addSubview:functionBtn];
|
|
|
|
|
UILabel* leftLab = [[UILabel alloc]initWithFrame:CGRectMake(20, 15, 70, 20)];
|
|
|
|
|
leftLab.text = functionArray[i];
|
|
|
|
|
leftLab.font = MT_FONT_MEDIUM_NO_SCALE_SIZE(14);
|
|
|
|
|
leftLab.textColor = COLOR_WITH_RGB(0xFFFFFF);
|
|
|
|
|
leftLab.textAlignment = NSTextAlignmentLeft;
|
|
|
|
|
[functionBtn addSubview:leftLab];
|
|
|
|
|
|
|
|
|
|
UIImageView* rightArrowImgV = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 20 - 24, (functionBtn.height - 24)/2.0, 24, 24)];
|
|
|
|
|
rightArrowImgV.image = [UIImage imageNamed:@"TH_base_rightWhite_arrow"];
|
|
|
|
|
[functionBtn addSubview:rightArrowImgV];
|
|
|
|
|
|
|
|
|
|
UILabel* subTitleLab = [[UILabel alloc]initWithFrame:CGRectMake(leftLab.right + 18, (functionBtn.height - 20)/2.0, rightArrowImgV.left - leftLab.right - 18 , 20)];
|
|
|
|
|
subTitleLab.font = MT_FONT_MEDIUM_NO_SCALE_SIZE(11);
|
|
|
|
|
subTitleLab.textColor = COLOR_WITH_RGB_A(0xFFFFFF, 0.7);
|
|
|
|
|
subTitleLab.text = @"请选择";
|
|
|
|
|
subTitleLab.textAlignment = NSTextAlignmentRight;
|
|
|
|
|
[functionBtn addSubview:subTitleLab];
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
_wantgendersLab = subTitleLab;
|
|
|
|
|
}else if(i == 1){
|
|
|
|
|
_locationLab = subTitleLab;
|
|
|
|
|
}else if(i == 2){
|
|
|
|
|
_birthdayLab = subTitleLab;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UIView* hLineV = [[UIView alloc]initWithFrame:CGRectMake(20, functionBtn.height - 1, SCREEN_WIDTH-40, 1)];
|
|
|
|
|
hLineV.backgroundColor = COLOR_WITH_RGB(0xD9D9D9);
|
|
|
|
|
[functionBtn addSubview:hLineV];
|
|
|
|
|
|
|
|
|
|
if (i == 2) {
|
|
|
|
|
_introductionTF = [[UITextField alloc]initWithFrame:CGRectMake(20, functionBtn.bottom, SCREEN_WIDTH-40, 50)];
|
|
|
|
|
_introductionTF.placeholder = @"请填写个人介绍";
|
|
|
|
|
_introductionTF.textAlignment = NSTextAlignmentRight;
|
|
|
|
|
_introductionTF.delegate = self;
|
|
|
|
|
_introductionTF.font = MT_FONT_MEDIUM_NO_SCALE_SIZE(11);
|
|
|
|
|
_introductionTF.textColor = COLOR_WITH_RGB_A(0xFFFFFF, 0.7);
|
|
|
|
|
[self.cardView addSubview:_introductionTF];
|
|
|
|
|
UILabel* leftTipLab = [[UILabel alloc]initWithFrame:CGRectMake(0, (_introductionTF.height - 20)/2.0, 70, 20)];
|
|
|
|
|
leftTipLab.text = @"个人介绍";
|
|
|
|
|
leftTipLab.textColor = COLOR_WITH_RGB(0xFFFFFF);
|
|
|
|
|
leftTipLab.textAlignment = NSTextAlignmentLeft;
|
|
|
|
|
leftTipLab.font = MT_FONT_MEDIUM_NO_SCALE_SIZE(14);
|
|
|
|
|
_introductionTF.leftView = leftTipLab;
|
|
|
|
|
_introductionTF.leftViewMode = UITextFieldViewModeAlways;
|
|
|
|
|
UIView* tfHLineV = [[UIView alloc]initWithFrame:CGRectMake(0, _introductionTF.height - 1, SCREEN_WIDTH-40, 1)];
|
|
|
|
|
tfHLineV.backgroundColor = COLOR_WITH_RGB(0xD9D9D9);
|
|
|
|
|
[_introductionTF addSubview:tfHLineV];
|
|
|
|
|
|
|
|
|
|
UILabel* inputBottomTipLab = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 20 - 70,_introductionTF.bottom + 10 , 70, 14)];
|
|
|
|
|
inputBottomTipLab.text = @"请输入5-30字";
|
|
|
|
|
inputBottomTipLab.textColor = COLOR_WITH_RGB_A(0xFFFFFF, 0.7);
|
|
|
|
|
inputBottomTipLab.textAlignment = NSTextAlignmentRight;
|
|
|
|
|
inputBottomTipLab.font = MT_FONT_MEDIUM_NO_SCALE_SIZE(10);
|
|
|
|
|
[self.cardView addSubview:inputBottomTipLab];
|
|
|
|
|
|
|
|
|
|
_nextBtn = [[UIButton alloc]initWithFrame:CGRectMake((SCREEN_WIDTH - 150)/2.0, inputBottomTipLab.bottom + 60, 150, 38)];
|
|
|
|
|
_nextBtn.layer.cornerRadius = 19;
|
|
|
|
|
_nextBtn.layer.masksToBounds = YES;
|
|
|
|
|
_nextBtn.layer.borderWidth = 1;
|
|
|
|
|
_nextBtn.layer.borderColor = COLOR_WITH_RGB_A(0xFFFFFF, 0.15).CGColor;
|
|
|
|
|
[_nextBtn setTitle:@"下一步" forState:UIControlStateNormal];
|
|
|
|
|
[_nextBtn setTitleColor:COLOR_WITH_RGB(0xFFFFFF) forState:UIControlStateNormal];
|
|
|
|
|
_nextBtn.titleLabel.font = MT_FONT_MEDIUM_NO_SCALE_SIZE(16);
|
|
|
|
|
_nextBtn.backgroundColor = COLOR_WITH_RGB_A(0xFFFFFF, 0.1);
|
|
|
|
|
[_nextBtn addTarget:self action:@selector(nextBtnClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
[self.cardView addSubview:_nextBtn];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(UILabel *)titleLab{
|
|
|
|
|
if (!_titleLab) {
|
|
|
|
|
_titleLab = [[UILabel alloc]initWithFrame:CGRectMake(20, 0, 200, 22)];
|
|
|
|
|
_titleLab.text = @"深入了解才会更有味道";
|
|
|
|
|
_titleLab.textColor = COLOR_WITH_RGB(0xFFFFFF);
|
|
|
|
|
_titleLab.font = MT_FONT_MEDIUM_NO_SCALE_SIZE(16);
|
|
|
|
|
_titleLab.textAlignment = NSTextAlignmentLeft;
|
|
|
|
|
}
|
|
|
|
|
return _titleLab;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(void)functionBtnClick:(UIButton*)sender{
|
|
|
|
|
NSLog(@"sender.title : %@",sender.titleLabel.text);
|
|
|
|
|
if([sender.titleLabel.text isEqualToString:@"想认识的人"]){
|
|
|
|
|
[self.view addSubview:self.wantGenderTextField];
|
|
|
|
|
[_wantGenderTextField becomeFirstResponder];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if([sender.titleLabel.text isEqualToString:@"所在地"]){
|
|
|
|
|
[self.view addSubview:self.locationTextField];
|
|
|
|
|
[_locationTextField becomeFirstResponder];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if([sender.titleLabel.text isEqualToString:@"生日"]){
|
|
|
|
|
[self.view addSubview:self.birthdayTextField];
|
|
|
|
|
[_birthdayTextField becomeFirstResponder];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(UITextField *)wantGenderTextField{
|
|
|
|
|
if (!_wantGenderTextField) {
|
|
|
|
|
WeakSelf(self);
|
|
|
|
|
// User *user = [UserService currentUser];
|
2023-08-18 14:05:39 +08:00
|
|
|
GenderPickerView *genderPickerView = [GenderPickerView pickerViewWithMultiple:YES selectedArr:weakself.wantGendersArray];
|
2023-07-27 09:20:00 +08:00
|
|
|
_wantGenderTextField = [[UITextField alloc] init];
|
|
|
|
|
_wantGenderTextField.delegate = self;
|
|
|
|
|
_wantGenderTextField.inputView = [MTPickerView pickerViewWithCustomView:genderPickerView done:^(NSArray<NSString *> * _Nonnull selectedValues) {
|
|
|
|
|
// [UserService updateUserToRemoteWithParams:@{
|
|
|
|
|
// @"want_genders": genderPickerView.selectedItems ?: @[],
|
|
|
|
|
// } completion:^(id _Nullable rsp, NSError * _Nullable error) {
|
|
|
|
|
// if (!error) {
|
|
|
|
|
// user.want_genders = genderPickerView.selectedItems ?: @[];
|
|
|
|
|
weakself.wantGendersArray = genderPickerView.selectedItems ?: @[];
|
|
|
|
|
weakself.wantgendersLab.text = [genderPickerView.selectedItems ?: @[] componentsJoinedByString:@"、"];
|
|
|
|
|
[self isNextClick];
|
|
|
|
|
// }else{
|
|
|
|
|
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
// [SVProgressHUD showErrorWithStatus:[error.userInfo objectForKey:@"message"]];
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// }];
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
return _wantGenderTextField;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(UITextField *)birthdayTextField{
|
|
|
|
|
if (!_birthdayTextField) {
|
|
|
|
|
WeakSelf(self);
|
|
|
|
|
// User *user = [UserService currentUser];
|
|
|
|
|
// GenderPickerView *genderPickerView = [GenderPickerView pickerViewWithMultiple:YES];
|
|
|
|
|
_birthdayTextField = [[UITextField alloc] init];
|
|
|
|
|
_birthdayTextField.delegate = self;
|
|
|
|
|
_birthdayTextField.text =weakself.birthdayLab.text > 0 ? weakself.birthdayLab.text : nil;
|
|
|
|
|
_birthdayTextField.inputView = [MTPickerView pickerViewWithType:MTPickerViewTypeBirthday defaultValues:[(_birthdayTextField.text.length > 0 ? _birthdayTextField.text : @"2000-01-01") componentsSeparatedByString:@"-"] valueDidChange:nil done:^(NSArray<NSString *> * _Nonnull selectedValues) {
|
|
|
|
|
NSString *birthday = [selectedValues componentsJoinedByString:@"-"];
|
|
|
|
|
// [UserService updateUserToRemoteWithParams:@{
|
|
|
|
|
// @"birthday": birthday?:@""
|
|
|
|
|
// } completion:^(id _Nullable rsp, NSError * _Nullable error) {
|
|
|
|
|
// if (!error) {
|
|
|
|
|
// user.birthday = birthday;
|
|
|
|
|
weakself.birthdayLab.text = birthday;
|
|
|
|
|
[self isNextClick];
|
|
|
|
|
// }else{
|
|
|
|
|
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
// [SVProgressHUD showErrorWithStatus:[error.userInfo objectForKey:@"message"]];
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// }];
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
return _birthdayTextField;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(UITextField *)locationTextField{
|
|
|
|
|
if (!_locationTextField) {
|
|
|
|
|
WeakSelf(self);
|
|
|
|
|
// User *user = [UserService currentUser];
|
|
|
|
|
// GenderPickerView *genderPickerView = [GenderPickerView pickerViewWithMultiple:YES];
|
|
|
|
|
_locationTextField = [[UITextField alloc] init];
|
|
|
|
|
_locationTextField.delegate = self;
|
|
|
|
|
_locationTextField.delegate = self;
|
|
|
|
|
_locationTextField.text = weakself.locationLab.text ?: @"选择城市-省市";
|
|
|
|
|
_locationTextField.inputView = [MTPickerView pickerViewWithType:MTPickerViewTypeLocation defaultValues:[weakself.locationLab.text ?: @"北京市-北京市-东城区" componentsSeparatedByString:@"-"] valueDidChange:^(NSArray<NSString *> * _Nonnull values) {
|
|
|
|
|
NSLog(@"改成数据.%@",values);
|
|
|
|
|
} done:^(NSArray<NSString *> * _Nonnull selectedValues) {
|
|
|
|
|
NSLog(@"选择.");
|
|
|
|
|
if (selectedValues.count == 3) {
|
|
|
|
|
// [UserService updateUserToRemoteWithParams:@{
|
|
|
|
|
// @"province": selectedValues[0]?:@"",
|
|
|
|
|
// @"city": selectedValues[1]?:@"",
|
|
|
|
|
// @"district": selectedValues[2]?:@"",
|
|
|
|
|
// } completion:^(id _Nullable rsp, NSError * _Nullable error) {
|
|
|
|
|
// if (!error) {
|
|
|
|
|
// user.province = selectedValues[0];
|
|
|
|
|
// user.city = selectedValues[1];
|
|
|
|
|
// user.district = selectedValues[2];
|
|
|
|
|
weakself.province = selectedValues[0];
|
|
|
|
|
weakself.city = selectedValues[1];
|
|
|
|
|
weakself.district = selectedValues[2];
|
|
|
|
|
weakself.locationLab.text = [NSString stringWithFormat:@"%@-%@-%@", weakself.province, weakself.city, weakself.district];
|
|
|
|
|
[self isNextClick];
|
|
|
|
|
// }else{
|
|
|
|
|
// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
|
|
// [SVProgressHUD showErrorWithStatus:[error.userInfo objectForKey:@"message"]];
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// }];
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
return _locationTextField;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(void)nextBtnClick:(UIButton*)sender{
|
|
|
|
|
if ([_wantgendersLab.text isEqualToString:@"请选择"]) {
|
|
|
|
|
[SVProgressHUD showErrorWithStatus:@"请选择想认识的人"];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ([_locationLab.text isEqualToString:@"请选择"]) {
|
|
|
|
|
[SVProgressHUD showErrorWithStatus:@"请选择所在地"];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ([_birthdayLab.text isEqualToString:@"请选择"]) {
|
|
|
|
|
[SVProgressHUD showErrorWithStatus:@"请选择生日"];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (_introductionTF.text.length < 5 || _introductionTF.text.length > 30) {
|
|
|
|
|
[SVProgressHUD showErrorWithStatus:@"请填写个人介绍并满足5-30字~"];
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//提交.
|
|
|
|
|
SetNickNameViewController *nickNameVC = [[SetNickNameViewController alloc] init];
|
|
|
|
|
nickNameVC.gender_str = self.gender_str;
|
|
|
|
|
nickNameVC.birthday = self.birthdayLab.text;
|
|
|
|
|
nickNameVC.wantGendersArray = self.wantGendersArray;
|
|
|
|
|
nickNameVC.province = self.province;
|
|
|
|
|
nickNameVC.city = self.city;
|
|
|
|
|
nickNameVC.district = self.district;
|
|
|
|
|
[PYAppService pushViewControllerAnimated:nickNameVC];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(void)isNextClick{
|
|
|
|
|
WeakSelf(self);
|
|
|
|
|
if ([weakself.locationLab.text isEqualToString:@"请选择"] ||
|
|
|
|
|
[weakself.wantgendersLab.text isEqualToString:@"请选择"] ||
|
|
|
|
|
[weakself.birthdayLab.text isEqualToString:@"请选择"] ||
|
|
|
|
|
(weakself.introductionTF.text.length < 5 ||
|
|
|
|
|
weakself.introductionTF.text.length > 30)) {
|
|
|
|
|
_nextBtn.backgroundColor = COLOR_WITH_RGB_A(0xFFFFFF, 0.1);
|
|
|
|
|
_nextBtn.layer.borderColor = COLOR_WITH_RGB_A(0xFFFFFF, 0.15).CGColor;
|
|
|
|
|
[_nextBtn setTitleColor:COLOR_WITH_RGB(0xFFFFFF) forState:UIControlStateNormal];
|
|
|
|
|
}else{
|
|
|
|
|
_nextBtn.backgroundColor = COLOR_WITH_RGB_A(0xFFB902, 1);
|
|
|
|
|
_nextBtn.layer.borderColor = COLOR_WITH_RGB_A(0xFFB902, 1).CGColor;
|
|
|
|
|
[_nextBtn setTitleColor:COLOR_WITH_RGB(0x000000) forState:UIControlStateNormal];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(void)textFieldDidChangeSelection:(UITextField *)textField{
|
|
|
|
|
NSLog(@"textFieldDidChangeSelection : %@",textField.text);
|
|
|
|
|
[self isNextClick];
|
|
|
|
|
}
|
|
|
|
|
-(void)textFieldDidEndEditing:(UITextField *)textField{
|
|
|
|
|
NSLog(@"textFieldDidEndEditing : %@",textField.text);
|
|
|
|
|
}
|
|
|
|
|
@end
|