diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 0a73d5e0..a4203509 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -630,6 +630,7 @@ E8A6C29B27CF53BF00AC7442 /* XPHomeLikePresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A6C29A27CF53BF00AC7442 /* XPHomeLikePresenter.m */; }; E8A6C29F27CF5FE500AC7442 /* HomeLiveRoomModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A6C29E27CF5FE500AC7442 /* HomeLiveRoomModel.m */; }; E8A6C2A227CF856E00AC7442 /* HomeCollectRoomModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A6C2A127CF856E00AC7442 /* HomeCollectRoomModel.m */; }; + E8A73F8728586A6F00FD9CBC /* XPGiftWeekStarCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A73F8628586A6F00FD9CBC /* XPGiftWeekStarCollectionViewCell.m */; }; E8A86DF727BA2F1C001C21F9 /* XPRoomLittleGameContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A86DF627BA2F1C001C21F9 /* XPRoomLittleGameContainerView.m */; }; E8A86E0427BA38DB001C21F9 /* SudCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A86DF927BA38DB001C21F9 /* SudCommon.m */; }; E8A86E0527BA38DB001C21F9 /* NSString+RW.m in Sources */ = {isa = PBXBuildFile; fileRef = E8A86DFC27BA38DB001C21F9 /* NSString+RW.m */; }; @@ -2110,6 +2111,8 @@ E8A6C29E27CF5FE500AC7442 /* HomeLiveRoomModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeLiveRoomModel.m; sourceTree = ""; }; E8A6C2A027CF856E00AC7442 /* HomeCollectRoomModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HomeCollectRoomModel.h; sourceTree = ""; }; E8A6C2A127CF856E00AC7442 /* HomeCollectRoomModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = HomeCollectRoomModel.m; sourceTree = ""; }; + E8A73F8528586A6F00FD9CBC /* XPGiftWeekStarCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPGiftWeekStarCollectionViewCell.h; sourceTree = ""; }; + E8A73F8628586A6F00FD9CBC /* XPGiftWeekStarCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPGiftWeekStarCollectionViewCell.m; sourceTree = ""; }; E8A86DF527BA2F1C001C21F9 /* XPRoomLittleGameContainerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomLittleGameContainerView.h; sourceTree = ""; }; E8A86DF627BA2F1C001C21F9 /* XPRoomLittleGameContainerView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomLittleGameContainerView.m; sourceTree = ""; }; E8A86DF927BA38DB001C21F9 /* SudCommon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SudCommon.m; sourceTree = ""; }; @@ -5128,6 +5131,8 @@ E890BC06273CF1800007C46B /* XPGiftCountCollectionViewCell.m */, E8133914273E532D00708B66 /* XPGiftItemCollectionViewCell.h */, E8133915273E532D00708B66 /* XPGiftItemCollectionViewCell.m */, + E8A73F8528586A6F00FD9CBC /* XPGiftWeekStarCollectionViewCell.h */, + E8A73F8628586A6F00FD9CBC /* XPGiftWeekStarCollectionViewCell.m */, E811FFF52742367B00918544 /* XPGiftEmptyCollectionViewCell.h */, E811FFF62742367B00918544 /* XPGiftEmptyCollectionViewCell.m */, E8659907273E800D00EE349D /* XPGiftCollectionViewFlowLayout.h */, @@ -7420,6 +7425,7 @@ E8D34D41280714F3009C4835 /* GuildSearchSuperAdminModel.m in Sources */, E824546126F5F4E400BE8163 /* XPMineResetPayPwdViewController.m in Sources */, E81D58822720082A003063FE /* MicroWaveView.m in Sources */, + E8A73F8728586A6F00FD9CBC /* XPGiftWeekStarCollectionViewCell.m in Sources */, E8B825C226EA00DF009E8E9F /* LoginVerifCodePresent.m in Sources */, 9B9EEF4E27C8755C006B0EB3 /* XPSkillCardResourcePropModel.m in Sources */, E88B5CB026FB1C6500DA9178 /* XPMineTeenagerPresenter.m in Sources */, diff --git a/xplan-ios/Assets.xcassets/Gift/gift_info_empty_bg.imageset/Contents.json b/xplan-ios/Assets.xcassets/Gift/gift_info_empty_bg.imageset/Contents.json new file mode 100644 index 00000000..cc25dc25 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Gift/gift_info_empty_bg.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "gift_info_empty_bg@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "gift_info_empty_bg@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Gift/gift_info_empty_bg.imageset/gift_info_empty_bg@2x.png b/xplan-ios/Assets.xcassets/Gift/gift_info_empty_bg.imageset/gift_info_empty_bg@2x.png new file mode 100644 index 00000000..59c613c3 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Gift/gift_info_empty_bg.imageset/gift_info_empty_bg@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Gift/gift_info_empty_bg.imageset/gift_info_empty_bg@3x.png b/xplan-ios/Assets.xcassets/Gift/gift_info_empty_bg.imageset/gift_info_empty_bg@3x.png new file mode 100644 index 00000000..056eb864 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Gift/gift_info_empty_bg.imageset/gift_info_empty_bg@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_charm_bg.imageset/Contents.json b/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_charm_bg.imageset/Contents.json new file mode 100644 index 00000000..b18954f0 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_charm_bg.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "gift_info_week_star_charm_bg@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "gift_info_week_star_charm_bg@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_charm_bg.imageset/gift_info_week_star_charm_bg@2x.png b/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_charm_bg.imageset/gift_info_week_star_charm_bg@2x.png new file mode 100644 index 00000000..3cadb7a2 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_charm_bg.imageset/gift_info_week_star_charm_bg@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_charm_bg.imageset/gift_info_week_star_charm_bg@3x.png b/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_charm_bg.imageset/gift_info_week_star_charm_bg@3x.png new file mode 100644 index 00000000..99d642ee Binary files /dev/null and b/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_charm_bg.imageset/gift_info_week_star_charm_bg@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_level_bg.imageset/Contents.json b/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_level_bg.imageset/Contents.json new file mode 100644 index 00000000..2818f68f --- /dev/null +++ b/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_level_bg.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "gift_info_week_star_level_bg@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "gift_info_week_star_level_bg@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_level_bg.imageset/gift_info_week_star_level_bg@2x.png b/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_level_bg.imageset/gift_info_week_star_level_bg@2x.png new file mode 100644 index 00000000..6cb0674b Binary files /dev/null and b/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_level_bg.imageset/gift_info_week_star_level_bg@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_level_bg.imageset/gift_info_week_star_level_bg@3x.png b/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_level_bg.imageset/gift_info_week_star_level_bg@3x.png new file mode 100644 index 00000000..6bbed4c5 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Gift/gift_info_week_star_level_bg.imageset/gift_info_week_star_level_bg@3x.png differ diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftEmptyCollectionViewCell.h b/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftEmptyCollectionViewCell.h index 19192e9f..937a66f5 100644 --- a/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftEmptyCollectionViewCell.h +++ b/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftEmptyCollectionViewCell.h @@ -10,7 +10,7 @@ NS_ASSUME_NONNULL_BEGIN @interface XPGiftEmptyCollectionViewCell : UICollectionViewCell - +@property (nonatomic,copy) NSString *emptyTitle; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftEmptyCollectionViewCell.m b/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftEmptyCollectionViewCell.m index 6f5e9618..42f19ba7 100644 --- a/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftEmptyCollectionViewCell.m +++ b/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftEmptyCollectionViewCell.m @@ -12,7 +12,7 @@ #import "ThemeColor+SendGift.h" @interface XPGiftEmptyCollectionViewCell () -/// +@property (nonatomic,strong) UIImageView *logoImageView; @property (nonatomic,strong) UILabel *emptyPackTip; @end @@ -29,16 +29,31 @@ #pragma mark - Private Method - (void)initSubViews { + [self.contentView addSubview:self.logoImageView]; [self.contentView addSubview:self.emptyPackTip]; } - (void)initSubViewConstraints { + [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(40, 40)); + make.bottom.mas_equalTo(self.mas_centerY).offset(-3); + make.centerX.mas_equalTo(self); + }]; + [self.emptyPackTip mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self); + make.top.mas_equalTo(self.mas_centerY).offset(3); + make.centerX.mas_equalTo(self); }]; } #pragma mark - Getters And Setters +- (void)setEmptyTitle:(NSString *)emptyTitle { + _emptyTitle = emptyTitle; + if (_emptyTitle.length > 0) { + self.emptyPackTip.text = _emptyTitle; + } +} + - (UILabel *)emptyPackTip { if (!_emptyPackTip) { _emptyPackTip = [[UILabel alloc] init]; @@ -50,4 +65,13 @@ return _emptyPackTip; } +- (UIImageView *)logoImageView { + if (!_logoImageView) { + _logoImageView = [[UIImageView alloc] init]; + _logoImageView.userInteractionEnabled = YES; + _logoImageView.image = [UIImage imageNamed:@"gift_info_empty_bg"]; + } + return _logoImageView; +} + @end diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftWeekStarCollectionViewCell.h b/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftWeekStarCollectionViewCell.h new file mode 100644 index 00000000..0967710b --- /dev/null +++ b/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftWeekStarCollectionViewCell.h @@ -0,0 +1,25 @@ +// +// XPGiftWeekStarCollectionViewCell.h +// xplan-ios +// +// Created by 冯硕 on 2022/6/14. +// + +#import + +NS_ASSUME_NONNULL_BEGIN +@class XPGiftWeekStarCollectionViewCell, GiftInfoModel; +@protocol XPGiftWeekStarCollectionViewCellDelegate + +- (void)xPGiftWeekStarCollectionViewCell:(XPGiftWeekStarCollectionViewCell *)view didSelectGift:(GiftInfoModel *)giftInfo; + +@end + +@interface XPGiftWeekStarCollectionViewCell : UICollectionViewCell +///周星礼物 +@property (nonatomic,strong) NSArray *weekStarGiftList; +///代理 +@property (nonatomic,weak) id delegate; +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftWeekStarCollectionViewCell.m b/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftWeekStarCollectionViewCell.m new file mode 100644 index 00000000..4e6f85ea --- /dev/null +++ b/xplan-ios/Main/ModuleKit/SendGiftView/View/Cell/XPGiftWeekStarCollectionViewCell.m @@ -0,0 +1,330 @@ +// +// XPGiftWeekStarCollectionViewCell.m +// xplan-ios +// +// Created by 冯硕 on 2022/6/14. +// + +#import "XPGiftWeekStarCollectionViewCell.h" +///Third +#import +///Tool +#import "NetImageView.h" +#import "ThemeColor.h" +#import "XPMacro.h" +#import "ThemeColor+SendGift.h" +#import "XPGiftCollectionViewFlowLayout.h" +///Model +#import "GiftInfoModel.h" +///View +#import "XPGiftItemCollectionViewCell.h" + +@interface XPGiftWeekStarUserView : UIView +///显示头像 +@property (nonatomic,strong) NetImageView *avatarImageView; +///显示昵称 +@property (nonatomic,strong) UILabel *nickLabel; +///显示内容 +@property (nonatomic,strong) UIButton *contentButton; +///上周对应礼物的魅力榜第一 +@property (nonatomic, strong) XPWeekStarRankUserModel *firstCharmRankUser; +///上周对应礼物豪气榜第一 +@property (nonatomic, strong) XPWeekStarRankUserModel *firstLevelRankUser; +@end + +@implementation XPGiftWeekStarUserView + +- (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.avatarImageView]; + [self addSubview:self.nickLabel]; + [self addSubview:self.contentButton]; +} + +- (void)initSubViewConstraints { + [self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(44, 44)); + make.centerX.mas_equalTo(self); + make.top.mas_equalTo(self).offset(12); + }]; + + [self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.mas_equalTo(self); + make.top.mas_equalTo(self.avatarImageView.mas_bottom).offset(4); + }]; + + [self.contentButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.size.mas_equalTo(CGSizeMake(111, 19)); + make.centerX.mas_equalTo(self); + make.top.mas_equalTo(self.nickLabel.mas_bottom).offset(12); + }]; +} +#pragma mark - Getters And Setters +- (void)setFirstCharmRankUser:(XPWeekStarRankUserModel *)firstCharmRankUser { + _firstCharmRankUser = firstCharmRankUser; + if (_firstCharmRankUser) { + self.avatarImageView.layer.borderColor = UIColorFromRGB(0xA563EB).CGColor; + [self.contentButton setBackgroundImage:[UIImage imageNamed:@"gift_info_week_star_charm_bg"] forState:UIControlStateNormal]; + self.avatarImageView.imageUrl = _firstCharmRankUser.avatar; + NSString * nick = _firstCharmRankUser.nick; + if (nick.length > 8) { + nick = [nick substringFromIndex:8]; + } + self.nickLabel.text = nick; + [self.contentButton setTitle:@"本周该礼物冠名者" forState:UIControlStateNormal]; + [self.contentButton setTitleColor:UIColorFromRGB(0x35105C) forState:UIControlStateNormal]; + } +} + +- (void)setFirstLevelRankUser:(XPWeekStarRankUserModel *)firstLevelRankUser { + _firstLevelRankUser = firstLevelRankUser; + if (_firstLevelRankUser) { + self.avatarImageView.layer.borderColor = UIColorFromRGB(0xFFBC51).CGColor; + [self.contentButton setBackgroundImage:[UIImage imageNamed:@"gift_info_week_star_level_bg"] forState:UIControlStateNormal]; + self.avatarImageView.imageUrl = _firstLevelRankUser.avatar; + NSString * nick = _firstLevelRankUser.nick; + if (nick.length > 8) { + nick = [nick substringFromIndex:8]; + } + self.nickLabel.text = nick; + [self.contentButton setTitle:@"本周该礼物星神豪" forState:UIControlStateNormal]; + [self.contentButton setTitleColor:UIColorFromRGB(0x754304) forState:UIControlStateNormal]; + } +} + + + +- (NetImageView *)avatarImageView { + if (!_avatarImageView) { + NetImageConfig * config = [[NetImageConfig alloc]init]; + config.imageType = ImageTypeUserIcon; + config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; + _avatarImageView = [[NetImageView alloc] initWithConfig:config]; + _avatarImageView.layer.masksToBounds = YES; + _avatarImageView.layer.cornerRadius = 22; + _avatarImageView.layer.borderWidth = 1; + } + return _avatarImageView; +} + +- (UILabel *)nickLabel { + if (!_nickLabel) { + _nickLabel = [[UILabel alloc] init]; + _nickLabel.font = [UIFont systemFontOfSize:10]; + _nickLabel.textColor = [UIColor whiteColor]; + _nickLabel.textAlignment = NSTextAlignmentCenter; + } + return _nickLabel; +} + +- (UIButton *)contentButton { + if (!_contentButton) { + _contentButton = [UIButton buttonWithType:UIButtonTypeCustom]; + _contentButton.titleLabel.font = [UIFont systemFontOfSize:10]; + } + return _contentButton; +} + + +@end + + +@interface XPGiftWeekStarCollectionViewCell () +///列表 +@property (nonatomic,strong) UICollectionView *collectionView; +///分页 +@property (nonatomic,strong) UIPageControl *pageController; +///用户的容器 +@property (nonatomic,strong) UIStackView *userStackView; +///冠名 +@property (nonatomic,strong) XPGiftWeekStarUserView *sendUserView; +///礼物神豪 +@property (nonatomic,strong) XPGiftWeekStarUserView *receiveUserView; +///选中的礼物 +@property (nonatomic,strong) GiftInfoModel *selectGiftInfo; +@end + +@implementation XPGiftWeekStarCollectionViewCell + +- (instancetype)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + if (self) { + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; +} +#pragma mark - Private Method +- (void)initSubViews { + [self.contentView addSubview:self.collectionView]; + [self.contentView addSubview:self.pageController]; + [self.contentView addSubview:self.userStackView]; + + [self.userStackView addArrangedSubview:self.sendUserView]; + [self.userStackView addArrangedSubview:self.receiveUserView]; +} + +- (void)initSubViewConstraints { + [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.top.mas_equalTo(self.contentView); + make.height.mas_equalTo(108); + }]; + + [self.pageController mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.collectionView.mas_bottom).offset(5); + make.left.right.mas_equalTo(self.contentView); + make.height.mas_equalTo(10); + }]; + + [self.userStackView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.right.bottom.mas_equalTo(self.contentView); + make.top.mas_equalTo(self.pageController.mas_bottom).offset(0); + }]; +} + + +#pragma mark - UICollectionViewDelegate And UICollectionDatasource +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { + CGFloat itemWidth = (CGFloat)(KScreenWidth - 15 * 2 - 5 * 3) / (CGFloat)4; + return CGSizeMake(itemWidth, 105); +} + +- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { + return self.weekStarGiftList.count; +} + +- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { + XPGiftItemCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftItemCollectionViewCell class]) forIndexPath:indexPath]; + GiftInfoModel * giftInfo; + giftInfo= [self.weekStarGiftList objectAtIndex:indexPath.item]; + if (giftInfo.giftId == self.selectGiftInfo.giftId) { + giftInfo.isSelected = YES; + } else { + giftInfo.isSelected = NO; + } + cell.giftInfo = giftInfo; + return cell; +} + +- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { + [collectionView deselectItemAtIndexPath:indexPath animated:YES]; + if (self.weekStarGiftList.count > 0) { + GiftInfoModel * giftInfo= [self.weekStarGiftList objectAtIndex:indexPath.item]; + self.selectGiftInfo = giftInfo; + [self.collectionView reloadData]; + + if (self.delegate && [self.delegate respondsToSelector:@selector(xPGiftWeekStarCollectionViewCell:didSelectGift:)]) { + [self.delegate xPGiftWeekStarCollectionViewCell:self didSelectGift:giftInfo]; + } + } +} +#pragma mark - scrollviewdelegate +- (void)scrollViewDidScroll:(UIScrollView *)scrollView { + CGFloat offX = scrollView.contentOffset.x; + CGFloat width = CGRectGetWidth(scrollView.frame); + self.pageController.currentPage = ceilf(offX/width); +} + +#pragma mark - Getters And Setters +- (void)setWeekStarGiftList:(NSArray *)weekStarGiftList { + _weekStarGiftList = weekStarGiftList; + if (_weekStarGiftList.count > 0) { + self.selectGiftInfo = _weekStarGiftList.firstObject; + } + NSInteger page = 0; + if (_weekStarGiftList.count % 4 == 0) { //刚好满页 + page = _weekStarGiftList.count / 4; + } else { + page = _weekStarGiftList.count / 4 + 1; + } + self.pageController.hidden = page <= 1; + [self.pageController setNumberOfPages:page]; + self.pageController.currentPage = 0; + [self.collectionView reloadData]; +} + +- (void)setSelectGiftInfo:(GiftInfoModel *)selectGiftInfo { + _selectGiftInfo = selectGiftInfo; + if (_selectGiftInfo) { + if (_selectGiftInfo.firstCharmRankUser) { + self.sendUserView.hidden = NO; + self.sendUserView.firstCharmRankUser = _selectGiftInfo.firstCharmRankUser; + } else { + self.sendUserView.hidden = YES; + } + + if (_selectGiftInfo.firstLevelRankUser) { + self.receiveUserView.hidden = NO; + self.receiveUserView.firstLevelRankUser = _selectGiftInfo.firstLevelRankUser; + } else { + self.receiveUserView.hidden = YES; + } + } else { + self.receiveUserView.hidden = YES; + self.sendUserView.hidden = YES; + } +} + +- (UICollectionView *)collectionView{ + if (!_collectionView) { + XPGiftCollectionViewFlowLayout *layout = [[XPGiftCollectionViewFlowLayout alloc] init]; + layout.minimumLineSpacing = 5; + layout.minimumInteritemSpacing = 5; + layout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0); + layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; + _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; + _collectionView.dataSource = self; + _collectionView.delegate = self; + _collectionView.backgroundColor = [UIColor clearColor]; + _collectionView.pagingEnabled = YES; + _collectionView.showsHorizontalScrollIndicator = NO; + [_collectionView registerClass:[XPGiftItemCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPGiftItemCollectionViewCell class])]; + } + return _collectionView; +} + +- (UIStackView *)userStackView { + if (!_userStackView) { + _userStackView = [[UIStackView alloc] init]; + _userStackView.axis = UILayoutConstraintAxisHorizontal; + _userStackView.distribution = UIStackViewDistributionFillEqually; + _userStackView.alignment = UIStackViewAlignmentFill; + _userStackView.spacing = 0; + } + return _userStackView; +} + +- (XPGiftWeekStarUserView *)sendUserView { + if (!_sendUserView) { + _sendUserView = [[XPGiftWeekStarUserView alloc] init]; + } + return _sendUserView; +} + +- (XPGiftWeekStarUserView *)receiveUserView { + if (!_receiveUserView) { + _receiveUserView = [[XPGiftWeekStarUserView alloc] init]; + } + return _receiveUserView; +} + +- (UIPageControl *)pageController { + if (!_pageController) { + _pageController = [[UIPageControl alloc] init]; + _pageController.currentPageIndicatorTintColor = [ThemeColor giftPageIndicatorColor]; + } + return _pageController; +} + + + +@end diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftInfoView.m b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftInfoView.m index 9657233d..e5964067 100644 --- a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftInfoView.m +++ b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPGiftInfoView.m @@ -17,10 +17,11 @@ ///View #import "XPGiftItemCollectionViewCell.h" #import "XPGiftEmptyCollectionViewCell.h" +#import "XPGiftWeekStarCollectionViewCell.h" #import "XPGiftCollectionViewFlowLayout.h" #import "XPWeekStarInfoView.h" -@interface XPGiftInfoView () +@interface XPGiftInfoView () /// @property (nonatomic,strong) UIStackView *segmentStackView; ///普通礼物 @@ -39,12 +40,12 @@ @property (nonatomic,strong) UIButton *playRuleButton; ///背包总价值 @property (nonatomic,strong) UILabel *totalValueLabel; +///周星榜 +@property (nonatomic,strong) XPWeekStarInfoView *weekStarView; ///贵族特权 @property (nonatomic, strong) UIButton *nobleButton; /// @property (nonatomic,strong) UIStackView *giftStackView; -///周星榜用户信息 -@property (nonatomic, strong) XPWeekStarInfoView *weekStarView; ///l礼物列表 @property (nonatomic,strong) UICollectionView *giftcollectionView; ///分页控件 @@ -127,9 +128,8 @@ [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 addSubview:self.weekStarView]; ///礼物 [self.giftStackView addArrangedSubview:self.giftcollectionView]; [self.giftStackView addArrangedSubview:self.pageController]; @@ -137,7 +137,7 @@ - (void)initSubViewConstraints { [self mas_makeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(30 + 108 * 2 + 10 + 10 + 25); + make.height.mas_equalTo(30 + 108 * 2 + 10 + 10 + 15); }]; @@ -146,15 +146,9 @@ make.top.mas_equalTo(self); make.height.mas_equalTo(30); }]; - - [self.weekStarView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.right.mas_equalTo(self).inset(15); - make.top.mas_equalTo(self.segmentStackView.mas_bottom); - make.height.mas_equalTo(25); - }]; [self.giftStackView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self.weekStarView.mas_bottom); + make.top.mas_equalTo(self.segmentStackView.mas_bottom).offset(10); make.left.right.mas_equalTo(self); make.height.mas_equalTo(108 * 2 + 20); }]; @@ -209,10 +203,6 @@ } self.playRuleButton.hidden = giftInfo.giftExplainUrl.length <= 0; giftInfo.isSelected = YES; - if (self.segmentType == GiftSegmentType_WeekStar) { - self.weekStarView.firstCharmRankUser = giftInfo.firstCharmRankUser; - self.weekStarView.firstLevelRankUser = giftInfo.firstLevelRankUser; - } } // 根据礼物id查找 @@ -240,6 +230,11 @@ if (self.segmentType == GiftSegmentType_Pack && self.datasource.count == 0) { return CGSizeMake(KScreenWidth, 105 * 2 + 10); } + + if (self.segmentType == GiftSegmentType_WeekStar) { + return CGSizeMake(KScreenWidth, 105 * 2 + 10); + } + CGFloat itemWidth = (CGFloat)(KScreenWidth - 15 * 2 - 5 * 3) / (CGFloat)4; return CGSizeMake(itemWidth, 108); } @@ -248,14 +243,28 @@ if (self.segmentType == GiftSegmentType_Pack && self.datasource.count == 0) { return 1; } + + if (self.segmentType == GiftSegmentType_WeekStar) { + return 1; + } + return self.datasource.count; } - (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { - if (self.segmentType ==GiftSegmentType_Pack && self.datasource.count == 0) { + if ((self.segmentType ==GiftSegmentType_Pack || self.segmentType == GiftSegmentType_WeekStar) && self.datasource.count == 0) { XPGiftEmptyCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftEmptyCollectionViewCell class]) forIndexPath:indexPath]; + cell.emptyTitle = @"暂时木有礼物~"; return cell; } + + if (self.segmentType == GiftSegmentType_WeekStar) { + XPGiftWeekStarCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftWeekStarCollectionViewCell class]) forIndexPath:indexPath]; + cell.delegate = self; + cell.weekStarGiftList = self.datasource; + return cell; + } + XPGiftItemCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPGiftItemCollectionViewCell class]) forIndexPath:indexPath]; GiftInfoModel * giftInfo; giftInfo= [self.datasource objectAtIndex:indexPath.item]; @@ -281,6 +290,11 @@ } } +#pragma mark - XPGiftWeekStarCollectionViewCellDelegate +- (void)xPGiftWeekStarCollectionViewCell:(XPGiftWeekStarCollectionViewCell *)view didSelectGift:(GiftInfoModel *)giftInfo { + [self dealSelectGift:giftInfo]; +} + #pragma mark - Getters And Setters - (void)setSegmentType:(GiftSegmentType)segmentType { if (segmentType == _segmentType) { @@ -410,14 +424,6 @@ return _giftStackView; } -- (XPWeekStarInfoView *)weekStarView { - if (!_weekStarView) { - _weekStarView = [[XPWeekStarInfoView alloc] init]; - _weekStarView.delegate = self; - } - return _weekStarView; -} - - (UIButton *)normalGiftButton { if (!_normalGiftButton) { _normalGiftButton = [UIButton buttonWithType:UIButtonTypeCustom]; @@ -520,6 +526,14 @@ return _totalValueLabel; } +- (XPWeekStarInfoView *)weekStarView { + if (!_weekStarView) { + _weekStarView = [[XPWeekStarInfoView alloc] init]; + _weekStarView.delegate = self; + } + return _weekStarView; +} + - (UICollectionView *)giftcollectionView{ if (!_giftcollectionView) { XPGiftCollectionViewFlowLayout *layout = [[XPGiftCollectionViewFlowLayout alloc] init]; @@ -533,6 +547,7 @@ _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])]; } return _giftcollectionView; } diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPWeekStarInfoView.h b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPWeekStarInfoView.h index a5b6bfc9..aad3312e 100644 --- a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPWeekStarInfoView.h +++ b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPWeekStarInfoView.h @@ -20,11 +20,6 @@ NS_ASSUME_NONNULL_BEGIN @interface XPWeekStarInfoView : UIView -///上周对应礼物的魅力榜第一 -@property (nonatomic, strong) XPWeekStarRankUserModel *firstCharmRankUser; -///上周对应礼物豪气榜第一 -@property (nonatomic, strong) XPWeekStarRankUserModel *firstLevelRankUser; - @property (nonatomic, weak) id delegate; @end diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPWeekStarInfoView.m b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPWeekStarInfoView.m index 4d310744..e3aff0a2 100644 --- a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPWeekStarInfoView.m +++ b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPWeekStarInfoView.m @@ -15,15 +15,6 @@ #import "XPWeekStarRankUserModel.h" @interface XPWeekStarInfoView() - -///冠名者标题 -@property (nonatomic, strong) UILabel *charmTitleLabel; -///神豪标题 -@property (nonatomic, strong) UILabel *contributeTitleLabel; -///冠名者 -@property (nonatomic, strong) UILabel *charmLabel; -///神豪 -@property (nonatomic, strong) UILabel *contributeLabel; ///周星版入口 @property (nonatomic, strong) UIButton *entranceButton; ///箭头 @@ -33,8 +24,7 @@ @implementation XPWeekStarInfoView -- (instancetype)initWithFrame:(CGRect)frame -{ +- (instancetype)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { [self initSubViews]; @@ -45,45 +35,26 @@ #pragma mark - Private Method - (void)initSubViews { - [self addSubview:self.charmTitleLabel]; - [self addSubview:self.contributeTitleLabel]; - [self addSubview:self.charmLabel]; - [self addSubview:self.contributeLabel]; [self addSubview:self.entranceButton]; [self addSubview:self.arrowImageView]; } - (void)initSubViewConstraints { - [self.charmTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.top.mas_equalTo(0); - make.height.mas_equalTo(14); - }]; - [self.charmLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(self.charmTitleLabel.mas_right); - make.centerY.mas_equalTo(self.charmTitleLabel); - }]; - - [self.contributeTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(self.charmLabel.mas_right).mas_offset(16); - make.centerY.mas_equalTo(self.charmTitleLabel); - }]; - - [self.contributeLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(self.contributeTitleLabel.mas_right); - make.centerY.mas_equalTo(self.charmTitleLabel); - }]; - + [self mas_makeConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(30); + }]; + [self.entranceButton mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(self.arrowImageView.mas_left).mas_offset(-4); make.width.mas_equalTo(48); make.height.mas_equalTo(14); - make.centerY.mas_equalTo(self.charmTitleLabel); + make.centerY.mas_equalTo(self); }]; [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(0); make.width.mas_equalTo(7); make.height.mas_equalTo(10); - make.centerY.mas_equalTo(self.charmTitleLabel); + make.centerY.mas_equalTo(self); }]; } @@ -95,70 +66,6 @@ } #pragma mark - getter and setter -- (void)setFirstCharmRankUser:(XPWeekStarRankUserModel *)firstCharmRankUser { - NSString *nickStr = firstCharmRankUser.nick; - if (firstCharmRankUser.nick.length > 5) { - nickStr = [NSString stringWithFormat:@"%@…", [firstCharmRankUser.nick substringToIndex:5]]; - } else if(!firstCharmRankUser.nick.length) { - nickStr = @""; - } - self.charmLabel.text = nickStr; - self.charmTitleLabel.text = firstCharmRankUser ? @"本周冠名者:" : @""; -} - -- (void)setFirstLevelRankUser:(XPWeekStarRankUserModel *)firstLevelRankUser { - NSString *nickStr = firstLevelRankUser.nick; - if (firstLevelRankUser.nick.length > 5) { - nickStr = [NSString stringWithFormat:@"%@…", [firstLevelRankUser.nick substringToIndex:5]]; - } else if(!firstLevelRankUser.nick.length) { - nickStr = @""; - } - self.contributeLabel.text = nickStr; - self.contributeTitleLabel.text = firstLevelRankUser ? @"周星神豪:" : @""; -} - -- (UILabel *)charmTitleLabel { - if (!_charmTitleLabel) { - UILabel *label = [[UILabel alloc] init]; - label.font = [UIFont systemFontOfSize:10]; - label.textColor = [ThemeColor giftSegmentNormalTitleColor]; - label.text = @"本周冠名者:"; - _charmTitleLabel = label; - } - return _charmTitleLabel; -} - -- (UILabel *)contributeTitleLabel { - if (!_contributeTitleLabel) { - UILabel *label = [[UILabel alloc] init]; - label.font = [UIFont systemFontOfSize:10]; - label.textColor = [ThemeColor giftSegmentNormalTitleColor]; - label.text = @"周星神豪:"; - _contributeTitleLabel = label; - } - return _contributeTitleLabel; -} - -- (UILabel *)charmLabel { - if (!_charmLabel) { - UILabel *label = [[UILabel alloc] init]; - label.font = [UIFont systemFontOfSize:10]; - label.textColor = [ThemeColor giftSegmentSelectTitleColor]; - _charmLabel = label; - } - return _charmLabel; -} - -- (UILabel *)contributeLabel { - if (!_contributeLabel) { - UILabel *label = [[UILabel alloc] init]; - label.font = [UIFont systemFontOfSize:10]; - label.textColor = [ThemeColor giftSegmentSelectTitleColor]; - _contributeLabel = label; - } - return _contributeLabel; -} - - (UIButton *)entranceButton { if (!_entranceButton) { _entranceButton = [UIButton buttonWithType:UIButtonTypeCustom];