Files
yinmeng-ios/xplan-ios/Main/Tabbar/View/NewUserRecharge/XPNewUserRechargeSucessView.m
2023-04-14 11:53:15 +08:00

154 lines
5.2 KiB
Objective-C

//
// XPNewUserRechargeSucessView.m
// xplan-ios
//
// Created by GreenLand on 2022/8/1.
//
#import "XPNewUserRechargeSucessView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "UIImage+Utils.h"
#import "ThemeColor+FirstRecharge.h"
#import "XPFirstRechargeFlowLayout.h"
#import "TTPopup.h"
#import "NSArray+Safe.h"
///Model
#import "FirstRechargeModel.h"
///View
#import "XPNewUserRechargeCollectionViewCell.h"
@interface XPNewUserRechargeSucessView ()<UICollectionViewDelegate, UICollectionViewDataSource>
///背景图
@property (nonatomic,strong) UIImageView *backImageView;
///列表
@property (nonatomic,strong) UICollectionView *collectionView;
///提示
@property (nonatomic,strong) UILabel *descriptionLabel;
///知道了
@property (nonatomic,strong) UIButton *knownButton;
///数据源
@property (nonatomic,strong) NSArray *datasource;
@end
@implementation XPNewUserRechargeSucessView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.backImageView];
[self addSubview:self.collectionView];
[self addSubview:self.knownButton];
[self addSubview:self.descriptionLabel];
}
- (void)initSubViewConstraints {
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(279);
make.height.mas_equalTo(268);
}];
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(0);
}];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(67);
make.left.mas_equalTo(25);
make.centerX.mas_equalTo(self);
make.height.mas_equalTo(94);
}];
[self.knownButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(200, 44));
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(self.collectionView.mas_bottom).mas_offset((20));
}];
[self.descriptionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self);
make.top.mas_equalTo(self.knownButton.mas_bottom).offset(4);
make.height.mas_equalTo(14);
}];
}
#pragma mark - UICollectionViewDelegate And UICollectionViewDatasource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.datasource.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
XPNewUserRechargeCollectionViewCell * cell= [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPNewUserRechargeCollectionViewCell class]) forIndexPath:indexPath];
cell.rewardInfo = [self.datasource safeObjectAtIndex1:indexPath.row];
return cell;
}
#pragma mark - Event Response
- (void)knowButtonAction:(UIButton *)sender {
[TTPopup dismiss];
}
#pragma mark - Getters And Setters
- (void)setRechargeInfo:(FirstRechargeModel *)rechargeInfo {
_rechargeInfo = rechargeInfo;
self.datasource = _rechargeInfo.firstChargeRewardList;
[self.collectionView reloadData];
}
- (UICollectionView *)collectionView{
if (!_collectionView) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.itemSize = CGSizeMake(64, 94);
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.showsHorizontalScrollIndicator = NO;
_collectionView.dataSource = self;
_collectionView.delegate = self;
_collectionView.backgroundColor = [UIColor clearColor];
[_collectionView registerClass:[XPNewUserRechargeCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPNewUserRechargeCollectionViewCell class])];
}
return _collectionView;
}
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.image = [UIImage imageNamed:@"new_user_recharge_success_bg"];
}
return _backImageView;
}
- (UILabel *)descriptionLabel {
if (!_descriptionLabel) {
_descriptionLabel = [[UILabel alloc] init];
_descriptionLabel.text = @"装扮类物品可进入“我的一我的装扮”使用哦";
_descriptionLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:10];
_descriptionLabel.textAlignment = NSTextAlignmentCenter;
_descriptionLabel.textColor = UIColorFromRGB(0xE64A94);
}
return _descriptionLabel;
}
- (UIButton *)knownButton {
if (!_knownButton) {
_knownButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_knownButton setBackgroundImage:[UIImage imageNamed:@"new_user_recharge_succedss_know"] forState:UIControlStateNormal];
[_knownButton setBackgroundImage:[UIImage imageNamed:@"new_user_recharge_succedss_know"] forState:UIControlStateSelected];
[_knownButton addTarget:self action:@selector(knowButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _knownButton;
}
@end