YMEditProfileIntroView.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // YMEditProfileIntroView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/18.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMEditProfileIntroView.h"
  9. #import "YMEditProfileViewModel.h"
  10. @interface YMEditProfileIntroView ()
  11. /// 信息VM
  12. @property (nonatomic, strong) YMEditProfileViewModel *viewModel;
  13. /// 介绍标题标签
  14. @property (nonatomic, strong) UILabel *introTitleLb;
  15. /// 介绍详情标签
  16. @property (nonatomic, strong) UILabel *introDetailLb;
  17. /// 介绍内容标签
  18. @property (nonatomic, strong) UILabel *introContentLb;
  19. /// 箭头图标
  20. @property (nonatomic, strong) UIImageView *arrowIcon;
  21. @end
  22. @implementation YMEditProfileIntroView
  23. - (void)ym_setupViews{
  24. [self addSubview:self.introTitleLb];
  25. [self addSubview:self.introDetailLb];
  26. [self addSubview:self.introContentLb];
  27. [self addSubview:self.arrowIcon];
  28. [self setNeedsUpdateConstraints];
  29. [self updateConstraintsIfNeeded];
  30. }
  31. - (void)updateConstraints{
  32. [self.introTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.top.equalTo(self).offset(adapt(10));
  34. make.left.equalTo(self).offset(adapt(15));
  35. make.height.mas_equalTo(adapt(25));
  36. }];
  37. [self.introDetailLb mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.centerY.equalTo(self.introTitleLb.mas_centerY);
  39. make.right.equalTo(self.arrowIcon.mas_left).offset(adapt(-10));
  40. }];
  41. [self.introContentLb mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.top.equalTo(self.introTitleLb.mas_bottom).offset(adapt(10));
  43. make.left.equalTo(self).offset(adapt(15));
  44. make.right.equalTo(self).offset(adapt(-15));
  45. make.bottom.equalTo(self).offset(adapt(-20));
  46. }];
  47. [self.arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.centerY.equalTo(self.introTitleLb.mas_centerY);
  49. make.right.equalTo(self).offset(adapt(-15));
  50. make.width.mas_equalTo(adapt(10));
  51. make.height.mas_equalTo(adapt(9));
  52. }];
  53. [super updateConstraints];
  54. }
  55. - (void)ym_bindViewModel:(YMEditProfileViewModel *)viewModel{
  56. if (!viewModel) {
  57. return;
  58. }
  59. _viewModel = viewModel;
  60. @weakify(self)
  61. [[[[RACObserve(self.viewModel, userIntro) distinctUntilChanged] deliverOnMainThread] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSString * userIntro) {
  62. @strongify(self)
  63. self.introContentLb.text = OCStringIsEmpty(userIntro) ? @"添加自我介绍,更容易获得别人的关注哦~" : userIntro;
  64. self.introDetailLb.hidden = !OCStringIsEmpty(userIntro) ? YES : NO;
  65. }];
  66. }
  67. - (UILabel *)introTitleLb{
  68. if (!_introTitleLb) {
  69. _introTitleLb = [[UILabel alloc]init];
  70. _introTitleLb.font = LCBoldFont(16);
  71. _introTitleLb.textColor = HexColorFromRGB(0x333333);
  72. _introTitleLb.textAlignment = NSTextAlignmentLeft;
  73. _introTitleLb.text = @"个性签名";
  74. }
  75. return _introTitleLb;
  76. }
  77. - (UILabel *)introDetailLb{
  78. if (!_introDetailLb) {
  79. _introDetailLb = [[UILabel alloc]init];
  80. _introDetailLb.font = LCFont(13);
  81. _introDetailLb.textColor = HexColorFromRGB(0x9c9c9c);
  82. _introDetailLb.textAlignment = NSTextAlignmentRight;
  83. _introDetailLb.text = @"去完善";
  84. }
  85. return _introDetailLb;
  86. }
  87. - (UILabel *)introContentLb{
  88. if (!_introContentLb) {
  89. _introContentLb = [[UILabel alloc]init];
  90. _introContentLb.font = LCFont(12);
  91. _introContentLb.textColor = HexColorFromRGB(0x9c9c9c);
  92. _introContentLb.textAlignment = NSTextAlignmentLeft;
  93. _introContentLb.text = @"添加自我介绍,更容易获得别人的关注哦~";
  94. }
  95. return _introContentLb;
  96. }
  97. - (UIImageView *)arrowIcon{
  98. if (!_arrowIcon) {
  99. _arrowIcon = [[UIImageView alloc]init];
  100. _arrowIcon.image = ImageByName(@"ym_edit_profile_arrow_icon");
  101. }
  102. return _arrowIcon;
  103. }
  104. @end