Files
peko-ios/YuMi/Modules/YMTabbar/View/PIFullScreenBannerAnimation.m
2023-07-19 14:41:04 +08:00

611 lines
28 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// PIFullScreenBannerAnimation.m
// YuMi
//
// Created by duoban on 2023/7/12.
//
#import "XPRoomAnimationView.h"
///Third
#import <Masonry/Masonry.h>
#import <SVGA.h>
#import <NIMSDK/NIMSDK.h>
#import <POP.h>
#import "QGVAPConfigModel.h"
#import "UIView+VAP.h"
#import <YYText/YYText.h>
#import <UIImageView+WebCache.h>
///Tool
#import "XPGiftStorage.h"
#import "YUMIMacroUitls.h"
#import "ThemeColor+Room.h"
#import "NetImageView.h"
#import "XPRoomGiftAnimationParser.h"
#import "XCCurrentVCStackManager.h"
#import "AccountInfoStorage.h"
#import "ClientConfig.h"
///Model
#import "MicroQueueModel.h"
#import "MicroStateModel.h"
#import "UserInfoModel.h"
#import "GiftReceiveInfoModel.h"
#import "GiftInfoModel.h"
#import "RoomInfoModel.h"
#import "AttachmentModel.h"
#import "XPGiftBigPrizeModel.h"
#import "XPGiftBannerUserInfoModel.h"
#import "GiftReceiveInfoModel.h"
#import "XPMessageRemoteExtModel.h"
#import "DatingInfoModel.h"
#import "AcrossRoomPKPrizeModel.h"
#import "RoomHalfHourRankModel.h"
#import "ClientConfig.h"
///View
#import "XPRoomGiftBannerView.h"
#import "XPRoomGiftBroadcastView.h"
#import "XPRoomCandyGiftView.h"
#import "XPRoomDatingAnimationView.h"
#import "XPRoomNobleLevelUpView.h"
#import "QGVAPWrapView.h"
#import "XPAcrossRoomPKPrizeView.h"
#import "XPRoomViewController.h"
#import "XPRoomAnchorRankBannerView.h"
#import "XPRoomEnterHideTipView.h"
#import "XPRoomLicneseHourRankView.h"
#import "XPRoomLuckyBigPrizeView.h"
#import "XPRoomGiftCompoundView.h"
#import "XPSailingAnimationView.h"
#import "XPRoomGraffitiGiftAnimationView.h"
#import "XPRoomStarKitchenBannerView.h"
#import "XPWebViewController.h"
#import "PIBaseAnimationViewModel.h"
#import "PIFullScreenBannerAnimation.h"
#import "XPSkillCardPlayerManager.h"
@interface PIFullScreenBannerAnimation()<XPRoomGiftBroadcastViewDelegate,XPRoomLuckyBigPrizeViewDelegate,XPRoomLicneseHourRankViewDelegate, XPRoomStarKitchenBannerViewDelegate>
///礼物飘屏 PresentAchieveAbstractMatrix
@property(nonatomic,strong) NSMutableArray<GiftReceiveInfoModel *> *animationListA;
///玩法飘屏 YUMIPresentBigCaptureMatrix
@property(nonatomic,strong) NSMutableArray<PIBaseAnimationViewModel *> *animationListB;
///礼物飘屏正在播放中
@property(nonatomic,assign) BOOL isPlayOfA;
///玩法飘屏正在播放中
@property(nonatomic,assign) BOOL isPlayOfB;
///animationListA播放完后如果有animationListB那么要在animationListA的位置上播放animationListB只播放一次
@property(nonatomic,assign) BOOL isAnimationListAFinish;
@end
@implementation PIFullScreenBannerAnimation
- (void)createGiftBroadcastViewAnimation:(GiftReceiveInfoModel *)giftModel {
self.isPlayOfA = YES;
XPRoomGiftBroadcastView * view = [[XPRoomGiftBroadcastView alloc] init];
view.delegate = self;
view.frame = CGRectMake(KScreenWidth, 35 + statusbarHeight, KScreenWidth, 150);
view.broadcastModel = giftModel;
[kWindow addSubview:view];
[self beginGiftBraodcastViewAnimation:view notifyStaySecond:giftModel.notifyStaySecond];
}
- (void)beginGiftBraodcastViewAnimation:(XPRoomGiftBroadcastView *)view notifyStaySecond:(int)notifyStaySecond{
CGFloat startTime = notifyStaySecond > 0 ? notifyStaySecond : 3.0;
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
springAnimation.springSpeed = 12;
springAnimation.springBounciness = 10.f;
springAnimation.fromValue = [NSValue valueWithCGPoint:view.center];
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0 + view.frame.size.width / 2, view.center.y)];
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) {
[self removeGiftBroadcastOutAnimation:view stayTime:startTime];
}
}];
[view pop_addAnimation:springAnimation forKey:@"spingOutAnimation"];
}
- (void)removeGiftBroadcastOutAnimation:(XPRoomGiftBroadcastView *)view stayTime:(CGFloat)stayTime{
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
moveAnimation.fromValue = [NSValue valueWithCGPoint:view.center];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, view.center.y)];
moveAnimation.beginTime = CACurrentMediaTime() + stayTime;
moveAnimation.duration = 0.5;
moveAnimation.repeatCount = 1;
moveAnimation.removedOnCompletion = YES;
@kWeakify(self);
[moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
@kStrongify(self);
if (finished) {
[view removeFromSuperview];
self.isPlayOfA = NO;
if (self.animationListA.count > 0) {
[self.animationListA removeObjectAtIndex:0];
}
if (self.animationListA.count > 0 && self.isPlayOfB == NO && self.isPlayOfA == NO) {
[self createGiftBroadcastViewAnimation:self.animationListA.firstObject];
}
}
}];
[view pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
/// 点击了关闭
- (void)xPRoomGiftBroadcastView:(XPRoomGiftBroadcastView *)view didClickClose:(GiftReceiveInfoModel *)broadcastModel{
[view removeFromSuperview];
[view pop_removeAllAnimations];
self.isPlayOfA = NO;
if (self.animationListA.count > 0) {
[self.animationListA removeObjectAtIndex:0];
}
if (self.animationListA.count > 0 && self.isPlayOfB == NO && self.isPlayOfA == NO) {
[self createGiftBroadcastViewAnimation:self.animationListA.firstObject];
}
}
///点击了进入房间
- (void)xPRoomGiftBroadcastView:(XPRoomGiftBroadcastView *)view enterRoom:(NSString *)roomUid{
if (roomUid.length > 0) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.7 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[XPRoomViewController openRoom:roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
});
}
}
///收到了礼物
- (void)receiveGift:(GiftReceiveInfoModel *)receiveInfo {
///CPU警告的时候 需要停止接收动画
GiftReceiveInfoModel *giftNotifyInfo = receiveInfo;
if (self.animationListA.count == 0 && self.isPlayOfB == NO && self.isPlayOfA == NO) {
[self createGiftBroadcastViewAnimation:giftNotifyInfo];
}
[self.animationListA addObject:giftNotifyInfo];
}
-(void)playAnimationACompletion{
PIBaseAnimationViewModel *model = self.animationListB.firstObject;
if(model.type == GiftBannerType_Lucky){
[self createBigPrizeAnimation:model];
}else if (model.type == GiftBannerType_Love){
[self createCandyTreeBannerAnimation:model];
}else if(model.type == GiftBannerType_Nobleman){
[self createNobleLevelUpBannerAnimation:model];
}else if(model.type == GiftBannerType_kitchen){
[self createStarKitchenBannerAnimation:model];
}else if(model.type == GiftBannerType_AnchorHour){
[self createAnchorHourRankAnimation:model];
}else if(model.type == GiftBannerType_LicneseHour){
[self createLicneseHourRankAnimation:model];
}
}
-(void)playAnimationWithModel{
if(self.isAnimationListAFinish == YES)return;
if(self.animationListB.count <= 0){
if(self.animationListA.count > 0 && self.isPlayOfB == NO && self.isPlayOfA == NO){
[self createGiftBroadcastViewAnimation:self.animationListA.firstObject];
}
return;
}
if(self.isPlayOfB == YES)return;
PIBaseAnimationViewModel *model = self.animationListB.firstObject;
if(model.type == GiftBannerType_Lucky){
[self createBigPrizeAnimation:model];
}else if (model.type == GiftBannerType_Love){
[self createCandyTreeBannerAnimation:model];
}else if(model.type == GiftBannerType_Nobleman){
[self createNobleLevelUpBannerAnimation:model];
}else if(model.type == GiftBannerType_kitchen){
[self createStarKitchenBannerAnimation:model];
}else if(model.type == GiftBannerType_AnchorHour){
[self createAnchorHourRankAnimation:model];
}else if(model.type == GiftBannerType_LicneseHour){
[self createLicneseHourRankAnimation:model];
}
}
#pragma mark - 福袋中 四级奖品
- (void)receiveLuckyGiftBigPrize:(AttachmentModel *)attachment {
if ( attachment.second == Custom_Message_Sub_Room_Gift_LuckBag_FullScree) {
PIBaseAnimationViewModel * prizeModel = [PIBaseAnimationViewModel modelWithDictionary:attachment.data];
prizeModel.type = GiftBannerType_Lucky;
prizeModel.isInRoomVisiable = attachment.second == Custom_Message_Sub_Room_Gift_LuckBag;
if(self.animationListB.count == 0 && self.isPlayOfB == NO){
[self createBigPrizeAnimation:prizeModel];
}
[self.animationListB addObject:prizeModel];
}
}
- (void)createBigPrizeAnimation:(PIBaseAnimationViewModel *)prizeModel {
self.isPlayOfB = YES;
CGFloat top = 0 ;
if([XPSkillCardPlayerManager shareInstance].isInRoom == YES){
top = self.isPlayOfA == YES ? 240 : (kNavigationHeight + 15);
}else{
top = self.isPlayOfA == YES ? 225 - kSafeAreaTopHeight : (kSafeAreaTopHeight + 15);
}
XPRoomLuckyBigPrizeView * luckyGiftEffectView = [[XPRoomLuckyBigPrizeView alloc] initWithFrame:CGRectMake(KScreenWidth, top, 375, 60)];
luckyGiftEffectView.delegate = self;
[kWindow addSubview:luckyGiftEffectView];
luckyGiftEffectView.giftInfo = prizeModel;
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
springAnimation.springSpeed = 12;
springAnimation.springBounciness = 10.f;
springAnimation.fromValue = [NSValue valueWithCGPoint:luckyGiftEffectView.center];
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(KScreenWidth / 2, luckyGiftEffectView.center.y)];
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) {
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(KScreenWidth / 2, luckyGiftEffectView.center.y)];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth, luckyGiftEffectView.center.y)];
moveAnimation.beginTime = CACurrentMediaTime() + 3;
moveAnimation.duration = 0.5;
moveAnimation.repeatCount = 1;
moveAnimation.removedOnCompletion = YES;
[moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
[luckyGiftEffectView removeFromSuperview];
if (self.animationListB.count > 0) {
[self.animationListB removeObjectAtIndex:0];
}
self.isPlayOfB = NO;
if(self.isAnimationListAFinish == YES){
self.isAnimationListAFinish = NO;
[self playAnimationWithModel];
return;
}
[self playAnimationWithModel];
}];
[luckyGiftEffectView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
}];
[luckyGiftEffectView pop_addAnimation:springAnimation forKey:@"nobleLevelUpspingOutAnimation"];
}
#pragma mark - XPRoomLuckyBigPrizeViewDelegate
- (void)xPRoomLuckyBigPrizeView:(XPRoomLuckyBigPrizeView *)view luckyGiftInfo:(PIBaseAnimationViewModel *)giftInfo {
if (!giftInfo.isInRoomVisiable && giftInfo.roomUid.length > 0 ) {
[XPRoomViewController openRoom:giftInfo.roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
}
}
#pragma mark - 糖果树横幅动画
- (void)receiveCandyTreeGiftHighLevle:(AttachmentModel *)attatchment {
PIBaseAnimationViewModel *giftModel = [PIBaseAnimationViewModel new];
giftModel.data = attatchment.data;
giftModel.second = attatchment.second;
giftModel.first = attatchment.first;
giftModel.type = GiftBannerType_Love;
if (self.animationListB.count == 0 && self.isPlayOfB == NO) {
[self createCandyTreeBannerAnimation:giftModel];
}
[self.animationListB addObject:giftModel];
}
- (void)createCandyTreeBannerAnimation:(PIBaseAnimationViewModel *)attatchment {
CGFloat kscale = (CGFloat)60 / (CGFloat)375;
self.isPlayOfB = YES;
CGFloat top = 0 ;
if([XPSkillCardPlayerManager shareInstance].isInRoom == YES){
top = self.isPlayOfA == YES ? 240 : (kNavigationHeight + 15);
}else{
top = self.isPlayOfA == YES ? 225 - kSafeAreaTopHeight : (kSafeAreaTopHeight + 15);
}
XPRoomCandyGiftView *candyTreeView = [[XPRoomCandyGiftView alloc] initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth , KScreenWidth * kscale)];
candyTreeView.isMaxLargeGift = attatchment.second == Custom_Message_Sub_Candy_Tree_InRoom_NeedAllMicSend;
candyTreeView.candyInfo = attatchment.data;
[kWindow addSubview:candyTreeView];
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
springAnimation.springSpeed = 12;
springAnimation.springBounciness = 10.f;
springAnimation.fromValue = [NSValue valueWithCGPoint:candyTreeView.center];
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(candyTreeView.frame.size.width / 2, candyTreeView.center.y)];
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) {
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, candyTreeView.center.y)];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, candyTreeView.center.y)];
moveAnimation.beginTime = CACurrentMediaTime() + 3;
moveAnimation.duration = 0.5;
moveAnimation.repeatCount = 1;
moveAnimation.removedOnCompletion = YES;
@kWeakify(self);
[moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
@kStrongify(self);
if (finished) {
[candyTreeView removeFromSuperview];
self.isPlayOfB = NO;
if (self.animationListB.count > 0) {
[self.animationListB removeObjectAtIndex:0];
}
if(self. isAnimationListAFinish == YES){
[self playAnimationWithModel];
self.isAnimationListAFinish = NO;
return;
}
[self playAnimationWithModel];
}
}];
[candyTreeView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
}];
[candyTreeView pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"];
}
#pragma mark - 贵族升级
- (void)receiveNobleLevelUp:(AttachmentModel *)attachment {
PIBaseAnimationViewModel *nobleModel = [PIBaseAnimationViewModel new];
nobleModel.data = attachment.data;
nobleModel.type = GiftBannerType_Nobleman;
if (self.animationListB.count == 0 && self.isPlayOfB == NO) {
[self createNobleLevelUpBannerAnimation:nobleModel];
}
[self.animationListB addObject:nobleModel];
}
- (void)createNobleLevelUpBannerAnimation:(PIBaseAnimationViewModel *)model {
self.isPlayOfB = YES;
CGFloat top = 0 ;
if([XPSkillCardPlayerManager shareInstance].isInRoom == YES){
top = self.isPlayOfA == YES ? 240 : (kNavigationHeight + 15);
}else{
top = self.isPlayOfA == YES ? 225 - kSafeAreaTopHeight : (kSafeAreaTopHeight + 15);
}
XPRoomNobleLevelUpView *nobleLevelUpView = [[XPRoomNobleLevelUpView alloc] initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth, 90)];
nobleLevelUpView.nobleInfo = model.data;
[kWindow addSubview:nobleLevelUpView];
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
springAnimation.springSpeed = 12;
springAnimation.springBounciness = 10.f;
springAnimation.fromValue = [NSValue valueWithCGPoint:nobleLevelUpView.center];
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(nobleLevelUpView.frame.size.width / 2, nobleLevelUpView.center.y)];
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) {
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, nobleLevelUpView.center.y)];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, nobleLevelUpView.center.y)];
moveAnimation.beginTime = CACurrentMediaTime() + 3;
moveAnimation.duration = 0.5;
moveAnimation.repeatCount = 1;
moveAnimation.removedOnCompletion = YES;
@kWeakify(self);
[moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
@kStrongify(self);
if (finished) {
self.isPlayOfB = NO;
[nobleLevelUpView removeFromSuperview];
if (self.animationListB.count > 0) {
[self.animationListB removeObjectAtIndex:0];
}
if(self.isAnimationListAFinish == YES){
[self playAnimationWithModel];
self.isAnimationListAFinish = NO;
return;
}
[self playAnimationWithModel];
}
}];
[nobleLevelUpView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
}];
[nobleLevelUpView pop_addAnimation:springAnimation forKey:@"nobleLevelUpspingOutAnimation"];
}
#pragma mark - 收到星级厨房飘屏
-(void)receiveRoomGraffitiStarKitchen:(AttachmentModel *)attacment{
PIBaseAnimationViewModel *roomGraffiti = [PIBaseAnimationViewModel new];
roomGraffiti.data = attacment.data;
roomGraffiti.type = GiftBannerType_kitchen;
if(self.animationListB.count == 0 && self.isPlayOfB == NO){
[self createStarKitchenBannerAnimation:roomGraffiti];
}
[self.animationListB addObject:roomGraffiti];
}
- (void)createStarKitchenBannerAnimation:(PIBaseAnimationViewModel *)attacment{
self.isPlayOfB = YES;
CGFloat top = 0 ;
if([XPSkillCardPlayerManager shareInstance].isInRoom == YES){
top = self.isPlayOfA == YES ? 240 : (kNavigationHeight + 15);
}else{
top = self.isPlayOfA == YES ? 225 - kSafeAreaTopHeight : (kSafeAreaTopHeight + 15);
}
XPRoomStarKitchenBannerView *starKitchenView = [[XPRoomStarKitchenBannerView alloc]initWithFrame:CGRectMake(0, top, KScreenWidth, kGetScaleWidth(60))];
starKitchenView.isSvga = attacment.second == Custom_Message_Sub_Star_Kitchen_Server;
XPRoomStarKitchenModel *starModel = [XPRoomStarKitchenModel modelWithDictionary:attacment.data];
starKitchenView.delegate = self;
starKitchenView.starModel = starModel;
[kWindow addSubview:starKitchenView];
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
springAnimation.springSpeed = 12;
springAnimation.springBounciness = 10.f;
springAnimation.fromValue = [NSValue valueWithCGPoint:starKitchenView.center];
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(starKitchenView.frame.size.width / 2, starKitchenView.center.y)];
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) {
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, starKitchenView.center.y)];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, starKitchenView.center.y)];
moveAnimation.beginTime = CACurrentMediaTime() + 3;
moveAnimation.duration = 0.5;
moveAnimation.repeatCount = 1;
moveAnimation.removedOnCompletion = YES;
@kWeakify(self);
[moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
@kStrongify(self);
if (finished) {
[starKitchenView removeFromSuperview];
self.isPlayOfB = NO;
if(self.animationListB.count > 0){
[self.animationListB removeObjectAtIndex:0];
}
if(self. isAnimationListAFinish == YES){
[self playAnimationWithModel];
self.isAnimationListAFinish = NO;
return;
}
[self playAnimationWithModel];
}
}];
[starKitchenView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
}];
[starKitchenView pop_addAnimation:springAnimation forKey:@"starKitchenOutAnimation"];
}
#pragma mark - XPRoomStarKitchenBannerViewDelegate
- (void)xPRoomStarKitchenBannerView:(XPRoomStarKitchenBannerView *)view didClick:(XPRoomStarKitchenModel *)starModel{
if(starModel.skipUrl == nil || starModel.skipUrl.length == 0)return;
XPWebViewController * webVC = [[XPWebViewController alloc] init];
webVC.isPush = YES;
webVC.roomUid = starModel.roomUid;
webVC.url = starModel.skipUrl;
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:webVC animated:YES];
}
#pragma mark - 牌照房小时榜飘屏
- (void)receiveLicneseHourRank:(AttachmentModel *)attachment {
PIBaseAnimationViewModel *licneseModel =[PIBaseAnimationViewModel new];
licneseModel.data = attachment.data;
licneseModel.type = GiftBannerType_AnchorHour;
if(self.animationListB.count == 0 && self.isPlayOfB == NO){
[self createLicneseHourRankAnimation:licneseModel];
}
[self.animationListB addObject:licneseModel];
}
- (void)createLicneseHourRankAnimation:(PIBaseAnimationViewModel *)attachment {
self.isPlayOfB = YES;
CGFloat top = 0 ;
if([XPSkillCardPlayerManager shareInstance].isInRoom == YES){
top = self.isPlayOfA == YES ? 240 : (kNavigationHeight + 15);
}else{
top = self.isPlayOfA == YES ? 225 - kSafeAreaTopHeight : (kSafeAreaTopHeight + 15);
} XPRoomLicneseHourRankView *anchorRankView = [[XPRoomLicneseHourRankView alloc] initWithFrame:CGRectMake(KScreenWidth, top, 375, 60)];
anchorRankView.delegate = self;
anchorRankView.licneseRankInfo = [RoomHalfHourRankModel modelWithDictionary:attachment.data];
[kWindow addSubview:anchorRankView];
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
springAnimation.springSpeed = 12;
springAnimation.springBounciness = 10.f;
springAnimation.fromValue = [NSValue valueWithCGPoint:anchorRankView.center];
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(KScreenWidth / 2, anchorRankView.center.y)];
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) {
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(KScreenWidth / 2, anchorRankView.center.y)];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth, anchorRankView.center.y)];
moveAnimation.beginTime = CACurrentMediaTime() + 3;
moveAnimation.duration = 0.5;
moveAnimation.repeatCount = 1;
moveAnimation.removedOnCompletion = YES;
[moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
[anchorRankView removeFromSuperview];
self.isPlayOfB = NO;
if(self.animationListB.count > 0){
[self.animationListB removeObjectAtIndex:0];
}
if(self.isAnimationListAFinish == YES){
self.isAnimationListAFinish = NO;
[self playAnimationWithModel];
return;
}
[self playAnimationWithModel];
}];
[anchorRankView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
}];
[anchorRankView pop_addAnimation:springAnimation forKey:@"nobleLevelUpspingOutAnimation"];
}
- (void)xPRoomLicneseHourRankView:(XPRoomLicneseHourRankView *)view rankInfo:(RoomHalfHourRankModel *)rankInfo {
[XPRoomViewController openRoom:rankInfo.uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
}
#pragma mark - 个播小时榜飘屏
- (void)receiveAnchorHourRank:(AttachmentModel *)attachment {
PIBaseAnimationViewModel *anchorModel =[PIBaseAnimationViewModel new];
anchorModel.data = attachment.data;
anchorModel.type = GiftBannerType_AnchorHour;
if(self.animationListB.count == 0 && self.isPlayOfB == NO){
[self createAnchorHourRankAnimation:anchorModel];
}
[self.animationListB addObject:anchorModel];
}
- (void)createAnchorHourRankAnimation:(PIBaseAnimationViewModel *)attachment {
self.isPlayOfB = YES;
CGFloat top = 0 ;
if([XPSkillCardPlayerManager shareInstance].isInRoom == YES){
top = self.isPlayOfA == YES ? 240 : (kNavigationHeight + 15);
}else{
top = self.isPlayOfA == YES ? 225 - kSafeAreaTopHeight : (kSafeAreaTopHeight + 15);
} XPRoomAnchorRankBannerView *anchorRankView = [[XPRoomAnchorRankBannerView alloc] initWithFrame:CGRectMake(KScreenWidth,top, KScreenWidth, 60)];
anchorRankView.anchorRankInfo = [RoomHalfHourRankModel modelWithDictionary:attachment.data];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(gotoTopRankAnchorRoom:)];
[anchorRankView addGestureRecognizer:tap];
[kWindow addSubview:anchorRankView];
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
springAnimation.springSpeed = 12;
springAnimation.springBounciness = 10.f;
springAnimation.fromValue = [NSValue valueWithCGPoint:anchorRankView.center];
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(anchorRankView.frame.size.width / 2, anchorRankView.center.y)];
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) {
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, anchorRankView.center.y)];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, anchorRankView.center.y)];
moveAnimation.beginTime = CACurrentMediaTime() + 3;
moveAnimation.duration = 0.5;
moveAnimation.repeatCount = 1;
moveAnimation.removedOnCompletion = YES;
[moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
[anchorRankView removeFromSuperview];
self.isPlayOfB = NO;
if(self.animationListB.count > 0){
[self.animationListB removeObjectAtIndex:0];
}
if(self.isAnimationListAFinish == YES){
self.isAnimationListAFinish = NO;
[self playAnimationWithModel];
return;
}
[self playAnimationWithModel];
}];
[anchorRankView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
}];
[anchorRankView pop_addAnimation:springAnimation forKey:@"nobleLevelUpspingOutAnimation"];
}
- (void)gotoTopRankAnchorRoom:(UITapGestureRecognizer *)tap {
XPRoomAnchorRankBannerView * view = (XPRoomAnchorRankBannerView *)tap.view;
if (view.anchorRankInfo.uid.integerValue > 0) {
[XPRoomViewController openRoom:view.anchorRankInfo.uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
}
}
#pragma mark - 懒加载
- (NSMutableArray *)animationListA{
if(!_animationListA){
_animationListA = [NSMutableArray array];
}
return _animationListA;
}
- (NSMutableArray *)animationListB{
if(!_animationListB){
_animationListB = [NSMutableArray array];
}
return _animationListB;
}
@end