YMCreateGreetingTemplateViewController.m 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. //
  2. // YMCreateGreetingTemplateViewController.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/24.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMCreateGreetingTemplateViewController.h"
  9. #import "YMCreateGreetingTemplateViewModel.h"
  10. #import "YMCreateGreetingTemplateTextView.h"
  11. #import "YMCreateGreetingTemplateImageView.h"
  12. #import "YMCreateGreetingTemplateVoiceView.h"
  13. @interface YMCreateGreetingTemplateViewController ()
  14. /// 完善信息VM
  15. @property (nonatomic, strong) YMCreateGreetingTemplateViewModel *viewModel;
  16. /// 提交按钮
  17. @property (nonatomic, strong) UIButton *submitBtn;
  18. /// 容器滚动视图
  19. @property (nonatomic, strong) UIScrollView *contentScrollView;
  20. /// 容器视图
  21. @property (nonatomic, strong) UIView *contentView;
  22. /// 打招呼模板文本视图
  23. @property (nonatomic, strong) YMCreateGreetingTemplateTextView *templateTextView;
  24. /// 打招呼模板图片视图
  25. @property (nonatomic, strong) YMCreateGreetingTemplateImageView *templateImageView;
  26. /// 打招呼模板图片视图
  27. @property (nonatomic, strong) YMCreateGreetingTemplateVoiceView *templateVoiceView;
  28. @end
  29. @implementation YMCreateGreetingTemplateViewController
  30. @dynamic viewModel;
  31. - (void)viewDidLoad {
  32. [super viewDidLoad];
  33. }
  34. - (void)ym_setupViews{
  35. [self setRightBarButtonWithCustomView:self.submitBtn];
  36. [self.view addSubview:self.contentScrollView];
  37. [self.contentScrollView addSubview:self.contentView];
  38. [self.contentView addSubview:self.templateTextView];
  39. [self.contentView addSubview:self.templateImageView];
  40. [self.contentView addSubview:self.templateVoiceView];
  41. [self.view setNeedsUpdateConstraints];
  42. [self.view updateConstraintsIfNeeded];
  43. }
  44. - (void)updateViewConstraints{
  45. [self.submitBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.width.equalTo(adapt(50));
  47. make.height.equalTo(adapt(28));
  48. }];
  49. [self.contentScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.top.equalTo(self.view).offset(kYMNavHeight);
  51. make.left.equalTo(self.view);
  52. make.right.equalTo(self.view);
  53. make.bottom.equalTo(self.view);
  54. }];
  55. [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.edges.equalTo(self.contentScrollView);
  57. make.width.equalTo(self.contentScrollView.mas_width);
  58. }];
  59. [self.templateTextView mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.top.equalTo(self.contentView).offset(adapt(10));
  61. make.left.equalTo(self.contentView);
  62. make.right.equalTo(self.contentView);
  63. }];
  64. [self.templateImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.top.equalTo(self.templateTextView.mas_bottom).offset(adapt(10));
  66. make.left.equalTo(self.contentView);
  67. make.right.equalTo(self.contentView);
  68. }];
  69. [self.templateVoiceView mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.top.equalTo(self.templateImageView.mas_bottom).offset(adapt(10));
  71. make.left.equalTo(self.contentView);
  72. make.right.equalTo(self.contentView);
  73. make.bottom.equalTo(self.contentView).offset(adapt(-10));
  74. }];
  75. [super updateViewConstraints];
  76. }
  77. - (void)ym_bindViewModel{
  78. [self.templateTextView ym_bindViewModel:self.viewModel];
  79. [self.templateImageView ym_bindViewModel:self.viewModel];
  80. [self.templateVoiceView ym_bindViewModel:self.viewModel];
  81. }
  82. - (UIButton *)submitBtn{
  83. if (!_submitBtn) {
  84. _submitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  85. _submitBtn.titleLabel.font = LCFont(13);
  86. [_submitBtn setTitle:@"提交" forState:UIControlStateNormal];
  87. [_submitBtn setTitleColor:MAINGRIDTitleC forState:UIControlStateNormal];
  88. [_submitBtn ym_setGradientBackgroundWithColors:kMainGradColors locations:kMainGradLocation startPoint:kMainGradStartP endPoint:kMainGradEndP];
  89. _submitBtn.layer.cornerRadius = adapt(8);
  90. _submitBtn.layer.masksToBounds = YES;
  91. WS(weakSelf)
  92. [[[_submitBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  93. [weakSelf.viewModel submitGreetingTemplate];
  94. }];
  95. }
  96. return _submitBtn;
  97. }
  98. - (UIScrollView *)contentScrollView{
  99. if (!_contentScrollView) {
  100. _contentScrollView = [[UIScrollView alloc]init];
  101. _contentScrollView.alwaysBounceVertical = YES;
  102. _contentScrollView.showsVerticalScrollIndicator = NO;
  103. _contentScrollView.showsHorizontalScrollIndicator = NO;
  104. _contentScrollView.backgroundColor = HexColorFromRGB(0xFFFFFF);
  105. _contentScrollView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
  106. }
  107. return _contentScrollView;
  108. }
  109. - (UIView *)contentView{
  110. if (!_contentView) {
  111. _contentView = [[UIView alloc]init];
  112. }
  113. return _contentView;
  114. }
  115. - (YMCreateGreetingTemplateTextView *)templateTextView{
  116. if (!_templateTextView) {
  117. _templateTextView = [[YMCreateGreetingTemplateTextView alloc]init];
  118. }
  119. return _templateTextView;
  120. }
  121. - (YMCreateGreetingTemplateImageView *)templateImageView{
  122. if (!_templateImageView) {
  123. _templateImageView = [[YMCreateGreetingTemplateImageView alloc]init];
  124. }
  125. return _templateImageView;
  126. }
  127. - (YMCreateGreetingTemplateVoiceView *)templateVoiceView{
  128. if (!_templateVoiceView) {
  129. _templateVoiceView = [[YMCreateGreetingTemplateVoiceView alloc]init];
  130. }
  131. return _templateVoiceView;
  132. }
  133. @end