礼物面板调整,增加福袋、周星横幅

This commit is contained in:
chenguilong
2022-10-08 19:01:20 +08:00
parent b40a7095bd
commit f701261328
38 changed files with 776 additions and 481 deletions

View File

@@ -20,9 +20,8 @@
#import "XPGiftEmptyCollectionViewCell.h"
#import "XPGiftWeekStarCollectionViewCell.h"
#import "XPGiftCollectionViewFlowLayout.h"
#import "XPWeekStarInfoView.h"
@interface XPGiftInfoView ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, XPWeekStarInfoViewDelegate, XPGiftWeekStarCollectionViewCellDelegate>
@interface XPGiftInfoView ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, XPGiftWeekStarCollectionViewCellDelegate>
///
@property (nonatomic,strong) UIScrollView *scrollView;
@property (nonatomic,strong) UIStackView *segmentStackView;
@@ -36,18 +35,10 @@
@property (nonatomic,strong) UIButton *nobleGiftButton;
///
@property (nonatomic, strong) UIButton *weekStarButton;
///
@property (nonatomic,strong) UIView * segmentPlaceView;
///
@property (nonatomic,strong) UIButton *playRuleButton;
///
@property (nonatomic,strong) UIButton *graffitiButton;
///
@property (nonatomic,strong) UILabel *totalValueLabel;
///
@property (nonatomic,strong) XPWeekStarInfoView *weekStarView;
///
@property (nonatomic, strong) UIButton *nobleButton;
///
@property (nonatomic,strong) UIStackView *giftStackView;
///l
@@ -102,23 +93,6 @@
self.segmentType = sender.tag;
}
- (void)playRuleButtonAction:(UIButton *)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoView:didClickPlayRule:)]) {
NSString * giftExplainUrl;
if (self.segmentType == GiftSegmentType_Lucky) {
giftExplainUrl = [NSString stringWithFormat:URLWithType(kLuckyGiftPlayRuleURL), [NSString stringWithFormat:@"%ld", self.lastSelectGift.giftId]];
} else {
giftExplainUrl = self.lastSelectGift.giftExplainUrl;
}
[self.delegate xPGiftInfoView:self didClickPlayRule:giftExplainUrl];
}
}
- (void)didClickNobleSegmentAction:(UIButton *)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoViewDidClickNobleEntrance:)]) {
[self.delegate xPGiftInfoViewDidClickNobleEntrance:self];
}
}
#pragma mark - Public Method
- (void)updatePackSource:(GiftReceiveInfoModel *)giftReceiveInfo numberUser:(NSInteger)numberUser {
GiftInfoModel * giftInfo = [self findGiftInfoByGiftId:giftReceiveInfo.giftId.integerValue];
@@ -129,25 +103,41 @@
[self.giftcollectionView reloadData];
}
- (void)giftHeadTypeHadChange:(NSInteger)headType {
if (headType == 1) {
[self.graffitiButton removeFromSuperview];
[self.segmentStackView addArrangedSubview:self.normalGiftButton];
[self.segmentStackView addArrangedSubview:self.luckyGiftButton];
[self.segmentStackView addArrangedSubview:self.nobleGiftButton];
[self.segmentStackView addArrangedSubview:self.weekStarButton];
if(self.segmentType != GiftSegmentType_Pack) {
[self didClickGiftSegmentAction:self.normalGiftButton];
}
} else {
[self.normalGiftButton removeFromSuperview];
[self.luckyGiftButton removeFromSuperview];
[self.nobleGiftButton removeFromSuperview];
[self.weekStarButton removeFromSuperview];
[self.segmentStackView addArrangedSubview:self.graffitiButton];
if(self.segmentType != GiftSegmentType_Pack) {
[self didClickGiftSegmentAction:self.graffitiButton];
}
}
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.scrollView];
[self addSubview:self.giftStackView];
[self addSubview:self.packGiftButton];
[self addSubview:self.totalValueLabel];
[self.scrollView addSubview:self.segmentStackView];
///
[self.segmentStackView addArrangedSubview:self.normalGiftButton];
[self.segmentStackView addArrangedSubview:self.luckyGiftButton];
[self.segmentStackView addArrangedSubview:self.nobleGiftButton];
[self.segmentStackView addArrangedSubview:self.weekStarButton];
[self.segmentStackView addArrangedSubview:self.graffitiButton];
[self.segmentStackView addArrangedSubview:self.packGiftButton];
[self.segmentStackView addArrangedSubview:self.segmentPlaceView];
[self.segmentStackView addArrangedSubview:self.playRuleButton];
[self.segmentStackView addArrangedSubview:self.totalValueLabel];
[self.segmentStackView addArrangedSubview:self.weekStarView];
[self.segmentStackView addArrangedSubview:self.nobleButton];
///
[self.giftStackView addArrangedSubview:self.giftcollectionView];
[self.giftStackView addArrangedSubview:self.pageController];
@@ -163,14 +153,20 @@
}];
[self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.mas_equalTo(self).inset(15);
make.left.mas_equalTo(self).mas_offset(15);
make.right.mas_equalTo(self.packGiftButton.mas_left);
make.top.mas_equalTo(self);
make.height.mas_equalTo(30);
}];
[self.playRuleButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(75);
}];
[self.packGiftButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-15);
make.centerY.height.mas_equalTo(self.scrollView);
make.width.mas_equalTo(30);
}];
[self.totalValueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(self.packGiftButton.mas_left);
make.centerY.mas_equalTo(self.packGiftButton);
}];
[self.giftStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.segmentStackView.mas_bottom).offset(10);
@@ -198,8 +194,8 @@
giftTotal += gift.count * gift.goldPrice;
}
}];
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"总价值:" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:11],NSForegroundColorAttributeName:[ThemeColor giftPlayRuleColor]}];
[str appendAttributedString:[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@钻石",[self countFormatCoinStr:giftTotal]] attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13],NSForegroundColorAttributeName:[ThemeColor mainTextColor]}]];
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"总价值:" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10],NSForegroundColorAttributeName:[ThemeColor secondTextColor]}];
[str appendAttributedString:[[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@钻石",[self countFormatCoinStr:giftTotal]] attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:[UIColor whiteColor]}]];
self.totalAttribute = str;
}
@@ -227,8 +223,12 @@
} else {
giftInfo.sourceType = GiftSourceType_Normal;
}
self.playRuleButton.hidden = self.segmentType == GiftSegmentType_Lucky ? NO : giftInfo.giftExplainUrl.length <= 0 ;
giftInfo.isSelected = YES;
if (self.segmentType == GiftSegmentType_WeekStar) {
if (self.delegate && [self.delegate respondsToSelector:@selector(xpGiftInfoViewDidClickWeekStarGift:)]) {
[self.delegate xpGiftInfoViewDidClickWeekStarGift:giftInfo];
}
}
}
// id
@@ -312,13 +312,6 @@
}
}
#pragma mark - XPWeekStarInfoViewDelegate
- (void)xPWeekStarInfoViewRankButtonClick {
if (self.delegate && [self.delegate respondsToSelector:@selector(xpGiftInfoViewDidClickWeekStarRank:)]) {
[self.delegate xpGiftInfoViewDidClickWeekStarRank:self];
}
}
#pragma mark - XPGiftWeekStarCollectionViewCellDelegate
- (void)xPGiftWeekStarCollectionViewCell:(XPGiftWeekStarCollectionViewCell *)view didSelectGift:(GiftInfoModel *)giftInfo {
[self dealSelectGift:giftInfo];
@@ -338,8 +331,6 @@
[self resetSelectGift:self.giftWeekStarArray];
[self resetSelectGift:self.giftGraffitiArray];
self.totalValueLabel.hidden = YES;
self.nobleButton.hidden = YES;
self.weekStarView.hidden = YES;
switch (_segmentType) {
case GiftSegmentType_Normal:
[self.datasource addObjectsFromArray:self.giftArray];
@@ -349,12 +340,10 @@
break;
case GiftSegmentType_Noble: {
[self.datasource addObjectsFromArray:self.giftNobleArray];
self.nobleButton.hidden = NO;
}
break;
case GiftSegmentType_WeekStar: {
[self.datasource addObjectsFromArray:self.giftWeekStarArray];
self.weekStarView.hidden = NO;
}
break;
case GiftSegmentType_Pack:
@@ -383,8 +372,6 @@
GiftInfoModel * gift = [self.datasource firstObject];
[self dealSelectGift:gift];
}
} else {
self.playRuleButton.hidden = YES;
}
NSInteger page = 0;
if (self.datasource.count % 8 == 0) { //
@@ -519,7 +506,7 @@
[_normalGiftButton setTitle:@"礼物" forState:UIControlStateNormal];
[_normalGiftButton setTitleColor:[ThemeColor giftSegmentSelectTitleColor] forState:UIControlStateSelected];
[_normalGiftButton setTitleColor:[ThemeColor giftSegmentNormalTitleColor] forState:UIControlStateNormal];
_normalGiftButton.titleLabel.font = [UIFont systemFontOfSize:14];
_normalGiftButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold];
_normalGiftButton.tag = GiftSegmentType_Normal;
_normalGiftButton.selected = YES;
[_normalGiftButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside];
@@ -533,7 +520,7 @@
[_luckyGiftButton setTitle:@"幸运礼物" forState:UIControlStateNormal];
[_luckyGiftButton setTitleColor:[ThemeColor giftSegmentSelectTitleColor] forState:UIControlStateSelected];
[_luckyGiftButton setTitleColor:[ThemeColor giftSegmentNormalTitleColor] forState:UIControlStateNormal];
_luckyGiftButton.titleLabel.font = [UIFont systemFontOfSize:14];
_luckyGiftButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold];
_luckyGiftButton.tag = GiftSegmentType_Lucky;
_luckyGiftButton.selected = NO;
[_luckyGiftButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside];
@@ -547,7 +534,7 @@
[_nobleGiftButton setTitle:@"贵族" forState:UIControlStateNormal];
[_nobleGiftButton setTitleColor:[ThemeColor giftSegmentSelectTitleColor] forState:UIControlStateSelected];
[_nobleGiftButton setTitleColor:[ThemeColor giftSegmentNormalTitleColor] forState:UIControlStateNormal];
_nobleGiftButton.titleLabel.font = [UIFont systemFontOfSize:14];
_nobleGiftButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold];
_nobleGiftButton.tag = GiftSegmentType_Noble;
_nobleGiftButton.selected = NO;
[_nobleGiftButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside];
@@ -561,7 +548,7 @@
[_weekStarButton setTitle:@"周星礼物" forState:UIControlStateNormal];
[_weekStarButton setTitleColor:[ThemeColor giftSegmentSelectTitleColor] forState:UIControlStateSelected];
[_weekStarButton setTitleColor:[ThemeColor giftSegmentNormalTitleColor] forState:UIControlStateNormal];
_weekStarButton.titleLabel.font = [UIFont systemFontOfSize:14];
_weekStarButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold];
_weekStarButton.tag = GiftSegmentType_WeekStar;
_weekStarButton.selected = NO;
[_weekStarButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside];
@@ -575,7 +562,7 @@
[_packGiftButton setTitle:@"背包" forState:UIControlStateNormal];
[_packGiftButton setTitleColor:[ThemeColor giftSegmentSelectTitleColor] forState:UIControlStateSelected];
[_packGiftButton setTitleColor:[ThemeColor giftSegmentNormalTitleColor] forState:UIControlStateNormal];
_packGiftButton.titleLabel.font = [UIFont systemFontOfSize:14];
_packGiftButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold];
_packGiftButton.tag = GiftSegmentType_Pack;
_packGiftButton.selected = NO;
[_packGiftButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside];
@@ -589,7 +576,7 @@
[_graffitiButton setTitle:@"涂鸦礼物" forState:UIControlStateNormal];
[_graffitiButton setTitleColor:[ThemeColor giftSegmentSelectTitleColor] forState:UIControlStateSelected];
[_graffitiButton setTitleColor:[ThemeColor giftSegmentNormalTitleColor] forState:UIControlStateNormal];
_graffitiButton.titleLabel.font = [UIFont systemFontOfSize:14];
_graffitiButton.titleLabel.font = [UIFont systemFontOfSize:13 weight:UIFontWeightSemibold];
_graffitiButton.tag = GiftSegmentType_Graffiti;
_graffitiButton.selected = NO;
[_graffitiButton addTarget:self action:@selector(didClickGiftSegmentAction:) forControlEvents:UIControlEventTouchUpInside];
@@ -597,32 +584,6 @@
return _graffitiButton;
}
- (UIButton *)nobleButton {
if (!_nobleButton) {
_nobleButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_nobleButton setBackgroundImage:[UIImage imageNamed:@"room_gift_noble_entrance"] forState:UIControlStateNormal];
_nobleButton.tag = GiftSegmentType_Normal;
[_nobleButton addTarget:self action:@selector(didClickNobleSegmentAction:) forControlEvents:UIControlEventTouchUpInside];
_nobleButton.hidden = YES;
}
return _nobleButton;
}
- (UIButton *)playRuleButton {
if (!_playRuleButton) {
_playRuleButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_playRuleButton setTitle:@"玩法说明" forState:UIControlStateNormal];
[_playRuleButton setTitleColor:[ThemeColor giftPlayRuleColor] forState:UIControlStateNormal];
_playRuleButton.titleLabel.font = [UIFont systemFontOfSize:13];
[_playRuleButton setImage:[UIImage imageNamed:@"gift_info_rule"] forState:UIControlStateNormal];
[_playRuleButton addTarget:self action:@selector(playRuleButtonAction:) forControlEvents:UIControlEventTouchUpInside];
[_playRuleButton setTitleEdgeInsets:UIEdgeInsetsMake(0, 5, 0, 0)];
_playRuleButton.hidden = YES;
}
return _playRuleButton;
}
- (UILabel *)totalValueLabel {
if (!_totalValueLabel) {
_totalValueLabel = [[UILabel alloc] init];
@@ -630,14 +591,6 @@
return _totalValueLabel;
}
- (XPWeekStarInfoView *)weekStarView {
if (!_weekStarView) {
_weekStarView = [[XPWeekStarInfoView alloc] init];
_weekStarView.delegate = self;
}
return _weekStarView;
}
- (UICollectionView *)giftcollectionView{
if (!_giftcollectionView) {
XPGiftCollectionViewFlowLayout *layout = [[XPGiftCollectionViewFlowLayout alloc] init];
@@ -652,6 +605,7 @@
[_giftcollectionView registerClass:[XPGiftItemCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftItemCollectionViewCell class])];
[_giftcollectionView registerClass:[XPGiftEmptyCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftEmptyCollectionViewCell class])];
[_giftcollectionView registerClass:[XPGiftWeekStarCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftWeekStarCollectionViewCell class])];
_giftcollectionView.showsHorizontalScrollIndicator = NO;
}
return _giftcollectionView;
}
@@ -665,17 +619,6 @@
return _pageController;
}
- (UIView *)segmentPlaceView {
if (!_segmentPlaceView) {
_segmentPlaceView = [[UIView alloc] init];
_segmentPlaceView.backgroundColor = [UIColor redColor];
[_segmentPlaceView setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
[_segmentPlaceView setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
}
return _segmentPlaceView;
}
- (NSMutableArray<GiftInfoModel *> *)datasource {
if (!_datasource) {
_datasource = [NSMutableArray array];