123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- //
- // YMEditProfileViewController.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/18.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMEditProfileViewController.h"
- #import "YMEditProfileViewModel.h"
- #import "YMEditProfileAvatarView.h"
- #import "YMEditProfileAlbumView.h"
- #import "YMEditProfileVoiceView.h"
- #import "YMEditProfileInfoView.h"
- #import "YMEditProfileIntroView.h"
- #import "YMEditProfileTagView.h"
- @interface YMEditProfileViewController ()
- /// 编辑资料VM
- @property (nonatomic, strong) YMEditProfileViewModel *viewModel;
- /// 保存按钮
- @property (nonatomic, strong) UIButton *saveBtn;
- /// 容器滚动视图
- @property (nonatomic, strong) UIScrollView *contentScrollView;
- /// 容器视图
- @property (nonatomic, strong) UIView *contentView;
- /// 头像视图
- @property (nonatomic, strong) YMEditProfileAvatarView *avatarView;
- /// 相册视图
- @property (nonatomic, strong) YMEditProfileAlbumView *albumView;
- /// 语音视图
- @property (nonatomic, strong) YMEditProfileVoiceView *voiceView;
- /// 信息视图
- @property (nonatomic, strong) YMEditProfileInfoView *infoView;
- /// 介绍视图
- @property (nonatomic, strong) YMEditProfileIntroView *introView;
- /// 标签视图
- @property (nonatomic, strong) YMEditProfileTagView *tagView;
- @end
- @implementation YMEditProfileViewController
- @dynamic viewModel;
- - (void)viewDidLoad {
- [super viewDidLoad];
-
- self.ym_customNavView.backgroundColor = UIColor.clearColor;
-
- UIImageView *topBgImgv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ym_messages_top_bg"]];
- topBgImgv.frame = CGRectMake(0, 0, kScreenWidth, StatusBarHeight + adapt(54));
- [self.view addSubview:topBgImgv];
-
- }
- - (void)ym_setupViews{
- //[self setRightBarButtonWithCustomView:self.saveBtn];
- [self.view addSubview:self.contentScrollView];
- [self.view sendSubviewToBack:self.contentScrollView];
- [self.contentScrollView addSubview:self.contentView];
- [self.contentView addSubview:self.avatarView];
- [self.contentView addSubview:self.albumView];
- [self.contentView addSubview:self.voiceView];
- [self.contentView addSubview:self.infoView];
- [self.contentView addSubview:self.introView];
- [self.contentView addSubview:self.tagView];
- [self.view addSubview:self.saveBtn];
- [self.view setNeedsUpdateConstraints];
- [self.view updateConstraintsIfNeeded];
- }
- - (void)updateViewConstraints{
-
- [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.view).offset(kYMNavHeight);
- make.left.equalTo(self.view);
- make.right.equalTo(self.view);
- make.bottom.equalTo(self.view);
- }];
-
- [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self.contentScrollView);
- make.width.equalTo(self.contentScrollView.mas_width);
- }];
-
- [self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.contentView).offset(adapt(15));
- make.left.equalTo(self.contentView).offset(adapt(15));
- make.right.equalTo(self.contentView).offset(adapt(-15));
- }];
-
- [self.albumView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.avatarView.mas_bottom).offset(adapt(10));
- make.left.equalTo(self.avatarView.mas_left);
- make.right.equalTo(self.avatarView.mas_right);
- }];
-
- [self.voiceView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.albumView.mas_bottom).offset(adapt(10));
- make.left.equalTo(self.avatarView.mas_left);
- make.right.equalTo(self.avatarView.mas_right);
- }];
-
- [self.infoView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.voiceView.mas_bottom).offset(adapt(10));
- make.left.equalTo(self.avatarView.mas_left);
- make.right.equalTo(self.avatarView.mas_right);
- }];
-
- [self.introView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.infoView.mas_bottom);
- make.left.equalTo(self.avatarView.mas_left);
- make.right.equalTo(self.avatarView.mas_right);
- }];
-
- [self.tagView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.introView.mas_bottom);
- make.left.equalTo(self.avatarView.mas_left);
- make.right.equalTo(self.avatarView.mas_right);
- make.bottom.equalTo(self.contentView).offset(adapt(-100));
- }];
-
- [self.saveBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.view).offset(adapt(32));
- make.right.equalTo(self.view).offset(adapt(-32));
- make.bottom.equalTo(self.view).offset(Is_iPhoneX ? adapt(-32) : adapt(-12));
- make.height.mas_equalTo(adapt(50));
- }];
-
- [super updateViewConstraints];
- }
- - (void)ym_bindViewModel{
- [self.avatarView ym_bindViewModel:self.viewModel];
- [self.albumView ym_bindViewModel:self.viewModel];
- [self.voiceView ym_bindViewModel:self.viewModel];
- [self.infoView ym_bindViewModel:self.viewModel];
- [self.introView ym_bindViewModel:self.viewModel];
- [self.tagView ym_bindViewModel:self.viewModel];
-
- [self.viewModel getEditProfileInfoData];
- }
- - (UIButton *)saveBtn{
- if (!_saveBtn) {
- _saveBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _saveBtn.titleLabel.font = LCBoldFont(18);
- [_saveBtn setTitle:@"保存" forState:UIControlStateNormal];
- [_saveBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
- [_saveBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
- _saveBtn.layer.cornerRadius = adapt(12);
- _saveBtn.layer.masksToBounds = YES;
- WS(weakSelf)
- [[[_saveBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- [weakSelf.viewModel uploadAlbumData];
- }];
- }
- return _saveBtn;
- }
- - (UIScrollView *)contentScrollView{
- if (!_contentScrollView) {
- _contentScrollView = [[UIScrollView alloc] init];
- _contentScrollView.alwaysBounceVertical = YES;
- _contentScrollView.showsVerticalScrollIndicator = NO;
- _contentScrollView.showsHorizontalScrollIndicator = NO;
- _contentScrollView.backgroundColor = UIColor.clearColor; //HexColorFromRGB(0xF8F8F8);
- _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
- }
- return _contentScrollView;
- }
- - (UIView *)contentView{
- if (!_contentView) {
- _contentView = [[UIView alloc]init];
- }
- return _contentView;
- }
- - (YMEditProfileAvatarView *)avatarView{
- if (!_avatarView) {
- _avatarView = [[YMEditProfileAvatarView alloc]init];
- _avatarView.backgroundColor = UIColor.whiteColor;
- [_avatarView addRectCorner:UIRectCornerAllCorners radius:adapt(10)];
- _avatarView.userInteractionEnabled = YES;
- WS(weakSelf)
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
- [_avatarView addGestureRecognizer:tap];
- [[[tap rac_gestureSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- [weakSelf.viewModel openAvatarPickerPopupView];
- }];
- }
- return _avatarView;
- }
- - (YMEditProfileAlbumView *)albumView{
- if (!_albumView) {
- _albumView = [[YMEditProfileAlbumView alloc]init];
- _albumView.backgroundColor = UIColor.whiteColor;
- [_albumView addRectCorner:UIRectCornerAllCorners radius:adapt(10)];
- }
- return _albumView;
- }
- - (YMEditProfileVoiceView *)voiceView{
- if (!_voiceView) {
- _voiceView = [[YMEditProfileVoiceView alloc]init];
- _voiceView.backgroundColor = UIColor.whiteColor;
- [_voiceView addRectCorner:UIRectCornerAllCorners radius:adapt(10)];
- _voiceView.userInteractionEnabled = YES;
- WS(weakSelf)
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
- [_voiceView addGestureRecognizer:tap];
- [[[tap rac_gestureSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- [weakSelf.viewModel gotoSoundShowcase];
- }];
- }
- return _voiceView;
- }
- - (YMEditProfileInfoView *)infoView{
- if (!_infoView) {
- _infoView = [[YMEditProfileInfoView alloc]init];
- _infoView.backgroundColor = UIColor.whiteColor;
- [_infoView addRectCorner:UIRectCornerTopLeft|UIRectCornerTopRight radius:adapt(10)];
- }
- return _infoView;
- }
- - (YMEditProfileIntroView *)introView{
- if (!_introView) {
- _introView = [[YMEditProfileIntroView alloc]init];
- _introView.backgroundColor = UIColor.whiteColor;
- _introView.userInteractionEnabled = YES;
- WS(weakSelf)
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
- [_introView addGestureRecognizer:tap];
- [[[tap rac_gestureSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- [weakSelf.viewModel.editProfileOperationSubject sendNext:@(YMEditProfileTypeIntro)];
- }];
- }
- return _introView;
- }
- - (YMEditProfileTagView *)tagView{
- if (!_tagView) {
- _tagView = [[YMEditProfileTagView alloc]init];
- _tagView.backgroundColor = UIColor.whiteColor;
- [_tagView addRectCorner:UIRectCornerBottomLeft|UIRectCornerBottomRight radius:adapt(10)];
- _tagView.userInteractionEnabled = YES;
- WS(weakSelf)
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
- [_tagView addGestureRecognizer:tap];
- [[[tap rac_gestureSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- [weakSelf.viewModel.editProfileOperationSubject sendNext:@(YMEditProfileTypeTag)];
- }];
- }
- return _tagView;
- }
- @end
|