房间520横幅

This commit is contained in:
fengshuo
2021-11-18 18:43:20 +08:00
parent 18f57d502e
commit df91606e97
26 changed files with 642 additions and 26 deletions

View File

@@ -140,6 +140,7 @@
E82EE0F8272FDDFA00D15DC1 /* UserPrivacyView.m in Sources */ = {isa = PBXBuildFile; fileRef = E82EE0F7272FDDFA00D15DC1 /* UserPrivacyView.m */; }; E82EE0F8272FDDFA00D15DC1 /* UserPrivacyView.m in Sources */ = {isa = PBXBuildFile; fileRef = E82EE0F7272FDDFA00D15DC1 /* UserPrivacyView.m */; };
E83DB47A27462C4500D8CBD1 /* XPGiftBigPrizeModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E83DB47927462C4500D8CBD1 /* XPGiftBigPrizeModel.m */; }; E83DB47A27462C4500D8CBD1 /* XPGiftBigPrizeModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E83DB47927462C4500D8CBD1 /* XPGiftBigPrizeModel.m */; };
E83DB47D2746372300D8CBD1 /* XPRoomGiftBannerView.m in Sources */ = {isa = PBXBuildFile; fileRef = E83DB47C2746372300D8CBD1 /* XPRoomGiftBannerView.m */; }; E83DB47D2746372300D8CBD1 /* XPRoomGiftBannerView.m in Sources */ = {isa = PBXBuildFile; fileRef = E83DB47C2746372300D8CBD1 /* XPRoomGiftBannerView.m */; };
E83DB481274649FB00D8CBD1 /* XPGiftBannerUserInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E83DB480274649FB00D8CBD1 /* XPGiftBannerUserInfoModel.m */; };
E84B0E3F2727EDF6008818C6 /* XPRoomMessageTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E3E2727EDF6008818C6 /* XPRoomMessageTableViewCell.m */; }; E84B0E3F2727EDF6008818C6 /* XPRoomMessageTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E3E2727EDF6008818C6 /* XPRoomMessageTableViewCell.m */; };
E84B0E422727EE0A008818C6 /* XPRoomMessageHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E412727EE0A008818C6 /* XPRoomMessageHeaderView.m */; }; E84B0E422727EE0A008818C6 /* XPRoomMessageHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E412727EE0A008818C6 /* XPRoomMessageHeaderView.m */; };
E84B0E462727EF9D008818C6 /* XPRoomMessageParser.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E452727EF9D008818C6 /* XPRoomMessageParser.m */; }; E84B0E462727EF9D008818C6 /* XPRoomMessageParser.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E452727EF9D008818C6 /* XPRoomMessageParser.m */; };
@@ -521,6 +522,8 @@
E83DB47927462C4500D8CBD1 /* XPGiftBigPrizeModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPGiftBigPrizeModel.m; sourceTree = "<group>"; }; E83DB47927462C4500D8CBD1 /* XPGiftBigPrizeModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPGiftBigPrizeModel.m; sourceTree = "<group>"; };
E83DB47B2746372300D8CBD1 /* XPRoomGiftBannerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomGiftBannerView.h; sourceTree = "<group>"; }; E83DB47B2746372300D8CBD1 /* XPRoomGiftBannerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomGiftBannerView.h; sourceTree = "<group>"; };
E83DB47C2746372300D8CBD1 /* XPRoomGiftBannerView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomGiftBannerView.m; sourceTree = "<group>"; }; E83DB47C2746372300D8CBD1 /* XPRoomGiftBannerView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomGiftBannerView.m; sourceTree = "<group>"; };
E83DB47F274649FB00D8CBD1 /* XPGiftBannerUserInfoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPGiftBannerUserInfoModel.h; sourceTree = "<group>"; };
E83DB480274649FB00D8CBD1 /* XPGiftBannerUserInfoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPGiftBannerUserInfoModel.m; sourceTree = "<group>"; };
E84B0E3D2727EDF6008818C6 /* XPRoomMessageTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageTableViewCell.h; sourceTree = "<group>"; }; E84B0E3D2727EDF6008818C6 /* XPRoomMessageTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageTableViewCell.h; sourceTree = "<group>"; };
E84B0E3E2727EDF6008818C6 /* XPRoomMessageTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomMessageTableViewCell.m; sourceTree = "<group>"; }; E84B0E3E2727EDF6008818C6 /* XPRoomMessageTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomMessageTableViewCell.m; sourceTree = "<group>"; };
E84B0E402727EE0A008818C6 /* XPRoomMessageHeaderView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageHeaderView.h; sourceTree = "<group>"; }; E84B0E402727EE0A008818C6 /* XPRoomMessageHeaderView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageHeaderView.h; sourceTree = "<group>"; };
@@ -1321,8 +1324,6 @@
E804875F2717DD70008595F2 /* Model */ = { E804875F2717DD70008595F2 /* Model */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E83DB47827462C4500D8CBD1 /* XPGiftBigPrizeModel.h */,
E83DB47927462C4500D8CBD1 /* XPGiftBigPrizeModel.m */,
E89D60BF271D64B9001F8895 /* RoomInfoModel.h */, E89D60BF271D64B9001F8895 /* RoomInfoModel.h */,
E89D60C0271D64B9001F8895 /* RoomInfoModel.m */, E89D60C0271D64B9001F8895 /* RoomInfoModel.m */,
); );
@@ -1426,6 +1427,17 @@
path = UIImage; path = UIImage;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
E83DB47E274649B200D8CBD1 /* Model */ = {
isa = PBXGroup;
children = (
E83DB47827462C4500D8CBD1 /* XPGiftBigPrizeModel.h */,
E83DB47927462C4500D8CBD1 /* XPGiftBigPrizeModel.m */,
E83DB47F274649FB00D8CBD1 /* XPGiftBannerUserInfoModel.h */,
E83DB480274649FB00D8CBD1 /* XPGiftBannerUserInfoModel.m */,
);
path = Model;
sourceTree = "<group>";
};
E84B0E3C2727EDD4008818C6 /* View */ = { E84B0E3C2727EDD4008818C6 /* View */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
@@ -1782,6 +1794,7 @@
E8AEAEE727141ACC0017FCE0 /* BaseUIContainerView */ = { E8AEAEE727141ACC0017FCE0 /* BaseUIContainerView */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E83DB47E274649B200D8CBD1 /* Model */,
E8AEAEEB27141AE20017FCE0 /* XPRoomBackContainerView.h */, E8AEAEEB27141AE20017FCE0 /* XPRoomBackContainerView.h */,
E8AEAEEC27141AE20017FCE0 /* XPRoomBackContainerView.m */, E8AEAEEC27141AE20017FCE0 /* XPRoomBackContainerView.m */,
E83DB47B2746372300D8CBD1 /* XPRoomGiftBannerView.h */, E83DB47B2746372300D8CBD1 /* XPRoomGiftBannerView.h */,
@@ -2396,6 +2409,7 @@
E884C3722743AEDE00E1EBED /* CustomAttachmentDecoder.m in Sources */, E884C3722743AEDE00E1EBED /* CustomAttachmentDecoder.m in Sources */,
E8B846BC26FD7C1200A777FE /* UploadImage.m in Sources */, E8B846BC26FD7C1200A777FE /* UploadImage.m in Sources */,
186A534D26FC6ED900D67B2C /* TTActionSheetView.m in Sources */, 186A534D26FC6ED900D67B2C /* TTActionSheetView.m in Sources */,
E83DB481274649FB00D8CBD1 /* XPGiftBannerUserInfoModel.m in Sources */,
E878893F273A54F500BF1D57 /* XPGiftPresenter.m in Sources */, E878893F273A54F500BF1D57 /* XPGiftPresenter.m in Sources */,
E8AEAEED27141AE20017FCE0 /* XPRoomBackContainerView.m in Sources */, E8AEAEED27141AE20017FCE0 /* XPRoomBackContainerView.m in Sources */,
E88B5CC126FB407B00DA9178 /* XPMineUserInfoViewController.m in Sources */, E88B5CC126FB407B00DA9178 /* XPMineUserInfoViewController.m in Sources */,

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_gift_all_mic@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_gift_all_mic@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_gift_banner_high_bg@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_gift_banner_high_bg@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_gift_banner_light@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_gift_banner_light@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_gift_banner_low_bg@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_gift_banner_low_bg@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_gift_banner_middle_bg@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_gift_banner_middle_bg@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -109,6 +109,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic,assign) RoomSendGiftType roomSendGiftType; @property (nonatomic,assign) RoomSendGiftType roomSendGiftType;
///是否是背包礼物 ///是否是背包礼物
@property (nonatomic,assign) BOOL isLuckyBagGift; @property (nonatomic,assign) BOOL isLuckyBagGift;
///是不是全麦
@property (nonatomic,assign) BOOL isBatch;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,19 @@
//
// XPGiftBannerUserInfoModel.h
// xplan-ios
//
// Created by 冯硕 on 2021/11/18.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPGiftBannerUserInfoModel : NSObject
///
@property (nonatomic,assign) int position;
///
@property (nonatomic,assign) NSInteger uid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,12 @@
//
// XPGiftBannerUserInfoModel.m
// xplan-ios
//
// Created by on 2021/11/18.
//
#import "XPGiftBannerUserInfoModel.h"
@implementation XPGiftBannerUserInfoModel
@end

View File

@@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface XPRoomBackContainerView : UIView @interface XPRoomBackContainerView : UIView
- (instancetype)initWithdelegate:(id<RoomHostDelegate>)delegate; - (instancetype)initWithdelegate:(id<RoomHostDelegate>)delegate;
- (void)superViewDidLayoutViews;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -10,19 +10,32 @@
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
#import <SVGA.h> #import <SVGA.h>
#import <NIMSDK/NIMSDK.h> #import <NIMSDK/NIMSDK.h>
#import <POP.h>
///Tool ///Tool
#import "XPGiftStorage.h" #import "XPGiftStorage.h"
#import "XPMacro.h" #import "XPMacro.h"
#import "ThemeColor+Room.h" #import "ThemeColor+Room.h"
///Model ///Model
#import "MicroQueueModel.h"
#import "MicroStateModel.h"
#import "UserInfoModel.h"
#import "GiftReceiveInfoModel.h" #import "GiftReceiveInfoModel.h"
#import "GiftInfoModel.h" #import "GiftInfoModel.h"
#import "RoomInfoModel.h" #import "RoomInfoModel.h"
#import "AttachmentModel.h" #import "AttachmentModel.h"
#import "XPGiftBigPrizeModel.h" #import "XPGiftBigPrizeModel.h"
#import "XPGiftBannerUserInfoModel.h"
///View
#import "XPRoomGiftBannerView.h"
@interface XPRoomBackContainerView ()<SVGAPlayerDelegate, NIMChatManagerDelegate> @interface XPRoomBackContainerView ()<SVGAPlayerDelegate, NIMChatManagerDelegate>
///
///
@property (nonatomic,strong) UIView * lowLevelView;
///
@property (nonatomic,strong) UIView * middleLevelView;
///
@property (nonatomic,strong) UIView * highLevleView;
/// ///
@property (strong, nonatomic) SVGAParser *parser; @property (strong, nonatomic) SVGAParser *parser;
/// ///
@@ -38,6 +51,10 @@
///520 ///520
@property (nonatomic,strong) NSMutableArray<GiftReceiveInfoModel *> *giftBannerQueue;; @property (nonatomic,strong) NSMutableArray<GiftReceiveInfoModel *> *giftBannerQueue;;
///
@property (strong,nonatomic)NSMutableSet * bannerDequePool;
///
@property (strong,nonatomic)NSMutableSet * bannerVisiablePool;
/// ///
@property (nonatomic,strong) NSMutableArray<XPGiftBigPrizeModel *> *bigPrizeGiftQueue; @property (nonatomic,strong) NSMutableArray<XPGiftBigPrizeModel *> *bigPrizeGiftQueue;
@@ -58,15 +75,37 @@
return self; return self;
} }
- (void)superViewDidLayoutViews {
[self.superview bringSubviewToFront:self.highLevleView];
[self.superview insertSubview:self.middleLevelView belowSubview:self.highLevleView];
[self.superview insertSubview:self.lowLevelView belowSubview:self.middleLevelView];
}
#pragma mark - Private Method #pragma mark - Private Method
- (void)initSubViews { - (void)initSubViews {
[self addSubview:self.backImageView]; [self addSubview:self.backImageView];
///
[self.superview addSubview:self.lowLevelView];
[self.superview addSubview:self.middleLevelView];
[self.superview addSubview:self.highLevleView];
} }
- (void)initSubViewConstraints { - (void)initSubViewConstraints {
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) { [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self); make.edges.mas_equalTo(self);
}]; }];
[self.lowLevelView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.superview);
}];
[self.middleLevelView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.superview);
}];
[self.highLevleView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.superview);
}];
} }
#pragma mark - NIMChatManagerDelegate #pragma mark - NIMChatManagerDelegate
- (void)onRecvMessages:(NSArray<NIMMessage *> *)messages { - (void)onRecvMessages:(NSArray<NIMMessage *> *)messages {
@@ -88,9 +127,11 @@
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data]; GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
if (attachment.first == CustomMessageType_Gift) { if (attachment.first == CustomMessageType_Gift) {
receiveInfo.isLuckyBagGift = attachment.second == Custom_Message_Sub_Gift_LuckySend; receiveInfo.isLuckyBagGift = attachment.second == Custom_Message_Sub_Gift_LuckySend;
receiveInfo.isBatch = YES;
[self receiveGift:receiveInfo]; [self receiveGift:receiveInfo];
} else if (attachment.first == CustomMessageType_ALLMicroSend) { // } else if (attachment.first == CustomMessageType_ALLMicroSend) { //
receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend); receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
[self receiveGift:receiveInfo]; [self receiveGift:receiveInfo];
} else if (attachment.first == CustomMessageType_LuckyBag) {// } else if (attachment.first == CustomMessageType_LuckyBag) {//
[self receiveLuckyGiftBigPrize:attachment]; [self receiveLuckyGiftBigPrize:attachment];
@@ -146,7 +187,7 @@
contentLabel.textAlignment = NSTextAlignmentCenter; contentLabel.textAlignment = NSTextAlignmentCenter;
contentLabel.numberOfLines = 2; contentLabel.numberOfLines = 2;
[luckyBgView addSubview:contentLabel]; [luckyBgView addSubview:contentLabel];
[self.superview addSubview:luckyBgView]; [self.middleLevelView addSubview:luckyBgView];
[UIView animateWithDuration:0.5 animations:^{ [UIView animateWithDuration:0.5 animations:^{
luckyBgView.frame = CGRectMake(0, kNavigationHeight + 15, KScreenWidth, 45); luckyBgView.frame = CGRectMake(0, kNavigationHeight + 15, KScreenWidth, 45);
} completion:^(BOOL finished) { } completion:^(BOOL finished) {
@@ -232,7 +273,6 @@
} }
} }
if (receiveInfo.targetUsers.count > 0 && receiveInfo.targetUids.count <= 0) { if (receiveInfo.targetUsers.count > 0 && receiveInfo.targetUids.count <= 0) {
receiveInfo.targetUids = [receiveInfo.targetUsers valueForKeyPath:@"uid"]; receiveInfo.targetUids = [receiveInfo.targetUsers valueForKeyPath:@"uid"];
} }
@@ -244,19 +284,85 @@
giftTotal = receiveInfo.giftNum * giftInfo.goldPrice; giftTotal = receiveInfo.giftNum * giftInfo.goldPrice;
} }
///
// if (giftTotal >= 520) { if (giftTotal >= 520) {
// if (self.giftBannerQueue.count == 0 || self.isAnimating == NO) { if (self.giftBannerQueue.count == 0) {
// [self _creatSpringView:giftReceiveInfo];// [self createGiftBannerViewAnimation:receiveInfo];//
// [self.giftBannerQueue addObject:receiveInfo]; [self.giftBannerQueue addObject:receiveInfo];
// } else { } else {
// [self.giftBannerQueue addObject:receiveInfo]; [self.giftBannerQueue addObject:receiveInfo];
// } }
// } }
} }
} }
/// - (void)createGiftBannerViewAnimation:(GiftReceiveInfoModel *)receiveInfo {
__block XPRoomGiftBannerView *view = [self.bannerDequePool anyObject];
if (view == nil) {
view = [[XPRoomGiftBannerView alloc] init];
[self.bannerVisiablePool addObject:view];
}else{
[self.bannerDequePool removeObject:view];
}
[view configGiftBanner:receiveInfo users:[self makeBannerUsers]];
view.frame = CGRectMake(KScreenWidth, 100, KScreenWidth, 153);
[self.middleLevelView addSubview:view];
POPSpringAnimation *springAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewCenter];
springAnimation.springSpeed = 12;
springAnimation.springBounciness = 10.f;
springAnimation.fromValue = [NSValue valueWithCGPoint:view.center];
springAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(view.frame.size.width / 2, view.center.y)];
@kWeakify(self);
[springAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
@kStrongify(self);
if (finished) {
[self removeAnimation:view];
}
}];
[view pop_addAnimation:springAnimation forKey:@"spingOutAnimation"];
}
//
- (void)removeAnimation:(XPRoomGiftBannerView *)view{
POPBasicAnimation *moveAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewCenter];
moveAnimation.fromValue = [NSValue valueWithCGPoint:view.center];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(view.center.x - KScreenWidth, view.center.y)];
moveAnimation.beginTime = CACurrentMediaTime() +5;
moveAnimation.duration = 0.5;
moveAnimation.repeatCount = 1;
moveAnimation.removedOnCompletion = YES;
@kWeakify(self);
[moveAnimation setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
@kStrongify(self);
if (finished) {
[self.giftBannerQueue removeObjectAtIndex:0];
if (self.giftBannerQueue.count > 0) {
[self createGiftBannerViewAnimation:self.giftBannerQueue.firstObject];
}
[view removeFromSuperview];
[view resetData];
[self.bannerVisiablePool removeObject:view];
[self.bannerDequePool addObject:view];
}
}];
[view pop_addAnimation:moveAnimation forKey:@"moveOutAnimation"];
}
- (NSArray<XPGiftBannerUserInfoModel *> *)makeBannerUsers {
NSArray<MicroQueueModel *> * microArray = [self.delegate getMicroQueue].allValues;
NSMutableArray * array = [NSMutableArray array];
[microArray enumerateObjectsUsingBlock:^(MicroQueueModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
XPGiftBannerUserInfoModel * bannserUser = [[XPGiftBannerUserInfoModel alloc] init];
bannserUser.position = obj.microState.position;
bannserUser.uid = obj.userInfo.uid;
[array addObject:bannserUser];
}];
return array;
}
/// SVGA
- (void)playGiftEffect:(GiftInfoModel *)giftInfo { - (void)playGiftEffect:(GiftInfoModel *)giftInfo {
self.isGiftEffectPlaying = YES; self.isGiftEffectPlaying = YES;
self.giftEffectView.hidden = NO; self.giftEffectView.hidden = NO;
@@ -268,7 +374,7 @@
make.height.mas_equalTo(KScreenHeight); make.height.mas_equalTo(KScreenHeight);
}]; }];
} }
[self.superview bringSubviewToFront:self.giftEffectView]; [self.lowLevelView bringSubviewToFront:self.giftEffectView];
[self.parser parseWithURL:[NSURL URLWithString:giftInfo.vggUrl] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) { [self.parser parseWithURL:[NSURL URLWithString:giftInfo.vggUrl] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
if (videoItem != nil) { if (videoItem != nil) {
CGFloat width = videoItem.videoSize.width; CGFloat width = videoItem.videoSize.width;
@@ -358,4 +464,41 @@
return _giftBannerQueue; return _giftBannerQueue;
} }
- (NSMutableSet *)bannerDequePool {
if (!_bannerDequePool) {
_bannerDequePool = [NSMutableSet set];
}
return _bannerDequePool;
}
- (NSMutableSet *)bannerVisiablePool {
if (!_bannerVisiablePool) {
_bannerVisiablePool = [NSMutableSet set];
}
return _bannerVisiablePool;
}
- (UIView *)lowLevelView {
if (!_lowLevelView) {
_lowLevelView = [[UIView alloc] init];
_lowLevelView.backgroundColor = [UIColor clearColor];
}
return _lowLevelView;
}
- (UIView *)middleLevelView {
if (!_middleLevelView) {
_middleLevelView = [[UIView alloc] init];
_middleLevelView.backgroundColor = [UIColor clearColor];
}
return _middleLevelView;
}
- (UIView *)highLevleView {
if (!_highLevleView) {
_highLevleView = [[UIView alloc] init];
_highLevleView.backgroundColor = [UIColor clearColor];
}
return _highLevleView;
}
@end @end

View File

@@ -8,8 +8,12 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class GiftReceiveInfoModel, XPGiftBannerUserInfoModel;
@interface XPRoomGiftBannerView : UIView @interface XPRoomGiftBannerView : UIView
///配上飘屏的数据
- (void)configGiftBanner:(GiftReceiveInfoModel *)receiveInfo users:(NSArray<XPGiftBannerUserInfoModel *> *)users;
///重置数据
- (void)resetData;
@end @end

View File

@@ -6,10 +6,22 @@
// //
#import "XPRoomGiftBannerView.h" #import "XPRoomGiftBannerView.h"
///Third
#import <Masonry/Masonry.h>
#import <pop/pop.h>
///Tool
#import "ThemeColor+Room.h"
#import "XPGiftStorage.h"
///Model
#import "GiftReceiveInfoModel.h"
#import "GiftInfoModel.h"
#import "XPGiftBannerUserInfoModel.h"
///View
#import "NetImageView.h"
@interface XPRoomAvatarNickView : UIView @interface XPRoomAvatarNickView : UIView
/// ///
@property (nonatomic,strong) UIImageView *avatImageView; @property (nonatomic,strong) NetImageView *avatImageView;
/// ///
@property (nonatomic,strong) UILabel *nickLabel; @property (nonatomic,strong) UILabel *nickLabel;
@end @end
@@ -18,34 +30,327 @@
- (instancetype)initWithFrame:(CGRect)frame { - (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) { if (self = [super initWithFrame:frame]) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
self.avatImageView.layer.cornerRadius = self.avatImageView.bounds.size.width / 2;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.avatImageView];
[self addSubview:self.nickLabel];
}
- (void)initSubViewConstraints {
[self mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.nickLabel.mas_bottom);
}];
[self.avatImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self);
make.height.mas_equalTo(self.avatImageView.mas_width);
}];
[self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self);
make.top.mas_equalTo(self.avatImageView.mas_bottom).offset(2);
make.width.mas_lessThanOrEqualTo(80);
}];
}
#pragma mark - Getters And Setters
- (NetImageView *)avatImageView {
if (!_avatImageView) {
_avatImageView = [[NetImageView alloc] init];
_avatImageView.userInteractionEnabled = YES;
_avatImageView.imageType = ImageTypeUserIcon;
_avatImageView.layer.masksToBounds = YES;
}
return _avatImageView;
}
- (UILabel *)nickLabel {
if (!_nickLabel) {
_nickLabel = [[UILabel alloc] init];
_nickLabel.font = [UIFont systemFontOfSize:12];
_nickLabel.textColor = [ThemeColor mainTextColor];
_nickLabel.textAlignment = NSTextAlignmentCenter;
}
return _nickLabel;
}
@end
@interface XPRoomGiftBannerView ()
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,strong) XPRoomAvatarNickView *sendView;
///
@property (nonatomic,strong) XPRoomAvatarNickView *receiveView;
///
@property (nonatomic,strong) XPRoomAvatarNickView *giftView;
///
@property (nonatomic,strong) UIImageView *lightImageView;
///
@property (nonatomic,strong) UILabel *giftCountLabel;
///
@property (nonatomic,strong) UILabel *sendLabel;
@end
@implementation XPRoomGiftBannerView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
} }
return self; return self;
} }
#pragma mark - Private Method #pragma mark - Private Method
- (void)initSubViews { - (void)initSubViews {
[self addSubview:self.backImageView];
[self.backImageView addSubview:self.sendView];
[self.backImageView addSubview:self.sendLabel];
[self.backImageView addSubview:self.receiveView];
[self.backImageView addSubview:self.lightImageView];
[self.backImageView addSubview:self.giftView];
[self.backImageView addSubview:self.giftCountLabel];
[self startLightCircleAnimation];
} }
- (void)initSubViewConstraints { - (void)initSubViewConstraints {
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self);
}];
[self.sendView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.backImageView).offset(49);
make.top.equalTo(self).offset(49);
make.width.mas_equalTo(40);
}];
[self.sendLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.sendView.mas_right).offset(24);
make.centerY.equalTo(self.sendView);
}];
[self.receiveView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.sendLabel.mas_right).offset(24);
make.centerY.width.equalTo(self.sendView);
}];
[self.lightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(self.receiveView.mas_right).offset(4);
make.centerY.equalTo(self.sendView);
make.width.height.equalTo(@100);
}];
[self.giftView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.equalTo(self.sendView);
make.center.equalTo(self.lightImageView);
}];
[self.giftCountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.giftView);
make.right.equalTo(self.backImageView).offset(-36);
}];
}
- (void)startLightCircleAnimation {
CABasicAnimation * animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
animation.duration = 1;
animation.cumulative = YES;
animation.repeatCount = MAXFLOAT;
[self.lightImageView.layer addAnimation:animation forKey:@"rotationAnimation"];
}
#pragma mark - Public Method
- (void)resetData {
self.sendView.avatImageView.image = nil;
self.sendView.nickLabel.text = nil;
self.receiveView.avatImageView.image = nil;
self.receiveView.nickLabel.text = nil;
self.giftView.avatImageView.image = nil;
self.giftView.nickLabel.text = nil;
self.giftCountLabel.text = nil;
}
- (void)configGiftBanner:(GiftReceiveInfoModel *)receiveInfo users:(NSArray<XPGiftBannerUserInfoModel *> *)users {
if (receiveInfo) {
NSInteger giftTotal = 0;
GiftInfoModel *giftInfo = receiveInfo.gift == nil ? receiveInfo.giftInfo : receiveInfo.gift;
if (!giftInfo) {
giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:receiveInfo.giftId];
}
self.sendView.avatImageView.imageUrl = receiveInfo.avatar;
self.sendView.nickLabel.text = receiveInfo.nick;
self.giftView.avatImageView.imageUrl = giftInfo.giftUrl;
self.giftView.nickLabel.text = giftInfo.giftName;
self.giftCountLabel.text = [NSString stringWithFormat:@" x %ld",receiveInfo.giftNum];
/*1. targetUid
2. targetUsers
3. targetUids
4. targetUid */
if (receiveInfo.targetUsers.count > 0) {
if (receiveInfo.isBatch) { //
NSString *subTitle = @"";
NSArray *targetUids = receiveInfo.targetUsers;
for (GiftReceiveUserInfoModel *targetUid in targetUids) {
NSInteger position = [self findPositionByUid:targetUid.uid users:users];
if (position == 0) {
continue; // ,
}
position += 1;
if (subTitle.length > 0) {
subTitle = [subTitle stringByAppendingFormat:@",%ld麦", position];
} else {
subTitle = [subTitle stringByAppendingFormat:@"%ld麦", position];
}
}
if (receiveInfo.targetUsers.count == 1) {
self.receiveView.nickLabel.text = [receiveInfo.targetUsers firstObject].nick;
self.receiveView.avatImageView.imageUrl = [receiveInfo.targetUsers firstObject].avatar;
} else {
self.receiveView.avatImageView.image = [UIImage imageNamed:@"room_gift_all_mic"];
self.receiveView.nickLabel.text = subTitle;
}
giftTotal = receiveInfo.giftNum * giftInfo.goldPrice * receiveInfo.targetUsers.count;
} else { //
self.receiveView.avatImageView.image = [UIImage imageNamed:@"room_gift_all_mic"];
self.receiveView.nickLabel.text = @"全麦";
giftTotal = receiveInfo.giftNum * giftInfo.goldPrice * receiveInfo.targetUsers.count;
}
}else if (receiveInfo.targetUids.count > 0) {///
if (receiveInfo.isBatch) {
NSString *subTitle = @"";
NSArray *targetUids = receiveInfo.targetUids;
for (NSString * targetUid in targetUids) {
NSInteger position = [self findPositionByUid:targetUid.integerValue users:users];
if (position == 0) {
continue; // ,
}
position+= 1;
if (subTitle.length > 0) {
subTitle = [subTitle stringByAppendingFormat:@",%ld麦", position];
} else {
subTitle = [subTitle stringByAppendingFormat:@"%ld麦", position];
}
}
self.receiveView.avatImageView.image = [UIImage imageNamed:@"room_gift_all_mic"];
self.receiveView.nickLabel.text = subTitle;
giftTotal = receiveInfo.giftNum * giftInfo.goldPrice * receiveInfo.targetUids.count;
} else { //
self.receiveView.avatImageView.image = [UIImage imageNamed:@"room_gift_all_mic"];
self.receiveView.nickLabel.text = @"全麦";
giftTotal = receiveInfo.giftNum * giftInfo.goldPrice * receiveInfo.targetUids.count;
}
}else {
self.receiveView.avatImageView.imageUrl = receiveInfo.targetAvatar;
self.receiveView.nickLabel.text = receiveInfo.targetNick;
giftTotal = receiveInfo.giftNum * giftInfo.goldPrice;
}
[self configAnimateImageByGiftTotal:giftTotal];
}
}
- (void)configAnimateImageByGiftTotal:(NSInteger)giftTotal {
if (giftTotal >= 520 && giftTotal < 4999) {
self.backImageView.image = [UIImage imageNamed:@"room_gift_banner_low_bg"];
}else if (giftTotal >= 4999 && giftTotal < 9999) {
self.backImageView.image = [UIImage imageNamed:@"room_gift_banner_middle_bg"];
}else if (giftTotal >= 9999) {
self.backImageView.image = [UIImage imageNamed:@"room_gift_banner_high_bg"];
}
} }
- (int)findPositionByUid:(NSInteger)uid users:(NSArray<XPGiftBannerUserInfoModel *> *)users{
@end if (uid > 0) {
for (XPGiftBannerUserInfoModel *userInfo in users) {
if (userInfo.uid == uid) {
return userInfo.position;
}
}
}
return 0;
}
#pragma mark - Getters And Setters
- (UIImageView *)backImageView {
if (!_backImageView) {
_backImageView = [[UIImageView alloc] init];
_backImageView.userInteractionEnabled = YES;
}
return _backImageView;
}
@interface XPRoomGiftBannerView () - (XPRoomAvatarNickView *)sendView {
/// if (!_sendView) {
@property (nonatomic,strong) UIImageView *backImageView; _sendView = [[XPRoomAvatarNickView alloc] init];
}
return _sendView;
}
@end - (XPRoomAvatarNickView *)receiveView {
if (!_receiveView) {
_receiveView = [[XPRoomAvatarNickView alloc] init];
}
return _receiveView;
}
- (XPRoomAvatarNickView *)giftView {
if (!_giftView) {
_giftView = [[XPRoomAvatarNickView alloc] init];
}
return _giftView;
}
@implementation XPRoomGiftBannerView - (UILabel *)sendLabel {
if (!_sendLabel) {
_sendLabel = [[UILabel alloc] init];
_sendLabel.text = @"赠送";
_sendLabel.font = [UIFont systemFontOfSize:12];
_sendLabel.textColor = [ThemeColor mainTextColor];
}
return _sendLabel;
}
- (UIImageView *)lightImageView {
if (!_lightImageView) {
_lightImageView = [[UIImageView alloc] init];
_lightImageView.userInteractionEnabled = YES;
_lightImageView.image = [UIImage imageNamed:@"room_gift_banner_light"];
}
return _lightImageView;
}
- (UILabel *)giftCountLabel {
if (!_giftCountLabel) {
_giftCountLabel = [[UILabel alloc] init];
_giftCountLabel.font = [UIFont systemFontOfSize:20.f weight:UIFontWeightBold];
_giftCountLabel.textColor = [ThemeColor mainTextColor];
}
return _giftCountLabel;
}
@end @end

View File

@@ -89,6 +89,11 @@
[self.view endEditing:YES]; [self.view endEditing:YES];
} }
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
[self.backContainerView superViewDidLayoutViews];
}
#pragma mark - Private Method #pragma mark - Private Method
- (void)initSubViews { - (void)initSubViews {
[self.view addSubview:self.backContainerView]; [self.view addSubview:self.backContainerView];