YMImproveInfoInviteCodeView.m 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // YMImproveInfoInviteCodeView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/8.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMImproveInfoInviteCodeView.h"
  9. #import "YMImproveInfoViewModel.h"
  10. @interface YMImproveInfoInviteCodeView ()
  11. /// 完善信息VM
  12. @property (nonatomic, strong) YMImproveInfoViewModel *viewModel;
  13. /// 邀请码标题标签
  14. @property (nonatomic, strong) UILabel *inviteCodeTitleLb;
  15. @end
  16. @implementation YMImproveInfoInviteCodeView
  17. - (void)ym_setupViews{
  18. [self addSubview:self.inviteCodeTitleLb];
  19. [self addSubview:self.inviteCodeContentInputBox];
  20. [self setNeedsUpdateConstraints];
  21. [self updateConstraintsIfNeeded];
  22. }
  23. - (void)updateConstraints{
  24. [self.inviteCodeTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  25. make.top.equalTo(self).offset(adapt(10));
  26. make.left.equalTo(self).offset(adapt(20));
  27. make.bottom.equalTo(self).offset(adapt(-10));
  28. make.height.mas_equalTo(adapt(25));
  29. }];
  30. [self.inviteCodeContentInputBox mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.top.equalTo(self.inviteCodeTitleLb.mas_top);
  32. make.right.equalTo(self).offset(adapt(-20));
  33. make.bottom.equalTo(self.inviteCodeTitleLb.mas_bottom);
  34. make.width.mas_equalTo(adapt(200));
  35. }];
  36. [super updateConstraints];
  37. }
  38. - (void)ym_bindViewModel:(YMImproveInfoViewModel *)viewModel{
  39. if (!viewModel) {
  40. return;
  41. }
  42. _viewModel = viewModel;
  43. }
  44. - (UILabel *)inviteCodeTitleLb{
  45. if (!_inviteCodeTitleLb) {
  46. _inviteCodeTitleLb = [[UILabel alloc]init];
  47. _inviteCodeTitleLb.font = LCFont(16);
  48. _inviteCodeTitleLb.textColor = HexColorFromRGB(0x1B2739);
  49. _inviteCodeTitleLb.textAlignment = NSTextAlignmentLeft;
  50. _inviteCodeTitleLb.text = @"邀请码";
  51. }
  52. return _inviteCodeTitleLb;
  53. }
  54. - (UITextField *)inviteCodeContentInputBox{
  55. if (!_inviteCodeContentInputBox) {
  56. NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc]init];
  57. style.minimumLineHeight = 0;
  58. NSMutableAttributedString *placeholderAttributed = [[NSMutableAttributedString alloc]initWithString:@"请输入邀请码(选填)"];
  59. placeholderAttributed.yy_paragraphStyle = style;
  60. placeholderAttributed.yy_font = LCFont(16);
  61. placeholderAttributed.yy_color = HexColorFromRGB(0xADB0BC);
  62. placeholderAttributed.yy_alignment = NSTextAlignmentRight;
  63. _inviteCodeContentInputBox = [[UITextField alloc]init];
  64. _inviteCodeContentInputBox.textAlignment = NSTextAlignmentRight;
  65. _inviteCodeContentInputBox.attributedPlaceholder = placeholderAttributed;
  66. _inviteCodeContentInputBox.clearButtonMode = UITextFieldViewModeWhileEditing;
  67. _inviteCodeContentInputBox.autocorrectionType = UITextAutocorrectionTypeDefault;
  68. _inviteCodeContentInputBox.autocapitalizationType = UITextAutocapitalizationTypeNone;
  69. _inviteCodeContentInputBox.keyboardType = UIKeyboardTypeDefault;
  70. @weakify(self)
  71. [[[_inviteCodeContentInputBox rac_textSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
  72. @strongify(self)
  73. }];
  74. }
  75. return _inviteCodeContentInputBox;
  76. }
  77. @end