diff --git a/Gemfile.lock b/Gemfile.lock index d6644dd9..9462fadd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -240,6 +240,7 @@ GEM PLATFORMS arm64-darwin-20 + ruby DEPENDENCIES fastlane diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 9391ff41..880081db 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -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 = ""; }; E8DEC98927637EA50078CB70 /* candyTree_open.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = candyTree_open.svga; sourceTree = ""; }; E8DEC98A27637EA50078CB70 /* candyTree_transform.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = candyTree_transform.svga; sourceTree = ""; }; + E8DEC98D27643EB30078CB70 /* XPCandyTreeAnimationManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyTreeAnimationManager.h; sourceTree = ""; }; + E8DEC98E27643EB30078CB70 /* XPCandyTreeAnimationManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCandyTreeAnimationManager.m; sourceTree = ""; }; + E8DEC990276441AA0078CB70 /* XPCandyTreeAnimationModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyTreeAnimationModel.h; sourceTree = ""; }; + E8DEC991276441AA0078CB70 /* XPCandyTreeAnimationModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPCandyTreeAnimationModel.m; sourceTree = ""; }; E8E70D7526F2F15100F03460 /* XPMineViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineViewController.h; sourceTree = ""; }; E8E70D7626F2F15100F03460 /* XPMineViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineViewController.m; sourceTree = ""; }; E8E70D7826F2F16600F03460 /* XPMinePresent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMinePresent.h; sourceTree = ""; }; @@ -2220,6 +2226,8 @@ E8A03DEB276301EF0098D9EA /* XPCandyTreeRankView.m */, E8A03DFA276350A60098D9EA /* XPCandyTreeGiftView.h */, E8A03DFB276350A60098D9EA /* XPCandyTreeGiftView.m */, + E8DEC98D27643EB30078CB70 /* XPCandyTreeAnimationManager.h */, + E8DEC98E27643EB30078CB70 /* XPCandyTreeAnimationManager.m */, ); path = View; sourceTree = ""; @@ -2242,6 +2250,8 @@ E8A03DF2276328FC0098D9EA /* CandyTreeRecordModel.m */, E8A03DF727634A590098D9EA /* CandyTreeResultModel.h */, E8A03DF827634A590098D9EA /* CandyTreeResultModel.m */, + E8DEC990276441AA0078CB70 /* XPCandyTreeAnimationModel.h */, + E8DEC991276441AA0078CB70 /* XPCandyTreeAnimationModel.m */, ); path = Model; sourceTree = ""; @@ -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 */, diff --git a/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fifth.imageset/Contents.json b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fifth.imageset/Contents.json new file mode 100644 index 00000000..2f26698b --- /dev/null +++ b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fifth.imageset/Contents.json @@ -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 + } +} diff --git a/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fifth.imageset/candy_tree_levle_fifth@2x.png b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fifth.imageset/candy_tree_levle_fifth@2x.png new file mode 100644 index 00000000..b60dbf29 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fifth.imageset/candy_tree_levle_fifth@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fifth.imageset/candy_tree_levle_fifth@3x.png b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fifth.imageset/candy_tree_levle_fifth@3x.png new file mode 100644 index 00000000..1e0a6a07 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fifth.imageset/candy_tree_levle_fifth@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fourth.imageset/Contents.json b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fourth.imageset/Contents.json new file mode 100644 index 00000000..cda301ed --- /dev/null +++ b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fourth.imageset/Contents.json @@ -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 + } +} diff --git a/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fourth.imageset/candy_tree_levle_fourth@2x.png b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fourth.imageset/candy_tree_levle_fourth@2x.png new file mode 100644 index 00000000..0dab4f44 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fourth.imageset/candy_tree_levle_fourth@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fourth.imageset/candy_tree_levle_fourth@3x.png b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fourth.imageset/candy_tree_levle_fourth@3x.png new file mode 100644 index 00000000..b5ca78f5 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_fourth.imageset/candy_tree_levle_fourth@3x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_third.imageset/Contents.json b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_third.imageset/Contents.json new file mode 100644 index 00000000..e8739e55 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_third.imageset/Contents.json @@ -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 + } +} diff --git a/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_third.imageset/candy_tree_levle_third@2x.png b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_third.imageset/candy_tree_levle_third@2x.png new file mode 100644 index 00000000..03c23d31 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_third.imageset/candy_tree_levle_third@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_third.imageset/candy_tree_levle_third@3x.png b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_third.imageset/candy_tree_levle_third@3x.png new file mode 100644 index 00000000..43405ad4 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/CandyTree/candy_tree_levle_third.imageset/candy_tree_levle_third@3x.png differ diff --git a/xplan-ios/Main/Room/View/AnimationView/XPRoomAnimationView.m b/xplan-ios/Main/Room/View/AnimationView/XPRoomAnimationView.m index be7ce11f..433856e2 100644 --- a/xplan-ios/Main/Room/View/AnimationView/XPRoomAnimationView.m +++ b/xplan-ios/Main/Room/View/AnimationView/XPRoomAnimationView.m @@ -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; diff --git a/xplan-ios/Main/Room/View/AnimationView/XPRoomCandyGiftView.m b/xplan-ios/Main/Room/View/AnimationView/XPRoomCandyGiftView.m index 7577fcfc..48786c1d 100644 --- a/xplan-ios/Main/Room/View/AnimationView/XPRoomCandyGiftView.m +++ b/xplan-ios/Main/Room/View/AnimationView/XPRoomCandyGiftView.m @@ -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"]; diff --git a/xplan-ios/Main/Room/View/CandyTree/Model/CandyTreeResultModel.h b/xplan-ios/Main/Room/View/CandyTree/Model/CandyTreeResultModel.h index 61fc3849..13820f8b 100644 --- a/xplan-ios/Main/Room/View/CandyTree/Model/CandyTreeResultModel.h +++ b/xplan-ios/Main/Room/View/CandyTree/Model/CandyTreeResultModel.h @@ -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 diff --git a/xplan-ios/Main/Room/View/CandyTree/Model/XPCandyTreeAnimationModel.h b/xplan-ios/Main/Room/View/CandyTree/Model/XPCandyTreeAnimationModel.h new file mode 100644 index 00000000..643b719e --- /dev/null +++ b/xplan-ios/Main/Room/View/CandyTree/Model/XPCandyTreeAnimationModel.h @@ -0,0 +1,33 @@ +// +// XPCandyTreeAnimationModel.h +// xplan-ios +// +// Created by 冯硕 on 2021/12/11. +// +///当前的view 需要进行什么样式的动画 +#import +#import +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 diff --git a/xplan-ios/Main/Room/View/CandyTree/Model/XPCandyTreeAnimationModel.m b/xplan-ios/Main/Room/View/CandyTree/Model/XPCandyTreeAnimationModel.m new file mode 100644 index 00000000..f12dce19 --- /dev/null +++ b/xplan-ios/Main/Room/View/CandyTree/Model/XPCandyTreeAnimationModel.m @@ -0,0 +1,12 @@ +// +// XPCandyTreeAnimationModel.m +// xplan-ios +// +// Created by 冯硕 on 2021/12/11. +// + +#import "XPCandyTreeAnimationModel.h" + +@implementation XPCandyTreeAnimationModel + +@end diff --git a/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeAnimationManager.h b/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeAnimationManager.h new file mode 100644 index 00000000..f804251b --- /dev/null +++ b/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeAnimationManager.h @@ -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 + +NS_ASSUME_NONNULL_BEGIN +@class CandyTreeGiftInfoModel; +@interface XPCandyTreeAnimationManager : NSObject + +///动画需要在什么地方执行 +@property (nonatomic,strong) UIView * containerView; + +- (void)receiveCandyTreeGift:(CandyTreeGiftInfoModel *)giftInfo; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeAnimationManager.m b/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeAnimationManager.m new file mode 100644 index 00000000..4c8d3f6d --- /dev/null +++ b/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeAnimationManager.m @@ -0,0 +1,291 @@ +// +// XPCandyTreeAnimationManager.m +// xplan-ios +// +// Created by 冯硕 on 2021/12/11. +// + +#import "XPCandyTreeAnimationManager.h" +///Third +#import +#import "XPCandyTreeGiftView.h" +#import "XPCandyTreeAnimationModel.h" +#import "CandyTreeResultModel.h" + +#define KitemHeight 20 +#define KitemMargin 5 + +@interface XPCandyTreeAnimationManager () +///存放所有需要显示的礼物的 +@property (strong, nonatomic) NSMutableArray*giftAnimateQueue; +///可见池 +@property (strong,nonatomic)NSMutableArray * 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 *)giftAnimateQueue { + if (!_giftAnimateQueue) { + _giftAnimateQueue = [NSMutableArray array]; + } + return _giftAnimateQueue; +} + +- (NSMutableArray *)giftVisiablePool { + if (!_giftVisiablePool) { + _giftVisiablePool = [NSMutableArray array]; + } + return _giftVisiablePool; +} +@end diff --git a/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeGiftView.h b/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeGiftView.h index 474558b8..c6c85460 100644 --- a/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeGiftView.h +++ b/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeGiftView.h @@ -8,10 +8,16 @@ #import 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 diff --git a/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeGiftView.m b/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeGiftView.m index 754cfe7c..b71fa16e 100644 --- a/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeGiftView.m +++ b/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeGiftView.m @@ -7,14 +7,18 @@ #import "XPCandyTreeGiftView.h" ///Third +#import #import #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 { diff --git a/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeViewController.m b/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeViewController.m index 1b1c4e4e..964732a6 100644 --- a/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeViewController.m +++ b/xplan-ios/Main/Room/View/CandyTree/View/XPCandyTreeViewController.m @@ -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) idhostDelegate; ///是否正在采摘 @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 diff --git a/xplan-ios/Main/Room/View/MessageContainerView/XPRoomMessageContainerView.m b/xplan-ios/Main/Room/View/MessageContainerView/XPRoomMessageContainerView.m index f619e3d7..4d2c7014 100644 --- a/xplan-ios/Main/Room/View/MessageContainerView/XPRoomMessageContainerView.m +++ b/xplan-ios/Main/Room/View/MessageContainerView/XPRoomMessageContainerView.m @@ -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;