123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- //
- // XYPersonalCenterWalletTableViewCell.m
- // Starbuds
- //
- // Created by 翟玉磊 on 2020/5/19.
- // Copyright © 2020 翟玉磊. All rights reserved.
- //
- #import "XYPersonalCenterWalletTableViewCell.h"
- #import "XYRechargeItemsViewController.h"
- #import "XYPersonalCenterHeaderItemView.h"
- #import "XYWalletViewController.h"
- @interface XYPersonalCenterWalletTableViewCell ()
- @property (nonatomic, strong) UILabel *titleLabel;
- @property (nonatomic, strong) UILabel *balanceLabel;
- @property (nonatomic, strong) UIButton *rechargeButton;
- @property (nonatomic, strong) UIView *line;
- @property (nonatomic, strong) UILabel *starYuanLabel;
- @property (nonatomic, strong) UIButton *detailsButton;
- @property (nonatomic, strong) NSMutableArray *itemViews;
- @end
- @implementation XYPersonalCenterWalletTableViewCell
- #pragma mark — Public
- + (instancetype)cellWithTableView:(UITableView *)tableView {
- static NSString * const cellId = @"XYPersonalCenterWalletTableViewCell";
- XYPersonalCenterWalletTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
- if (cell == nil) {
- cell = [[XYPersonalCenterWalletTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- return cell;
- }
- - (void)configureModel:(id)model {
- self.titleLabel.text = [NSString stringWithFormat:kLocalizedString(@"我的%@"), @"钱包"/*App_CoinName(Wallet_Type_Star_Diamond)*/];
- if ([XYUserInfoManager nowUser]) {
- self.balanceLabel.text = [NSString stringWithFormat:@"%@", [XYUserInfoManager nowUser].coinBalance];
- self.starYuanLabel.text = [NSString stringWithFormat:@"%@ %@", App_CoinName(Wallet_Type_Star_Dust), [XYUserInfoManager nowUser].dustBalance];
- }else {
- self.balanceLabel.text = @"0";
- self.starYuanLabel.text = [NSString stringWithFormat:@"%@ %@", App_CoinName(Wallet_Type_Star_Dust), @"0"];
- }
- for (UIView *view in self.itemViews) {
- [view removeFromSuperview];
- }
- [self.itemViews removeAllObjects];
- int itemCount = 3;
- CGFloat width = (self.f_width) / itemCount;
- CGFloat y = 44;
- for (NSInteger i = 0; i < itemCount; i++) {
- XYPersonalCenterHeaderItemView *item = [[XYPersonalCenterHeaderItemView alloc] initWithFrame:CGRectMake(width * i, y, width, 44.0f)];
- item.lineView.image = ImageNamed(@"icon_anchor_head_line");
- item.tag = i;
- switch (i) {
- case 0:
- [item setupTitle:[NSString stringWithFormat:@"%@余额",App_CoinName(Wallet_Type_Star_Diamond)] content:[HandleString caluteWValue:[[XYUserInfoManager nowUser].coinBalance integerValue]]];
- break;
- case 1:
- [item setupTitle:[NSString stringWithFormat:@"%@余额",App_CoinName(Wallet_Type_Star_Dust)] content:[HandleString caluteWValue:[[XYUserInfoManager nowUser].dustBalance integerValue]]];
- break;
- case 2:
- [item setupTitle:[NSString stringWithFormat:@"%@余额",App_CoinName(Wallet_Type_Gold_Coin)] content:[HandleString caluteWValue:[[XYUserInfoManager nowUser].goldBalance integerValue]]];
- item.lineView.hidden = YES;
- break;
- default:
- break;
- }
- [self.contentView addSubview:item];
- [self.itemViews addObject:item];
- WeakSelf
- [item setItemClickActionBlock:^(NSInteger index) {
- if (index == 0) {
- [StatisticsManager event:@"my_wealth_diamond_click"];
- }else if (index == 1){
- [StatisticsManager event:@"my_wealth_pinkdiamond_click"];
- }else if (index == 2){
- [StatisticsManager event:@"my_wealth_goldcoin_click"];
- }
- XYWalletViewController *vc = [[XYWalletViewController alloc] init];
- [[AppDelegate sharedDelegate].getCurrentController.navigationController pushViewController:vc animated:YES];
- }];
- }
- }
- - (void)setIndexPath:(NSIndexPath *)indexPath rowsInSection:(NSInteger)rows {
- }
- #pragma mark — Action
- - (void)rechargeButtonAction:(id)sender {
-
- // 我的Tab,点我的钻石-[充值]的次数
- [StatisticsManager event:@"my_wealth_recharge_click"];
- [[ApplicationDelegate getCurrentController].navigationController pushViewController:XYRechargeItemsViewController.new animated:YES];
- }
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
- if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
- [self _setup];
- [self _setupSubViews];
- [self _makeSubViewsConstraint];
- }
- return self;
- }
- #pragma mark - 配置属性
- - (void)_setup {
-
- }
- #pragma mark - 设置子控件
- - (void)_setupSubViews {
- [self.contentView addSubview:self.titleLabel];
- [self.contentView addSubview:self.balanceLabel];
- [self.contentView addSubview:self.rechargeButton];
- [self.contentView addSubview:self.line];
- [self.contentView addSubview:self.starYuanLabel];
- [self.contentView addSubview:self.detailsButton];
- }
- #pragma mark - 布局子控件
- - (void)_makeSubViewsConstraint {
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(SPACING_EDGE);
- make.top.equalTo(self.contentView).offset(14.0f);
- make.height.equalTo(@17.0f);
- }];
- [self.balanceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(SPACING_EDGE);
- make.top.equalTo(self.titleLabel.mas_bottom).offset(7.0f);
- make.height.equalTo(@33.0f);
- make.right.equalTo(self.rechargeButton.mas_left).offset(-10.0f);
- }];
- [self.rechargeButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.contentView).offset(-15.0f);
- make.centerY.equalTo(self.balanceLabel);
- make.width.equalTo(@60.0f);
- make.height.equalTo(@28.0f);
- }];
- [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(9.0f);
- make.right.equalTo(self.contentView).offset(-9.0f);
- make.top.equalTo(self.balanceLabel.mas_bottom).offset(13.0f);
- make.height.equalTo(@(LINE_HEIGHT));
- }];
- [self.starYuanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(SPACING_EDGE);
- make.top.equalTo(self.line.mas_bottom).offset(11.0f);
- make.height.equalTo(@18.0f);
- make.right.equalTo(self.detailsButton.mas_left).offset(-10.0f);
- }];
- [self.detailsButton mas_makeConstraints:^(MASConstraintMaker *make) {
- make.right.equalTo(self.contentView).offset(-SPACING_EDGE);
- make.centerY.equalTo(self.titleLabel);
- make.height.equalTo(@30.0f);
- make.width.equalTo(@80.0f);
- }];
-
- [self.rechargeButton addViewBorder:Color_TextRed redian:14.0f];
- [self.detailsButton buttonDistance:7.0f direction:right];
- }
- #pragma mark - Getter/Setter
- - (UILabel *)titleLabel {
- if (!_titleLabel) {
- _titleLabel = [UILabel createLabelTextColor:Color_TextFont fount:Font_B(14)];
- _titleLabel.text = [NSString stringWithFormat:kLocalizedString(@"我的%@"), @"钱包"/*App_CoinName(Wallet_Type_Star_Diamond)*/];
- }
- return _titleLabel;
- }
- - (UILabel *)balanceLabel {
- if (!_balanceLabel) {
- _balanceLabel = [UILabel createLabelTextColor:Color_TextFont fount:Font_B(24)];
- _balanceLabel.text = [XYUserInfoManager nowUser].coinBalance;
- _balanceLabel.hidden = YES;
- }
- return _balanceLabel;
- }
- - (UIButton *)rechargeButton {
- if (!_rechargeButton) {
- _rechargeButton = [UIButton createButtonTextColor:Color_TextRed textFont:Font(12)];
- [_rechargeButton setTitle:kLocalizedString(@"充值") forState:UIControlStateNormal];
- [_rechargeButton addTarget:self action:@selector(rechargeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
- _rechargeButton.hidden = YES;
- }
- return _rechargeButton;
- }
- - (UIView *)line {
- if (!_line) {
- _line = [UIView new];
- _line.backgroundColor = Color_line;
- _line.hidden = YES;
- }
- return _line;
- }
- - (UILabel *)starYuanLabel {
- if (!_starYuanLabel) {
- _starYuanLabel = [UILabel createLabelTextColor:Color_Nakaguro fount:Font(13)];
- _starYuanLabel.hidden = YES;
- }
- return _starYuanLabel;
- }
- - (UIButton *)detailsButton {
- if (!_detailsButton) {
- _detailsButton = [UIButton createButtonTextColor:Color_TextGray textFont:Font(12)];
- [_detailsButton setTitle:kLocalizedString(@" ") forState:UIControlStateNormal];
- [_detailsButton setImage:arrowMore() forState:UIControlStateNormal];
- _detailsButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
- _detailsButton.userInteractionEnabled = NO;
- }
- return _detailsButton;
- }
- - (NSMutableArray *)itemViews{
- if (_itemViews == nil) {
- _itemViews = [[NSMutableArray alloc] init];
- }
- return _itemViews;
- }
- @end
|