diff --git a/xplan-ios/Global/XPConstant.m b/xplan-ios/Global/XPConstant.m index 206529d7..4a04a931 100644 --- a/xplan-ios/Global/XPConstant.m +++ b/xplan-ios/Global/XPConstant.m @@ -14,6 +14,7 @@ NSString * const kTeenagerAlertDatekey = @"kTeenagerAlertDatekey"; NSString * const kRoomMiniNotificationKey = @"RoomMiniNotificationKey"; NSString * const kRoomGiftEffectUpdateNotificationKey = @"RoomGiftEffectUpdateNotificationKey"; NSString * const kRoomRoomSettingNotificationKey = @"kRoomRoomSettingNotificationKey"; +NSString * const kHomeMoreScrollPageKey = @"kHomeMoreScrollPageKey"; ///在里面进行判断当前环境是什么 NSString * const KeyWithType(KeyType type) { BOOL isRelase = NO; diff --git a/xplan-ios/Main/Home/View/Cell/XPHomeHotRoomCollectionViewCell.m b/xplan-ios/Main/Home/View/Cell/XPHomeHotRoomCollectionViewCell.m index 3dc0300e..bf8e2f08 100644 --- a/xplan-ios/Main/Home/View/Cell/XPHomeHotRoomCollectionViewCell.m +++ b/xplan-ios/Main/Home/View/Cell/XPHomeHotRoomCollectionViewCell.m @@ -11,10 +11,10 @@ ///Tool #import "NetImageView.h" #import "ThemeColor.h" +#import "XPMacro.h" #import "UIImage+Utils.h" ///Model #import "HomeRecommendRoomModel.h" - @interface XPHomeHotRoomCollectionViewCell () ///背景 @property (nonatomic,strong) UIImageView *backImageView; @@ -32,7 +32,8 @@ @property (nonatomic,strong) UIImageView *sexImageView; ///昵称 @property (nonatomic,strong) UILabel *nickLabel; - +///水波纹动画 +@property (nonatomic,strong) UIView *rippleView; @end @implementation XPHomeHotRoomCollectionViewCell @@ -50,6 +51,7 @@ #pragma mark - Private Method - (void)initSubViews { [self.contentView addSubview:self.backImageView]; + [self.backImageView addSubview:self.rippleView]; [self.backImageView addSubview:self.roomTagImageView]; [self.backImageView addSubview:self.roomDesLabel]; [self.backImageView addSubview:self.notImageView]; @@ -57,6 +59,46 @@ [self.backImageView addSubview:self.avatarImageView]; [self.backImageView addSubview:self.sexImageView]; [self.backImageView addSubview:self.nickLabel]; + [self addAnimation]; + +} + +- (void)addAnimation { + NSInteger pulsingCount = 3; + double animationDuration = 3; + CALayer * animationLayer = [CALayer layer]; + for (int i = 0; i < pulsingCount; i++) { + CALayer * pulsingLayer = [CALayer layer]; + pulsingLayer.frame = CGRectMake(0, 0, 50, 50); + pulsingLayer.borderColor = [UIColor whiteColor].CGColor; + pulsingLayer.borderWidth = 1; + pulsingLayer.cornerRadius = 50 / 2; + + CAMediaTimingFunction * defaultCurve = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]; + + CAAnimationGroup * animationGroup = [CAAnimationGroup animation]; + animationGroup.fillMode = kCAFillModeBackwards; + animationGroup.beginTime = CACurrentMediaTime() + (double)i * animationDuration / (double)pulsingCount; + animationGroup.duration = animationDuration; + animationGroup.repeatCount = HUGE; + animationGroup.removedOnCompletion = NO; + animationGroup.timingFunction = defaultCurve; + + CABasicAnimation * scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; + scaleAnimation.fromValue = @1.4; + scaleAnimation.toValue = @3; + scaleAnimation.removedOnCompletion = NO; + + CAKeyframeAnimation * opacityAnimation = [CAKeyframeAnimation animationWithKeyPath:@"opacity"]; + opacityAnimation.values = @[@1, @0.9, @0.8, @0.7, @0.6, @0.5, @0.4, @0.3, @0.2, @0.1, @0]; + opacityAnimation.keyTimes = @[@0, @0.1, @0.2, @0.3, @0.4, @0.5, @0.6, @0.7, @0.8, @0.9, @1]; + opacityAnimation.removedOnCompletion = NO; + + animationGroup.animations = @[scaleAnimation, opacityAnimation]; + [pulsingLayer addAnimation:animationGroup forKey:@"plulsing"]; + [animationLayer addSublayer:pulsingLayer]; + } + [self.rippleView.layer addSublayer:animationLayer]; } - (void)initSubViewConstraints { @@ -94,6 +136,11 @@ make.top.mas_equalTo(self.notImageView.mas_bottom).offset(9); }]; + [self.rippleView mas_makeConstraints:^(MASConstraintMaker *make) { + make.center.mas_equalTo(self.avatarImageView); + make.size.mas_equalTo(CGSizeMake(50, 50)); + }]; + [self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.mas_equalTo(self.backImageView); @@ -146,7 +193,7 @@ config.placeHolder = [UIImageConstant defaultAvatarPlaceholder]; _avatarImageView = [[NetImageView alloc] initWithConfig:config]; _avatarImageView.layer.masksToBounds = YES; - _avatarImageView.layer.cornerRadius = 48/2; + _avatarImageView.layer.cornerRadius = 50/2; _avatarImageView.layer.borderColor = [UIColor whiteColor].CGColor; _avatarImageView.layer.borderWidth = 1.1; } @@ -205,4 +252,13 @@ return _notImageView; } +- (UIView *)rippleView { + if (!_rippleView) { + _rippleView = [[UIView alloc] init]; + _rippleView.backgroundColor = [UIColor clearColor]; + } + return _rippleView; +} + + @end diff --git a/xplan-ios/Main/Home/View/Cell/XPHomeHotRoomTableViewCell.h b/xplan-ios/Main/Home/View/Cell/XPHomeHotRoomTableViewCell.h index edee94a6..a1ef72b9 100644 --- a/xplan-ios/Main/Home/View/Cell/XPHomeHotRoomTableViewCell.h +++ b/xplan-ios/Main/Home/View/Cell/XPHomeHotRoomTableViewCell.h @@ -8,9 +8,17 @@ #import NS_ASSUME_NONNULL_BEGIN +@class XPHomeHotRoomTableViewCell, HomeRecommendRoomModel; +@protocol XPHomeHotRoomTableViewCellDelegate +- (void)xPHomeHotRoomTableViewCell:(XPHomeHotRoomTableViewCell *)view didClickItem:(HomeRecommendRoomModel *)roomInfo; + +@end @interface XPHomeHotRoomTableViewCell : UITableViewCell @property (nonatomic,strong) NSArray *hotAnchorList; +///代理 +@property (nonatomic,weak) id delegate; + @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Home/View/Cell/XPHomeHotRoomTableViewCell.m b/xplan-ios/Main/Home/View/Cell/XPHomeHotRoomTableViewCell.m index b2cceb80..bcca761b 100644 --- a/xplan-ios/Main/Home/View/Cell/XPHomeHotRoomTableViewCell.m +++ b/xplan-ios/Main/Home/View/Cell/XPHomeHotRoomTableViewCell.m @@ -61,6 +61,12 @@ - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { [collectionView deselectItemAtIndexPath:indexPath animated:YES]; + if (self.hotAnchorList.count > 0) { + HomeRecommendRoomModel * info = [self.hotAnchorList objectAtIndex:indexPath.row]; + if (self.delegate && [self.delegate respondsToSelector:@selector(xPHomeHotRoomTableViewCell:didClickItem:)]) { + [self.delegate xPHomeHotRoomTableViewCell:self didClickItem:info]; + } + } } #pragma mark - Getters And Setters diff --git a/xplan-ios/Main/Home/View/Cell/XPHomeRecommendTableViewCell.h b/xplan-ios/Main/Home/View/Cell/XPHomeRecommendTableViewCell.h index 882ff2de..3149dfaa 100644 --- a/xplan-ios/Main/Home/View/Cell/XPHomeRecommendTableViewCell.h +++ b/xplan-ios/Main/Home/View/Cell/XPHomeRecommendTableViewCell.h @@ -8,9 +8,17 @@ #import NS_ASSUME_NONNULL_BEGIN +@class XPHomeRecommendTableViewCell, HomeRecommendRoomModel; +@protocol XPHomeRecommendTableViewCellDelegate + +- (void)xPHomeRecommendTableViewCell:(XPHomeRecommendTableViewCell *)view didClickItem:(HomeRecommendRoomModel *)roomInfo; + +@end @interface XPHomeRecommendTableViewCell : UITableViewCell @property (nonatomic,strong) NSArray *recommendList; +///代理 +@property (nonatomic,weak) id delegate; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Home/View/Cell/XPHomeRecommendTableViewCell.m b/xplan-ios/Main/Home/View/Cell/XPHomeRecommendTableViewCell.m index 59ed2160..3b49508a 100644 --- a/xplan-ios/Main/Home/View/Cell/XPHomeRecommendTableViewCell.m +++ b/xplan-ios/Main/Home/View/Cell/XPHomeRecommendTableViewCell.m @@ -92,7 +92,13 @@ } #pragma mark - Event Response - (void)tapRecognizer:(UITapGestureRecognizer *)tap { - + NSInteger index = tap.view.tag - 1001; + if (index < self.recommendList.count) { + HomeRecommendRoomModel * recommend = [_recommendList objectAtIndex:index]; + if (self.delegate && [self.delegate respondsToSelector:@selector(xPHomeRecommendTableViewCell:didClickItem:)]) { + [self.delegate xPHomeRecommendTableViewCell:self didClickItem:recommend]; + } + } } #pragma mark - Getters And Setters diff --git a/xplan-ios/Main/Home/View/SubViews/XPHomeRecommendHeaderView.m b/xplan-ios/Main/Home/View/SubViews/XPHomeRecommendHeaderView.m index c9b41849..22d53480 100644 --- a/xplan-ios/Main/Home/View/SubViews/XPHomeRecommendHeaderView.m +++ b/xplan-ios/Main/Home/View/SubViews/XPHomeRecommendHeaderView.m @@ -10,6 +10,7 @@ #import ///Tool #import "XPMacro.h" +#import "XPConstant.h" ///View #import "XPHomeBannerTableViewCell.h" #import "XPHomeMenuTableViewCell.h" @@ -29,8 +30,9 @@ #define recommendHeight (230 + 11 +108) * kScreenScale #define hotRoomHeight (162 + 4) #define sectionHeight 38 +UIKIT_EXTERN NSString * kHomeMoreScrollPageKey; -@interface XPHomeRecommendHeaderView () +@interface XPHomeRecommendHeaderView () ///列表 @property (nonatomic,strong) UITableView *tableView; @end @@ -126,14 +128,18 @@ if (section == 2) { XPHomeSectionView * sectionView = [[XPHomeSectionView alloc] init]; sectionView.frame = CGRectMake(0, 0, KScreenWidth, sectionHeight); + sectionView.tag = 1000 + section; sectionView.imageName = @"home_recommend_section_logo"; sectionView.title = @"最新推荐"; + sectionView.delegate= self; return sectionView; } else if (section == 3) { XPHomeSectionView * sectionView = [[XPHomeSectionView alloc] init]; sectionView.frame = CGRectMake(0, 0, KScreenWidth, sectionHeight); sectionView.imageName = @"home_hot_section_logo"; sectionView.title = @"人气主播"; + sectionView.tag = 1000 + section; + sectionView.delegate= self; return sectionView; } return [UIView new]; @@ -169,6 +175,7 @@ cell = [[XPHomeRecommendTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPHomeRecommendTableViewCell class])]; } cell.recommendList = self.recommendList; + cell.delegate = self; return cell; } else { XPHomeHotRoomTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPHomeHotRoomTableViewCell class])]; @@ -176,6 +183,7 @@ cell = [[XPHomeHotRoomTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPHomeHotRoomTableViewCell class])]; } cell.hotAnchorList = self.hotRoomList; + cell.delegate = self; return cell; } } @@ -224,6 +232,28 @@ } } +#pragma mark - XPHomeHotRoomTableViewCellDelegate +- (void)xPHomeHotRoomTableViewCell:(XPHomeHotRoomTableViewCell *)view didClickItem:(HomeRecommendRoomModel *)roomInfo { + if (roomInfo.uid.length > 0) { + [XPRoomViewController openRoom:roomInfo.uid viewController:self.currenViewController]; + } +} + +#pragma mark - XPHomeRecommendTableViewCellDelegate +- (void)xPHomeRecommendTableViewCell:(XPHomeRecommendTableViewCell *)view didClickItem:(HomeRecommendRoomModel *)roomInfo { + if (roomInfo.roomUid.length > 0) { + [XPRoomViewController openRoom:roomInfo.roomUid viewController:self.currenViewController]; + } +} + +#pragma mark - XPHomeSectionViewDelegate +- (void)didClickXPHomeSectionView:(XPHomeSectionView *)view { + NSInteger section = view.tag - 1000; + NSString * sectionStr = [NSString stringWithFormat:@"%ld",section]; + NSDictionary * dic = @{@"section": sectionStr}; + [[NSNotificationCenter defaultCenter] postNotificationName:kHomeMoreScrollPageKey object:dic]; +} + #pragma mark - Getters And Setters - (void)setBannerList:(NSArray *)bannerList { _bannerList = bannerList; diff --git a/xplan-ios/Main/Home/View/SubViews/XPHomeSectionView.h b/xplan-ios/Main/Home/View/SubViews/XPHomeSectionView.h index e3950ca0..f57052fa 100644 --- a/xplan-ios/Main/Home/View/SubViews/XPHomeSectionView.h +++ b/xplan-ios/Main/Home/View/SubViews/XPHomeSectionView.h @@ -8,14 +8,19 @@ #import NS_ASSUME_NONNULL_BEGIN +@class XPHomeSectionView; +@protocol XPHomeSectionViewDelegate +- (void)didClickXPHomeSectionView:(XPHomeSectionView *)view; + +@end @interface XPHomeSectionView : UIView ///显示标题 @property (nonatomic,copy) NSString *title; ///显示图片的名称 @property (nonatomic,copy) NSString *imageName; -///是否隐藏logo -@property (nonatomic,assign) BOOL isHiddenLogo; +///代理 +@property (nonatomic,weak) id delegate; @end diff --git a/xplan-ios/Main/Home/View/SubViews/XPHomeSectionView.m b/xplan-ios/Main/Home/View/SubViews/XPHomeSectionView.m index 92b3124b..e640c9f8 100644 --- a/xplan-ios/Main/Home/View/SubViews/XPHomeSectionView.m +++ b/xplan-ios/Main/Home/View/SubViews/XPHomeSectionView.m @@ -24,6 +24,8 @@ @property (nonatomic,strong) UILabel *moreLabel; ///箭头 @property (nonatomic,strong) UIImageView *arrowImageView; +///点击更多 +@property (nonatomic,strong) UIControl *moreControl; @end @implementation XPHomeSectionView @@ -40,6 +42,7 @@ - (void)initSubViews { [self addSubview:self.logoStackView]; [self addSubview:self.moreStackView]; + [self addSubview:self.moreControl]; [self.logoStackView addArrangedSubview:self.logoImageView]; [self.logoStackView addArrangedSubview:self.titleLabel]; @@ -65,6 +68,17 @@ [self.arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(6, 10)); }]; + + [self.moreControl mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.bottom.right.mas_equalTo(self); + make.width.mas_equalTo(200); + }]; +} +#pragma mark - Event Response +- (void)moreControlAction:(UIControl *)sender { + if (self.delegate && [self.delegate respondsToSelector:@selector(didClickXPHomeSectionView:)]) { + [self.delegate didClickXPHomeSectionView:self]; + } } #pragma mark - Getters And Setters @@ -82,10 +96,6 @@ } } -- (void)setIsHiddenLogo:(BOOL)isHiddenLogo { - _isHiddenLogo = isHiddenLogo; - self.logoImageView.hidden = isHiddenLogo; -} - (UIStackView *)logoStackView { if (!_logoStackView) { @@ -144,5 +154,12 @@ return _titleLabel; } +- (UIControl *)moreControl { + if (!_moreControl) { + _moreControl = [[UIControl alloc] init]; + [_moreControl addTarget:self action:@selector(moreControlAction:) forControlEvents:UIControlEventTouchUpInside]; + } + return _moreControl; +} @end diff --git a/xplan-ios/Main/Home/View/XPHomeHappyViewController.m b/xplan-ios/Main/Home/View/XPHomeHappyViewController.m index d8337e43..ac0642c4 100644 --- a/xplan-ios/Main/Home/View/XPHomeHappyViewController.m +++ b/xplan-ios/Main/Home/View/XPHomeHappyViewController.m @@ -126,6 +126,17 @@ } return cell; } + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + if (self.roomList.count > 0) { + HomePlayRoomModel * model = [self.roomList objectAtIndex:indexPath.row]; + if (!model.isBanner && model.uid.integerValue > 0) { + [XPRoomViewController openRoom:model.uid viewController:self]; + } + } +} + #pragma mark - XPHomeBannerTableViewCellDelegate - (void)xPHomeBannerTableViewCell:(XPHomeBannerTableViewCell *)view didClickBanner:(HomeBannerInfoModel *)info { switch (info.skipType) { diff --git a/xplan-ios/Main/Home/View/XPHomeHotRoomViewController.m b/xplan-ios/Main/Home/View/XPHomeHotRoomViewController.m index 7491b86e..566e0ae5 100644 --- a/xplan-ios/Main/Home/View/XPHomeHotRoomViewController.m +++ b/xplan-ios/Main/Home/View/XPHomeHotRoomViewController.m @@ -14,6 +14,8 @@ ///VC #import "XPWebViewController.h" #import "XPRoomViewController.h" +///Model +#import "HomePlayRoomModel.h" @interface XPHomeHotRoomViewController () ///列表 @@ -73,7 +75,16 @@ cell = [[XPHomeListEmptyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPHomeListEmptyTableViewCell class])]; } return cell; - +} + +- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [tableView deselectRowAtIndexPath:indexPath animated:YES]; + if (self.roomList.count > 0) { + HomePlayRoomModel * model = [self.roomList objectAtIndex:indexPath.row]; + if (!model.isBanner && model.uid.integerValue > 0) { + [XPRoomViewController openRoom:model.uid viewController:self]; + } + } } #pragma mark - JXPagingViewListViewDelegate - (UIView *)listView { diff --git a/xplan-ios/Main/Home/View/XPHomeRecommendViewController.m b/xplan-ios/Main/Home/View/XPHomeRecommendViewController.m index 976aac4f..10ef8f82 100644 --- a/xplan-ios/Main/Home/View/XPHomeRecommendViewController.m +++ b/xplan-ios/Main/Home/View/XPHomeRecommendViewController.m @@ -172,6 +172,7 @@ } return (id )viewController; } + #pragma mark - JXPagerMainTableViewGestureDelegate - (BOOL)mainTableViewGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer { diff --git a/xplan-ios/Main/Home/View/XPHomeViewController.m b/xplan-ios/Main/Home/View/XPHomeViewController.m index 5bc6d09e..e6b846b3 100644 --- a/xplan-ios/Main/Home/View/XPHomeViewController.m +++ b/xplan-ios/Main/Home/View/XPHomeViewController.m @@ -13,6 +13,7 @@ #import "ThemeColor+Home.h" #import "XPMacro.h" #import "XPHtmlURL.h" +#import "XPConstant.h" ///View #import "XPHomeNavView.h" #import "XPHomeRecommendViewController.h" @@ -20,6 +21,8 @@ #import "XPHomePartyContainerViewController.h" #import "XPWebViewController.h" +UIKIT_EXTERN NSString *kHomeMoreScrollPageKey; + @interface XPHomeViewController () ///标题 @property (nonatomic,strong) NSArray *titles; @@ -52,6 +55,7 @@ self.homeNavView.titleView.delegate = self; self.homeNavView.titleView.listContainer = self.listContainerView; [self.homeNavView.titleView reloadData]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(recommendMoreNotification:) name:kHomeMoreScrollPageKey object:nil]; } - (void)initSubViewConstraints { @@ -98,6 +102,14 @@ webVC.url = URLWithType(kHomeRankURL); [self.navigationController pushViewController:webVC animated:YES]; } + +#pragma mark - Event Response +- (void)recommendMoreNotification:(NSNotification *)notification { + NSDictionary * dic = notification.object; + //TODO: 跳转对应的tad + [self.homeNavView.titleView selectItemAtIndex:1]; +} + #pragma mark - Getters And Setters - (JXCategoryListContainerView *)listContainerView { if (!_listContainerView) {