优化礼物面板效果

This commit is contained in:
eggmanQQQ
2024-07-30 16:45:40 +08:00
parent dae2a03c35
commit a4c3327c29
6 changed files with 122 additions and 132 deletions

View File

@@ -371,6 +371,7 @@
_headWearImageView = [[YYAnimatedImageView alloc] init];
_headWearImageView.backgroundColor = [UIColor clearColor];
_headWearImageView.contentMode = UIViewContentModeScaleAspectFit;
_headWearImageView.userInteractionEnabled = NO;
}
return _headWearImageView;
}
@@ -380,7 +381,7 @@
_headWearSVGAImageView = [[SVGAImageView alloc]init];
_headWearSVGAImageView.backgroundColor = [UIColor clearColor];
_headWearSVGAImageView.frame = CGRectZero;
_headWearSVGAImageView.userInteractionEnabled = YES;
_headWearSVGAImageView.userInteractionEnabled = NO;
_headWearSVGAImageView.autoPlay = YES;
}
return _headWearSVGAImageView;

View File

@@ -83,6 +83,8 @@ XPMineCustomNavViewDelegate, XPMineUserInfoProtocol, XPMineUserInfoHeaderViewDel
@property (nonatomic, strong) XPMineGameMateOrderView *gameOrderView;
@property (nonatomic, assign) CGFloat headerHeight;
@end
@implementation XPMineUserInfoViewController
@@ -252,7 +254,7 @@ XPMineCustomNavViewDelegate, XPMineUserInfoProtocol, XPMineUserInfoHeaderViewDel
#pragma mark - JXCategoryViewDelegate
- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
return [XPMineUserInfoHeaderView headerHeight:self.userInfo];
return self.headerHeight;
}
- (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
@@ -356,6 +358,9 @@ XPMineCustomNavViewDelegate, XPMineUserInfoProtocol, XPMineUserInfoHeaderViewDel
[self.titleView selectItemAtIndex:0];
});
}
self.headerHeight = [XPMineUserInfoHeaderView headerHeight:userInfo];
[self.pagingView reloadData];
}

View File

@@ -144,9 +144,9 @@ return view;\
}
+ (CGFloat)headerHeight:(UserInfoModel *)model {
if (model.userDesc.length == 0) {
return 470;
} else {
CGFloat height = 0;
NSInteger numberOfLines = 1;
if (model.userDesc.length > 0) {
//
CGFloat maxWidth = KScreenWidth - 70;
UIFont *font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
@@ -155,20 +155,20 @@ return view;\
//
CGRect textRect = [model.userDesc boundingRectWithSize:CGSizeMake(maxWidth, CGFLOAT_MAX)
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
attributes:attributes
context:nil];
options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
attributes:attributes
context:nil];
//
CGFloat lineHeight = font.lineHeight;
//
NSInteger numberOfLines = ceil(textRect.size.height / lineHeight);
if (numberOfLines>1) {
return 470 + 14 * numberOfLines;
}
numberOfLines = ceil(textRect.size.height / lineHeight);
}
return 500;
height = 470 + 14 * numberOfLines;
return height;
}
#pragma mark - Private Method
@@ -738,14 +738,6 @@ return view;\
make.top.bottom.right.mas_equalTo(self.idStackView);
make.left.mas_equalTo(self.idStackView).offset(-20);
}];
// [self.copyIdImageView mas_updateConstraints:^(MASConstraintMaker *make) {
// if (isMSRTL()) {
// make.right.mas_equalTo(self.idLabel.mas_left).offset(-24);
// } else {
// make.left.mas_equalTo(self.idLabel.mas_right).offset(6);
// }
// }];
} else {
self.idLabel.text = text;
self.idLabel.alpha = 0.8;

View File

@@ -285,18 +285,18 @@
- (void)setUsingplaceType:(SendGiftType)usingplaceType {
_usingplaceType = usingplaceType;
self.packGiftView.usingplaceType = _usingplaceType;
if (_usingplaceType == SendGiftType_User) {
self.pi_titles = @[YMLocalizedString(@"XPGiftInfoView2"),
YMLocalizedString(@"XPGiftInfoView4"),
YMLocalizedString(@"XPGiftInfoView9")];
self.titleView.titles = self.pi_titles;
[self.titleView reloadData];
self.titleView.titleColor = [DJDKMIMOMColor secondTextColor];
self.titleView.titleSelectedColor = [DJDKMIMOMColor mainTextColor];
self.segmentBgView.hidden = NO;
[self.packGiftButton setTitleColor:[DJDKMIMOMColor mainTextColor] forState:UIControlStateSelected];
[self.packGiftButton setTitleColor:[DJDKMIMOMColor secondTextColor] forState:UIControlStateNormal];
}
if (_usingplaceType == SendGiftType_User) {
self.pi_titles = @[YMLocalizedString(@"XPGiftInfoView2"),
YMLocalizedString(@"XPGiftInfoView4"),
YMLocalizedString(@"XPGiftInfoView9")];
self.titleView.titles = self.pi_titles;
[self.titleView reloadData];
self.titleView.titleColor = [DJDKMIMOMColor secondTextColor];
self.titleView.titleSelectedColor = [DJDKMIMOMColor mainTextColor];
self.segmentBgView.hidden = NO;
[self.packGiftButton setTitleColor:[DJDKMIMOMColor mainTextColor] forState:UIControlStateSelected];
[self.packGiftButton setTitleColor:[DJDKMIMOMColor secondTextColor] forState:UIControlStateNormal];
}
}
///
- (void)updatePackSource:(GiftReceiveInfoModel *)giftReceiveInfo numberUser:(NSInteger)numberUser{
@@ -356,14 +356,7 @@
}
return _pi_containerView;
}
//- (UILabel *)totalValueLabel {
// if (!_totalValueLabel) {
// _totalValueLabel = [[UILabel alloc] init];
// _totalValueLabel.hidden = YES;
// _totalValueLabel.textAlignment = NSTextAlignmentRight;
// }
// return _totalValueLabel;
//}
- (UIButton *)packGiftButton {
if (!_packGiftButton) {
_packGiftButton = [UIButton buttonWithType:UIButtonTypeCustom];

View File

@@ -30,11 +30,9 @@
@interface XPGiftInfoView ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, XPGiftWeekStarCollectionViewCellDelegate>
///l
@property (nonatomic,strong) UICollectionView *giftcollectionView;
@property (nonatomic,strong) UICollectionView *giftCollectionView;
@property (nonatomic, strong) UICollectionViewFlowLayout *giftLayout;
///
@property (nonatomic, strong) UIPageControl *pageController;
///
@@ -42,7 +40,6 @@
///
@property (nonatomic,strong) GiftInfoModel *lastSelectGift;
@end
@implementation XPGiftInfoView
@@ -51,22 +48,22 @@
{
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.segmentType = GiftSegmentType_Normal;
// /
[self addSubview:self.giftcollectionView];
[self addSubview:self.giftCollectionView];
[self addSubview:self.pageController];
}
- (void)initSubViewConstraints {
[self.giftcollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
[self.giftCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
[self.pageController mas_makeConstraints:^(MASConstraintMaker *make) {
@@ -106,17 +103,11 @@
self.pageController.currentPage = page > 1 ? page - 1 : 0;
[self dealSelectGift:gift];
}
}
}
[self.giftcollectionView reloadData];
[self.giftCollectionView reloadData];
}
- (void)dealSelectGift:(GiftInfoModel *)giftInfo {
self.lastSelectGift = giftInfo;
if (self.segmentType == GiftSegmentType_Pack) {
@@ -125,7 +116,6 @@
giftInfo.sourceType = GiftSourceType_Normal;
}
giftInfo.isSelected = YES;
}
// id
@@ -139,11 +129,17 @@
return nil;
}
- (void)updateCollectionViewInsetWith:(NSInteger)count {
if (count == 0) {
self.giftLayout.sectionInset = UIEdgeInsetsZero;
} else {
self.giftLayout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 15);
}
}
#pragma mark - scrollviewdelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView == self.giftcollectionView) {
if (scrollView == self.giftCollectionView) {
CGFloat offX = scrollView.contentOffset.x;
CGFloat width = CGRectGetWidth(scrollView.frame);
self.pageController.currentPage = ceilf(offX/width);
@@ -165,6 +161,7 @@
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
if (self.segmentType == GiftSegmentType_Pack && self.datasource.count == 0) {
return 1;
}
@@ -177,6 +174,12 @@
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
if (self.datasource.count == 0) {
XPGiftEmptyCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftEmptyCollectionViewCell class]) forIndexPath:indexPath];
cell.emptyTitle = YMLocalizedString(@"XPGiftInfoView1");
return cell;
}
if ((self.segmentType == GiftSegmentType_Pack || self.segmentType == GiftSegmentType_WeekStar) && self.datasource.count == 0) {
XPGiftEmptyCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftEmptyCollectionViewCell class]) forIndexPath:indexPath];
cell.emptyTitle = YMLocalizedString(@"XPGiftInfoView1");
@@ -215,7 +218,7 @@
if (self.datasource.count > 0) {
GiftInfoModel * giftInfo= [self.datasource xpSafeObjectAtIndex:indexPath.item];
[self dealSelectGift:giftInfo];
[self.giftcollectionView reloadData];
[self.giftCollectionView reloadData];
if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftInfoView:didClickItem:type:)]) {
[self.delegate xPGiftInfoView:self didClickItem:giftInfo type:self.segmentType];
}
@@ -241,8 +244,6 @@
[self.delegate xPGiftInfoView:self didClickItem:giftModel type:self.segmentType];
}
}
}
self.datasource = [[NSMutableArray alloc]initWithArray:_normalOriginArray];
NSInteger currentPage = 0;
@@ -255,10 +256,9 @@
self.pageController.hidden = page <= 1 || _segmentType == GiftSegmentType_WeekStar;
[self.pageController setNumberOfPages:page];
self.pageController.currentPage = currentPage;
[self.giftcollectionView reloadData];
[self updateCollectionViewInsetWith:normalOriginArray.count];
[self.giftCollectionView reloadData];
}
- (void)setPackOriginArray:(NSArray *)packOriginArray {
@@ -287,14 +287,15 @@
self.pageController.hidden = page <= 1;
[self.pageController setNumberOfPages:page];
self.pageController.currentPage = currentPage;
[self.giftcollectionView reloadData];
[self updateCollectionViewInsetWith:packOriginArray.count];
[self.giftCollectionView reloadData];
}
- (void)setCurUserNobleLevel:(NSInteger)curUserNobleLevel {
_curUserNobleLevel = curUserNobleLevel;
[self.giftcollectionView reloadData];
[self.giftCollectionView reloadData];
}
#pragma mark - JXCategoryListContentViewDelegate
@@ -302,24 +303,23 @@
return self;
}
- (UICollectionView *)giftcollectionView{
if (!_giftcollectionView) {
XPGiftCollectionViewFlowLayout *layout = [[XPGiftCollectionViewFlowLayout alloc] init];
layout.minimumLineSpacing = 5;
layout.minimumInteritemSpacing = 5;
layout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 15);
_giftcollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_giftcollectionView.dataSource = self;
_giftcollectionView.delegate = self;
_giftcollectionView.backgroundColor = [UIColor clearColor];
_giftcollectionView.pagingEnabled = YES;
[_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 registerClass:[XPGiftFreeItemCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftFreeItemCell class])];
_giftcollectionView.showsHorizontalScrollIndicator = NO;
- (UICollectionView *)giftCollectionView{
if (!_giftCollectionView) {
_giftLayout = [[XPGiftCollectionViewFlowLayout alloc] init];
_giftLayout.minimumLineSpacing = 5;
_giftLayout.minimumInteritemSpacing = 5;
_giftCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:_giftLayout];
_giftCollectionView.dataSource = self;
_giftCollectionView.delegate = self;
_giftCollectionView.backgroundColor = [UIColor clearColor];
_giftCollectionView.pagingEnabled = YES;
[_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 registerClass:[XPGiftFreeItemCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftFreeItemCell class])];
_giftCollectionView.showsHorizontalScrollIndicator = NO;
}
return _giftcollectionView;
return _giftCollectionView;
}
@@ -338,9 +338,4 @@
return _datasource;
}
@end

View File

@@ -178,8 +178,7 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
[self.presenter getUserInfo:[AccountInfoStorage instance].getUid];
[self.presenter getUserWallInfo];
// [self.presenter getPackGiftList];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_global_queue(0, 0), ^{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_global_queue(0, 0), ^{
[self.presenter luckyGiftBroadcastRecord];
});
}
@@ -309,7 +308,6 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
[self sendCustomMessage:attachment];
}
}
}
- (void)sendCustomMessage:(AttachmentModel *)attachment {
@@ -456,7 +454,9 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
}
- (void)xPGiftBarViewDidClickFirstRecharge:(XPGiftBarView *)view {
@kWeakify(self);
[self dismissViewControllerAnimated:NO completion:^{
@kStrongify(self);
[[NSNotificationCenter defaultCenter]postNotificationName:kShowFirstRechargeView object:@{@"type":@"1",@"diamonds": self.giftBarView.walletInfoModel.diamonds ?: @"0"}];
}];
}
@@ -534,52 +534,56 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
self.segmentType = type;
self.giftBarView.type = type;
self.giftBarView.drawGiftCount = 10;
if (type == GiftSegmentType_Lucky) {
[self.constellationBanner removeFromSuperview];
if (view.lastSelectGift.giftType == GiftType_super){
[self.luckyBroadcastView removeFromSuperview];
if (!self.superGiftView.superview) {
[self.view addSubview:self.superGiftView];
[self.superGiftView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.contentView.mas_top);
make.leading.trailing.mas_equalTo(0);
make.height.mas_equalTo(kGetScaleWidth(90));
}];
}
}else{
[self.superGiftView removeFromSuperview];
if (!self.luckyBroadcastView.superview) {
[self.view addSubview:self.luckyBroadcastView];
[self.luckyBroadcastView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.contentView.mas_top);
make.leading.trailing.mas_equalTo(0);
make.height.mas_equalTo(kGetScaleWidth(56));
}];
[self.superGiftView removeFromSuperview];
[self.luckyBroadcastView removeFromSuperview];
[self.constellationBanner removeFromSuperview];
switch (type) {
case GiftSegmentType_Lucky:{
if (view.lastSelectGift.giftType == GiftType_super){
if (!self.superGiftView.superview) {
[self.view addSubview:self.superGiftView];
[self.superGiftView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.contentView.mas_top);
make.leading.trailing.mas_equalTo(0);
make.height.mas_equalTo(kGetScaleWidth(90));
}];
}
}else{
if (!self.luckyBroadcastView.superview) {
[self.view addSubview:self.luckyBroadcastView];
[self.luckyBroadcastView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.contentView.mas_top);
make.leading.trailing.mas_equalTo(0);
make.height.mas_equalTo(kGetScaleWidth(56));
}];
}
}
}
} else if(type == GiftSegmentType_WeekStar) {
[self.luckyBroadcastView removeFromSuperview];
[self.superGiftView removeFromSuperview];
break;
case GiftSegmentType_WeekStar: {
if (!self.constellationBanner.superview) {
[self.view addSubview:self.constellationBanner];
[self.constellationBanner mas_makeConstraints:^(MASConstraintMaker *make) {
[self.constellationBanner mas_remakeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.contentView.mas_top);
make.leading.trailing.mas_equalTo(0);
make.height.mas_equalTo(kGetScaleWidth(56));
}];
}
} else {
[self.superGiftView removeFromSuperview];
[self.luckyBroadcastView removeFromSuperview];
[self.constellationBanner removeFromSuperview];
if (!self.didLoadPackGiftList) {
self.didLoadPackGiftList = YES;
[self.giftInfoView showLoading];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_global_queue(0, 0), ^{
[self.presenter getPackGiftList];
});
}
break;
case GiftSegmentType_Pack: {
if (!self.didLoadPackGiftList) {
self.didLoadPackGiftList = YES;
[self.giftInfoView showLoading];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_global_queue(0, 0), ^{
[self.presenter getPackGiftList];
});
}
}
break;
default:
break;
}
}