YMAccountBalanceInfoView.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // YMAccountBalanceInfoView.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/28.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMAccountBalanceInfoView.h"
  9. #import "YMAccountBalanceViewModel.h"
  10. @interface YMAccountBalanceInfoView ()
  11. /// 账户余额VM
  12. @property (nonatomic, strong) YMAccountBalanceViewModel *viewModel;
  13. /// 信息背景图
  14. @property (nonatomic, strong) UIImageView *infoBgView;
  15. /// 用户余额图标
  16. @property (nonatomic, strong) UIImageView *userBalanceIcon;
  17. /// 用户剩余余额标签
  18. @property (nonatomic, strong) UILabel *userRemainingBalanceLb;
  19. /// 用户余额名称标签
  20. @property (nonatomic, strong) UILabel *userBalanceNameLb;
  21. @end
  22. @implementation YMAccountBalanceInfoView
  23. - (void)ym_setupViews{
  24. self.backgroundColor = UIColor.clearColor;
  25. [self addSubview:self.infoBgView];
  26. [self.infoBgView addSubview:self.userBalanceNameLb];
  27. [self.infoBgView addSubview:self.userBalanceIcon];
  28. [self.infoBgView addSubview:self.userRemainingBalanceLb];
  29. [self setNeedsUpdateConstraints];
  30. [self updateConstraintsIfNeeded];
  31. }
  32. - (void)updateConstraints{
  33. [self.infoBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.top.equalTo(self);
  35. make.left.equalTo(self).offset(12);
  36. make.right.equalTo(self).offset(-12);
  37. make.bottom.equalTo(self);
  38. make.height.mas_equalTo(adapt(160));
  39. }];
  40. [self.userBalanceIcon mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.top.equalTo(self.infoBgView.mas_top).offset(adapt(57));
  42. make.left.equalTo(self.infoBgView.mas_left).offset(adapt(44));
  43. make.width.mas_equalTo(adapt(19));
  44. make.height.mas_equalTo(adapt(15));
  45. }];
  46. [self.userBalanceNameLb mas_makeConstraints:^(MASConstraintMaker *make) {
  47. make.centerY.equalTo(self.userBalanceIcon.mas_centerY).offset(adapt(0));
  48. make.left.equalTo(self.userBalanceIcon.mas_right).offset(adapt(4));
  49. }];
  50. [self.userRemainingBalanceLb mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.left.equalTo(self.userBalanceIcon).offset(adapt(2));
  52. make.top.equalTo(self.userBalanceIcon.mas_bottom).offset(adapt(7));
  53. }];
  54. [super updateConstraints];
  55. }
  56. - (void)ym_bindViewModel:(YMAccountBalanceViewModel *)viewModel{
  57. if (!viewModel) {
  58. return;
  59. }
  60. _viewModel = viewModel;
  61. RAC(self.userRemainingBalanceLb, text) = RACObserve(self.viewModel, userRemainingBalance);
  62. }
  63. - (UIImageView *)infoBgView{
  64. if (!_infoBgView) {
  65. _infoBgView = [[UIImageView alloc]init];
  66. _infoBgView.image = ImageByName(@"ym_account_balance_bg_icon");
  67. // _infoBgView.layer.cornerRadius = adapt(10);
  68. // _infoBgView.layer.masksToBounds = YES;
  69. // _infoBgView.clipsToBounds = YES;
  70. }
  71. return _infoBgView;
  72. }
  73. - (UIImageView *)userBalanceIcon{
  74. if (!_userBalanceIcon) {
  75. _userBalanceIcon = [[UIImageView alloc]init];
  76. _userBalanceIcon.image = ImageByName(@"ym_account_balance_diamond_icon");
  77. }
  78. return _userBalanceIcon;
  79. }
  80. - (UILabel *)userRemainingBalanceLb{
  81. if (!_userRemainingBalanceLb) {
  82. _userRemainingBalanceLb = [[UILabel alloc]init];
  83. _userRemainingBalanceLb.font = LCBoldFont(30);
  84. _userRemainingBalanceLb.textColor = HexColorFromRGB(0xFFFFFF);
  85. _userRemainingBalanceLb.textAlignment = NSTextAlignmentLeft;
  86. _userRemainingBalanceLb.text = @"******";
  87. }
  88. return _userRemainingBalanceLb;
  89. }
  90. - (UILabel *)userBalanceNameLb{
  91. if (!_userBalanceNameLb) {
  92. _userBalanceNameLb = [[UILabel alloc]init];
  93. _userBalanceNameLb.font = LCFont(14);
  94. _userBalanceNameLb.textColor = HexColorFromRGB(0xFFFFFF);
  95. _userBalanceNameLb.textAlignment = NSTextAlignmentLeft;
  96. _userBalanceNameLb.text = @"钻石余额";
  97. }
  98. return _userBalanceNameLb;
  99. }
  100. @end