糖果树礼物动画
This commit is contained in:
@@ -240,6 +240,7 @@ GEM
|
||||
|
||||
PLATFORMS
|
||||
arm64-darwin-20
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
fastlane
|
||||
|
@@ -303,6 +303,8 @@
|
||||
E8DEC99527648FA50078CB70 /* ClientConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC99427648FA50078CB70 /* ClientConfig.m */; };
|
||||
E8DEC98B27637EA50078CB70 /* candyTree_open.svga in Resources */ = {isa = PBXBuildFile; fileRef = E8DEC98927637EA50078CB70 /* candyTree_open.svga */; };
|
||||
E8DEC98C27637EA50078CB70 /* candyTree_transform.svga in Resources */ = {isa = PBXBuildFile; fileRef = E8DEC98A27637EA50078CB70 /* candyTree_transform.svga */; };
|
||||
E8DEC98F27643EB30078CB70 /* XPCandyTreeAnimationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC98E27643EB30078CB70 /* XPCandyTreeAnimationManager.m */; };
|
||||
E8DEC992276441AA0078CB70 /* XPCandyTreeAnimationModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC991276441AA0078CB70 /* XPCandyTreeAnimationModel.m */; };
|
||||
E8E70D7726F2F15100F03460 /* XPMineViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E8E70D7626F2F15100F03460 /* XPMineViewController.m */; };
|
||||
E8E70D7A26F2F16600F03460 /* XPMinePresent.m in Sources */ = {isa = PBXBuildFile; fileRef = E8E70D7926F2F16600F03460 /* XPMinePresent.m */; };
|
||||
E8E70D7E26F2F19D00F03460 /* Api+Mine.m in Sources */ = {isa = PBXBuildFile; fileRef = E8E70D7D26F2F19D00F03460 /* Api+Mine.m */; };
|
||||
@@ -918,6 +920,10 @@
|
||||
E8DEC99427648FA50078CB70 /* ClientConfig.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ClientConfig.m; sourceTree = "<group>"; };
|
||||
E8DEC98927637EA50078CB70 /* candyTree_open.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = candyTree_open.svga; sourceTree = "<group>"; };
|
||||
E8DEC98A27637EA50078CB70 /* candyTree_transform.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = candyTree_transform.svga; sourceTree = "<group>"; };
|
||||
E8DEC98D27643EB30078CB70 /* XPCandyTreeAnimationManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyTreeAnimationManager.h; sourceTree = "<group>"; };
|
||||
E8DEC98E27643EB30078CB70 /* XPCandyTreeAnimationManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCandyTreeAnimationManager.m; sourceTree = "<group>"; };
|
||||
E8DEC990276441AA0078CB70 /* XPCandyTreeAnimationModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyTreeAnimationModel.h; sourceTree = "<group>"; };
|
||||
E8DEC991276441AA0078CB70 /* XPCandyTreeAnimationModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCandyTreeAnimationModel.m; sourceTree = "<group>"; };
|
||||
E8E70D7526F2F15100F03460 /* XPMineViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineViewController.h; sourceTree = "<group>"; };
|
||||
E8E70D7626F2F15100F03460 /* XPMineViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineViewController.m; sourceTree = "<group>"; };
|
||||
E8E70D7826F2F16600F03460 /* XPMinePresent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMinePresent.h; sourceTree = "<group>"; };
|
||||
@@ -2220,6 +2226,8 @@
|
||||
E8A03DEB276301EF0098D9EA /* XPCandyTreeRankView.m */,
|
||||
E8A03DFA276350A60098D9EA /* XPCandyTreeGiftView.h */,
|
||||
E8A03DFB276350A60098D9EA /* XPCandyTreeGiftView.m */,
|
||||
E8DEC98D27643EB30078CB70 /* XPCandyTreeAnimationManager.h */,
|
||||
E8DEC98E27643EB30078CB70 /* XPCandyTreeAnimationManager.m */,
|
||||
);
|
||||
path = View;
|
||||
sourceTree = "<group>";
|
||||
@@ -2242,6 +2250,8 @@
|
||||
E8A03DF2276328FC0098D9EA /* CandyTreeRecordModel.m */,
|
||||
E8A03DF727634A590098D9EA /* CandyTreeResultModel.h */,
|
||||
E8A03DF827634A590098D9EA /* CandyTreeResultModel.m */,
|
||||
E8DEC990276441AA0078CB70 /* XPCandyTreeAnimationModel.h */,
|
||||
E8DEC991276441AA0078CB70 /* XPCandyTreeAnimationModel.m */,
|
||||
);
|
||||
path = Model;
|
||||
sourceTree = "<group>";
|
||||
@@ -2875,6 +2885,7 @@
|
||||
18EE3FF12750D2AD00A452BF /* NIMTimeUtils.m in Sources */,
|
||||
E8B846D826FDE17300A777FE /* XPMineRechargeProtocol.h in Sources */,
|
||||
E8B846C726FDB45000A777FE /* XPMineUserInfoAlbumProtocol.h in Sources */,
|
||||
E8DEC992276441AA0078CB70 /* XPCandyTreeAnimationModel.m in Sources */,
|
||||
E890BC07273CF1800007C46B /* XPGiftCountCollectionViewCell.m in Sources */,
|
||||
E8EEB91126FC6AE2007C6EBA /* XPMineUserInfoEditProtocol.h in Sources */,
|
||||
E8EEB90326FC31DC007C6EBA /* XPMineUserInfoProtocol.h in Sources */,
|
||||
@@ -3025,6 +3036,7 @@
|
||||
E811FFF72742367B00918544 /* XPGiftEmptyCollectionViewCell.m in Sources */,
|
||||
189DD67E26E1FD8900AB55B1 /* UIImage+Utils.m in Sources */,
|
||||
E824545626F5E51900BE8163 /* XPMineVerifIdentityViewController.m in Sources */,
|
||||
E8DEC98F27643EB30078CB70 /* XPCandyTreeAnimationManager.m in Sources */,
|
||||
186A534726FC6ED900D67B2C /* TTAlertConfig.m in Sources */,
|
||||
18F403EE2758CF2F00A6C548 /* MessageContentImage.m in Sources */,
|
||||
18E7B31E26F0984C0064BC9B /* UserLevelVo.m in Sources */,
|
||||
|
22
xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fifth.imageset/Contents.json
vendored
Normal file
22
xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fifth.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "candy_tree_levle_fifth@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "candy_tree_levle_fifth@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
22
xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fourth.imageset/Contents.json
vendored
Normal file
22
xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fourth.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "candy_tree_levle_fourth@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "candy_tree_levle_fourth@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 951 B |
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
22
xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_third.imageset/Contents.json
vendored
Normal file
22
xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_third.imageset/Contents.json
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"filename" : "candy_tree_levle_third@2x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"filename" : "candy_tree_levle_third@3x.png",
|
||||
"idiom" : "universal",
|
||||
"scale" : "3x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"author" : "xcode",
|
||||
"version" : 1
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 781 B |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@@ -157,7 +157,7 @@
|
||||
[self receiveGift:receiveInfo];
|
||||
} else if (attachment.first == CustomMessageType_LuckyBag) {//福袋消息厅内展示
|
||||
[self receiveLuckyGiftBigPrize:attachment];
|
||||
} else if (attachment.first == CustomMessageType_Candy_Tree || attachment.second == Custom_Message_Sub_Candy_Tree_InRoom_NeedAllMicSend ) {//糖果树
|
||||
} else if (attachment.first == CustomMessageType_Candy_Tree && attachment.second == Custom_Message_Sub_Candy_Tree_InRoom_NeedAllMicSend ) {//糖果树
|
||||
[self receiveCandyTreeGiftHighLevle:attachment];
|
||||
}
|
||||
}
|
||||
@@ -184,7 +184,7 @@
|
||||
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
|
||||
if (finished) {
|
||||
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
|
||||
moveAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(candyTreeView.frame.size.width / 2, candyTreeView.center.y)];
|
||||
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;
|
||||
|
@@ -20,10 +20,6 @@
|
||||
|
||||
@implementation XPRoomCandyGiftView
|
||||
|
||||
- (void)dealloc {
|
||||
NSLog(@"销毁了");
|
||||
}
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
@@ -61,7 +57,7 @@
|
||||
@kWeakify(self);
|
||||
[self.parser parseWithNamed:@"candyTree_banner" inBundle:[NSBundle mainBundle] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
|
||||
@kStrongify(self);
|
||||
self.candyTreeView.loops = INT_MAX;
|
||||
self.candyTreeView.loops = 1;
|
||||
self.candyTreeView.clearsAfterStop = NO;
|
||||
self.candyTreeView.videoItem = videoItem;
|
||||
[self.candyTreeView setAttributedText:attribute forKey:@"tgs_copywriting"];
|
||||
|
@@ -13,7 +13,8 @@ typedef NS_ENUM(NSInteger, CandyTreeGiftLevel) {
|
||||
CandyTreeGiftLevel_First = 1,
|
||||
CandyTreeGiftLevel_Second,
|
||||
CandyTreeGiftLevel_Third,
|
||||
CandyTreeGiftLevel_Four,
|
||||
CandyTreeGiftLevel_Fourth,
|
||||
CandyTreeGiftLevel_Fifth,
|
||||
};
|
||||
|
||||
@interface CandyTreeGiftInfoModel : NSObject
|
||||
|
@@ -0,0 +1,33 @@
|
||||
//
|
||||
// XPCandyTreeAnimationModel.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/12/11.
|
||||
//
|
||||
///当前的view 需要进行什么样式的动画
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <pop/POP.h>
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPCandyTreeAnimationModel : NSObject
|
||||
///移除的时间
|
||||
@property (nonatomic,assign) CGFloat removeTime;
|
||||
///是不是移除动画 默认动画完 不移除
|
||||
@property (nonatomic,assign) BOOL isRemoveAnimation;
|
||||
///开始的时间
|
||||
@property (nonatomic,assign) CGFloat beginTime;
|
||||
///动画的key
|
||||
@property (nonatomic,strong) NSString *animationKey;
|
||||
///透明度起始值
|
||||
@property (nonatomic,assign) CGFloat alphaFromValue;
|
||||
///透明度变化到的值
|
||||
@property (nonatomic,assign) CGFloat alphaToValue;
|
||||
///持续的时间
|
||||
@property (nonatomic,assign) CGFloat durationTime;
|
||||
///平移的时候动画的开始位置
|
||||
@property (nonatomic,assign) CGFloat offsetFromY;
|
||||
///平移的时候动画的结束位置
|
||||
@property (nonatomic,assign) CGFloat offsetToY;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// XPCandyTreeAnimationModel.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/12/11.
|
||||
//
|
||||
|
||||
#import "XPCandyTreeAnimationModel.h"
|
||||
|
||||
@implementation XPCandyTreeAnimationModel
|
||||
|
||||
@end
|
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// XPCandyTreeAnimationManager.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/12/11.
|
||||
//
|
||||
/**
|
||||
开糖果的动画
|
||||
1. 只有一个的时候 alpha 0-1 的动画 然后 alpha 1-0
|
||||
2. 当第一个还没结束的时候第二个来了 第一个执行平移动画 向上移动 第二个做alpha 0-1 如果没有第三个的话 第一个 先执行 aplha 1-0 完成之后 第二个执行alpha 1-0
|
||||
3. 第三个 同上面的逻辑
|
||||
4. 第四个来的时候 第一个消失 第二个移动到第一个位置 第三个移动到第二个的位置 第四个执行alpha 0-1
|
||||
*/
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class CandyTreeGiftInfoModel;
|
||||
@interface XPCandyTreeAnimationManager : NSObject
|
||||
|
||||
///动画需要在什么地方执行
|
||||
@property (nonatomic,strong) UIView * containerView;
|
||||
|
||||
- (void)receiveCandyTreeGift:(CandyTreeGiftInfoModel *)giftInfo;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,291 @@
|
||||
//
|
||||
// XPCandyTreeAnimationManager.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/12/11.
|
||||
//
|
||||
|
||||
#import "XPCandyTreeAnimationManager.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
#import "XPCandyTreeGiftView.h"
|
||||
#import "XPCandyTreeAnimationModel.h"
|
||||
#import "CandyTreeResultModel.h"
|
||||
|
||||
#define KitemHeight 20
|
||||
#define KitemMargin 5
|
||||
|
||||
@interface XPCandyTreeAnimationManager ()
|
||||
///存放所有需要显示的礼物的
|
||||
@property (strong, nonatomic) NSMutableArray<XPCandyTreeGiftView *>*giftAnimateQueue;
|
||||
///可见池
|
||||
@property (strong,nonatomic)NSMutableArray<XPCandyTreeGiftView *> * giftVisiablePool;
|
||||
///Timer
|
||||
@property (nonatomic ,strong)dispatch_source_t timer;
|
||||
///是否正在动画
|
||||
@property (nonatomic,assign) BOOL isAnimationing;
|
||||
///view的中心
|
||||
@property (nonatomic,assign) CGFloat offsetY;
|
||||
@end
|
||||
|
||||
@implementation XPCandyTreeAnimationManager
|
||||
|
||||
- (void)receiveCandyTreeGift:(CandyTreeGiftInfoModel *)giftInfo {
|
||||
XPCandyTreeGiftView * newAnimaView = [[XPCandyTreeGiftView alloc] init];
|
||||
newAnimaView.giftInfo = giftInfo;
|
||||
NSString * giftTitle = [NSString stringWithFormat:@"%@ x %d", giftInfo.prizeName, giftInfo.prizeNum];
|
||||
CGFloat widht = [giftTitle boundingRectWithSize:CGSizeMake(200, CGFLOAT_MAX) options:NSStringDrawingUsesFontLeading | NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10]} context:nil].size.width + 10;
|
||||
newAnimaView.frame = CGRectMake(7, 291, widht, KitemHeight);
|
||||
self.offsetY = newAnimaView.center.y;
|
||||
newAnimaView.alpha = 0;
|
||||
///把所有收到的礼物加到队列中
|
||||
[self.giftAnimateQueue addObject:newAnimaView];
|
||||
if (self.timer == nil) {
|
||||
[self startTheGiftQueueTimer];
|
||||
}
|
||||
}
|
||||
|
||||
//扫描礼物队列
|
||||
- (void)startTheGiftQueueTimer {
|
||||
///没0.3秒刷新一次
|
||||
NSTimeInterval period = 0.3; //设置时间间隔
|
||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); dispatch_source_set_timer(_timer, dispatch_walltime(NULL, 0), period * NSEC_PER_SEC, 0); //每秒执行
|
||||
dispatch_source_set_event_handler(_timer, ^{
|
||||
if (self.giftAnimateQueue.count > 0) {
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
//handle gift
|
||||
if (!self.isAnimationing) {
|
||||
if (self.giftAnimateQueue.count > 0) {
|
||||
[self beginSendGiftAnimation1];
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
dispatch_source_cancel(_timer);
|
||||
self.timer = nil;
|
||||
}
|
||||
|
||||
});
|
||||
dispatch_resume(_timer);
|
||||
self.timer = _timer;
|
||||
}
|
||||
|
||||
- (void)beginSendGiftAnimation1 {
|
||||
if (self.giftVisiablePool.count == 0) {///当前没有显示
|
||||
self.isAnimationing = YES;
|
||||
XPCandyTreeGiftView * animaView = [self.giftAnimateQueue firstObject];
|
||||
[self.containerView addSubview:animaView];
|
||||
[self.giftVisiablePool addObject:animaView];
|
||||
////加到了 显示的池中 从队列中移除
|
||||
[self.giftAnimateQueue removeObject:animaView];
|
||||
///显示
|
||||
XPCandyTreeAnimationModel * model = [[XPCandyTreeAnimationModel alloc] init];
|
||||
model.animationKey = kPOPViewAlpha;
|
||||
model.alphaFromValue = 0;
|
||||
model.alphaToValue = 1;
|
||||
model.beginTime = 0;
|
||||
model.durationTime = 1;
|
||||
model.removeTime = 2;
|
||||
model.isRemoveAnimation = YES;
|
||||
[animaView createAnimationWithAnimations:model finishBlock:^(BOOL finish) {
|
||||
[animaView removeFromSuperview];
|
||||
[self.giftVisiablePool removeObject:animaView];
|
||||
} complete:^(BOOL complete) {
|
||||
self.isAnimationing = NO;
|
||||
}];
|
||||
|
||||
} else if(self.giftVisiablePool.count == 1) {///当前显示一个
|
||||
self.isAnimationing = YES;
|
||||
///在第一个已经显示的情况下 并且已经移除了的话 如果还有的话 那就继续显示第二个
|
||||
XPCandyTreeGiftView * currentVisibalView = [self.giftVisiablePool objectAtIndex:0];
|
||||
currentVisibalView.alpha = 1;
|
||||
///显示第二的时候 需要把第一个的动画 取消不然等会第一个就消失了
|
||||
[currentVisibalView canclueRemoveAnimation];
|
||||
///需要显示view
|
||||
XPCandyTreeGiftView * needVisiableReceiveInfor = [self.giftAnimateQueue objectAtIndex:0];
|
||||
needVisiableReceiveInfor.alpha = 1;
|
||||
[self.containerView addSubview:needVisiableReceiveInfor];
|
||||
[self.containerView bringSubviewToFront:currentVisibalView];
|
||||
[self.giftVisiablePool addObject:needVisiableReceiveInfor];
|
||||
[self.giftAnimateQueue removeObject:needVisiableReceiveInfor];
|
||||
|
||||
XPCandyTreeAnimationModel * secondModel = [[XPCandyTreeAnimationModel alloc] init];
|
||||
secondModel.animationKey = kPOPViewCenter;
|
||||
secondModel.offsetFromY = self.offsetY;
|
||||
secondModel.offsetToY = self.offsetY-KitemHeight - KitemMargin;
|
||||
secondModel.beginTime = 0;
|
||||
secondModel.durationTime = 1;
|
||||
secondModel.isRemoveAnimation = YES;
|
||||
secondModel.removeTime = 2;
|
||||
[currentVisibalView createAnimationWithAnimations:secondModel finishBlock:^(BOOL finish) {
|
||||
///a 1-0 结束的时候
|
||||
[currentVisibalView removeFromSuperview];
|
||||
[self.giftAnimateQueue removeObject:currentVisibalView];
|
||||
///结束的时候才移除队列
|
||||
[self.giftAnimateQueue removeObject:needVisiableReceiveInfor];
|
||||
[needVisiableReceiveInfor removeFromSuperview];
|
||||
} complete:^(BOOL complete) {
|
||||
self.isAnimationing = NO;
|
||||
}];
|
||||
}else if(self.giftVisiablePool.count == 2) {///当前显示两个
|
||||
self.isAnimationing = YES;
|
||||
///最上面的view
|
||||
XPCandyTreeGiftView * topVisiableView = [self.giftVisiablePool objectAtIndex:0];
|
||||
///中间的那个view
|
||||
XPCandyTreeGiftView * middleVisiableView = [self.giftVisiablePool objectAtIndex:1];
|
||||
|
||||
///需要显示的的那个view
|
||||
XPCandyTreeGiftView * needVisiableView = [self.giftAnimateQueue objectAtIndex:0];
|
||||
[self.containerView addSubview:needVisiableView];
|
||||
[self.giftVisiablePool addObject:needVisiableView];
|
||||
[self.giftAnimateQueue removeObject:needVisiableView];
|
||||
///取消移除的动画
|
||||
[topVisiableView canclueRemoveAnimation];
|
||||
[middleVisiableView canclueRemoveAnimation];
|
||||
|
||||
XPCandyTreeAnimationModel * topPositionModel = [[XPCandyTreeAnimationModel alloc] init];
|
||||
topPositionModel.animationKey = kPOPViewCenter;
|
||||
topPositionModel.offsetToY = self.offsetY -KitemHeight * 2 - KitemMargin * 2;
|
||||
topPositionModel.offsetFromY = self.offsetY -KitemHeight - KitemMargin;
|
||||
topPositionModel.beginTime = 0;
|
||||
topPositionModel.durationTime = 1;
|
||||
topPositionModel.isRemoveAnimation = YES;
|
||||
topPositionModel.removeTime = 4;
|
||||
[topVisiableView createAnimationWithAnimations:topPositionModel finishBlock:^(BOOL finish) {
|
||||
[topVisiableView removeFromSuperview];
|
||||
[self.giftVisiablePool removeObject:topVisiableView];
|
||||
[middleVisiableView removeAmimation];
|
||||
} complete:^(BOOL complete) {
|
||||
|
||||
}];
|
||||
|
||||
XPCandyTreeAnimationModel * middlePositionModel = [[XPCandyTreeAnimationModel alloc] init];
|
||||
middlePositionModel.animationKey = kPOPViewCenter;
|
||||
middlePositionModel.offsetToY = self.offsetY -KitemHeight - KitemMargin;
|
||||
middlePositionModel.offsetFromY = self.offsetY;
|
||||
middlePositionModel.beginTime = 0.5;
|
||||
middlePositionModel.durationTime = 1;
|
||||
middlePositionModel.isRemoveAnimation = NO;
|
||||
[middleVisiableView createAnimationWithAnimations:middlePositionModel finishBlock:^(BOOL finish) {
|
||||
[middleVisiableView removeFromSuperview];
|
||||
[self.giftVisiablePool removeObject:topVisiableView];
|
||||
[needVisiableView removeAmimation];
|
||||
} complete:^(BOOL complete) {
|
||||
|
||||
}];
|
||||
|
||||
///显示
|
||||
XPCandyTreeAnimationModel * dowAlphtmodel = [[XPCandyTreeAnimationModel alloc] init];
|
||||
dowAlphtmodel.animationKey = kPOPViewAlpha;
|
||||
dowAlphtmodel.alphaFromValue = 0;
|
||||
dowAlphtmodel.alphaToValue = 1;
|
||||
dowAlphtmodel.beginTime = 1;
|
||||
dowAlphtmodel.durationTime = 1;
|
||||
dowAlphtmodel.isRemoveAnimation = NO;
|
||||
[needVisiableView createAnimationWithAnimations:dowAlphtmodel finishBlock:^(BOOL finish) {
|
||||
[self.giftVisiablePool removeObject:needVisiableView];
|
||||
[needVisiableView removeFromSuperview];
|
||||
} complete:^(BOOL complete) {
|
||||
self.isAnimationing = NO;
|
||||
}];
|
||||
} else if(self.giftVisiablePool.count == 3) {///当前显示三个的
|
||||
self.isAnimationing = YES;
|
||||
///最上面的view
|
||||
XPCandyTreeGiftView * topVisiableView = [self.giftVisiablePool objectAtIndex:0];
|
||||
///中间的那个view
|
||||
XPCandyTreeGiftView * middleVisiableView = [self.giftVisiablePool objectAtIndex:1];
|
||||
///底部的那个view
|
||||
XPCandyTreeGiftView * downVisiavleView = [self.giftVisiablePool objectAtIndex:2];
|
||||
///需要显示的view
|
||||
XPCandyTreeGiftView * needVisiavleView = [self.giftAnimateQueue objectAtIndex:0];
|
||||
[self.containerView addSubview:needVisiavleView];
|
||||
|
||||
[self.giftVisiablePool addObject:needVisiavleView];
|
||||
///移除最上面的哪一个
|
||||
[self.giftVisiablePool removeObject:topVisiableView];
|
||||
|
||||
[self.giftAnimateQueue removeObject:needVisiavleView];
|
||||
///取消移除的动画
|
||||
[topVisiableView canclueRemoveAnimation];
|
||||
[middleVisiableView canclueRemoveAnimation];
|
||||
[downVisiavleView canclueRemoveAnimation];
|
||||
|
||||
///隐藏
|
||||
XPCandyTreeAnimationModel * model = [[XPCandyTreeAnimationModel alloc] init];
|
||||
model.animationKey = kPOPViewAlpha;
|
||||
model.alphaFromValue = 1;
|
||||
model.alphaToValue = 0;
|
||||
model.beginTime = 0;
|
||||
model.durationTime = 0.5;
|
||||
model.isRemoveAnimation = NO;
|
||||
[topVisiableView createAnimationWithAnimations:model finishBlock:^(BOOL finish) {///消失动画完成
|
||||
|
||||
} complete:^(BOOL complete) {///这一组动画完成
|
||||
[topVisiableView removeFromSuperview];
|
||||
}];
|
||||
|
||||
|
||||
XPCandyTreeAnimationModel * middlePositionModel = [[XPCandyTreeAnimationModel alloc] init];
|
||||
middlePositionModel.animationKey = kPOPViewCenter;
|
||||
middlePositionModel.offsetToY = self.offsetY -KitemHeight * 2 - KitemMargin * 2;
|
||||
middlePositionModel.offsetFromY = self.offsetY -KitemHeight - KitemMargin;
|
||||
middlePositionModel.beginTime = 0.5;
|
||||
middlePositionModel.durationTime = 1;
|
||||
middlePositionModel.isRemoveAnimation = YES;
|
||||
middlePositionModel.removeTime = 4;
|
||||
[middleVisiableView createAnimationWithAnimations:middlePositionModel finishBlock:^(BOOL finish) {
|
||||
[middleVisiableView removeFromSuperview];
|
||||
[downVisiavleView removeAmimation];
|
||||
[self.giftVisiablePool removeObject:middleVisiableView];
|
||||
} complete:^(BOOL complete) {
|
||||
///动画已经上去了 可以开始下一个动画
|
||||
}];
|
||||
|
||||
XPCandyTreeAnimationModel * downPositionModel = [[XPCandyTreeAnimationModel alloc] init];
|
||||
downPositionModel.animationKey = kPOPViewCenter;
|
||||
downPositionModel.offsetToY = self.offsetY -KitemHeight - KitemMargin;
|
||||
downPositionModel.offsetFromY = self.offsetY;
|
||||
downPositionModel.beginTime = 1;
|
||||
downPositionModel.durationTime = 1;
|
||||
downPositionModel.isRemoveAnimation = NO;
|
||||
[downVisiavleView createAnimationWithAnimations:downPositionModel finishBlock:^(BOOL finish) {
|
||||
[downVisiavleView removeFromSuperview];
|
||||
[self.giftVisiablePool removeObject:downVisiavleView];
|
||||
[needVisiavleView removeAmimation];
|
||||
} complete:^(BOOL complete) {
|
||||
|
||||
}];
|
||||
|
||||
///最下面的那个
|
||||
XPCandyTreeAnimationModel * newModel = [[XPCandyTreeAnimationModel alloc] init];
|
||||
newModel.animationKey = kPOPViewAlpha;
|
||||
newModel.alphaFromValue = 0;
|
||||
newModel.alphaToValue = 1;
|
||||
newModel.beginTime = 1.5;
|
||||
newModel.durationTime = 0.5;
|
||||
newModel.isRemoveAnimation = NO;
|
||||
[needVisiavleView createAnimationWithAnimations:newModel finishBlock:^(BOOL finish) {///消失动画完成
|
||||
[needVisiavleView removeFromSuperview];
|
||||
[self.giftVisiablePool removeObject:needVisiavleView];
|
||||
} complete:^(BOOL complete) {///这一组动画完成
|
||||
self.isAnimationing = NO;
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (NSMutableArray<XPCandyTreeGiftView *> *)giftAnimateQueue {
|
||||
if (!_giftAnimateQueue) {
|
||||
_giftAnimateQueue = [NSMutableArray array];
|
||||
}
|
||||
return _giftAnimateQueue;
|
||||
}
|
||||
|
||||
- (NSMutableArray<XPCandyTreeGiftView *> *)giftVisiablePool {
|
||||
if (!_giftVisiablePool) {
|
||||
_giftVisiablePool = [NSMutableArray array];
|
||||
}
|
||||
return _giftVisiablePool;
|
||||
}
|
||||
@end
|
@@ -8,10 +8,16 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
@class CandyTreeGiftInfoModel;
|
||||
@class CandyTreeGiftInfoModel, XPCandyTreeAnimationModel;
|
||||
@interface XPCandyTreeGiftView : UIView
|
||||
///礼物的信息
|
||||
@property (nonatomic,strong) CandyTreeGiftInfoModel *giftInfo;
|
||||
///取消动画
|
||||
- (void)canclueRemoveAnimation;
|
||||
///隐藏View
|
||||
- (void)removeAmimation;
|
||||
/// 开始动画 finishBlock 是一组动画完成 比如 alpha 0-1 然后再 1-0 complete 是XPCandyTreeAnimationModel 中的动画完成
|
||||
- (void)createAnimationWithAnimations:(XPCandyTreeAnimationModel *)model finishBlock:(void(^)(BOOL finish))finishBlock complete:(void(^)(BOOL complete))complete;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -7,14 +7,18 @@
|
||||
|
||||
#import "XPCandyTreeGiftView.h"
|
||||
///Third
|
||||
#import <pop/POP.h>
|
||||
#import <Masonry/Masonry.h>
|
||||
#import "CandyTreeResultModel.h"
|
||||
#import "XPCandyTreeAnimationModel.h"
|
||||
|
||||
@interface XPCandyTreeGiftView ()
|
||||
///礼物背景
|
||||
@property (nonatomic,strong) UIImageView *backImageView;
|
||||
///显示文字
|
||||
@property (nonatomic,strong) UILabel *titleLabel;
|
||||
///动画完成
|
||||
@property (nonatomic,copy) void(^FinishBlock)(BOOL finish);
|
||||
@end
|
||||
|
||||
@implementation XPCandyTreeGiftView
|
||||
@@ -28,6 +32,60 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Public Method
|
||||
///取消动画
|
||||
- (void)canclueRemoveAnimation {
|
||||
[[self class] cancelPreviousPerformRequestsWithTarget:self];
|
||||
}
|
||||
|
||||
/// 开始动画
|
||||
- (void)createAnimationWithAnimations:(XPCandyTreeAnimationModel *)model finishBlock:(void(^)(BOOL finish))finishBlock complete:(void(^)(BOOL complete))complete {
|
||||
self.FinishBlock = finishBlock;
|
||||
///只有两个动画 一个平移的 一个alpha
|
||||
if (model.animationKey == kPOPViewAlpha) {
|
||||
POPBasicAnimation * OpacitySpring = [POPBasicAnimation animationWithPropertyNamed:kPOPViewAlpha];
|
||||
OpacitySpring.beginTime = CACurrentMediaTime() + model.beginTime;
|
||||
OpacitySpring.toValue = @(model.alphaToValue);
|
||||
OpacitySpring.fromValue = @(model.alphaFromValue);
|
||||
OpacitySpring.duration = model.durationTime;
|
||||
OpacitySpring.completionBlock = ^(POPAnimation *anim, BOOL finished) {
|
||||
complete(finished);
|
||||
};
|
||||
if (model.isRemoveAnimation) {
|
||||
[self performSelector:@selector(removeAmimation) withObject:nil afterDelay:model.removeTime];
|
||||
}
|
||||
[self pop_addAnimation:OpacitySpring forKey:@"OpacitySpring"];
|
||||
} else {
|
||||
POPBasicAnimation *anSpring = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
|
||||
anSpring.fromValue = [NSValue valueWithCGPoint:CGPointMake(self.center.x, model.offsetFromY)];;
|
||||
anSpring.toValue = [NSValue valueWithCGPoint:CGPointMake(self.center.x, model.offsetToY)];;;
|
||||
anSpring.beginTime = CACurrentMediaTime() + model.beginTime;
|
||||
anSpring.duration = model.durationTime;
|
||||
anSpring.completionBlock = ^(POPAnimation *anim, BOOL finished) {
|
||||
complete(finished);
|
||||
};
|
||||
if (model.isRemoveAnimation) {
|
||||
[self performSelector:@selector(removeAmimation) withObject:nil afterDelay:model.removeTime];
|
||||
}
|
||||
[self pop_addAnimation:anSpring forKey:@"OpacitySpring"];
|
||||
}
|
||||
}
|
||||
|
||||
///隐藏View
|
||||
- (void)removeAmimation {
|
||||
POPBasicAnimation * OpacitySpring1 = [POPBasicAnimation animationWithPropertyNamed:kPOPViewAlpha];
|
||||
OpacitySpring1.beginTime = CACurrentMediaTime();
|
||||
OpacitySpring1.toValue = @(0);
|
||||
OpacitySpring1.fromValue = @(1);
|
||||
OpacitySpring1.duration = 0.5;
|
||||
OpacitySpring1.completionBlock = ^(POPAnimation *anim, BOOL finished) {
|
||||
if(finished && self.FinishBlock){
|
||||
self.FinishBlock(YES);
|
||||
}
|
||||
};
|
||||
[self pop_addAnimation:OpacitySpring1 forKey:@"OpacitySpring"];
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self addSubview:self.backImageView];
|
||||
@@ -36,9 +94,8 @@
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self);
|
||||
make.left.right.centerY.mas_equalTo(self);
|
||||
make.height.mas_equalTo(19);
|
||||
make.right.mas_equalTo(self.titleLabel.mas_right).offset(3);
|
||||
}];
|
||||
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
@@ -50,15 +107,11 @@
|
||||
- (void)setGiftInfo:(CandyTreeGiftInfoModel *)giftInfo {
|
||||
_giftInfo = giftInfo;
|
||||
if (_giftInfo) {
|
||||
NSString * backImage= @"";
|
||||
if (giftInfo.prizeLevel == CandyTreeGiftLevel_First) {
|
||||
backImage = @"";
|
||||
} else if(giftInfo.prizeLevel == CandyTreeGiftLevel_Second) {
|
||||
backImage = @"";
|
||||
} else if(giftInfo.prizeLevel == CandyTreeGiftLevel_Third) {
|
||||
backImage = @"";
|
||||
} else if(giftInfo.prizeLevel == CandyTreeGiftLevel_Four) {
|
||||
backImage = @"";
|
||||
NSString * backImage= @"candy_tree_levle_third";
|
||||
if(giftInfo.prizeLevel == CandyTreeGiftLevel_Fourth) {
|
||||
backImage = @"candy_tree_levle_fourth";
|
||||
} else if(giftInfo.prizeLevel == CandyTreeGiftLevel_Fifth) {
|
||||
backImage = @"candy_tree_levle_fifth";
|
||||
}
|
||||
self.backImageView.image = [UIImage imageNamed:backImage];
|
||||
if (_giftInfo.prizeName.length > 7) {
|
||||
@@ -67,6 +120,7 @@
|
||||
NSString * giftTitle = [NSString stringWithFormat:@"%@ x %d", _giftInfo.prizeName, _giftInfo.prizeNum];
|
||||
self.titleLabel.text = giftTitle;
|
||||
}
|
||||
[self layoutIfNeeded];
|
||||
}
|
||||
|
||||
- (UIImageView *)backImageView {
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#import "ThemeColor.h"
|
||||
#import "TTPopup.h"
|
||||
#import "XPHtmlUrl.h"
|
||||
#import "XPCandyTreeAnimationManager.h"
|
||||
///Model
|
||||
#import "RoomInfoModel.h"
|
||||
#import "AttachMentModel.h"
|
||||
@@ -84,6 +85,8 @@
|
||||
@property (nonatomic,weak) id<RoomHostDelegate>hostDelegate;
|
||||
///是否正在采摘
|
||||
@property (nonatomic,assign) BOOL isPicking;
|
||||
///送礼物的动画
|
||||
@property (nonatomic,strong) XPCandyTreeAnimationManager *giftManager;
|
||||
@end
|
||||
|
||||
@implementation XPCandyTreeViewController
|
||||
@@ -130,6 +133,11 @@
|
||||
self.isPicking = NO;
|
||||
self.countLabel.text = result.remainKeyNum > 0 ? [NSString stringWithFormat:@"%ld", result.remainKeyNum] : @"0";
|
||||
self.candyInfo.keyNum = result.remainKeyNum;
|
||||
|
||||
[result.prizeItemList enumerateObjectsUsingBlock:^(CandyTreeGiftInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
|
||||
[self.giftManager receiveCandyTreeGift:obj];
|
||||
}];
|
||||
|
||||
@kWeakify(self);
|
||||
[self.parser parseWithNamed:@"candyTree_transform" inBundle:[NSBundle mainBundle] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
|
||||
@kStrongify(self);
|
||||
@@ -607,5 +615,13 @@
|
||||
return _pickButton;
|
||||
}
|
||||
|
||||
- (XPCandyTreeAnimationManager *)giftManager {
|
||||
if (!_giftManager) {
|
||||
_giftManager = [[XPCandyTreeAnimationManager alloc] init];
|
||||
_giftManager.containerView = self.backView;
|
||||
}
|
||||
return _giftManager;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
@@ -146,7 +146,6 @@
|
||||
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
||||
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
||||
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
||||
NSLog(@"%@", attachment);
|
||||
return [[[self supportMessageDic] objectForKey:@(attachment.first)] containsObject:@(attachment.second)];
|
||||
}
|
||||
return NO;
|
||||
|
Reference in New Issue
Block a user