Files
peko-ios/YuMi/Modules/YMTabbar/View/PIFullScreenBannerAnimation.m

749 lines
36 KiB
Mathematica
Raw Normal View History

2023-07-14 18:50:55 +08:00
//
// 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"
2023-10-28 04:46:10 +08:00
2023-07-14 18:50:55 +08:00
#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 "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"
2023-08-16 14:21:58 +08:00
#import "XPTreasureFairyGiftView.h"
2023-09-14 11:16:47 +08:00
#import "XPRoomTarrowBannerView.h"
2023-10-24 12:27:53 +08:00
#import "PIRoomGiftBroadcastWindow.h"
@interface PIFullScreenBannerAnimation()<XPRoomGiftBroadcastViewDelegate,XPRoomLuckyBigPrizeViewDelegate, XPRoomStarKitchenBannerViewDelegate,XPRoomAnchorRankBannerViewDelegate,PIRoomGiftBroadcastWindowDelegate>
2023-07-14 18:50:55 +08:00
/// PresentAchieveAbstractMatrix
@property(nonatomic,strong) NSMutableArray<GiftReceiveInfoModel *> *animationListA;
/// YUMIPresentBigCaptureMatrix
@property(nonatomic,strong) NSMutableArray<PIBaseAnimationViewModel *> *animationListB;
///
@property(nonatomic,assign) BOOL isPlayOfA;
///
@property(nonatomic,assign) BOOL isPlayOfB;
///animationListAanimationListBanimationListAanimationListB
2023-07-21 18:53:10 +08:00
//@property(nonatomic,assign) BOOL isAnimationListAFinish;
2023-10-24 12:27:53 +08:00
@property(nonatomic,assign) CGFloat broadCastHieght;
2023-07-14 18:50:55 +08:00
@end
@implementation PIFullScreenBannerAnimation
- (void)createGiftBroadcastViewAnimation:(GiftReceiveInfoModel *)giftModel {
self.isPlayOfA = YES;
XPRoomGiftBroadcastView * view = [[XPRoomGiftBroadcastView alloc] init];
view.delegate = self;
2023-10-24 12:27:53 +08:00
view.frame = CGRectMake(KScreenWidth, 35 + statusbarHeight, KScreenWidth, kGetScaleWidth(69));
2023-07-14 18:50:55 +08:00
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];
}
2023-07-21 18:53:10 +08:00
if(self.animationListB.count > 0){
// self.isAnimationListAFinish = YES;
[self playAnimationWithModel];
return;
}
2023-07-14 18:50:55 +08:00
if (self.animationListA.count > 0 && self.isPlayOfB == NO && self.isPlayOfA == NO) {
[self createGiftBroadcastViewAnimation:self.animationListA.firstObject];
}
}
}];
[view pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
2023-10-24 12:27:53 +08:00
///
- (void)xPRoomGiftBroadcastView:(XPRoomGiftBroadcastView *)view enterRoom:(NSString *)roomUid roomName:(NSString *)roomName{
id isShowBroadcastView = [[NSUserDefaults standardUserDefaults]valueForKey:@"kSaveBrooadcastSelectState"];
if(isShowBroadcastView == nil){
PIRoomGiftBroadcastWindow *broadcastView = [[PIRoomGiftBroadcastWindow alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
broadcastView.roodUid = roomUid;
broadcastView.roomName = roomName;
broadcastView.delegate = self;
[kWindow addSubview:broadcastView];
return;
2023-07-14 18:50:55 +08:00
}
2023-10-24 12:27:53 +08:00
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];
});
2023-07-14 18:50:55 +08:00
}
}
2023-10-24 12:27:53 +08:00
#pragma mark -PIRoomGiftBroadcastWindowDelegate
-(void)confirmLeaveForTheRoom:(NSString *_Nonnull)roomUid{
2023-07-14 18:50:55 +08:00
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){
2023-09-25 16:02:57 +08:00
[self createAnchorHourRankAnimation:model];
2023-08-16 14:21:58 +08:00
}else if(model.type == GiftBannerType_Fairy){
[self createTreasureFairyBannerAnimation:model];
2023-09-14 11:16:47 +08:00
}else if(model.type == GiftBannerType_Tarrow){
[self createBigPrizeAnimation:model];
}else if(model.type == GiftBannerType_Common_H5){
[self createCommonH5BannerAnimation:model];
2023-07-14 18:50:55 +08:00
}
}
-(void)playAnimationWithModel{
2023-07-21 18:53:10 +08:00
// if(self.isAnimationListAFinish == YES)return;
2023-07-14 18:50:55 +08:00
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){
2023-09-25 16:02:57 +08:00
[self createAnchorHourRankAnimation:model];
2023-08-16 14:21:58 +08:00
}else if(model.type == GiftBannerType_Fairy){
[self createTreasureFairyBannerAnimation:model];
2023-09-14 11:16:47 +08:00
}else if(model.type == GiftBannerType_Tarrow){
[self createBigPrizeAnimation:model];
}else if(model.type == GiftBannerType_Common_H5){
[self createCommonH5BannerAnimation:model];
2023-07-14 18:50:55 +08:00
}
}
2023-09-14 11:16:47 +08:00
#pragma mark - h5
-(void)receiveCommonH5Banner:(AttachmentModel *)attachment{
PIBaseAnimationViewModel *giftNotifyInfo = [PIBaseAnimationViewModel modelWithJSON:attachment.data];
giftNotifyInfo.type = GiftBannerType_Common_H5;
giftNotifyInfo.second = attachment.second;
if (self.animationListB.count == 0 && self.isPlayOfB == NO) {
[self createCommonH5BannerAnimation:giftNotifyInfo];
}
[self.animationListB addObject:giftNotifyInfo];
}
- (void)createCommonH5BannerAnimation:(PIBaseAnimationViewModel *)attatchment {
CGFloat kscale = (CGFloat)55 / (CGFloat)375;
self.isPlayOfB = YES;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-09-20 18:38:51 +08:00
2023-09-14 11:16:47 +08:00
XPRoomTarrowBannerView *tarrowVeiw = [[XPRoomTarrowBannerView alloc]initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth , KScreenWidth * kscale)isH5:YES];
tarrowVeiw.isBig = attatchment.second == Custom_Message_Sub_Common_H5_Advanced;
2023-09-15 16:08:43 +08:00
tarrowVeiw.giftH5Info = attatchment;
2023-09-14 11:16:47 +08:00
[kWindow addSubview:tarrowVeiw];
2023-09-20 18:38:51 +08:00
2023-09-14 11:16:47 +08:00
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
springAnimation.springSpeed = 12;
springAnimation.springBounciness = 10.f;
springAnimation.fromValue = [NSValue valueWithCGPoint:tarrowVeiw.center];
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(tarrowVeiw.frame.size.width / 2, tarrowVeiw.center.y)];
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) {
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, tarrowVeiw.center.y)];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2,tarrowVeiw.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) {
[tarrowVeiw 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];
}
}];
[tarrowVeiw pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
}];
[tarrowVeiw pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"];
}
#pragma mark -
-(void)receiveTarotBanner:(AttachmentModel *)attachment{
PIBaseAnimationViewModel *giftNotifyInfo = [PIBaseAnimationViewModel modelWithJSON:attachment.data];
giftNotifyInfo.type = GiftBannerType_Tarrow;
giftNotifyInfo.second = attachment.second;
if (self.animationListB.count == 0 && self.isPlayOfB == NO) {
[self createTarotBannerAnimation:giftNotifyInfo];
}
[self.animationListB addObject:giftNotifyInfo];
}
- (void)createTarotBannerAnimation:(PIBaseAnimationViewModel *)attatchment {
CGFloat kscale = (CGFloat)55 / (CGFloat)375;
self.isPlayOfB = YES;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-09-14 11:16:47 +08:00
XPRoomTarrowBannerView *tarrowVeiw = [[XPRoomTarrowBannerView alloc]initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth , KScreenWidth * kscale) isH5:NO];
tarrowVeiw.isBig = attatchment.second == Custom_Message_Sub_Tarot_Advanced;
tarrowVeiw.giftInfo = attatchment;
[kWindow addSubview:tarrowVeiw];
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
springAnimation.springSpeed = 12;
springAnimation.springBounciness = 10.f;
springAnimation.fromValue = [NSValue valueWithCGPoint:tarrowVeiw.center];
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(tarrowVeiw.frame.size.width / 2, tarrowVeiw.center.y)];
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) {
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, tarrowVeiw.center.y)];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2,tarrowVeiw.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) {
[tarrowVeiw 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];
}
}];
[tarrowVeiw pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
}];
[tarrowVeiw pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"];
}
2023-08-16 14:21:58 +08:00
#pragma mark -
- (void)receiveTreasureFairyGiftHighLevel:(AttachmentModel *)attatchment {
PIBaseAnimationViewModel *giftModel = [PIBaseAnimationViewModel new];
giftModel.data = attatchment.data;
giftModel.second = attatchment.second;
giftModel.first = attatchment.first;
giftModel.type = GiftBannerType_Fairy;
if (self.animationListB.count == 0 && self.isPlayOfB == NO) {
[self createTreasureFairyBannerAnimation:giftModel];
}
[self.animationListB addObject:giftModel];
}
- (void)createTreasureFairyBannerAnimation:(PIBaseAnimationViewModel *)attatchment {
CGFloat kscale = (CGFloat)60 / (CGFloat)375;
self.isPlayOfB = YES;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-08-16 14:21:58 +08:00
XPTreasureFairyGiftView *treasureView = [[XPTreasureFairyGiftView alloc] initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth , KScreenWidth * kscale)];
//
if ((attatchment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5) || (attatchment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L3)) {
treasureView.isMaxLargeGift = YES;
}else{
treasureView.isMaxLargeGift = NO;
}
if ((attatchment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L4) || (attatchment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5)) {
treasureView.isDrawGift = YES; //
}else{
treasureView.isDrawGift = NO; //
}
treasureView.treasureInfo = attatchment.data;
[kWindow addSubview:treasureView];
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
springAnimation.springSpeed = 12;
springAnimation.springBounciness = 10.f;
springAnimation.fromValue = [NSValue valueWithCGPoint:treasureView.center];
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(treasureView.frame.size.width / 2, treasureView.center.y)];
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
if (finished) {
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, treasureView.center.y)];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(-KScreenWidth/2, treasureView.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) {
[treasureView 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];
}
}];
[treasureView pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
}];
[treasureView pop_addAnimation:springAnimation forKey:@"candyTreespingOutAnimation"];
}
2023-07-14 18:50:55 +08:00
#pragma mark -
- (void)receiveLuckyGiftBigPrize:(AttachmentModel *)attachment {
2023-07-18 18:26:10 +08:00
if ( attachment.second == Custom_Message_Sub_Room_Gift_LuckBag_FullScree) {
2023-07-14 18:50:55 +08:00
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;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-07-14 18:50:55 +08:00
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;
2023-07-21 18:53:10 +08:00
// if(self.isAnimationListAFinish == YES){
// self.isAnimationListAFinish = NO;
// [self playAnimationWithModel];
// return;
// }
2023-07-14 18:50:55 +08:00
[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;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-07-14 18:50:55 +08:00
XPRoomCandyGiftView *candyTreeView = [[XPRoomCandyGiftView alloc] initWithFrame:CGRectMake(KScreenWidth, top, KScreenWidth , KScreenWidth * kscale)];
candyTreeView.isMaxLargeGift = attatchment.second == Custom_Message_Sub_Look_Love_InRoom_NeedAllMicSend;
2023-07-14 18:50:55 +08:00
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];
}
2023-07-21 18:53:10 +08:00
// if(self. isAnimationListAFinish == YES){
//
// [self playAnimationWithModel];
// self.isAnimationListAFinish = NO;
// return;
// }
2023-07-14 18:50:55 +08:00
[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;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-07-14 18:50:55 +08:00
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];
2023-07-19 14:41:04 +08:00
if (self.animationListB.count > 0) {
2023-07-14 18:50:55 +08:00
[self.animationListB removeObjectAtIndex:0];
}
2023-07-21 18:53:10 +08:00
// if(self.isAnimationListAFinish == YES){
//
// [self playAnimationWithModel];
// self.isAnimationListAFinish = NO;
// return;
// }
2023-07-14 18:50:55 +08:00
[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;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-07-14 18:50:55 +08:00
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];
}
2023-07-21 18:53:10 +08:00
// if(self. isAnimationListAFinish == YES){
//
// [self playAnimationWithModel];
// self.isAnimationListAFinish = NO;
// return;
// }
2023-07-14 18:50:55 +08:00
[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];
}
2023-09-25 16:02:57 +08:00
#pragma mark - XPRoomAnchorRankBannerViewDelegate
- (void)xPRoomAnchorRankBannerView:(XPRoomAnchorRankBannerView *)view rankInfo:(RoomHalfHourRankModel *)rankInfo{
[XPRoomViewController openRoom:rankInfo.uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
}
#pragma mark -
2023-07-14 18:50:55 +08:00
- (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;
2023-10-24 12:27:53 +08:00
CGFloat top = self.isPlayOfA == YES ? (self.broadCastHieght + statusbarHeight) : (kNavigationHeight + 15);
2023-09-25 16:02:57 +08:00
XPRoomAnchorRankBannerView *anchorRankView = [[XPRoomAnchorRankBannerView alloc] initWithFrame:CGRectMake(KScreenWidth,top, KScreenWidth, kGetScaleWidth(55))];
2023-07-14 18:50:55 +08:00
anchorRankView.anchorRankInfo = [RoomHalfHourRankModel modelWithDictionary:attachment.data];
2023-09-25 16:02:57 +08:00
anchorRankView.delegate = self;
2023-07-14 18:50:55 +08:00
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];
}
2023-07-21 18:53:10 +08:00
// if(self.isAnimationListAFinish == YES){
// self.isAnimationListAFinish = NO;
// [self playAnimationWithModel];
// return;
// }
2023-07-14 18:50:55 +08:00
[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;
}
2023-10-24 12:27:53 +08:00
- (CGFloat)broadCastHieght{
if(_broadCastHieght == 0){
_broadCastHieght = 190 - 150 + kGetScaleWidth(69);
}
return _broadCastHieght;
}
2023-07-14 18:50:55 +08:00
@end