房间送礼物特效 福袋飘屏动画

This commit is contained in:
fengshuo
2021-11-18 15:34:52 +08:00
parent e4ec4c4228
commit 18f57d502e
17 changed files with 493 additions and 10 deletions

View File

@@ -45,6 +45,7 @@ target 'xplan-ios' do
pod 'mob_sharesdk/ShareSDKPlatforms/WeChat'
pod 'mob_sharesdk/ShareSDKPlatforms/Apple'
pod 'mob_sharesdk/ShareSDKExtension'
pod 'SVGAPlayer', '~> 2.3'
#调试
pod 'LookinServer', :configurations => ['Debug']

View File

@@ -46,6 +46,7 @@ PODS:
- NIMSDK_LITE (7.8.5)
- NTESQuickPass (2.1.9)
- pop (1.0.12)
- Protobuf (3.19.1)
- Qiniu (8.3.2):
- HappyDNS (~> 0.3.17)
- ReactiveObjC (3.1.1)
@@ -55,6 +56,15 @@ PODS:
- SDWebImage/Core (= 5.11.1)
- SDWebImage/Core (5.11.1)
- SSKeychain (1.4.1)
- SSZipArchive (2.4.2)
- SVGAPlayer (2.5.7):
- SVGAPlayer/Core (= 2.5.7)
- SVGAPlayer/ProtoFiles (= 2.5.7)
- SVGAPlayer/Core (2.5.7):
- SSZipArchive (>= 1.8.1)
- SVGAPlayer/ProtoFiles
- SVGAPlayer/ProtoFiles (2.5.7):
- Protobuf (~> 3.4)
- SZTextView (1.3.0)
- YYText (1.0.7)
@@ -83,6 +93,7 @@ DEPENDENCIES:
- SDCycleScrollView
- SDWebImage
- SSKeychain
- SVGAPlayer (~> 2.3)
- SZTextView
- YYText
@@ -105,11 +116,14 @@ SPEC REPOS:
- NIMSDK_LITE
- NTESQuickPass
- pop
- Protobuf
- Qiniu
- ReactiveObjC
- SDCycleScrollView
- SDWebImage
- SSKeychain
- SSZipArchive
- SVGAPlayer
- SZTextView
- YYText
@@ -131,14 +145,17 @@ SPEC CHECKSUMS:
NIMSDK_LITE: 8e28ae0a26dd1dccc4684b697381f0a72a733f51
NTESQuickPass: 8431dc52737c95883cd382c2ee75664d58f39377
pop: d582054913807fd11fd50bfe6a539d91c7e1a55a
Protobuf: 3724efa50cb2846d7ccebc8691c574e85fd74471
Qiniu: 61f1e2fdfb35b37f98c8f03a718faf12652f9994
ReactiveObjC: 011caa393aa0383245f2dcf9bf02e86b80b36040
SDCycleScrollView: a0d74c3384caa72bdfc81470bdbc8c14b3e1fbcf
SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d
SSKeychain: 55cc80f66f5c73da827e3077f02e43528897db41
SSZipArchive: e7b4f3d9e780c2acc1764cd88fbf2de28f26e5b2
SVGAPlayer: 318b85a78b61292d6ae9dfcd651f3f0d1cdadd86
SZTextView: 094dc6acc9beec537685c545d6e3e0d4975174e1
YYText: 5c461d709e24d55a182d1441c41dc639a18a4849
PODFILE CHECKSUM: c67a976c4f7626b406093a8fb7efe4601ebeda8a
PODFILE CHECKSUM: e8e216a3e86155b1d25433a4eb105e33395eca92
COCOAPODS: 1.10.1

View File

@@ -138,6 +138,8 @@
E824546426F5FF1C00BE8163 /* XPMineResetPayPasswordPresenter.m in Sources */ = {isa = PBXBuildFile; fileRef = E824546326F5FF1C00BE8163 /* XPMineResetPayPasswordPresenter.m */; };
E824546626F5FF6000BE8163 /* XPMineResetPayPasswordProtocol.h in Sources */ = {isa = PBXBuildFile; fileRef = E824546526F5FF5100BE8163 /* XPMineResetPayPasswordProtocol.h */; };
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 */; };
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 */; };
@@ -515,6 +517,10 @@
E824546526F5FF5100BE8163 /* XPMineResetPayPasswordProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineResetPayPasswordProtocol.h; sourceTree = "<group>"; };
E82EE0F6272FDDFA00D15DC1 /* UserPrivacyView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UserPrivacyView.h; sourceTree = "<group>"; };
E82EE0F7272FDDFA00D15DC1 /* UserPrivacyView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UserPrivacyView.m; sourceTree = "<group>"; };
E83DB47827462C4500D8CBD1 /* XPGiftBigPrizeModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPGiftBigPrizeModel.h; 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>"; };
E83DB47C2746372300D8CBD1 /* XPRoomGiftBannerView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomGiftBannerView.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>"; };
@@ -1315,6 +1321,8 @@
E804875F2717DD70008595F2 /* Model */ = {
isa = PBXGroup;
children = (
E83DB47827462C4500D8CBD1 /* XPGiftBigPrizeModel.h */,
E83DB47927462C4500D8CBD1 /* XPGiftBigPrizeModel.m */,
E89D60BF271D64B9001F8895 /* RoomInfoModel.h */,
E89D60C0271D64B9001F8895 /* RoomInfoModel.m */,
);
@@ -1776,6 +1784,8 @@
children = (
E8AEAEEB27141AE20017FCE0 /* XPRoomBackContainerView.h */,
E8AEAEEC27141AE20017FCE0 /* XPRoomBackContainerView.m */,
E83DB47B2746372300D8CBD1 /* XPRoomGiftBannerView.h */,
E83DB47C2746372300D8CBD1 /* XPRoomGiftBannerView.m */,
);
path = BaseUIContainerView;
sourceTree = "<group>";
@@ -2227,6 +2237,7 @@
E8AC723226F49710007D6E91 /* XPMineNotificationTableViewCell.m in Sources */,
E8AC722926F488DA007D6E91 /* XPMineFeedbackProtocol.h in Sources */,
E8AC721E26F472BF007D6E91 /* XPMineSettingProtocol.h in Sources */,
E83DB47A27462C4500D8CBD1 /* XPGiftBigPrizeModel.m in Sources */,
E81366F826F0C12A0076364C /* LoginFullInfoProtocol.h in Sources */,
E8E70D7E26F2F19D00F03460 /* Api+Mine.m in Sources */,
E824543D26F58C3A00BE8163 /* XPLoginBindSuccessView.m in Sources */,
@@ -2374,6 +2385,7 @@
187EEEF026E89FE8002833B2 /* AccountInfoStorage.m in Sources */,
186A536B26FC6F2E00D67B2C /* XCShareItemCell.m in Sources */,
E8B846C526FDB41A00A777FE /* XPMineUserInfolbumPresenter.m in Sources */,
E83DB47D2746372300D8CBD1 /* XPRoomGiftBannerView.m in Sources */,
E872309326E8D31500B90D4F /* LoginVerifCodeView.m in Sources */,
186A534626FC6ED900D67B2C /* TTPopup.m in Sources */,
E81C278C26EAFAF60031E639 /* Base64.m in Sources */,

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@@ -10,8 +10,12 @@
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, CustomMessageType) {
CustomMessageType_Gift = 3,///送礼物的接口
CustomMessageType_ALLMicroSend = 12, //全麦送
///送礼物的接口
CustomMessageType_Gift = 3,
///全麦送
CustomMessageType_ALLMicroSend = 12,
///福袋消息
CustomMessageType_LuckyBag = 61,
};
@@ -28,6 +32,14 @@ typedef NS_ENUM(NSUInteger, CustomMessageSubAllMicroSend) {
Custom_Message_Sub_AllBatchMicroLuckySend = 124, // 非全麦 多人送福袋礼物
};
typedef NS_ENUM(NSUInteger, CustomMessageSubLuckyBag) {
/// 福袋礼物房间飘屏通知
Custom_Message_Sub_Room_Gift_LuckBag= 610,
/// 福袋礼物全服飘屏通知
Custom_Message_Sub_Room_Gift_LuckBag_Server = 611,
};
@interface AttachmentModel : NSObject<NIMCustomAttachment>
@property (nonatomic,assign) int first;

View File

@@ -107,6 +107,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic,assign) GiftSourceType sourceType;
///房间送礼物的类型
@property (nonatomic,assign) RoomSendGiftType roomSendGiftType;
///是否是背包礼物
@property (nonatomic,assign) BOOL isLuckyBagGift;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,21 @@
//
// XPGiftBigPrizeModel.h
// xplan-ios
//
// Created by 冯硕 on 2021/11/18.
//
///四级礼物的模型
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPGiftBigPrizeModel : NSObject
///送礼物的人
@property(nonatomic, copy)NSString *nick;
///礼物的名称
@property(nonatomic, copy)NSString *giftName;
///幸运的礼物
@property (nonatomic,copy) NSString *luckyBagName;
@end
NS_ASSUME_NONNULL_END

View File

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

View File

@@ -6,11 +6,11 @@
//
#import <UIKit/UIKit.h>
#import "RoomHostDelegate.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPRoomBackContainerView : UIView
- (instancetype)initWithdelegate:(id<RoomHostDelegate>)delegate;
@end
NS_ASSUME_NONNULL_END

View File

@@ -8,17 +8,50 @@
#import "XPRoomBackContainerView.h"
///Third
#import <Masonry/Masonry.h>
#import <SVGA.h>
#import <NIMSDK/NIMSDK.h>
///Tool
#import "XPGiftStorage.h"
#import "XPMacro.h"
#import "ThemeColor+Room.h"
///Model
#import "GiftReceiveInfoModel.h"
#import "GiftInfoModel.h"
#import "RoomInfoModel.h"
#import "AttachmentModel.h"
#import "XPGiftBigPrizeModel.h"
@interface XPRoomBackContainerView ()
@interface XPRoomBackContainerView ()<SVGAPlayerDelegate, NIMChatManagerDelegate>
///
@property (strong, nonatomic) SVGAParser *parser;
///
@property (nonatomic,strong) SVGAImageView *giftEffectView;
///
@property (nonatomic,strong) UIImageView *backImageView;
///
@property (nonatomic,weak) id<RoomHostDelegate>delegate;
///
@property (nonatomic,strong) NSMutableArray<GiftInfoModel *> *giftEffectQueue;
///
@property (nonatomic,assign) BOOL isGiftEffectPlaying;
///520
@property (nonatomic,strong) NSMutableArray<GiftReceiveInfoModel *> *giftBannerQueue;;
///
@property (nonatomic,strong) NSMutableArray<XPGiftBigPrizeModel *> *bigPrizeGiftQueue;
///
@property (nonatomic,strong)dispatch_source_t luckyprizeTimer;
@end
@implementation XPRoomBackContainerView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
- (instancetype)initWithdelegate:(id<RoomHostDelegate>)delegate {
self = [super init];
if (self) {
[[NIMSDK sharedSDK].chatManager addDelegate:self];
self.delegate = delegate;
[self initSubViews];
[self initSubViewConstraints];
}
@@ -35,6 +68,244 @@
make.edges.mas_equalTo(self);
}];
}
#pragma mark - NIMChatManagerDelegate
- (void)onRecvMessages:(NSArray<NIMMessage *> *)messages {
for (NIMMessage * message in messages) {
[self handleMessage:message];
}
}
//
- (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error {
[self handleMessage:message];
}
- (void)handleMessage:(NIMMessage *)message {
if (message.session.sessionType == NIMSessionTypeChatroom && message.messageType == NIMMessageTypeCustom) {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
if (attachment.first == CustomMessageType_Gift) {
receiveInfo.isLuckyBagGift = attachment.second == Custom_Message_Sub_Gift_LuckySend;
[self receiveGift:receiveInfo];
} else if (attachment.first == CustomMessageType_ALLMicroSend) { //
receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
[self receiveGift:receiveInfo];
} else if (attachment.first == CustomMessageType_LuckyBag) {//
[self receiveLuckyGiftBigPrize:attachment];
}
}
}
}
#pragma mark -
- (void)receiveLuckyGiftBigPrize:(AttachmentModel *)attachment {
if (attachment.second == Custom_Message_Sub_Room_Gift_LuckBag || attachment.second == Custom_Message_Sub_Room_Gift_LuckBag_Server) {
XPGiftBigPrizeModel * prizeModel = [[XPGiftBigPrizeModel alloc] init];
prizeModel.giftName = attachment.data[@"giftName"];
prizeModel.luckyBagName = attachment.data[@"luckyBagName"];
prizeModel.nick = attachment.data[@"nick"];
[self.bigPrizeGiftQueue addObject:prizeModel];
if (self.luckyprizeTimer == nil) {
[self startHandleBigPrizeGiftTimer];
}
}
}
- (void)startHandleBigPrizeGiftTimer {
NSTimeInterval period = 1.0; //
dispatch_queue_t queue = dispatch_get_global_queue(0, 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); //
@kWeakify(self);
dispatch_source_set_event_handler(_timer, ^{
@kStrongify(self)
if (self.bigPrizeGiftQueue.count > 0) {
dispatch_sync(dispatch_get_main_queue(), ^{
XPGiftBigPrizeModel * prizeModel = [self.bigPrizeGiftQueue firstObject];
[self createBigPrizeAnimation:prizeModel];
[self.bigPrizeGiftQueue removeObject:prizeModel];
});
}else {
dispatch_source_cancel(_timer);
self.luckyprizeTimer = nil;
}
});
dispatch_resume(_timer);
self.luckyprizeTimer = _timer;
}
- (void)createBigPrizeAnimation:(XPGiftBigPrizeModel *)prizeModel {
NSAttributedString *text = [self createBigPrizeAttribute:prizeModel];
UIImageView *luckyBgView = [[UIImageView alloc] initWithFrame:CGRectMake(KScreenWidth, kNavigationHeight + 15, KScreenWidth, 45)];
luckyBgView.contentMode = UIViewContentModeScaleAspectFill;
luckyBgView.image= [UIImage imageNamed:@"room_lucky_gift_big_prize_bg"];
UILabel *contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(90, 0, KScreenWidth - 160, 45)];
contentLabel.attributedText = text;
contentLabel.textAlignment = NSTextAlignmentCenter;
contentLabel.numberOfLines = 2;
[luckyBgView addSubview:contentLabel];
[self.superview addSubview:luckyBgView];
[UIView animateWithDuration:0.5 animations:^{
luckyBgView.frame = CGRectMake(0, kNavigationHeight + 15, KScreenWidth, 45);
} completion:^(BOOL finished) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[UIView animateWithDuration:0.5 animations:^{
luckyBgView.hidden = YES;
} completion:^(BOOL finished) {
[luckyBgView removeFromSuperview];
}];
});
}];
}
- (NSAttributedString *)createBigPrizeAttribute:(XPGiftBigPrizeModel *)prizModel {
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init];
[attributedString appendAttributedString:
[self createTextAttribute:@"哇偶 ! "
color:[ThemeColor messageViewTipColor] font:12]];
[attributedString appendAttributedString:
[self createTextAttribute:prizModel.nick
color:[ThemeColor messageNickColor] font:12]];
[attributedString appendAttributedString:
[self createTextAttribute:@"通过"
color:[ThemeColor messageViewTipColor] font:12]];
[attributedString appendAttributedString:
[self createTextAttribute:prizModel.luckyBagName
color:[ThemeColor messageNickColor] font:12]];
[attributedString appendAttributedString:
[self createTextAttribute:@"开出了"
color:[ThemeColor messageNickColor] font:12]];
[attributedString appendAttributedString:
[self createTextAttribute:prizModel.giftName color:[ThemeColor messageNickColor] font:12]];
return attributedString;
}
///
/// @param text
/// @param color
/// @param font
- (NSMutableAttributedString *)createTextAttribute:(NSString *)text color:(UIColor *)color font:(CGFloat)font {
if (text == nil || text.length <= 0) {
text = @"";
}
NSDictionary * dic = @{NSFontAttributeName:[UIFont systemFontOfSize:12], NSForegroundColorAttributeName:color};
NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:text attributes:dic];
return attribute;
}
#pragma mark -
///
- (void)receiveGift:(GiftReceiveInfoModel *)receiveInfo {
///CPU
///TODO:
RoomInfoModel * roomInfor = [self.delegate getRoomInfo];
if (receiveInfo.isLuckyBagGift) {
// SVGA
if (receiveInfo.displayGift.count > 0) {
[receiveInfo.displayGift enumerateObjectsUsingBlock:^(GiftInfoModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (obj.hasVggPic && roomInfor.hasAnimationEffect) {
[self.giftEffectQueue addObject:obj];
}
}];
if (!self.isGiftEffectPlaying && self.giftEffectQueue.count > 0) {
GiftInfoModel * displayInfo = [self.giftEffectQueue firstObject];
[self playGiftEffect:displayInfo];
}
}
} else {
GiftInfoModel *giftInfo = receiveInfo.gift == nil ? receiveInfo.gift : receiveInfo.giftInfo;
if (!giftInfo) {
giftInfo = [[XPGiftStorage shareStorage] findGiftInfo: receiveInfo.giftId];
}
if (giftInfo.hasVggPic && roomInfor.hasAnimationEffect) {
[self.giftEffectQueue addObject:giftInfo];
if (!self.isGiftEffectPlaying && self.giftEffectQueue.count > 0) {
GiftInfoModel * displayInfo = [self.giftEffectQueue firstObject];
[self playGiftEffect:displayInfo];
}
}
if (receiveInfo.targetUsers.count > 0 && receiveInfo.targetUids.count <= 0) {
receiveInfo.targetUids = [receiveInfo.targetUsers valueForKeyPath:@"uid"];
}
NSInteger giftTotal = 0;
if (receiveInfo.targetUids.count > 0) {
giftTotal = receiveInfo.giftNum * giftInfo.goldPrice * receiveInfo.targetUids.count;
} else {
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];
// }
// }
}
}
///
- (void)playGiftEffect:(GiftInfoModel *)giftInfo {
self.isGiftEffectPlaying = YES;
self.giftEffectView.hidden = NO;
if (self.giftEffectView.superview == nil) {
[self.superview addSubview:self.giftEffectView];
[self.giftEffectView mas_makeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.superview);
make.width.mas_equalTo(KScreenWidth);
make.height.mas_equalTo(KScreenHeight);
}];
}
[self.superview bringSubviewToFront:self.giftEffectView];
[self.parser parseWithURL:[NSURL URLWithString:giftInfo.vggUrl] completionBlock:^(SVGAVideoEntity * _Nullable videoItem) {
if (videoItem != nil) {
CGFloat width = videoItem.videoSize.width;
CGFloat height = videoItem.videoSize.height;
if (width > height) {
self.giftEffectView.contentMode = UIViewContentModeScaleAspectFit;
} else {//
CGFloat resizeH = KScreenWidth * height / width;//
if (resizeH > KScreenHeight) {//
self.giftEffectView.contentMode = UIViewContentModeScaleAspectFill;
} else {//
self.giftEffectView.contentMode = UIViewContentModeScaleAspectFit;
}
}
self.giftEffectView.alpha = 1;
self.giftEffectView.loops = 1;
self.giftEffectView.clearsAfterStop = YES;
self.giftEffectView.videoItem = videoItem;
[self.giftEffectView startAnimation];
}
} failureBlock:^(NSError * _Nullable error) {
}];
[self.giftEffectQueue removeObject:giftInfo];
}
#pragma mark - SVGAPlayerDelegate
- (void)svgaPlayerDidFinishedAnimation:(SVGAPlayer *)player {
if (player == self.giftEffectView) {
self.giftEffectView.hidden = YES;
self.isGiftEffectPlaying = NO;
if (self.giftEffectQueue.count > 0) {
GiftInfoModel * infor = [self.giftEffectQueue firstObject];
[self playGiftEffect:infor];
}
}
}
#pragma mark - Getters And Setters
- (UIImageView *)backImageView {
@@ -48,4 +319,43 @@
return _backImageView;
}
- (SVGAImageView *)giftEffectView {
if (!_giftEffectView) {
_giftEffectView = [[SVGAImageView alloc]init];
_giftEffectView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.5];
_giftEffectView.userInteractionEnabled = NO;
_giftEffectView.delegate = self;
_giftEffectView.hidden = YES;
}
return _giftEffectView;
}
- (SVGAParser *)parser {
if (!_parser) {
_parser = [[SVGAParser alloc]init];
}
return _parser;
}
- (NSMutableArray<GiftInfoModel *> *)giftEffectQueue {
if (!_giftEffectQueue) {
_giftEffectQueue = [NSMutableArray array];
}
return _giftEffectQueue;
}
- (NSMutableArray<XPGiftBigPrizeModel *> *)bigPrizeGiftQueue {
if (!_bigPrizeGiftQueue) {
_bigPrizeGiftQueue = [NSMutableArray array];
}
return _bigPrizeGiftQueue;
}
- (NSMutableArray<GiftReceiveInfoModel *> *)giftBannerQueue {
if (!_giftBannerQueue) {
_giftBannerQueue = [NSMutableArray array];
}
return _giftBannerQueue;
}
@end

View File

@@ -0,0 +1,16 @@
//
// XPRoomGiftBannerView.h
// xplan-ios
//
// Created by 冯硕 on 2021/11/18.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPRoomGiftBannerView : UIView
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,51 @@
//
// XPRoomGiftBannerView.m
// xplan-ios
//
// Created by on 2021/11/18.
//
#import "XPRoomGiftBannerView.h"
@interface XPRoomAvatarNickView : UIView
///
@property (nonatomic,strong) UIImageView *avatImageView;
///
@property (nonatomic,strong) UILabel *nickLabel;
@end
@implementation XPRoomAvatarNickView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
}
- (void)initSubViewConstraints {
}
@end
@interface XPRoomGiftBannerView ()
///
@property (nonatomic,strong) UIImageView *backImageView;
@end
@implementation XPRoomGiftBannerView
@end

View File

@@ -27,6 +27,8 @@ NS_ASSUME_NONNULL_BEGIN
+ (UIColor *)messageNickColor;
///默认的文字的颜色
+ (UIColor *)messageDefaultTextColor;
///获取公屏提示 颜色 #FFFFFE 0.5
+ (UIColor *)messageViewTipColor;
// ------公屏相关颜色 END------ /
@end

View File

@@ -48,6 +48,11 @@
return [UIColor colorWithWhite:1 alpha:0.5];
}
/// #FFFFFE 0.5
+ (UIColor *)messageViewTipColor{
return UIColorRGBAlpha(0xfffffe, 0.5);
}
// ------ END------ /
@end

View File

@@ -191,7 +191,7 @@
}
- (void)onMicroQueueUpdate:(NSMutableDictionary<NSString *,MicroQueueModel *> *)queue {
[self.menuContainerView onMicroQueueUpdate:queue];
}
- (void)exitRoom {
@@ -203,7 +203,7 @@
- (XPRoomBackContainerView *)backContainerView {
if (!_backContainerView) {
_backContainerView = [[XPRoomBackContainerView alloc] init];
_backContainerView = [[XPRoomBackContainerView alloc] initWithdelegate:self];
}
return _backContainerView;
}