diff --git a/Podfile b/Podfile index b89d77b4..49975533 100644 --- a/Podfile +++ b/Podfile @@ -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'] diff --git a/Podfile.lock b/Podfile.lock index 2dacd8c9..29944836 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -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 diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 2c5bf066..30e35078 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -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 = ""; }; E82EE0F6272FDDFA00D15DC1 /* UserPrivacyView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UserPrivacyView.h; sourceTree = ""; }; E82EE0F7272FDDFA00D15DC1 /* UserPrivacyView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UserPrivacyView.m; sourceTree = ""; }; + E83DB47827462C4500D8CBD1 /* XPGiftBigPrizeModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPGiftBigPrizeModel.h; sourceTree = ""; }; + E83DB47927462C4500D8CBD1 /* XPGiftBigPrizeModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPGiftBigPrizeModel.m; sourceTree = ""; }; + E83DB47B2746372300D8CBD1 /* XPRoomGiftBannerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomGiftBannerView.h; sourceTree = ""; }; + E83DB47C2746372300D8CBD1 /* XPRoomGiftBannerView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomGiftBannerView.m; sourceTree = ""; }; E84B0E3D2727EDF6008818C6 /* XPRoomMessageTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageTableViewCell.h; sourceTree = ""; }; E84B0E3E2727EDF6008818C6 /* XPRoomMessageTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomMessageTableViewCell.m; sourceTree = ""; }; E84B0E402727EE0A008818C6 /* XPRoomMessageHeaderView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageHeaderView.h; sourceTree = ""; }; @@ -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 = ""; @@ -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 */, diff --git a/xplan-ios/Assets.xcassets/Room/room_lucky_gift_big_prize_bg.imageset/Contents.json b/xplan-ios/Assets.xcassets/Room/room_lucky_gift_big_prize_bg.imageset/Contents.json new file mode 100644 index 00000000..82027caf --- /dev/null +++ b/xplan-ios/Assets.xcassets/Room/room_lucky_gift_big_prize_bg.imageset/Contents.json @@ -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 + } +} diff --git a/xplan-ios/Assets.xcassets/Room/room_lucky_gift_big_prize_bg.imageset/room_lucky_gift_big_prize_bg@2x.png b/xplan-ios/Assets.xcassets/Room/room_lucky_gift_big_prize_bg.imageset/room_lucky_gift_big_prize_bg@2x.png new file mode 100644 index 00000000..0f277643 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/room_lucky_gift_big_prize_bg.imageset/room_lucky_gift_big_prize_bg@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/room_lucky_gift_big_prize_bg.imageset/room_lucky_gift_big_prize_bg@3x.png b/xplan-ios/Assets.xcassets/Room/room_lucky_gift_big_prize_bg.imageset/room_lucky_gift_big_prize_bg@3x.png new file mode 100644 index 00000000..b14578a8 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/room_lucky_gift_big_prize_bg.imageset/room_lucky_gift_big_prize_bg@3x.png differ diff --git a/xplan-ios/Main/IM/Model/AttachmentModel.h b/xplan-ios/Main/IM/Model/AttachmentModel.h index dec547a1..35b6e9e1 100644 --- a/xplan-ios/Main/IM/Model/AttachmentModel.h +++ b/xplan-ios/Main/IM/Model/AttachmentModel.h @@ -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 @property (nonatomic,assign) int first; diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/Model/GiftReceiveInfoModel.h b/xplan-ios/Main/ModuleKit/SendGiftView/Model/GiftReceiveInfoModel.h index 847176f5..6b9e1576 100644 --- a/xplan-ios/Main/ModuleKit/SendGiftView/Model/GiftReceiveInfoModel.h +++ b/xplan-ios/Main/ModuleKit/SendGiftView/Model/GiftReceiveInfoModel.h @@ -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 diff --git a/xplan-ios/Main/Room/Model/XPGiftBigPrizeModel.h b/xplan-ios/Main/Room/Model/XPGiftBigPrizeModel.h new file mode 100644 index 00000000..015c853c --- /dev/null +++ b/xplan-ios/Main/Room/Model/XPGiftBigPrizeModel.h @@ -0,0 +1,21 @@ +// +// XPGiftBigPrizeModel.h +// xplan-ios +// +// Created by 冯硕 on 2021/11/18. +// +///四级礼物的模型 +#import + +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 diff --git a/xplan-ios/Main/Room/Model/XPGiftBigPrizeModel.m b/xplan-ios/Main/Room/Model/XPGiftBigPrizeModel.m new file mode 100644 index 00000000..b8e9b816 --- /dev/null +++ b/xplan-ios/Main/Room/Model/XPGiftBigPrizeModel.m @@ -0,0 +1,12 @@ +// +// XPGiftBigPrizeModel.m +// xplan-ios +// +// Created by 冯硕 on 2021/11/18. +// + +#import "XPGiftBigPrizeModel.h" + +@implementation XPGiftBigPrizeModel + +@end diff --git a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomBackContainerView.h b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomBackContainerView.h index 77f43bfb..a3e9d76d 100644 --- a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomBackContainerView.h +++ b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomBackContainerView.h @@ -6,11 +6,11 @@ // #import - +#import "RoomHostDelegate.h" NS_ASSUME_NONNULL_BEGIN @interface XPRoomBackContainerView : UIView - +- (instancetype)initWithdelegate:(id)delegate; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomBackContainerView.m b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomBackContainerView.m index 5316ec91..57fdd682 100644 --- a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomBackContainerView.m +++ b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomBackContainerView.m @@ -8,17 +8,50 @@ #import "XPRoomBackContainerView.h" ///Third #import +#import +#import +///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 () +///动画管理类 +@property (strong, nonatomic) SVGAParser *parser; +///送礼物的特效 +@property (nonatomic,strong) SVGAImageView *giftEffectView; /// @property (nonatomic,strong) UIImageView *backImageView; +/// +@property (nonatomic,weak) iddelegate; +///礼物特效的队列 +@property (nonatomic,strong) NSMutableArray *giftEffectQueue; +///礼物特效是否正在播放 +@property (nonatomic,assign) BOOL isGiftEffectPlaying; + +///礼物价格大于520横幅的队列 +@property (nonatomic,strong) NSMutableArray *giftBannerQueue;; + +///福袋大礼物的队列 +@property (nonatomic,strong) NSMutableArray *bigPrizeGiftQueue; +///福袋 +@property (nonatomic,strong)dispatch_source_t luckyprizeTimer; @end @implementation XPRoomBackContainerView -- (instancetype)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; +- (instancetype)initWithdelegate:(id)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 *)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 *)giftEffectQueue { + if (!_giftEffectQueue) { + _giftEffectQueue = [NSMutableArray array]; + } + return _giftEffectQueue; +} + +- (NSMutableArray *)bigPrizeGiftQueue { + if (!_bigPrizeGiftQueue) { + _bigPrizeGiftQueue = [NSMutableArray array]; + } + return _bigPrizeGiftQueue; +} + +- (NSMutableArray *)giftBannerQueue { + if (!_giftBannerQueue) { + _giftBannerQueue = [NSMutableArray array]; + } + return _giftBannerQueue; +} + @end diff --git a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomGiftBannerView.h b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomGiftBannerView.h new file mode 100644 index 00000000..268ea3e8 --- /dev/null +++ b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomGiftBannerView.h @@ -0,0 +1,16 @@ +// +// XPRoomGiftBannerView.h +// xplan-ios +// +// Created by 冯硕 on 2021/11/18. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface XPRoomGiftBannerView : UIView + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomGiftBannerView.m b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomGiftBannerView.m new file mode 100644 index 00000000..655e2044 --- /dev/null +++ b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomGiftBannerView.m @@ -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 diff --git a/xplan-ios/Main/Room/View/ThemeColor+Room.h b/xplan-ios/Main/Room/View/ThemeColor+Room.h index 79b9fb32..64229a97 100644 --- a/xplan-ios/Main/Room/View/ThemeColor+Room.h +++ b/xplan-ios/Main/Room/View/ThemeColor+Room.h @@ -27,6 +27,8 @@ NS_ASSUME_NONNULL_BEGIN + (UIColor *)messageNickColor; ///默认的文字的颜色 + (UIColor *)messageDefaultTextColor; +///获取公屏提示 颜色 #FFFFFE 0.5 ++ (UIColor *)messageViewTipColor; // ------公屏相关颜色 END------ / @end diff --git a/xplan-ios/Main/Room/View/ThemeColor+Room.m b/xplan-ios/Main/Room/View/ThemeColor+Room.m index a4141cde..38556281 100644 --- a/xplan-ios/Main/Room/View/ThemeColor+Room.m +++ b/xplan-ios/Main/Room/View/ThemeColor+Room.m @@ -48,6 +48,11 @@ return [UIColor colorWithWhite:1 alpha:0.5]; } +///获取公屏提示 颜色 #FFFFFE 0.5 ++ (UIColor *)messageViewTipColor{ + return UIColorRGBAlpha(0xfffffe, 0.5); +} + // ------公屏相关颜色 END------ / @end diff --git a/xplan-ios/Main/Room/View/XPRoomViewController.m b/xplan-ios/Main/Room/View/XPRoomViewController.m index 86d4be64..b95d0c7b 100644 --- a/xplan-ios/Main/Room/View/XPRoomViewController.m +++ b/xplan-ios/Main/Room/View/XPRoomViewController.m @@ -191,7 +191,7 @@ } - (void)onMicroQueueUpdate:(NSMutableDictionary *)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; }