123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- //
- // YMAccountBalanceInfoView.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/28.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMAccountBalanceInfoView.h"
- #import "YMAccountBalanceViewModel.h"
- @interface YMAccountBalanceInfoView ()
- /// 账户余额VM
- @property (nonatomic, strong) YMAccountBalanceViewModel *viewModel;
- /// 信息背景图
- @property (nonatomic, strong) UIImageView *infoBgView;
- /// 用户余额图标
- @property (nonatomic, strong) UIImageView *userBalanceIcon;
- /// 用户剩余余额标签
- @property (nonatomic, strong) UILabel *userRemainingBalanceLb;
- /// 用户余额名称标签
- @property (nonatomic, strong) UILabel *userBalanceNameLb;
- @end
- @implementation YMAccountBalanceInfoView
- - (void)ym_setupViews{
- self.backgroundColor = UIColor.clearColor;
- [self addSubview:self.infoBgView];
- [self.infoBgView addSubview:self.userBalanceNameLb];
- [self.infoBgView addSubview:self.userBalanceIcon];
- [self.infoBgView addSubview:self.userRemainingBalanceLb];
- [self setNeedsUpdateConstraints];
- [self updateConstraintsIfNeeded];
- }
- - (void)updateConstraints{
- [self.infoBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self);
- make.left.equalTo(self).offset(12);
- make.right.equalTo(self).offset(-12);
- make.bottom.equalTo(self);
- make.height.mas_equalTo(adapt(160));
- }];
-
- [self.userBalanceIcon mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.infoBgView.mas_top).offset(adapt(57));
- make.left.equalTo(self.infoBgView.mas_left).offset(adapt(44));
- make.width.mas_equalTo(adapt(19));
- make.height.mas_equalTo(adapt(15));
- }];
-
- [self.userBalanceNameLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.userBalanceIcon.mas_centerY).offset(adapt(0));
- make.left.equalTo(self.userBalanceIcon.mas_right).offset(adapt(4));
- }];
-
- [self.userRemainingBalanceLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.userBalanceIcon).offset(adapt(2));
- make.top.equalTo(self.userBalanceIcon.mas_bottom).offset(adapt(7));
- }];
-
-
-
- [super updateConstraints];
- }
- - (void)ym_bindViewModel:(YMAccountBalanceViewModel *)viewModel{
- if (!viewModel) {
- return;
- }
-
- _viewModel = viewModel;
-
- RAC(self.userRemainingBalanceLb, text) = RACObserve(self.viewModel, userRemainingBalance);
-
- }
- - (UIImageView *)infoBgView{
- if (!_infoBgView) {
- _infoBgView = [[UIImageView alloc]init];
- _infoBgView.image = ImageByName(@"ym_account_balance_bg_icon");
- // _infoBgView.layer.cornerRadius = adapt(10);
- // _infoBgView.layer.masksToBounds = YES;
- // _infoBgView.clipsToBounds = YES;
- }
- return _infoBgView;
- }
- - (UIImageView *)userBalanceIcon{
- if (!_userBalanceIcon) {
- _userBalanceIcon = [[UIImageView alloc]init];
- _userBalanceIcon.image = ImageByName(@"ym_account_balance_diamond_icon");
- }
- return _userBalanceIcon;
- }
- - (UILabel *)userRemainingBalanceLb{
- if (!_userRemainingBalanceLb) {
- _userRemainingBalanceLb = [[UILabel alloc]init];
- _userRemainingBalanceLb.font = LCBoldFont(30);
- _userRemainingBalanceLb.textColor = HexColorFromRGB(0xFFFFFF);
- _userRemainingBalanceLb.textAlignment = NSTextAlignmentLeft;
- _userRemainingBalanceLb.text = @"******";
- }
- return _userRemainingBalanceLb;
- }
- - (UILabel *)userBalanceNameLb{
- if (!_userBalanceNameLb) {
- _userBalanceNameLb = [[UILabel alloc]init];
- _userBalanceNameLb.font = LCFont(14);
- _userBalanceNameLb.textColor = HexColorFromRGB(0xFFFFFF);
- _userBalanceNameLb.textAlignment = NSTextAlignmentLeft;
- _userBalanceNameLb.text = @"钻石余额";
- }
- return _userBalanceNameLb;
- }
- @end
|