ASUserBaseInfoView.m 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. //
  2. // ASUserBaseInfoView.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/5/15.
  6. //
  7. #import "ASUserBaseInfoView.h"
  8. @interface ASUserBaseInfoView ()
  9. @property (nonatomic, strong) UILabel *uNameLb;
  10. @property (nonatomic, strong) UILabel *emailLb;
  11. @property (nonatomic, strong) UIImageView *vipLevelV;
  12. @property (nonatomic, strong) UIStackView *stv;
  13. @end
  14. @implementation ASUserBaseInfoView
  15. - (void)setData {
  16. ASUserModel *user = ASUserInfoManager.shared.userInfo;
  17. NSString *userName = [NSString stringWithFormat:@"%@ %@", user.lastname, user.firstname];
  18. [self.avaterV setUserHeadV:@"" uName:userName];
  19. self.uNameLb.text = userName;
  20. NSInteger level = ASUserInfoManager.shared.curVipInfo.level.integerValue;
  21. self.vipLevelV.image = [UIImage imageNamed:[NSString stringWithFormat:@"uc_vip_level_%ld", level]];
  22. self.emailLb.text = user.email;
  23. self.usefualLb.text = [NSString stringWithFormat: @"%@ points", ASUserInfoManager.shared.userPoints];
  24. }
  25. - (instancetype)initWithFrame:(CGRect)frame {
  26. self = [super initWithFrame:frame];
  27. if (self) {
  28. self.backgroundColor = UIColor.clearColor;
  29. [self loadSubV];
  30. }
  31. return self;
  32. }
  33. - (void)loadSubV {
  34. [self addSubview:self.avaterV];
  35. self.stv = [UIStackView baseStackV:true];
  36. self.stv.spacing = 4;
  37. self.stv.distribution = UIStackViewDistributionFill;
  38. [self addSubview:self.stv];
  39. [self.stv addArrangedSubview:self.uNameLb];
  40. [self.stv addArrangedSubview:self.emailLb];
  41. UIView *levelBgV = [UIView baseV];
  42. levelBgV.backgroundColor = UIColor.clearColor;
  43. [self.stv addArrangedSubview:levelBgV];
  44. [self.stv addArrangedSubview:self.usefualLb];
  45. [levelBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  46. make.height.equalTo(@16);
  47. }];
  48. [levelBgV addSubview:self.vipLevelV];
  49. [self.vipLevelV mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.top.leading.bottom.equalTo(levelBgV);
  51. }];
  52. [self setSubVMas];
  53. }
  54. - (void)setSubVMas {
  55. [self.uNameLb mas_makeConstraints:^(MASConstraintMaker *make) {
  56. make.height.equalTo(@17);
  57. }];
  58. [self.emailLb mas_makeConstraints:^(MASConstraintMaker *make) {
  59. make.height.greaterThanOrEqualTo(@14);
  60. }];
  61. [self.usefualLb mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.height.equalTo(@17);
  63. }];
  64. [self.avaterV mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.width.height.equalTo(@100);
  66. make.top.leading.bottom.equalTo(self);
  67. }];
  68. [self.stv mas_makeConstraints:^(MASConstraintMaker *make) {
  69. make.top.equalTo(self.avaterV.mas_top).offset(10);
  70. make.leading.equalTo(self.avaterV.mas_trailing).offset(10);
  71. make.trailing.equalTo(self);
  72. make.bottom.equalTo(self.avaterV.mas_bottom).offset(-10);
  73. }];
  74. }
  75. - (void)reSetSubVMas {
  76. [self.uNameLb mas_makeConstraints:^(MASConstraintMaker *make) {
  77. make.height.equalTo(@22);
  78. }];
  79. [self.emailLb mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.height.equalTo(@17);
  81. }];
  82. [self.usefualLb mas_makeConstraints:^(MASConstraintMaker *make) {
  83. make.height.equalTo(@17);
  84. }];
  85. [self.avaterV setCorner:8];
  86. [self.avaterV mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.width.height.equalTo(@88);
  88. make.top.leading.bottom.equalTo(self);
  89. }];
  90. [self.stv mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.top.equalTo(self.avaterV.mas_top).offset(0);
  92. make.leading.equalTo(self.avaterV.mas_trailing).offset(10);
  93. make.trailing.equalTo(self);
  94. make.bottom.equalTo(self.avaterV.mas_bottom).offset(0);
  95. }];
  96. }
  97. - (UIImageView *)vipLevelV {
  98. if (!_vipLevelV) {
  99. UIImageView *v = [[UIImageView alloc] init];
  100. v.contentMode = UIViewContentModeScaleAspectFit;
  101. _vipLevelV = v;
  102. }
  103. return _vipLevelV;
  104. }
  105. - (ASUserAvaterView *)avaterV {
  106. if (!_avaterV) {
  107. ASUserAvaterView *v = [[ASUserAvaterView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
  108. _avaterV = v;
  109. }
  110. return _avaterV;
  111. }
  112. - (UILabel *)uNameLb {
  113. if (!_uNameLb) {
  114. UILabel *lb = [UILabel baseLb];
  115. lb.font = [UIFont fontWithName:Rob_Bold size:14];
  116. lb.textColor = Col_000;
  117. _uNameLb = lb;
  118. }
  119. return _uNameLb;
  120. }
  121. - (UILabel *)emailLb {
  122. if (!_emailLb) {
  123. UILabel *lb = [UILabel baseLb];
  124. lb.font = [UIFont fontWithName:Rob_Regular size:12];
  125. lb.textColor = Col_000;
  126. _emailLb = lb;
  127. }
  128. return _emailLb;
  129. }
  130. - (UILabel *)usefualLb {
  131. if (!_usefualLb) {
  132. UILabel *lb = [UILabel baseLb];
  133. lb.font = [UIFont fontWithName:Rob_Bold size:14];
  134. lb.textColor = Col_000;
  135. _usefualLb = lb;
  136. }
  137. return _usefualLb;
  138. }
  139. @end