// // YMCreateGreetingTemplateViewController.m // MSYOUPAI // // Created by YoMi on 2024/2/24. // Copyright © 2024 MS. All rights reserved. // #import "YMCreateGreetingTemplateViewController.h" #import "YMCreateGreetingTemplateViewModel.h" #import "YMCreateGreetingTemplateTextView.h" #import "YMCreateGreetingTemplateImageView.h" #import "YMCreateGreetingTemplateVoiceView.h" @interface YMCreateGreetingTemplateViewController () /// 完善信息VM @property (nonatomic, strong) YMCreateGreetingTemplateViewModel *viewModel; /// 提交按钮 @property (nonatomic, strong) UIButton *submitBtn; /// 容器滚动视图 @property (nonatomic, strong) UIScrollView *contentScrollView; /// 容器视图 @property (nonatomic, strong) UIView *contentView; /// 打招呼模板文本视图 @property (nonatomic, strong) YMCreateGreetingTemplateTextView *templateTextView; /// 打招呼模板图片视图 @property (nonatomic, strong) YMCreateGreetingTemplateImageView *templateImageView; /// 打招呼模板图片视图 @property (nonatomic, strong) YMCreateGreetingTemplateVoiceView *templateVoiceView; @end @implementation YMCreateGreetingTemplateViewController @dynamic viewModel; - (void)viewDidLoad { [super viewDidLoad]; } - (void)ym_setupViews{ [self setRightBarButtonWithCustomView:self.submitBtn]; [self.view addSubview:self.contentScrollView]; [self.contentScrollView addSubview:self.contentView]; [self.contentView addSubview:self.templateTextView]; [self.contentView addSubview:self.templateImageView]; [self.contentView addSubview:self.templateVoiceView]; [self.view setNeedsUpdateConstraints]; [self.view updateConstraintsIfNeeded]; } - (void)updateViewConstraints{ [self.submitBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.width.equalTo(adapt(50)); make.height.equalTo(adapt(28)); }]; [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.templateTextView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.contentView).offset(adapt(10)); make.left.equalTo(self.contentView); make.right.equalTo(self.contentView); }]; [self.templateImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.templateTextView.mas_bottom).offset(adapt(10)); make.left.equalTo(self.contentView); make.right.equalTo(self.contentView); }]; [self.templateVoiceView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.templateImageView.mas_bottom).offset(adapt(10)); make.left.equalTo(self.contentView); make.right.equalTo(self.contentView); make.bottom.equalTo(self.contentView).offset(adapt(-10)); }]; [super updateViewConstraints]; } - (void)ym_bindViewModel{ [self.templateTextView ym_bindViewModel:self.viewModel]; [self.templateImageView ym_bindViewModel:self.viewModel]; [self.templateVoiceView ym_bindViewModel:self.viewModel]; } - (UIButton *)submitBtn{ if (!_submitBtn) { _submitBtn = [UIButton buttonWithType:UIButtonTypeCustom]; _submitBtn.titleLabel.font = LCFont(13); [_submitBtn setTitle:@"提交" forState:UIControlStateNormal]; [_submitBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal]; [_submitBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP]; _submitBtn.layer.cornerRadius = adapt(8); _submitBtn.layer.masksToBounds = YES; WS(weakSelf) [[[_submitBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) { [weakSelf.viewModel submitGreetingTemplate]; }]; } return _submitBtn; } - (UIScrollView *)contentScrollView{ if (!_contentScrollView) { _contentScrollView = [[UIScrollView alloc]init]; _contentScrollView.alwaysBounceVertical = YES; _contentScrollView.showsVerticalScrollIndicator = NO; _contentScrollView.showsHorizontalScrollIndicator = NO; _contentScrollView.backgroundColor = HexColorFromRGB(0xFFFFFF); _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag; } return _contentScrollView; } - (UIView *)contentView{ if (!_contentView) { _contentView = [[UIView alloc]init]; } return _contentView; } - (YMCreateGreetingTemplateTextView *)templateTextView{ if (!_templateTextView) { _templateTextView = [[YMCreateGreetingTemplateTextView alloc]init]; } return _templateTextView; } - (YMCreateGreetingTemplateImageView *)templateImageView{ if (!_templateImageView) { _templateImageView = [[YMCreateGreetingTemplateImageView alloc]init]; } return _templateImageView; } - (YMCreateGreetingTemplateVoiceView *)templateVoiceView{ if (!_templateVoiceView) { _templateVoiceView = [[YMCreateGreetingTemplateVoiceView alloc]init]; } return _templateVoiceView; } @end