123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- //
- // 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
|