2021-09-14 21:01:09 +08:00
|
|
|
|
//
|
|
|
|
|
// LoginFullInfoViewController.m
|
|
|
|
|
// xplan-ios
|
|
|
|
|
//
|
|
|
|
|
// Created by 冯硕 on 2021/9/14.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "LoginFullInfoViewController.h"
|
|
|
|
|
///Third
|
|
|
|
|
#import <Masonry/Masonry.h>
|
|
|
|
|
#import <ReactiveObjC/ReactiveObjC.h>
|
|
|
|
|
///Tool
|
|
|
|
|
#import "XPMacro.h"
|
|
|
|
|
#import "ThemeColor.h"
|
|
|
|
|
#import "UIImage+Utils.h"
|
|
|
|
|
#import "UIButton+EnlargeTouchArea.h"
|
2021-09-27 20:16:27 +08:00
|
|
|
|
#import "StatisticsServiceHelper.h"
|
2021-11-04 15:14:13 +08:00
|
|
|
|
#import "AccountInfoStorage.h"
|
2021-09-15 18:41:40 +08:00
|
|
|
|
///Model
|
|
|
|
|
#import "ThirdUserInfo.h"
|
2021-09-14 21:01:09 +08:00
|
|
|
|
///P
|
|
|
|
|
#import "LoginFullInfoPresenter.h"
|
|
|
|
|
#import "LoginFullInfoProtocol.h"
|
|
|
|
|
|
|
|
|
|
@interface LoginFullInfoViewController ()<LoginFullInfoProtocol>
|
|
|
|
|
///完善资料
|
|
|
|
|
@property (nonatomic,strong) UILabel *titleLabel;
|
|
|
|
|
///性别后期无法修改
|
|
|
|
|
@property (nonatomic,strong) UILabel *remindLabel;
|
|
|
|
|
///昵称的背景
|
|
|
|
|
@property (nonatomic,strong) UIView * backView;
|
|
|
|
|
///容器
|
|
|
|
|
@property (nonatomic,strong) UIStackView *stackView;
|
|
|
|
|
///显示昵称
|
|
|
|
|
@property (nonatomic,strong) UILabel *nameLabel;
|
|
|
|
|
///输入框
|
|
|
|
|
@property (nonatomic,strong) UITextField *textField;
|
|
|
|
|
///更新
|
|
|
|
|
@property (nonatomic,strong) UIButton *refreshButton;
|
|
|
|
|
///x性别的容器
|
|
|
|
|
@property (nonatomic,strong) UIStackView *sexStackView;
|
|
|
|
|
///男用户
|
|
|
|
|
@property (nonatomic,strong) UIButton *maleButton;
|
|
|
|
|
///女用户
|
|
|
|
|
@property (nonatomic,strong) UIButton *femaleButton;
|
|
|
|
|
///下一步
|
|
|
|
|
@property (nonatomic,strong) UIButton *nextButton;
|
2021-09-15 18:41:40 +08:00
|
|
|
|
///第三方的用户信息
|
|
|
|
|
@property (nonatomic,strong) ThirdUserInfo *thirdInfo;
|
|
|
|
|
///目前选择的性别
|
|
|
|
|
@property (nonatomic,copy) NSString *sexString;
|
2021-09-14 21:01:09 +08:00
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation LoginFullInfoViewController
|
|
|
|
|
|
|
|
|
|
- (LoginFullInfoPresenter *)createPresenter {
|
|
|
|
|
return [[LoginFullInfoPresenter alloc] init];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
|
|
[super viewDidLoad];
|
|
|
|
|
[self initSubViews];
|
|
|
|
|
[self initSubViewConstraints];
|
|
|
|
|
[self initEvents];
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-15 18:41:40 +08:00
|
|
|
|
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
|
|
|
|
|
[self.view endEditing:YES];
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 21:01:09 +08:00
|
|
|
|
#pragma mark - Private Method
|
|
|
|
|
- (void)initSubViews {
|
|
|
|
|
[self.view addSubview:self.titleLabel];
|
|
|
|
|
[self.view addSubview:self.remindLabel];
|
|
|
|
|
[self.view addSubview:self.backView];
|
|
|
|
|
[self.view addSubview:self.sexStackView];
|
|
|
|
|
[self.view addSubview:self.nextButton];
|
|
|
|
|
[self.backView addSubview:self.stackView];
|
|
|
|
|
[self.stackView addArrangedSubview:self.nameLabel];
|
|
|
|
|
[self.stackView addArrangedSubview:self.textField];
|
|
|
|
|
[self.stackView addArrangedSubview:self.refreshButton];
|
|
|
|
|
|
|
|
|
|
[self.sexStackView addArrangedSubview:self.maleButton];
|
|
|
|
|
[self.sexStackView addArrangedSubview:self.femaleButton];
|
2021-09-15 18:41:40 +08:00
|
|
|
|
|
|
|
|
|
if ([self.presenter getThirdUserInfo]) {
|
|
|
|
|
self.textField.text = [self.presenter getThirdUserInfo].userName;
|
|
|
|
|
} else {
|
|
|
|
|
[self.presenter randomRequestNick];
|
|
|
|
|
}
|
2021-09-14 21:01:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)initSubViewConstraints {
|
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.centerX.mas_equalTo(self.view);
|
|
|
|
|
make.top.mas_equalTo(self.view).offset(139 + kSafeAreaTopHeight);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.remindLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.centerX.mas_equalTo(self.view);
|
|
|
|
|
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(8);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.right.mas_equalTo(self.view).inset(52);
|
|
|
|
|
make.height.mas_equalTo(45);
|
|
|
|
|
make.top.mas_equalTo(self.remindLabel.mas_bottom).offset(49);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.right.mas_equalTo(self.backView).inset(25);
|
|
|
|
|
make.top.bottom.mas_equalTo(self.backView);
|
|
|
|
|
}];
|
2021-09-15 18:41:40 +08:00
|
|
|
|
|
2021-09-14 21:01:09 +08:00
|
|
|
|
|
|
|
|
|
[self.sexStackView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.mas_equalTo(self.backView);
|
|
|
|
|
make.top.mas_equalTo(self.backView.mas_bottom).offset(15);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[self.nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.right.mas_equalTo(self.view).inset(52);
|
|
|
|
|
make.height.mas_equalTo(45);
|
|
|
|
|
make.top.mas_equalTo(self.sexStackView.mas_bottom).offset(75);
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)initEvents {
|
|
|
|
|
@weakify(self);
|
|
|
|
|
[[self.maleButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
|
|
|
|
|
@strongify(self);
|
|
|
|
|
self.femaleButton.selected = NO;
|
|
|
|
|
x.selected = YES;
|
2021-09-15 18:41:40 +08:00
|
|
|
|
self.sexString = @"1";
|
2021-09-14 21:01:09 +08:00
|
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[[self.femaleButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
|
2021-09-15 18:41:40 +08:00
|
|
|
|
@strongify(self);
|
2021-09-14 21:01:09 +08:00
|
|
|
|
x.selected = YES;
|
|
|
|
|
self.maleButton.selected = NO;
|
2021-09-15 18:41:40 +08:00
|
|
|
|
self.sexString = @"2";
|
2021-09-14 21:01:09 +08:00
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[[self.refreshButton rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
|
|
|
|
|
@strongify(self);
|
|
|
|
|
CAKeyframeAnimation *lAni = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
|
|
|
|
|
lAni.duration = 1;
|
|
|
|
|
lAni.values=@[@0,@(M_PI*2)];
|
|
|
|
|
//使得动画结束后,保持动画效果
|
|
|
|
|
lAni.removedOnCompletion = NO;
|
|
|
|
|
lAni.fillMode = kCAFillModeForwards;
|
|
|
|
|
[x.layer addAnimation:lAni forKey:nil];
|
|
|
|
|
[self.presenter randomRequestNick];
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
[[self.nextButton rac_signalForControlEvents:UIControlEventTouchUpInside]subscribeNext:^(__kindof UIControl * _Nullable x) {
|
2021-09-15 18:41:40 +08:00
|
|
|
|
@strongify(self);
|
|
|
|
|
[self updateUserInfo];
|
2021-09-14 21:01:09 +08:00
|
|
|
|
}];
|
|
|
|
|
|
2021-09-15 18:41:40 +08:00
|
|
|
|
[[self.textField.rac_textSignal map:^id _Nullable(NSString * _Nullable value) {
|
|
|
|
|
if (value.length > 15) {
|
|
|
|
|
value = [value substringToIndex:15];
|
|
|
|
|
}
|
|
|
|
|
return value;
|
|
|
|
|
}] subscribeNext:^(id _Nullable x) {
|
|
|
|
|
@strongify(self);
|
|
|
|
|
self.textField.text = x;
|
|
|
|
|
[self updateNextButton];
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///更新用户信息
|
|
|
|
|
- (void)updateUserInfo {
|
|
|
|
|
[self.presenter complectionInfoWithAvatar:[self getAvatarUrl] gender:self.maleButton.selected ? @"1":@"2" nick:self.textField.text inviteCode:nil roomUid:nil shareUid:nil shareChannel:nil];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///获取头像 可能是从第三方获取的头像
|
|
|
|
|
- (NSString *)getAvatarUrl {
|
|
|
|
|
NSString * avatar;
|
|
|
|
|
if ([self.presenter getThirdUserInfo] && [self.presenter getThirdUserInfo].avatarUrl.length > 0) {
|
|
|
|
|
avatar = [self.presenter getThirdUserInfo].avatarUrl;
|
|
|
|
|
} else {
|
|
|
|
|
avatar = @"https://image.lecheng163.com/yinyou_default_avatar.png";
|
|
|
|
|
}
|
|
|
|
|
return avatar;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)updateNextButton {
|
|
|
|
|
if (self.textField.text.length > 0 && self.sexString.length > 0) {
|
|
|
|
|
self.nextButton.enabled = YES;
|
|
|
|
|
} else {
|
|
|
|
|
self.nextButton.enabled = NO;
|
|
|
|
|
}
|
2021-09-14 21:01:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - LoginFullInfoProtocol
|
|
|
|
|
- (void)requestRandomNickSuccess:(NSString *)nick {
|
|
|
|
|
self.textField.text = nick;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)complementInfoSuccess {
|
2021-09-27 20:16:27 +08:00
|
|
|
|
[StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventLoginRepariSuccess];
|
2021-11-04 15:14:13 +08:00
|
|
|
|
///需要重新加载一次 ticket 刷新tabbar的item
|
|
|
|
|
[[AccountInfoStorage instance] saveTicket:nil];
|
2021-09-15 18:41:40 +08:00
|
|
|
|
UIViewController *vc = self.presentingViewController;
|
|
|
|
|
while (vc.presentingViewController) {
|
|
|
|
|
vc = vc.presentingViewController;
|
|
|
|
|
}
|
|
|
|
|
[vc dismissViewControllerAnimated:YES completion:^{
|
|
|
|
|
}];
|
2021-09-14 21:01:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - Getters And Setters
|
2021-09-15 18:41:40 +08:00
|
|
|
|
- (void)setSexString:(NSString *)sexString {
|
|
|
|
|
_sexString = sexString;
|
|
|
|
|
[self updateNextButton];
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 21:01:09 +08:00
|
|
|
|
- (UILabel *)titleLabel {
|
|
|
|
|
if (!_titleLabel) {
|
|
|
|
|
_titleLabel = [[UILabel alloc] init];
|
|
|
|
|
_titleLabel.text = @"完善资料";
|
|
|
|
|
_titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Bold" size:18];
|
|
|
|
|
_titleLabel.textColor = [ThemeColor mainTextColor];
|
|
|
|
|
_titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
|
|
}
|
|
|
|
|
return _titleLabel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UILabel *)remindLabel {
|
|
|
|
|
if (!_remindLabel) {
|
|
|
|
|
_remindLabel = [[UILabel alloc] init];
|
|
|
|
|
_remindLabel.text = @"性别后期无法进行修改";
|
|
|
|
|
_remindLabel.font = [UIFont systemFontOfSize:13];
|
|
|
|
|
_remindLabel.textColor = [ThemeColor secondTextColor];
|
|
|
|
|
}
|
|
|
|
|
return _remindLabel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIStackView *)stackView {
|
|
|
|
|
if (!_stackView) {
|
|
|
|
|
_stackView = [[UIStackView alloc] init];
|
|
|
|
|
_stackView.axis = UILayoutConstraintAxisHorizontal;
|
|
|
|
|
_stackView.distribution = UIStackViewDistributionFill;
|
|
|
|
|
_stackView.alignment = UIStackViewAlignmentFill;
|
|
|
|
|
_stackView.spacing = 10;
|
|
|
|
|
}
|
|
|
|
|
return _stackView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIView *)backView {
|
|
|
|
|
if (!_backView) {
|
|
|
|
|
_backView = [[UIView alloc] init];
|
|
|
|
|
_backView.backgroundColor = [ThemeColor appCellBackgroundColor];
|
|
|
|
|
_backView.layer.masksToBounds = YES;
|
|
|
|
|
_backView.layer.cornerRadius = 45/2;
|
|
|
|
|
}
|
|
|
|
|
return _backView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UILabel *)nameLabel {
|
|
|
|
|
if (!_nameLabel) {
|
|
|
|
|
_nameLabel = [[UILabel alloc] init];
|
|
|
|
|
_nameLabel.text = @"昵称";
|
|
|
|
|
_nameLabel.font = [UIFont systemFontOfSize:15];
|
|
|
|
|
_nameLabel.textColor = [ThemeColor secondTextColor];
|
2021-09-15 18:41:40 +08:00
|
|
|
|
[_nameLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
2021-09-14 21:01:09 +08:00
|
|
|
|
[_nameLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return _nameLabel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UITextField *)textField {
|
|
|
|
|
if (!_textField) {
|
|
|
|
|
_textField = [[UITextField alloc] init];
|
|
|
|
|
_textField.textColor = [ThemeColor mainTextColor];
|
|
|
|
|
_textField.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:15.f];
|
|
|
|
|
_textField.borderStyle = UITextBorderStyleNone;
|
|
|
|
|
_textField.tintColor = [ThemeColor appMainColor];
|
|
|
|
|
_textField.textAlignment = NSTextAlignmentRight;
|
|
|
|
|
_textField.backgroundColor = [UIColor clearColor];
|
|
|
|
|
}
|
|
|
|
|
return _textField;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIButton *)refreshButton {
|
|
|
|
|
if (!_refreshButton) {
|
|
|
|
|
_refreshButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[_refreshButton setImage:[UIImage imageNamed:@"login_full_info_refresh"] forState:UIControlStateNormal];
|
|
|
|
|
[_refreshButton setImage:[UIImage imageNamed:@"login_full_info_refresh"] forState:UIControlStateSelected];
|
2021-09-15 18:41:40 +08:00
|
|
|
|
[_refreshButton setEnlargeEdgeWithTop:0 right:0 bottom:0 left:10];
|
|
|
|
|
[_refreshButton setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
|
|
|
|
[_refreshButton setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
|
2021-09-14 21:01:09 +08:00
|
|
|
|
}
|
|
|
|
|
return _refreshButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIStackView *)sexStackView {
|
|
|
|
|
if (!_sexStackView) {
|
|
|
|
|
_sexStackView = [[UIStackView alloc] init];
|
|
|
|
|
_sexStackView.axis = UILayoutConstraintAxisHorizontal;
|
|
|
|
|
_sexStackView.distribution = UIStackViewDistributionFill;
|
|
|
|
|
_sexStackView.alignment = UIStackViewAlignmentCenter;
|
|
|
|
|
_sexStackView.spacing = 15;
|
|
|
|
|
}
|
|
|
|
|
return _sexStackView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIButton *)maleButton {
|
|
|
|
|
if (!_maleButton) {
|
|
|
|
|
_maleButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[_maleButton setImage:[UIImage imageNamed:@"login_full_info_male_normal"] forState:UIControlStateNormal];
|
|
|
|
|
[_maleButton setImage:[UIImage imageNamed:@"login_full_info_male_select"] forState:UIControlStateSelected];
|
|
|
|
|
}
|
|
|
|
|
return _maleButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIButton *)femaleButton {
|
|
|
|
|
if (!_femaleButton) {
|
|
|
|
|
_femaleButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[_femaleButton setImage:[UIImage imageNamed:@"login_full_info_female_normal"] forState:UIControlStateNormal];
|
|
|
|
|
[_femaleButton setImage:[UIImage imageNamed:@"login_full_info_female_select"] forState:UIControlStateSelected];
|
|
|
|
|
}
|
|
|
|
|
return _femaleButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UIButton *)nextButton{
|
|
|
|
|
if (!_nextButton) {
|
|
|
|
|
_nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
_nextButton.layer.masksToBounds = YES;
|
|
|
|
|
_nextButton.layer.cornerRadius = 45/2.f;
|
|
|
|
|
[_nextButton setTitle:@"下一步" forState:UIControlStateNormal];
|
2021-09-23 18:35:40 +08:00
|
|
|
|
_nextButton.titleLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:18];
|
2021-09-14 21:01:09 +08:00
|
|
|
|
[_nextButton setTitleColor:[ThemeColor confirmButtonTextColor] forState:UIControlStateNormal];
|
|
|
|
|
_nextButton.enabled = NO;
|
|
|
|
|
UIImage *image = [UIImage gradientColorImageFromColors:@[[ThemeColor confirmButtonGradientStartColor], [ThemeColor confirmButtonGradientEndColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
|
|
|
|
|
[_nextButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[[ThemeColor disableButtonColor], [ThemeColor disableButtonColor]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateDisabled];
|
|
|
|
|
[_nextButton setBackgroundImage:image forState:UIControlStateNormal];
|
|
|
|
|
}
|
|
|
|
|
return _nextButton;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|