年度礼物可以在房间外显示

This commit is contained in:
fengshuo
2022-12-10 12:07:35 +08:00
parent a215585469
commit b9f8b9c953
2 changed files with 85 additions and 2 deletions

View File

@@ -1096,6 +1096,10 @@
- (void)receiveBroadcastGift:(AttachmentModel *)attachment {
if ([self isInSudGame]) {return;}
XPRoomGiftBroadCastModel *giftNotifyInfo = [XPRoomGiftBroadCastModel modelWithJSON:attachment.data];
///广 tabbar
if (giftNotifyInfo.ceremonyGift) {
return;
}
if (self.giftBroadcastQueue.count == 0) {
[self createGiftBroadcastViewAnimation:giftNotifyInfo];
}

View File

@@ -11,6 +11,7 @@
#import <NIMSDK/NIMSDK.h>
#import <Masonry/Masonry.h>
#import <AudioToolbox/AudioToolbox.h>
#import <POP.h>
///Tool
#import "XPMacro.h"
#import "ThemeColor.h"
@@ -42,6 +43,7 @@
#import "FirstRechargeModel.h"
#import "MonentsUnReadModel.h"
#import "XPReceiveRedPacketModel.h"
#import "XPRoomGiftBroadCastModel.h"
///VC
#import "TabbarViewController.h"
#import "BaseViewController.h"
@@ -69,6 +71,7 @@
#import "XPMonentsRecommendViewController.h"
#import "XPMonentsViewController.h"
#import "XPReceiveRedPacketView.h"
#import "XPRoomYearActivityView.h"
///Present
#import "MainPresenter.h"
#import "MainProtocol.h"
@@ -81,7 +84,7 @@ NSString * const kLastShowAnchorCardTime = @"kLastShowAnchorCardTime";
UIKIT_EXTERN NSString * kNewUserRechargeKey;
UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
@interface TabbarViewController () <BaseMvpProtocol, MainProtocol, NIMLoginManagerDelegate, NIMSystemNotificationManagerDelegate, NIMChatManagerDelegate, XPAnchorCardViewDelegate, NIMBroadcastManagerDelegate>
@interface TabbarViewController () <BaseMvpProtocol, MainProtocol, NIMLoginManagerDelegate, NIMSystemNotificationManagerDelegate, NIMChatManagerDelegate, XPAnchorCardViewDelegate, NIMBroadcastManagerDelegate, XPRoomYearActivityViewDelegate>
@property (nonatomic, strong) MainPresenter *presenter;
///
@@ -100,6 +103,8 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
@property (nonatomic, strong) XPTaskCompleteTipView *taskTipView;
///
@property (nonatomic,weak) id<RoomHostDelegate>delegate;
///广
@property (nonatomic,strong) NSMutableArray<XPRoomGiftBroadCastModel *> *giftBroadcastQueue;
///
@property (nonatomic, assign) BOOL parentMode;
@@ -427,7 +432,9 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
[currentVc.view addSubview:view];
[currentVc.view bringSubviewToFront:view];
}
}
} else if (attachment.first == CustomMessageType_Gift && attachment.second == Custom_Message_Sub_Gift_ChannelNotify){///广
[self receiveBroadcastGift:attachment];
}
}
}
@@ -736,6 +743,71 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
}
}
#pragma mark -
- (void)receiveBroadcastGift:(AttachmentModel *)attachment {
XPRoomGiftBroadCastModel *giftNotifyInfo = [XPRoomGiftBroadCastModel modelWithJSON:attachment.data];
if (self.giftBroadcastQueue.count == 0) {
[self createGiftBroadcastViewAnimation:giftNotifyInfo];
}
[self.giftBroadcastQueue addObject:giftNotifyInfo];
}
- (void)createGiftBroadcastViewAnimation:(XPRoomGiftBroadCastModel *)giftModel {
XPRoomYearActivityView * view = [[XPRoomYearActivityView alloc] init];
view.delegate = self;
view.frame = CGRectMake(KScreenWidth, 35 + statusbarHeight, KScreenWidth, 150);
view.model = giftModel;
[self.view addSubview:view];
[self beginGiftBraodcastViewAnimation:view notifyStaySecond:giftModel.notifyStaySecond];
}
- (void)beginGiftBraodcastViewAnimation:(XPRoomYearActivityView *)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:(XPRoomYearActivityView *)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.giftBroadcastQueue removeObjectAtIndex:0];
if (self.giftBroadcastQueue.count > 0) {
[self createGiftBroadcastViewAnimation:self.giftBroadcastQueue.firstObject];
}
}
}];
[view pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
#pragma mark - XPRoomGiftBroadcastViewDelegate
- (void)xPRoomYearActivityViewEnterRoom:(NSString *)roomUid{
if (roomUid.length > 0) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.7 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[XPRoomViewController openRoom:roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
});
}
}
#pragma mark - Getters And Setters
- (XPMiniRoomView *)roomMineView {
if (!_roomMineView) {
@@ -762,4 +834,11 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
return _taskTipView;
}
- (NSMutableArray<XPRoomGiftBroadCastModel *> *)giftBroadcastQueue {
if (!_giftBroadcastQueue) {
_giftBroadcastQueue = [NSMutableArray array];
}
return _giftBroadcastQueue;
}
@end