房间520横幅
@@ -140,6 +140,7 @@
|
||||
E82EE0F8272FDDFA00D15DC1 /* UserPrivacyView.m in Sources */ = {isa = PBXBuildFile; fileRef = E82EE0F7272FDDFA00D15DC1 /* UserPrivacyView.m */; };
|
||||
E83DB47A27462C4500D8CBD1 /* XPGiftBigPrizeModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E83DB47927462C4500D8CBD1 /* XPGiftBigPrizeModel.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 */; };
|
||||
E84B0E422727EE0A008818C6 /* XPRoomMessageHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = E84B0E412727EE0A008818C6 /* XPRoomMessageHeaderView.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>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
@@ -1321,8 +1324,6 @@
|
||||
E804875F2717DD70008595F2 /* Model */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E83DB47827462C4500D8CBD1 /* XPGiftBigPrizeModel.h */,
|
||||
E83DB47927462C4500D8CBD1 /* XPGiftBigPrizeModel.m */,
|
||||
E89D60BF271D64B9001F8895 /* RoomInfoModel.h */,
|
||||
E89D60C0271D64B9001F8895 /* RoomInfoModel.m */,
|
||||
);
|
||||
@@ -1426,6 +1427,17 @@
|
||||
path = UIImage;
|
||||
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 */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -1782,6 +1794,7 @@
|
||||
E8AEAEE727141ACC0017FCE0 /* BaseUIContainerView */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E83DB47E274649B200D8CBD1 /* Model */,
|
||||
E8AEAEEB27141AE20017FCE0 /* XPRoomBackContainerView.h */,
|
||||
E8AEAEEC27141AE20017FCE0 /* XPRoomBackContainerView.m */,
|
||||
E83DB47B2746372300D8CBD1 /* XPRoomGiftBannerView.h */,
|
||||
@@ -2396,6 +2409,7 @@
|
||||
E884C3722743AEDE00E1EBED /* CustomAttachmentDecoder.m in Sources */,
|
||||
E8B846BC26FD7C1200A777FE /* UploadImage.m in Sources */,
|
||||
186A534D26FC6ED900D67B2C /* TTActionSheetView.m in Sources */,
|
||||
E83DB481274649FB00D8CBD1 /* XPGiftBannerUserInfoModel.m in Sources */,
|
||||
E878893F273A54F500BF1D57 /* XPGiftPresenter.m in Sources */,
|
||||
E8AEAEED27141AE20017FCE0 /* XPRoomBackContainerView.m in Sources */,
|
||||
E88B5CC126FB407B00DA9178 /* XPMineUserInfoViewController.m in Sources */,
|
||||
|
22
xplan-ios/Assets.xcassets/Room/room_gift_all_mic.imageset/Contents.json
vendored
Normal 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
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Room/room_gift_all_mic.imageset/room_gift_all_mic@2x.png
vendored
Normal file
After Width: | Height: | Size: 5.9 KiB |
BIN
xplan-ios/Assets.xcassets/Room/room_gift_all_mic.imageset/room_gift_all_mic@3x.png
vendored
Normal file
After Width: | Height: | Size: 10 KiB |
22
xplan-ios/Assets.xcassets/Room/room_gift_banner_high_bg.imageset/Contents.json
vendored
Normal 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
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Room/room_gift_banner_high_bg.imageset/room_gift_banner_high_bg@2x.png
vendored
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
xplan-ios/Assets.xcassets/Room/room_gift_banner_high_bg.imageset/room_gift_banner_high_bg@3x.png
vendored
Normal file
After Width: | Height: | Size: 47 KiB |
22
xplan-ios/Assets.xcassets/Room/room_gift_banner_light.imageset/Contents.json
vendored
Normal 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
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Room/room_gift_banner_light.imageset/room_gift_banner_light@2x.png
vendored
Normal file
After Width: | Height: | Size: 4.7 KiB |
BIN
xplan-ios/Assets.xcassets/Room/room_gift_banner_light.imageset/room_gift_banner_light@3x.png
vendored
Normal file
After Width: | Height: | Size: 9.2 KiB |
22
xplan-ios/Assets.xcassets/Room/room_gift_banner_low_bg.imageset/Contents.json
vendored
Normal 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
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Room/room_gift_banner_low_bg.imageset/room_gift_banner_low_bg@2x.png
vendored
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
xplan-ios/Assets.xcassets/Room/room_gift_banner_low_bg.imageset/room_gift_banner_low_bg@3x.png
vendored
Normal file
After Width: | Height: | Size: 40 KiB |
22
xplan-ios/Assets.xcassets/Room/room_gift_banner_middle_bg.imageset/Contents.json
vendored
Normal 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
|
||||
}
|
||||
}
|
BIN
xplan-ios/Assets.xcassets/Room/room_gift_banner_middle_bg.imageset/room_gift_banner_middle_bg@2x.png
vendored
Normal file
After Width: | Height: | Size: 24 KiB |
BIN
xplan-ios/Assets.xcassets/Room/room_gift_banner_middle_bg.imageset/room_gift_banner_middle_bg@3x.png
vendored
Normal file
After Width: | Height: | Size: 38 KiB |
@@ -109,6 +109,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property (nonatomic,assign) RoomSendGiftType roomSendGiftType;
|
||||
///是否是背包礼物
|
||||
@property (nonatomic,assign) BOOL isLuckyBagGift;
|
||||
///是不是全麦
|
||||
@property (nonatomic,assign) BOOL isBatch;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -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
|
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// XPGiftBannerUserInfoModel.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2021/11/18.
|
||||
//
|
||||
|
||||
#import "XPGiftBannerUserInfoModel.h"
|
||||
|
||||
@implementation XPGiftBannerUserInfoModel
|
||||
|
||||
@end
|
@@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPRoomBackContainerView : UIView
|
||||
- (instancetype)initWithdelegate:(id<RoomHostDelegate>)delegate;
|
||||
|
||||
- (void)superViewDidLayoutViews;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@@ -10,19 +10,32 @@
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <SVGA.h>
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
#import <POP.h>
|
||||
///Tool
|
||||
#import "XPGiftStorage.h"
|
||||
#import "XPMacro.h"
|
||||
#import "ThemeColor+Room.h"
|
||||
///Model
|
||||
#import "MicroQueueModel.h"
|
||||
#import "MicroStateModel.h"
|
||||
#import "UserInfoModel.h"
|
||||
#import "GiftReceiveInfoModel.h"
|
||||
#import "GiftInfoModel.h"
|
||||
#import "RoomInfoModel.h"
|
||||
#import "AttachmentModel.h"
|
||||
#import "XPGiftBigPrizeModel.h"
|
||||
|
||||
#import "XPGiftBannerUserInfoModel.h"
|
||||
///View
|
||||
#import "XPRoomGiftBannerView.h"
|
||||
|
||||
@interface XPRoomBackContainerView ()<SVGAPlayerDelegate, NIMChatManagerDelegate>
|
||||
///展示的不同层级
|
||||
///最底层的
|
||||
@property (nonatomic,strong) UIView * lowLevelView;
|
||||
///中层的
|
||||
@property (nonatomic,strong) UIView * middleLevelView;
|
||||
///高层的
|
||||
@property (nonatomic,strong) UIView * highLevleView;
|
||||
///动画管理类
|
||||
@property (strong, nonatomic) SVGAParser *parser;
|
||||
///送礼物的特效
|
||||
@@ -38,6 +51,10 @@
|
||||
|
||||
///礼物价格大于520横幅的队列
|
||||
@property (nonatomic,strong) NSMutableArray<GiftReceiveInfoModel *> *giftBannerQueue;;
|
||||
///复用池
|
||||
@property (strong,nonatomic)NSMutableSet * bannerDequePool;
|
||||
///可见池
|
||||
@property (strong,nonatomic)NSMutableSet * bannerVisiablePool;
|
||||
|
||||
///福袋大礼物的队列
|
||||
@property (nonatomic,strong) NSMutableArray<XPGiftBigPrizeModel *> *bigPrizeGiftQueue;
|
||||
@@ -58,15 +75,37 @@
|
||||
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
|
||||
- (void)initSubViews {
|
||||
[self addSubview:self.backImageView];
|
||||
///需要那一层的就加到那一层上面
|
||||
[self.superview addSubview:self.lowLevelView];
|
||||
[self.superview addSubview:self.middleLevelView];
|
||||
[self.superview addSubview:self.highLevleView];
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
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
|
||||
- (void)onRecvMessages:(NSArray<NIMMessage *> *)messages {
|
||||
@@ -88,9 +127,11 @@
|
||||
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
|
||||
if (attachment.first == CustomMessageType_Gift) {
|
||||
receiveInfo.isLuckyBagGift = attachment.second == Custom_Message_Sub_Gift_LuckySend;
|
||||
receiveInfo.isBatch = YES;
|
||||
[self receiveGift:receiveInfo];
|
||||
} else if (attachment.first == CustomMessageType_ALLMicroSend) { //发送全麦礼物 或者多人礼物
|
||||
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];
|
||||
} else if (attachment.first == CustomMessageType_LuckyBag) {//福袋消息厅内展示
|
||||
[self receiveLuckyGiftBigPrize:attachment];
|
||||
@@ -146,7 +187,7 @@
|
||||
contentLabel.textAlignment = NSTextAlignmentCenter;
|
||||
contentLabel.numberOfLines = 2;
|
||||
[luckyBgView addSubview:contentLabel];
|
||||
[self.superview addSubview:luckyBgView];
|
||||
[self.middleLevelView addSubview:luckyBgView];
|
||||
[UIView animateWithDuration:0.5 animations:^{
|
||||
luckyBgView.frame = CGRectMake(0, kNavigationHeight + 15, KScreenWidth, 45);
|
||||
} completion:^(BOOL finished) {
|
||||
@@ -232,7 +273,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (receiveInfo.targetUsers.count > 0 && receiveInfo.targetUids.count <= 0) {
|
||||
receiveInfo.targetUids = [receiveInfo.targetUsers valueForKeyPath:@"uid"];
|
||||
}
|
||||
@@ -244,19 +284,85 @@
|
||||
giftTotal = receiveInfo.giftNum * giftInfo.goldPrice;
|
||||
}
|
||||
|
||||
|
||||
// if (giftTotal >= 520) {
|
||||
// if (self.giftBannerQueue.count == 0 || self.isAnimating == NO) {
|
||||
// [self _creatSpringView:giftReceiveInfo];//创建特效动画
|
||||
// [self.giftBannerQueue addObject:receiveInfo];
|
||||
// } else {
|
||||
// [self.giftBannerQueue addObject:receiveInfo];
|
||||
// }
|
||||
// }
|
||||
///房间横幅
|
||||
if (giftTotal >= 520) {
|
||||
if (self.giftBannerQueue.count == 0) {
|
||||
[self createGiftBannerViewAnimation:receiveInfo];//创建特效动画
|
||||
[self.giftBannerQueue addObject:receiveInfo];
|
||||
} else {
|
||||
[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 {
|
||||
self.isGiftEffectPlaying = YES;
|
||||
self.giftEffectView.hidden = NO;
|
||||
@@ -268,7 +374,7 @@
|
||||
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) {
|
||||
if (videoItem != nil) {
|
||||
CGFloat width = videoItem.videoSize.width;
|
||||
@@ -358,4 +464,41 @@
|
||||
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
|
||||
|
@@ -8,8 +8,12 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class GiftReceiveInfoModel, XPGiftBannerUserInfoModel;
|
||||
@interface XPRoomGiftBannerView : UIView
|
||||
///配上飘屏的数据
|
||||
- (void)configGiftBanner:(GiftReceiveInfoModel *)receiveInfo users:(NSArray<XPGiftBannerUserInfoModel *> *)users;
|
||||
///重置数据
|
||||
- (void)resetData;
|
||||
|
||||
@end
|
||||
|
||||
|
@@ -6,10 +6,22 @@
|
||||
//
|
||||
|
||||
#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
|
||||
///
|
||||
@property (nonatomic,strong) UIImageView *avatImageView;
|
||||
@property (nonatomic,strong) NetImageView *avatImageView;
|
||||
///
|
||||
@property (nonatomic,strong) UILabel *nickLabel;
|
||||
@end
|
||||
@@ -18,34 +30,327 @@
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)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;
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (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 {
|
||||
[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"];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@end
|
||||
- (int)findPositionByUid:(NSInteger)uid users:(NSArray<XPGiftBannerUserInfoModel *> *)users{
|
||||
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 ()
|
||||
///
|
||||
@property (nonatomic,strong) UIImageView *backImageView;
|
||||
- (XPRoomAvatarNickView *)sendView {
|
||||
if (!_sendView) {
|
||||
_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
|
||||
|
@@ -89,6 +89,11 @@
|
||||
[self.view endEditing:YES];
|
||||
}
|
||||
|
||||
- (void)viewDidLayoutSubviews {
|
||||
[super viewDidLayoutSubviews];
|
||||
[self.backContainerView superViewDidLayoutViews];
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self.view addSubview:self.backContainerView];
|
||||
|