diff --git a/xplan-ios.xcodeproj/project.pbxproj b/xplan-ios.xcodeproj/project.pbxproj index 48d749df..93683cb1 100644 --- a/xplan-ios.xcodeproj/project.pbxproj +++ b/xplan-ios.xcodeproj/project.pbxproj @@ -669,6 +669,9 @@ E8395339276A0CC100CF2F24 /* XPMineHeadwearTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E8395338276A0CC100CF2F24 /* XPMineHeadwearTableViewCell.m */; }; E839533C276A0CCD00CF2F24 /* XPMineCarTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E839533B276A0CCD00CF2F24 /* XPMineCarTableViewCell.m */; }; E839533F276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = E839533E276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.m */; }; + E83980662902728D0084BFC8 /* XPSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = E83980652902728D0084BFC8 /* XPSlider.m */; }; + E839806829027D4A0084BFC8 /* room_wish_gift_sendCelebrate.svga in Resources */ = {isa = PBXBuildFile; fileRef = E839806729027D4A0084BFC8 /* room_wish_gift_sendCelebrate.svga */; }; + E839806B290288660084BFC8 /* XPMessageInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E839806A290288660084BFC8 /* XPMessageInfoModel.m */; }; E83ABEF6280E9AD800322EE4 /* MessageContentUnSupportView.m in Sources */ = {isa = PBXBuildFile; fileRef = E83ABEF5280E9AD800322EE4 /* MessageContentUnSupportView.m */; }; E83ABEF9280EAF3F00322EE4 /* MessageContentOpenLiveView.m in Sources */ = {isa = PBXBuildFile; fileRef = E83ABEF8280EAF3F00322EE4 /* MessageContentOpenLiveView.m */; }; E83ABEFD280EB5E200322EE4 /* ContentOpenLiveInfoModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E83ABEFC280EB5E200322EE4 /* ContentOpenLiveInfoModel.m */; }; @@ -2380,6 +2383,11 @@ E839533B276A0CCD00CF2F24 /* XPMineCarTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineCarTableViewCell.m; sourceTree = ""; }; E839533D276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMineNameplateTableViewCell.h; sourceTree = ""; }; E839533E276A0CDB00CF2F24 /* XPMineNameplateTableViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMineNameplateTableViewCell.m; sourceTree = ""; }; + E83980642902728D0084BFC8 /* XPSlider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPSlider.h; sourceTree = ""; }; + E83980652902728D0084BFC8 /* XPSlider.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPSlider.m; sourceTree = ""; }; + E839806729027D4A0084BFC8 /* room_wish_gift_sendCelebrate.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = room_wish_gift_sendCelebrate.svga; sourceTree = ""; }; + E8398069290288660084BFC8 /* XPMessageInfoModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMessageInfoModel.h; sourceTree = ""; }; + E839806A290288660084BFC8 /* XPMessageInfoModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMessageInfoModel.m; sourceTree = ""; }; E83ABEF4280E9AD800322EE4 /* MessageContentUnSupportView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageContentUnSupportView.h; sourceTree = ""; }; E83ABEF5280E9AD800322EE4 /* MessageContentUnSupportView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MessageContentUnSupportView.m; sourceTree = ""; }; E83ABEF7280EAF3F00322EE4 /* MessageContentOpenLiveView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MessageContentOpenLiveView.h; sourceTree = ""; }; @@ -6463,6 +6471,8 @@ children = ( E87A24EF272935920086A794 /* XPMessageRemoteExtModel.h */, E87A24F0272935920086A794 /* XPMessageRemoteExtModel.m */, + E8398069290288660084BFC8 /* XPMessageInfoModel.h */, + E839806A290288660084BFC8 /* XPMessageInfoModel.m */, ); path = Model; sourceTree = ""; @@ -7196,6 +7206,7 @@ E8A1E45C276220B100B294CA /* Sources */ = { isa = PBXGroup; children = ( + E839806729027D4A0084BFC8 /* room_wish_gift_sendCelebrate.svga */, E897AC0228AF9DDE003B3587 /* sailing_prize_cowry.svga */, E897AC0028AF6B90003B3587 /* sailing_prize.svga */, 9B8DE0E7289CFE8100FB6EC2 /* compound_gift_banner.svga */, @@ -7384,6 +7395,8 @@ E89DCF5928FFF1AD001647EC /* XPWishGiftSectionView.m */, E89DCF5E2900F4FB001647EC /* XPWishGiftEnterView.h */, E89DCF5F2900F4FB001647EC /* XPWishGiftEnterView.m */, + E83980642902728D0084BFC8 /* XPSlider.h */, + E83980652902728D0084BFC8 /* XPSlider.m */, ); path = View; sourceTree = ""; @@ -8914,6 +8927,7 @@ E8E859E428264D8800EE4857 /* index.html in Resources */, E80EC89528ACD84000D133C5 /* emoji_99@2x.png in Resources */, E80EC89128ACD84000D133C5 /* emoji_133@2x.png in Resources */, + E839806829027D4A0084BFC8 /* room_wish_gift_sendCelebrate.svga in Resources */, E80EC87F28ACD84000D133C5 /* emoji_137@2x.png in Resources */, E80EC8B028ACD84100D133C5 /* emoji_152@2x.png in Resources */, E80EC85728ACD84000D133C5 /* emoji_130@2x.png in Resources */, @@ -9524,6 +9538,7 @@ E82325F2274E2DE6003A3332 /* XPUserCardViewController.m in Sources */, E8E859D228264C2300EE4857 /* HTTPServer.m in Sources */, E8F65C222869A36F009BB5B9 /* ContentShareMonentsModel.m in Sources */, + E83980662902728D0084BFC8 /* XPSlider.m in Sources */, E8C167182806A03800ECB15C /* XPSuperAdminSetPresenter.m in Sources */, 9B6E856E281AABAB0041A321 /* XPRoomRecommendModel.m in Sources */, E801274B27E327DA00BAC3F2 /* XPRoomPKTypeTableViewCell.m in Sources */, @@ -10022,6 +10037,7 @@ E8A30BE328534A28003B4873 /* XPSessionFindNewViewController.m in Sources */, E8A03DF927634A590098D9EA /* CandyTreeResultModel.m in Sources */, E872308D26E89DAA00B90D4F /* LoginInputView.m in Sources */, + E839806B290288660084BFC8 /* XPMessageInfoModel.m in Sources */, E851E46827FF2141002F3ACB /* XPGuildSetNamePresenter.m in Sources */, E81C1B2C27706E5C0020D1E4 /* ArrangeMicModel.m in Sources */, 9B1B729528002099003FACE9 /* XPMineFansTeamViewController.m in Sources */, diff --git a/xplan-ios/Assets.xcassets/Room/WishGift/room_wish_gift_mesage_finish.imageset/Contents.json b/xplan-ios/Assets.xcassets/Room/WishGift/room_wish_gift_mesage_finish.imageset/Contents.json new file mode 100644 index 00000000..a6547082 --- /dev/null +++ b/xplan-ios/Assets.xcassets/Room/WishGift/room_wish_gift_mesage_finish.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "room_wish_gift_mesage_finish@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "room_wish_gift_mesage_finish@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/xplan-ios/Assets.xcassets/Room/WishGift/room_wish_gift_mesage_finish.imageset/room_wish_gift_mesage_finish@2x.png b/xplan-ios/Assets.xcassets/Room/WishGift/room_wish_gift_mesage_finish.imageset/room_wish_gift_mesage_finish@2x.png new file mode 100644 index 00000000..0b86e971 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/WishGift/room_wish_gift_mesage_finish.imageset/room_wish_gift_mesage_finish@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/WishGift/room_wish_gift_mesage_finish.imageset/room_wish_gift_mesage_finish@3x.png b/xplan-ios/Assets.xcassets/Room/WishGift/room_wish_gift_mesage_finish.imageset/room_wish_gift_mesage_finish@3x.png new file mode 100644 index 00000000..f4222bc2 Binary files /dev/null and b/xplan-ios/Assets.xcassets/Room/WishGift/room_wish_gift_mesage_finish.imageset/room_wish_gift_mesage_finish@3x.png differ diff --git a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPSendGiftView.m b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPSendGiftView.m index 70f811a9..ca0abe71 100644 --- a/xplan-ios/Main/ModuleKit/SendGiftView/View/XPSendGiftView.m +++ b/xplan-ios/Main/ModuleKit/SendGiftView/View/XPSendGiftView.m @@ -375,6 +375,7 @@ return; } self.giftBarView.sendButtonIsEnable = NO; + NSLog(@"送礼物陈宫之前的时间:%@", [NSDate date]); ///发送消息 [self.presenter sendGift:uidString giftNum:giftNumber sendType:sendType giftId:giftId giftSource:sourceType giftType:giftInfo.giftType roomSendType:roomSendType roomUid:self.roomUid msg:@""]; } else { @@ -591,6 +592,7 @@ } - (void)sendGiftSuccess:(GiftReceiveInfoModel *)receiveInfo originDic:(NSDictionary *)originDic uidCount:(NSInteger)uidCount{ + NSLog(@"送礼物陈宫之后的时间:%@", [NSDate date]); self.giftBarView.sendButtonIsEnable = YES; if (receiveInfo.sourceType == GiftSourceType_Pack) { ///更新个数 diff --git a/xplan-ios/Main/Room/View/AnimationView/XPRoomAnimationView.m b/xplan-ios/Main/Room/View/AnimationView/XPRoomAnimationView.m index b44b4600..523abe7a 100644 --- a/xplan-ios/Main/Room/View/AnimationView/XPRoomAnimationView.m +++ b/xplan-ios/Main/Room/View/AnimationView/XPRoomAnimationView.m @@ -130,6 +130,8 @@ @property (nonatomic, strong) NSMutableArray *graffitiGiftQueue; ///幸运礼物动画是否在播放 @property (nonatomic,assign) BOOL isLuckyGiftAnimation; +#pragma mark - 心愿礼物 +@property (nonatomic,strong) SVGAImageView *wishGiftEffectView; @end @implementation XPRoomAnimationView @@ -283,6 +285,8 @@ [self receiveRoomSailing:attachment]; } else if(attachment.first == CustomMessageType_Graffiti_Gift) {///涂鸦礼物 [self receiveRoomGraffitiGift:attachment]; + } else if(attachment.first == CustomMessageType_Wish_Gift && attachment.second == Custom_Message_Sub_Wish_Gift_Gelebrate) { + [self receiveRoomWishGiftCelebrate:attachment]; } } } @@ -1578,6 +1582,30 @@ } } +#pragma mark - 心愿礼物 +- (void)receiveRoomWishGiftCelebrate:(AttachmentModel *)attachment { + if (self.wishGiftEffectView.superview == nil) { + [self.lowLevelView addSubview:self.wishGiftEffectView]; + CGFloat x = random() % 300; + CGFloat y= random() % 20 + kNavigationHeight; + [self.wishGiftEffectView mas_makeConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(x); + make.top.mas_equalTo(y); + make.width.mas_equalTo(200); + make.height.mas_equalTo(167); + }]; + } + [self.parser parseWithNamed:@"room_wish_gift_sendCelebrate" inBundle:NSBundle.mainBundle completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) { + self.wishGiftEffectView.alpha = 1; + self.wishGiftEffectView.loops = 1; + self.wishGiftEffectView.clearsAfterStop = YES; + self.wishGiftEffectView.videoItem = videoItem; + [self.wishGiftEffectView startAnimation]; + } failureBlock:^(NSError * _Nonnull error) { + + }]; +} + #pragma mark - HWDMP4PlayDelegate //即将开始播放时询问,true马上开始播放,false放弃播放 - (BOOL)shouldStartPlayMP4:(VAPView *)container config:(QGVAPConfigModel *)config { @@ -1884,4 +1912,19 @@ } +- (SVGAImageView *)wishGiftEffectView { + if (_wishGiftEffectView == nil) { + _wishGiftEffectView = [[SVGAImageView alloc]init]; + _wishGiftEffectView.delegate = self; + _wishGiftEffectView.contentMode = UIViewContentModeScaleAspectFit; + _wishGiftEffectView.frame = CGRectMake(0, 0, 210, 183); + _wishGiftEffectView.backgroundColor = [UIColor clearColor]; + _wishGiftEffectView.alpha = 1; + _wishGiftEffectView.userInteractionEnabled = NO; + } + return _wishGiftEffectView; +} + + + @end diff --git a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m index 7529d3b0..235a0efa 100644 --- a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m +++ b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m @@ -140,6 +140,8 @@ @property (nonatomic, strong) dispatch_source_t userGiftTimer; ///许愿礼物 @property (nonatomic,strong) XPWishGiftEnterView *wishGiftView; +///心愿礼物面板 更新进度 +@property (nonatomic,weak) XPWishGiftViewController* wishGiftVC ; @end @@ -883,7 +885,9 @@ [self handleAnchorFansTeam:attachment]; } else if (attachment.first == CustomMessageType_Noble_VIP && attachment.second == Custom_Message_Sub_Room_Trumpet) { [self handleTrumpet:attachment]; - } + } else if(attachment.first == CustomMessageType_Wish_Gift) { + [self handleWishGiftMessage:attachment]; + } } } @@ -1647,6 +1651,7 @@ - (void)tapWishGift { NSString * roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid]; XPWishGiftViewController * vc = [[XPWishGiftViewController alloc] initWithRoomUid:roomUid]; + self.wishGiftVC = vc; vc.delegate = self; vc.modalPresentationStyle = UIModalPresentationOverFullScreen; [self.delegate.getCurrentNav presentViewController:vc animated:YES completion:nil]; @@ -1655,16 +1660,7 @@ - (void)configWishGiftEnter { RoomInfoModel * roomInfo = self.delegate.getRoomInfo; NSString * roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid]; - roomInfo.hasOpenWishGift = YES; if (roomInfo.hasOpenWishGift) { - if (!self.wishGiftView.superview) { - [self addSubview:self.wishGiftView]; - [self.wishGiftView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self).offset(kNavigationHeight + 47); - make.right.mas_equalTo(self.mas_right).offset(0); - make.size.mas_equalTo(CGSizeMake(81, 30)); - }]; - } [Api wishGiftList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if (code == 200) { NSArray * array = [WishGiftInfoModel modelsWithArray:data.data]; @@ -1673,6 +1669,15 @@ } else { self.wishGiftView.hidden = YES; } + + if (!self.wishGiftView.superview) { + [self addSubview:self.wishGiftView]; + [self.wishGiftView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self).offset(kNavigationHeight + 47); + make.right.mas_equalTo(self.mas_right).offset(0); + make.size.mas_equalTo(CGSizeMake(81, 30)); + }]; + } } roomUid:roomUid]; } else { if (self.wishGiftView.superview) { @@ -1691,6 +1696,22 @@ [self.delegate.getCurrentNav presentViewController:giftView animated:YES completion:nil]; } +- (void)handleWishGiftMessage:(AttachmentModel *)attachment { + if (attachment.second == Custom_Message_Sub_Wish_Gift_Open || attachment.second == Custom_Message_Sub_Wish_Gift_Update) { + NSArray * array = [WishGiftInfoModel modelsWithArray:attachment.data[@"gifts"]]; + self.wishGiftView.giftList = array; + if (!self.wishGiftView.superview) { + [self addSubview:self.wishGiftView]; + [self.wishGiftView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self).offset(kNavigationHeight + 47); + make.right.mas_equalTo(self.mas_right).offset(0); + make.size.mas_equalTo(CGSizeMake(81, 30)); + }]; + } + [self.wishGiftVC getWishGiftListSuccess:array]; + } +} + #pragma mark - Getters And Setters - (XPRoomRankEntranceView *)contributeEnterView { if (!_contributeEnterView) { diff --git a/xplan-ios/Main/Room/View/MessageContainerView/Model/XPMessageInfoModel.h b/xplan-ios/Main/Room/View/MessageContainerView/Model/XPMessageInfoModel.h new file mode 100644 index 00000000..7ac79bdb --- /dev/null +++ b/xplan-ios/Main/Room/View/MessageContainerView/Model/XPMessageInfoModel.h @@ -0,0 +1,35 @@ +// +// XPMessageInfoModel.h +// xplan-ios +// +// Created by 冯硕 on 2022/10/21. +// + +#import +NS_ASSUME_NONNULL_BEGIN + +@interface XPMessageInfoModel : NSObject +///显示文本 +@property (nonatomic,strong) NSAttributedString *content; +///cell的高度 +@property (nonatomic,assign) CGFloat rowHeight; +///文本内容的 +@property (nonatomic,assign) CGFloat contentLeftMargin; +///文本右边的间隙 +@property (nonatomic,assign) CGFloat contentRightMargin; +///文本上面的间隙 +@property (nonatomic,assign) CGFloat contentTopMargin; +///文本底部的间隙 +@property (nonatomic,assign) CGFloat contentBottomMargin; +///底部的间隙 +@property (nonatomic,assign) CGFloat cellBottomMargin; +///是否要隐藏背景 +@property (nonatomic,assign) BOOL isHiddenBubble; +///是否改变内容的区域 +@property (nonatomic,assign) BOOL isUpdateContentFrame; +///气泡url +@property (nonatomic, copy) NSString *bubbleImageUrl; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/MessageContainerView/Model/XPMessageInfoModel.m b/xplan-ios/Main/Room/View/MessageContainerView/Model/XPMessageInfoModel.m new file mode 100644 index 00000000..e721a41b --- /dev/null +++ b/xplan-ios/Main/Room/View/MessageContainerView/Model/XPMessageInfoModel.m @@ -0,0 +1,28 @@ +// +// XPMessageInfoModel.m +// xplan-ios +// +// Created by 冯硕 on 2022/10/21. +// + +#import "XPMessageInfoModel.h" +#import "XPRoomMessageConstant.h" +#import + + +@implementation XPMessageInfoModel + +- (instancetype)init { + if ([super init]) { + self.contentLeftMargin = 12; + self.contentRightMargin = 0; + self.contentTopMargin = 10; + self.contentBottomMargin = 10; + self.cellBottomMargin = 6; + self.isUpdateContentFrame = NO; + self.isHiddenBubble = NO; + } + return self; +} + +@end diff --git a/xplan-ios/Main/Room/View/MessageContainerView/Tool/XPRoomMessageParser.h b/xplan-ios/Main/Room/View/MessageContainerView/Tool/XPRoomMessageParser.h index da36d981..949e7dfd 100644 --- a/xplan-ios/Main/Room/View/MessageContainerView/Tool/XPRoomMessageParser.h +++ b/xplan-ios/Main/Room/View/MessageContainerView/Tool/XPRoomMessageParser.h @@ -9,11 +9,11 @@ #import "RoomHostDelegate.h" NS_ASSUME_NONNULL_BEGIN -@class NIMMessage; +@class NIMMessage, XPMessageInfoModel; @interface XPRoomMessageParser : NSObject -- (NSAttributedString*)parseMessageAttribute:(NIMMessage *)message; +- (XPMessageInfoModel*)parseMessageAttribute:(NIMMessage *)message; - (NSString *)parseMessageBubble:(NIMMessage *)message; ///房间的代理 diff --git a/xplan-ios/Main/Room/View/MessageContainerView/Tool/XPRoomMessageParser.m b/xplan-ios/Main/Room/View/MessageContainerView/Tool/XPRoomMessageParser.m index 6a9d00d6..d9ca92bc 100644 --- a/xplan-ios/Main/Room/View/MessageContainerView/Tool/XPRoomMessageParser.m +++ b/xplan-ios/Main/Room/View/MessageContainerView/Tool/XPRoomMessageParser.m @@ -17,6 +17,7 @@ #import "XPGiftStorage.h" #import "XPRoomFaceTool.h" #import "TTPopup.h" +#import "Api+WishGift.h" ///Model #import "XPMessageRemoteExtModel.h" #import "AttachmentModel.h" @@ -37,6 +38,7 @@ #import "XPGiftCompoundModel.h" #import "RoomSailingPrizeModel.h" #import "XPOpenRedPacketModel.h" +#import "XPMessageInfoModel.h" #import "NetImageView.h" @@ -47,20 +49,21 @@ @implementation XPRoomMessageParser -- (NSAttributedString*)parseMessageAttribute:(NIMMessage *)message { +- (XPMessageInfoModel*)parseMessageAttribute:(NIMMessage *)message { NIMMessageType messageType = message.messageType; + XPMessageInfoModel * messageInfo = [[XPMessageInfoModel alloc] init]; switch (messageType) { case NIMMessageTypeText: - return [self makeChatAttribute:message]; + return [self makeChatAttribute:message messageInfo:messageInfo]; case NIMMessageTypeTip: - return [self makeTipsAttribute:message]; + return [self makeTipsAttribute:message messageInfo:messageInfo]; case NIMMessageTypeNotification: - return [self makeNotificationAttribute:message]; + return [self makeNotificationAttribute:message messageInfo:messageInfo]; case NIMMessageTypeCustom: - return [self makeCustomAttribute:message]; + return [self makeCustomAttribute:message messageInfo:messageInfo]; default: return nil; } @@ -72,60 +75,63 @@ } /// 用户公屏聊天 -- (NSAttributedString *)makeCustomAttribute:(NIMMessage *)message { +- (XPMessageInfoModel *)makeCustomAttribute:(NIMMessage *)message messageInfo:(XPMessageInfoModel*)messageInfo{ NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; AttachmentModel *attachment = (AttachmentModel *)obj.attachment; XPMessageRemoteExtModel * model = [XPMessageRemoteExtModel modelWithJSON:message.remoteExt[message.from]]; + messageInfo.bubbleImageUrl = [self parseMessageBubble:message]; int first = attachment.first; if (first == CustomMessageType_Gift) {///单人送 - return [self createSendGiftAttribute:attachment sendInfo:model]; + return [self createSendGiftAttribute:attachment sendInfo:model messageInfo:messageInfo]; } else if(first == CustomMessageType_AllMicroSend) {///全麦送 多人送 - return [self createBatchMicroSendGiftAttribute:attachment sendInfo:model]; + return [self createBatchMicroSendGiftAttribute:attachment sendInfo:model messageInfo:messageInfo]; } else if(first == CustomMessageType_Room_Tip) {///分享/收藏房间 - return [self createShareOrAttentionRoomAttribute:attachment sendInfo:model uid:message.from]; + return [self createShareOrAttentionRoomAttribute:attachment sendInfo:model uid:message.from messageInfo:messageInfo]; } else if(first == CustomMessageType_Kick_User || first == CustomMessageType_Queue) { XPKickUserModel * kickModel = [XPKickUserModel modelWithJSON:attachment.data]; - return [self createKickUserAttribute:attachment info:kickModel]; + return [self createKickUserAttribute:attachment info:kickModel messageInfo:messageInfo]; } else if(first == CustomMessageType_Candy_Tree) {//糖果树 - return [self createCandyTreeHighLevelAttribute:attachment]; + return [self createCandyTreeHighLevelAttribute:attachment messageInfo:messageInfo]; } else if(first == CustomMessageType_Arrange_Mic) { - return [self createArrangeMicAttribute:attachment]; + return [self createArrangeMicAttribute:attachment messageInfo:messageInfo]; }else if(first == CustomMessageType_Update_RoomInfo) { - return [self createRoomInfoUpdateAttribute:attachment]; + return [self createRoomInfoUpdateAttribute:attachment messageInfo:messageInfo]; } else if(first == CustomMessageType_Collection_Room) { - return [self createCollectRoomAttribute:attachment]; + return [self createCollectRoomAttribute:attachment messageInfo:messageInfo]; } else if(first == CustomMessageType_RoomPlay_Dating) { - return [self createRoomDatingAttribute:attachment]; + return [self createRoomDatingAttribute:attachment messageInfo:messageInfo]; } else if (first == CustomMessageType_Noble_VIP) {//贵族 - return [self createNobleLevelAttribute:attachment]; + return [self createNobleLevelAttribute:attachment messageInfo:messageInfo]; } else if (first == CustomMessageType_Face) {//贵族 - return [self createRoomFaceAttribute:attachment]; + return [self createRoomFaceAttribute:attachment messageInfo:messageInfo]; } else if (first == CustomMessageType_Tarot) {//塔罗 - return [self createTarotAttribute:attachment]; + return [self createTarotAttribute:attachment messageInfo:messageInfo]; } else if (first == CustomMessageType_Anchor_FansTeam) {//粉丝团 - return [self createAnchorFansTeamAttribute:attachment]; + return [self createAnchorFansTeamAttribute:attachment messageInfo:messageInfo]; } else if(first == CustomMessageType_Hall_Super_Admin) {///超管踢人出房间 XPKickUserModel * kickModel = [XPKickUserModel modelWithJSON:attachment.data]; - return [self createKickUserAttribute:attachment info:kickModel]; + return [self createKickUserAttribute:attachment info:kickModel messageInfo:messageInfo]; } else if (first == CustomMessageType_Room_PK) {///房内PK - return [self createRoomPKAttribute:attachment]; + return [self createRoomPKAttribute:attachment messageInfo:messageInfo]; } else if (first == CustomMessageType_LuckyBag) {///幸运礼物 - return [self createRoomLuckyBigPrizeAttribute:attachment]; + return [self createRoomLuckyBigPrizeAttribute:attachment messageInfo:messageInfo]; } else if(first == CustomMessageType_Gift_Compound) {///礼物合成 - return [self createRoomGiftCompoundAttribute:attachment]; + return [self createRoomGiftCompoundAttribute:attachment messageInfo:messageInfo]; } else if(first == CustomMessageType_Room_Sailing) {///航海 - return [self createRoomSailingAttribute:attachment]; + return [self createRoomSailingAttribute:attachment messageInfo:messageInfo]; } else if (first == CustomMessageType_RedPacket && attachment.second == Custom_Message_Sub_OpenRedPacketSuccess) { - return [self createRedPacketAttribute:attachment]; - } + return [self createRedPacketAttribute:attachment messageInfo:messageInfo]; + } else if (first == CustomMessageType_Wish_Gift) { + return [self createWishGiftAttribute:attachment messageInfo:messageInfo]; +} return nil; } /// @param message 消息的实体 -- (NSAttributedString*)makeChatAttribute:(NIMMessage *)message{ +- (XPMessageInfoModel*)makeChatAttribute:(NIMMessage *)message messageInfo:(XPMessageInfoModel *)messageInfo{ NSString * uid = [AccountInfoStorage instance].getUid; XPMessageRemoteExtModel * model = [XPMessageRemoteExtModel modelWithJSON:message.remoteExt[message.from]]; - + messageInfo.bubbleImageUrl = [self parseMessageBubble:message]; NSString * nick = [NSString stringWithFormat:@"%@:", ((NIMMessageChatroomExtension *)message.messageExt).roomNickname]; if ([message.from isEqualToString:uid]) { nick = @"我:"; @@ -176,15 +182,17 @@ [attribute appendAttributedString:msgStr]; } [self attributeAddLongPressHihtLight:attribute uid:message.from nick:((NIMMessageChatroomExtension *)message.messageExt).roomNickname]; - return attribute; + messageInfo.content = attribute; + return messageInfo; } /// 房间tips消息 /// @param message 消息的实体 -- (NSAttributedString*)makeTipsAttribute:(NIMMessage *)message { +- (XPMessageInfoModel*)makeTipsAttribute:(NIMMessage *)message messageInfo:(XPMessageInfoModel *)messageInfo{ + messageInfo.bubbleImageUrl = [self parseMessageBubble:message]; if ([message.localExt.allKeys containsObject:@"isRoomTopic"]) { NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; - [attribute appendAttributedString: [self createTextAttribute:message.text color:[UIColor whiteColor] font:kRoomMessageDefalutFont]]; + [attribute appendAttributedString: [self createTextAttribute:message.text color:[UIColor whiteColor] font:kRoomMessageDefalutFont]]; if ([[message.localExt objectForKey:@"isRoomTopic"] boolValue] == YES) { [attribute yy_setTextHighlightRange:NSMakeRange(0, attribute.length) color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) { RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo; @@ -196,15 +204,18 @@ [TTPopup popupWithConfig:config]; }]; } - return attribute; + messageInfo.content = attribute; } else { - return [self createTextAttribute:message.text color:UIColorFromRGB(0xFE5D7F) font:kRoomMessageDefalutFont]; + NSAttributedString * attribute = [self createTextAttribute:message.text color:UIColorFromRGB(0xFE5D7F) font:kRoomMessageDefalutFont]; + messageInfo.content = attribute; } + return messageInfo; } /// 房间通知类消息 /// @param message 消息的实体 -- (NSAttributedString*)makeNotificationAttribute:(NIMMessage *)message { +- (XPMessageInfoModel*)makeNotificationAttribute:(NIMMessage *)message messageInfo:(XPMessageInfoModel *)messageInfo{ + messageInfo.bubbleImageUrl = [self parseMessageBubble:message]; NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject; NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content; NIMChatroomNotificationMember *member = content.targets[0]; @@ -256,14 +267,16 @@ } } [attribute appendAttributedString:[self createTextAttribute:@"进入了房间" color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]]; - return attribute; + messageInfo.content = attribute; + return messageInfo; } break; case NIMChatroomEventTypeInfoUpdated:{ NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; if (self.hostDelegate.getRoomInfo.datingState == RoomDatingStateChangeType_Open) { [attribute appendAttributedString:[self createTextAttribute:@"相亲玩法已开启,请点击主持人麦位选择主持人" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; - return attribute; + messageInfo.content = attribute; + return messageInfo; } } break; @@ -273,8 +286,32 @@ return nil; } +#pragma mark - 心愿礼物 +- (XPMessageInfoModel *)createWishGiftAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ + UIImageView *imaveView = [[UIImageView alloc]init]; + imaveView.image = [UIImage imageNamed:@"room_wish_gift_mesage_finish"]; + imaveView.bounds = CGRectMake(0, 0, 170, 34); + NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imaveView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imaveView.frame.size.width, imaveView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter]; + @kWeakify(self); + [attrString yy_setTextHighlightRange:NSMakeRange(0, attrString.length) color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) { + @kStrongify(self); + NSString * roomUid = [NSString stringWithFormat:@"%ld", [self.hostDelegate getRoomInfo].uid]; + [Api wishGiftSendCelebrate:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + + } roomUid:roomUid]; + }]; + messageInfo.contentLeftMargin = 0; + messageInfo.contentRightMargin = 0; + messageInfo.contentTopMargin = 0; + messageInfo.contentBottomMargin = 0; + messageInfo.isUpdateContentFrame = YES; + messageInfo.isHiddenBubble = YES; + messageInfo.content = attrString; + return messageInfo; +} + #pragma mark - 红包 -- (NSAttributedString *)createRedPacketAttribute:(AttachmentModel *)attachment { +- (XPMessageInfoModel *)createRedPacketAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ XPOpenRedPacketModel *info = [XPOpenRedPacketModel modelWithDictionary:attachment.data]; NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; [attribute appendAttributedString:[self createNickAtrribute:info.openRedEnvelopeUserNick uid:info.openRedEnvelopeId.integerValue]]; @@ -284,11 +321,12 @@ if (info.amount.floatValue>0) { [attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"%@钻石", info.amount] color:[ThemeColor messageNickColor] font:kRoomMessageDefalutFont]]; } - return attribute; + messageInfo.content = attribute; + return messageInfo; } #pragma mark - 航海 -- (NSAttributedString *)createRoomSailingAttribute:(AttachmentModel *)attachment { +- (XPMessageInfoModel *)createRoomSailingAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ RoomSailingPrizeModel *info = [RoomSailingPrizeModel modelWithDictionary:attachment.data]; NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; [attribute appendAttributedString:[self createTextAttribute:@"厉害了! " color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]]; @@ -299,11 +337,12 @@ [attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"x%d", info.prizeNum] color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]]; } [self attributeAddHihtLight:attribute uid:info.uid.integerValue]; - return attribute; + messageInfo.content = attribute; + return messageInfo; } #pragma mark - 礼物合成 -- (NSAttributedString *)createRoomGiftCompoundAttribute:(AttachmentModel *)attachment { +- (XPMessageInfoModel *)createRoomGiftCompoundAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ XPGiftCompoundModel *info = [XPGiftCompoundModel modelWithDictionary:attachment.data]; NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; [attribute appendAttributedString:[self createTextAttribute:@"恭喜" color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]]; @@ -311,11 +350,12 @@ [attribute appendAttributedString:[self createTextAttribute:info.msg color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]]; [attribute appendAttributedString:[self createTextAttribute:info.giftName color:[ThemeColor messageNickColor] font:kRoomMessageDefalutFont]]; [self attributeAddHihtLight:attribute uid:info.uid.integerValue]; - return attribute; + messageInfo.content = attribute; + return messageInfo; } #pragma mark - 房间内幸运礼物 大价值 -- (NSAttributedString *)createRoomLuckyBigPrizeAttribute:(AttachmentModel *)attachment { +- (XPMessageInfoModel *)createRoomLuckyBigPrizeAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ XPGiftBigPrizeModel * info= [XPGiftBigPrizeModel modelWithDictionary:attachment.data]; NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; [attribute appendAttributedString:[self createTextAttribute:@"恭喜" color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]]; @@ -324,11 +364,12 @@ [attribute appendAttributedString:[self createTextAttribute:info.roomTitle color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]]; [attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"通过%@", info.luckyBagName] color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]]; [attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@",开出%@", info.giftName] color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]]; - return attribute; + messageInfo.content = attribute; + return messageInfo; } #pragma mark - 房间内PK -- (NSAttributedString *)createRoomPKAttribute:(AttachmentModel *)attachment { +- (XPMessageInfoModel *)createRoomPKAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; if (attachment.second == Custom_Message_Sub_Room_PK_Manager_Up_Mic) { [attribute appendAttributedString:[self createTextAttribute:@"房主/管理员邀请" color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]]; @@ -453,7 +494,8 @@ [attribute appendAttributedString:[self createTextAttribute:title color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]]; } } - return attribute; + messageInfo.content = attribute; + return messageInfo; } - (void)showRoomPKResult:(NSDictionary *)dic { @@ -466,7 +508,7 @@ } #pragma mark - 表情显示 -- (NSAttributedString*)createRoomFaceAttribute:(AttachmentModel *)attachment { +- (XPMessageInfoModel*)createRoomFaceAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; if ([attachment.data[@"data"] isKindOfClass:[NSArray class]]) { NSArray * array = [RoomFaceSendInfoModel modelsWithArray:attachment.data[@"data"]]; @@ -490,11 +532,12 @@ } } } - return attribute; + messageInfo.content = attribute; + return messageInfo; } #pragma mark - 收藏房间 -- (NSAttributedString*)createCollectRoomAttribute:(AttachmentModel *)attachment { +- (XPMessageInfoModel*)createCollectRoomAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; NSDictionary *data = attachment.data[@"data"]; NSString *nick = [NSString stringWithFormat:@"%@",data[@"nick"]]; @@ -504,11 +547,12 @@ tipString = @"收藏了房间"; } [attribute appendAttributedString:[self createTextAttribute:tipString color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; - return attribute; + messageInfo.content = attribute; + return messageInfo; } #pragma mark - 房间信息更新 -- (NSAttributedString*)createRoomInfoUpdateAttribute:(AttachmentModel *)attachment { +- (XPMessageInfoModel*)createRoomInfoUpdateAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ if (attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) { NSDictionary * dic= attachment.data[@"roomInfo"]; if (dic.allKeys.count <=0) { @@ -522,7 +566,7 @@ } else { [attribute appendAttributedString:[self createTextAttribute:@"管理员已开启聊天公屏" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; } - return attribute; + messageInfo.content = attribute; } else if(attachment.second == Custom_Message_Sub_Update_RoomInfo_AnimateEffect) { NSDictionary * dic = attachment.data[@"roomInfo"]; if (dic.allKeys.count <=0) { @@ -538,7 +582,7 @@ [attribute appendAttributedString:[self createImageAttribute:[UIImage imageNamed:@"room_menu_more"]]]; [attribute appendAttributedString:[self createTextAttribute:@"图标即可开启" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; } - return attribute; + messageInfo.content = attribute; } else if (attachment.second == Custom_Message_Sub_Update_RoomInfo_CleanScreen) { NSNumber *roleType = attachment.data[@"roleType"]; NSString *nick = attachment.data[@"nick"]; @@ -559,13 +603,13 @@ } [attribute appendAttributedString:[self createTextAttribute:@"已清空房间公屏消息" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; [self attributeAddHihtLight:attribute uid:uid]; - return attribute; + messageInfo.content = attribute; } - return nil; + return messageInfo; } #pragma mark - 相亲 -- (NSAttributedString *)createRoomDatingAttribute:(AttachmentModel *)attachment { +- (XPMessageInfoModel *)createRoomDatingAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; if(attachment.second == Custom_Message_Sub_Room_Play_Dating_Pick_Heart) { DatingInfoModel * datingModel = [DatingInfoModel modelWithDictionary:attachment.data]; @@ -598,11 +642,12 @@ [attribute appendAttributedString:[self createTextAttribute:@"未选择心动对象" color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]]; } } - return attribute; + messageInfo.content = attribute; + return messageInfo; } #pragma mark - 排麦 -- (NSAttributedString *)createArrangeMicAttribute:(AttachmentModel *)attachment { +- (XPMessageInfoModel *)createArrangeMicAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; [attribute appendAttributedString:[self createTextAttribute:@"管理员" color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]]; if (attachment.second == Custom_Message_Sub_Arrange_Mic_Mode_Open) { @@ -622,11 +667,12 @@ [attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"%d麦", ((NSNumber *)dic[@"micPos"]).intValue + 1 ] color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; [attribute appendAttributedString:[self createTextAttribute:@"自由麦" color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]]; } - return attribute; + messageInfo.content = attribute; + return messageInfo; } #pragma mark - 糖果树公屏消息 -- (NSAttributedString *)createCandyTreeHighLevelAttribute:(AttachmentModel *)attachment { +- (XPMessageInfoModel *)createCandyTreeHighLevelAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; //action [attribute appendAttributedString:[self createTextAttribute:@"厉害了 " color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; @@ -643,11 +689,12 @@ } [self attributeAddHihtLight:attribute uid:giftInfo.uid.integerValue]; - return attribute; + messageInfo.content = attribute; + return messageInfo; } #pragma mark - 贵族 -- (NSAttributedString *)createNobleLevelAttribute:(AttachmentModel *)attachment { +- (XPMessageInfoModel *)createNobleLevelAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; NSInteger uid = 0; if ([attachment.data[@"uid"] isKindOfClass:[NSNumber class]]) { @@ -669,11 +716,12 @@ [attribute appendAttributedString:[self createTextAttribute:@"!" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; } [self attributeAddHihtLight:attribute uid:uid]; - return attribute; + messageInfo.content = attribute; + return messageInfo; } #pragma mark - 塔罗 -- (NSAttributedString *)createTarotAttribute:(AttachmentModel *)attachment { +- (XPMessageInfoModel *)createTarotAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; if (attachment.second == Custom_Message_Sub_Tarot) { [attribute appendAttributedString:[self createTextAttribute:@"恭喜" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; @@ -685,11 +733,12 @@ } [attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"%@ ", attachment.data[@"chargeProdName"]] color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; } - return attribute; + messageInfo.content = attribute; + return messageInfo; } #pragma mark - 个播粉丝团 -- (NSAttributedString *)createAnchorFansTeamAttribute:(AttachmentModel *)attachment { +- (XPMessageInfoModel *)createAnchorFansTeamAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; NSInteger uid = 0; if ([attachment.data[@"uid"] isKindOfClass:[NSNumber class]]) { @@ -715,11 +764,12 @@ [attribute appendAttributedString:[self createTextAttribute:@"已退出粉丝团" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; } [self attributeAddHihtLight:attribute uid:uid]; - return attribute; + messageInfo.content = attribute; + return messageInfo; } #pragma mark - 踢出房间/拉黑/下麦 -- (NSAttributedString *)createKickUserAttribute:(AttachmentModel *)attachment info:(XPKickUserModel *)info { +- (XPMessageInfoModel *)createKickUserAttribute:(AttachmentModel *)attachment info:(XPKickUserModel *)info messageInfo:(XPMessageInfoModel *)messageInfo{ NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; [attribute appendAttributedString:[self createNickAtrribute:info.targetNick uid:info.targetUid]]; [attribute appendAttributedString:[self createTextAttribute:@"被" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; @@ -733,12 +783,13 @@ content = @"请下麦"; } [attribute appendAttributedString:[self createTextAttribute:content color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; - return attribute; + messageInfo.content = attribute; + return messageInfo; } #pragma mark - 分享房间 -- (NSAttributedString *)createShareOrAttentionRoomAttribute:(AttachmentModel *)attachment sendInfo:(XPMessageRemoteExtModel *)sendInfo uid:(NSString *)uid { +- (XPMessageInfoModel *)createShareOrAttentionRoomAttribute:(AttachmentModel *)attachment sendInfo:(XPMessageRemoteExtModel *)sendInfo uid:(NSString *)uid messageInfo:(XPMessageInfoModel *)messageInfo{ NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; NSDictionary *data = attachment.data[@"data"]; NSString *nick = [NSString stringWithFormat:@"%@",data[@"nick"]]; @@ -751,11 +802,12 @@ } [attribute appendAttributedString:[self createTextAttribute:tipString color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; [self attributeAddHihtLight:attribute uid:uid.integerValue]; - return attribute; + messageInfo.content = attribute; + return messageInfo; } #pragma mark - 送礼物的公屏 -- (NSAttributedString *)createBatchMicroSendGiftAttribute:(AttachmentModel *)attachment sendInfo:(XPMessageRemoteExtModel *)sendInfo { +- (XPMessageInfoModel *)createBatchMicroSendGiftAttribute:(AttachmentModel *)attachment sendInfo:(XPMessageRemoteExtModel *)sendInfo messageInfo:(XPMessageInfoModel *)messageInfo{ NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; GiftReceiveInfoModel *info = [GiftReceiveInfoModel modelWithJSON:attachment.data]; GiftInfoModel *giftInfo = info.gift == nil ? info.giftInfo : info.gift; @@ -845,10 +897,11 @@ }]; } } - return attribute; + messageInfo.content = attribute; + return messageInfo; } -- (NSAttributedString *)createSendGiftAttribute:(AttachmentModel *)attachment sendInfo:(XPMessageRemoteExtModel *)sendInfo { +- (XPMessageInfoModel *)createSendGiftAttribute:(AttachmentModel *)attachment sendInfo:(XPMessageRemoteExtModel *)sendInfo messageInfo:(XPMessageInfoModel *)messageInfo{ NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; GiftReceiveInfoModel *info = [GiftReceiveInfoModel modelWithJSON:attachment.data]; GiftInfoModel *giftInfo = info.gift == nil ? info.giftInfo : info.gift; @@ -904,7 +957,8 @@ //x N [attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@" X%ld",info.giftNum] color:[ThemeColor messageTextColor] font:kRoomMessageDefalutFont]]; } - return attribute; + messageInfo.content = attribute; + return messageInfo; } #pragma mark - Commond Mehotd diff --git a/xplan-ios/Main/Room/View/MessageContainerView/View/XPRoomMessageTableViewCell.h b/xplan-ios/Main/Room/View/MessageContainerView/View/XPRoomMessageTableViewCell.h index 81de0054..f9582927 100644 --- a/xplan-ios/Main/Room/View/MessageContainerView/View/XPRoomMessageTableViewCell.h +++ b/xplan-ios/Main/Room/View/MessageContainerView/View/XPRoomMessageTableViewCell.h @@ -7,7 +7,7 @@ #import #import "RoomInfoModel.h" -@class XPNetImageYYLabel; +@class XPNetImageYYLabel, XPMessageInfoModel; NS_ASSUME_NONNULL_BEGIN @@ -22,9 +22,8 @@ NS_ASSUME_NONNULL_BEGIN ///当前房间的类型 @property (nonatomic,assign) RoomType roomType; -@property (nonatomic,strong) NSAttributedString *attributedString; -///气泡url -@property (nonatomic, copy) NSString *bubbleImageUrl; +@property (nonatomic,strong) XPMessageInfoModel *messageInfo; + ///代理 @property (nonatomic,weak) id delegate; diff --git a/xplan-ios/Main/Room/View/MessageContainerView/View/XPRoomMessageTableViewCell.m b/xplan-ios/Main/Room/View/MessageContainerView/View/XPRoomMessageTableViewCell.m index 816b13be..6c026c40 100644 --- a/xplan-ios/Main/Room/View/MessageContainerView/View/XPRoomMessageTableViewCell.m +++ b/xplan-ios/Main/Room/View/MessageContainerView/View/XPRoomMessageTableViewCell.m @@ -14,6 +14,7 @@ #import "XPMacro.h" #import "ThemeColor+Room.h" #import "UIImage+Utils.h" +#import "XPMessageInfoModel.h" #import "XPRoomMessageConstant.h" @@ -57,8 +58,8 @@ [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.bubbleImageView).offset(12); - make.centerY.mas_equalTo(self.bubbleImageView); - make.top.mas_equalTo(self.bubbleImageView).mas_offset(5); + make.right.bottom.mas_equalTo(self.bubbleImageView).offset(-10); + make.top.mas_equalTo(self.bubbleImageView).mas_offset(10); }]; } @@ -89,21 +90,29 @@ } #pragma mark - Getters And Setters -- (void)setAttributedString:(NSAttributedString *)attribute { - _attributedString = attribute; - self.contentLabel.attributedText = attribute; -} +- (void)setMessageInfo:(XPMessageInfoModel *)messageInfo { + _messageInfo = messageInfo; + if (_messageInfo) { + self.contentLabel.attributedText = _messageInfo.content; + if (_messageInfo.bubbleImageUrl.length) { + [self.bubbleImageView loadImageWithUrl:_messageInfo.bubbleImageUrl completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) { + UIImage *image1 = [UIImage imageWithCGImage:image.CGImage scale:2.0 orientation:UIImageOrientationUp]; + self.bubbleImageView.image = [self resizableImage:image1]; + }]; + } else { + _bubbleImageView.image = [UIImage imageWithColor:[ThemeColor messageBubbleColor]]; + } + if (_messageInfo.isUpdateContentFrame) { + [self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) { + make.left.mas_equalTo(self.bubbleImageView).offset(_messageInfo.contentLeftMargin); + make.right.mas_equalTo(self.bubbleImageView).offset(_messageInfo.contentRightMargin); + make.top.mas_equalTo(self.bubbleImageView).offset(_messageInfo.contentTopMargin); + make.bottom.mas_equalTo(self.bubbleImageView).offset(-_messageInfo.contentBottomMargin); + }]; + } + self.bubbleImageView.hidden = _messageInfo.isHiddenBubble; -- (void)setBubbleImageUrl:(NSString *)bubbleImageUrl { - _bubbleImageUrl = bubbleImageUrl; - if (bubbleImageUrl.length) { - [self.bubbleImageView loadImageWithUrl:bubbleImageUrl completion:^(UIImage * _Nonnull image, NSURL * _Nonnull url) { - UIImage *image1 = [UIImage imageWithCGImage:image.CGImage scale:2.0 orientation:UIImageOrientationUp]; - self.bubbleImageView.image = [self resizableImage:image1]; - }]; - } else { - _bubbleImageView.image = [UIImage imageWithColor:[ThemeColor messageBubbleColor]]; - } + } } - (UIImage *)scaleToSize:(UIImage *)img { @@ -124,7 +133,7 @@ - (void)setRoomType:(RoomType)roomType { _roomType = roomType; - if (self.bubbleImageUrl.length > 0) { + if (self.messageInfo.bubbleImageUrl.length > 0) { return; } if (_roomType == RoomType_MiniGame) { @@ -134,6 +143,7 @@ } } + - (NetImageView *)bubbleImageView { if (!_bubbleImageView) { _bubbleImageView = [[NetImageView alloc] init]; diff --git a/xplan-ios/Main/Room/View/MessageContainerView/XPRoomMessageContainerView.m b/xplan-ios/Main/Room/View/MessageContainerView/XPRoomMessageContainerView.m index be16c637..708d9df0 100644 --- a/xplan-ios/Main/Room/View/MessageContainerView/XPRoomMessageContainerView.m +++ b/xplan-ios/Main/Room/View/MessageContainerView/XPRoomMessageContainerView.m @@ -30,6 +30,7 @@ #import "CandyTreeResultModel.h" #import "RoomSailingPrizeModel.h" #import "UserInfoModel.h" +#import "XPMessageInfoModel.h" ///View #import "XPRoomMessageTableViewCell.h" #import "XPRoomMessageHeaderView.h" @@ -54,11 +55,9 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; ///是否是最小化进房的 @property (nonatomic,assign) BOOL isMiniEnter; ///数据源 -@property (nonatomic,strong) NSMutableArray *datasource; +@property (nonatomic,strong) NSMutableArray *datasource; ///临时存放消息的数组 @property (nonatomic,strong) NSMutableArray *incomingMessages; -///气泡数组 -@property (nonatomic, strong) NSMutableArray *messageBubbles; ///有多少人at我 @property (nonatomic, assign) NSInteger atCount; ///@我的消息位置集合 @@ -138,7 +137,6 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)]; NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set]; [self.datasource removeObjectsInArray:needRemoveMsgArray]; - [self.messageBubbles removeObjectsAtIndexes:set]; NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet]; for (int i = 0; i *)datasource { +- (NSMutableArray *)datasource { if (!_datasource) { _datasource = [NSMutableArray array]; } @@ -950,13 +941,6 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; return _incomingMessages; } -- (NSMutableArray *)messageBubbles { - if (!_messageBubbles) { - _messageBubbles = [NSMutableArray array]; - } - return _messageBubbles; -} - - (NSMutableArray *)locationArray { if (!_locationArray) { _locationArray = [NSMutableArray array]; diff --git a/xplan-ios/Main/Room/View/MoreView/View/XPRoomMoreMenuViewController.m b/xplan-ios/Main/Room/View/MoreView/View/XPRoomMoreMenuViewController.m index e028159b..9a0309d9 100644 --- a/xplan-ios/Main/Room/View/MoreView/View/XPRoomMoreMenuViewController.m +++ b/xplan-ios/Main/Room/View/MoreView/View/XPRoomMoreMenuViewController.m @@ -466,7 +466,7 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey; [StatisticsServiceHelper trackEventWithKey:StatisticsServiceEventroom_more_tool_click eventAttributes:@{@"roomMoreMenuType" : @"redPacket"}]; [self dismissViewControllerAnimated:YES completion:nil]; - XPWishGiftCreateViewController *wishGiftVC = [[XPWishGiftCreateViewController alloc] initWithRoomUid:roomUid]; + XPWishGiftCreateViewController *wishGiftVC = [[XPWishGiftCreateViewController alloc] initWithDelegate:self.hostDelegate]; [self.hostDelegate.getCurrentNav pushViewController:wishGiftVC animated:YES]; } break; diff --git a/xplan-ios/Main/Room/View/WishGift/Api/Api+WishGift.h b/xplan-ios/Main/Room/View/WishGift/Api/Api+WishGift.h index cd4dad04..d8147fc7 100644 --- a/xplan-ios/Main/Room/View/WishGift/Api/Api+WishGift.h +++ b/xplan-ios/Main/Room/View/WishGift/Api/Api+WishGift.h @@ -40,6 +40,10 @@ NS_ASSUME_NONNULL_BEGIN /// @param roomUid 房主的uid + (void)wishGiftHistoryList:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid; +/// 发送心愿完成庆祝特效 +/// @param roomUid 房主的uid ++ (void)wishGiftSendCelebrate:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid; + @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/WishGift/Api/Api+WishGift.m b/xplan-ios/Main/Room/View/WishGift/Api/Api+WishGift.m index 9cd80773..15318f60 100644 --- a/xplan-ios/Main/Room/View/WishGift/Api/Api+WishGift.m +++ b/xplan-ios/Main/Room/View/WishGift/Api/Api+WishGift.m @@ -67,4 +67,10 @@ [self makeRequest:@"wishGift/listWishGiftHistory" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, roomUid, nil]; } +/// 发送心愿完成庆祝特效 +/// @param roomUid 房主的uid ++ (void)wishGiftSendCelebrate:(HttpRequestHelperCompletion)completion roomUid:(NSString *)roomUid { + [self makeRequest:@"wishGift/sendCelebrate" method:HttpRequestHelperMethodGET completion:completion, __FUNCTION__, roomUid, nil]; +} + @end diff --git a/xplan-ios/Main/Room/View/WishGift/View/View/XPSlider.h b/xplan-ios/Main/Room/View/WishGift/View/View/XPSlider.h new file mode 100644 index 00000000..fc6a121c --- /dev/null +++ b/xplan-ios/Main/Room/View/WishGift/View/View/XPSlider.h @@ -0,0 +1,18 @@ +// +// XPSlider.h +// xplan-ios +// +// Created by 冯硕 on 2022/10/21. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface XPSlider : UISlider +/// +@property (nonatomic,assign) CGFloat height; + +@end + +NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/WishGift/View/View/XPSlider.m b/xplan-ios/Main/Room/View/WishGift/View/View/XPSlider.m new file mode 100644 index 00000000..8498feba --- /dev/null +++ b/xplan-ios/Main/Room/View/WishGift/View/View/XPSlider.m @@ -0,0 +1,16 @@ +// +// XPSlider.m +// xplan-ios +// +// Created by 冯硕 on 2022/10/21. +// + +#import "XPSlider.h" + +@implementation XPSlider + +- (CGRect)trackRectForBounds:(CGRect)bounds { + return CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.width, self.height); +} + +@end diff --git a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.m b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.m index 46852869..fe1bb0f5 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.m +++ b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftEnterView.m @@ -15,6 +15,7 @@ #import "NetImageView.h" #import "UIImage+Utils.h" #import "UIView+Corner.h" +#import "XPSlider.h" ///Model #import "WishGiftInfoModel.h" @@ -27,7 +28,7 @@ ///进度 @property (nonatomic,strong) UILabel *progressLabel; ///进度 -@property (nonatomic,strong) UISlider *progressView; +@property (nonatomic,strong) XPSlider *progressView; @property (nonatomic,strong) WishGiftInfoModel *giftInfo; @end @@ -71,7 +72,7 @@ }]; [self.progressView mas_makeConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(2); + make.height.mas_equalTo(5); make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-2); make.left.mas_equalTo(self.giftImageView.mas_right).offset(2); make.right.mas_equalTo(self.contentView).offset(-5); @@ -83,7 +84,7 @@ NSString * actualNum = (self.giftInfo.actualNum > self.giftInfo.targetNum) ? [NSString stringWithFormat:@"%ld+", self.giftInfo.targetNum] : [NSString stringWithFormat:@"%ld", self.giftInfo.actualNum]; NSString * title = [NSString stringWithFormat:@"%@%@", actualNum, targetNum]; NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10], NSForegroundColorAttributeName:[ThemeColor colorWithHexString:@"#FFC300"]}]; - if (self.giftInfo.targetNum == self.giftInfo.actualNum) { + if (self.giftInfo.targetNum <= self.giftInfo.actualNum) { [attribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor colorWithHexString:@"#FFC300"] range:[title rangeOfString:targetNum]]; } else { [attribute addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithWhite:1 alpha:1] range:[title rangeOfString:targetNum]]; @@ -97,19 +98,28 @@ if (_giftInfo) { self.giftImageView.imageUrl = _giftInfo.giftUrl; self.giftLabel.text = _giftInfo.giftName; - self.progressView.value = (CGFloat)giftInfo.actualNum / (CGFloat)_giftInfo.targetNum; + CGFloat value = (CGFloat)giftInfo.actualNum / (CGFloat)giftInfo.targetNum; + if (value > 1){ + value = 1; + } + self.progressView.value = value; self.progressLabel.attributedText = [self createProgressAttribute]; self.progressLabel.textAlignment = NSTextAlignmentCenter; } } -- (UISlider *)progressView { +- (XPSlider *)progressView { if(!_progressView) { - _progressView = [[UISlider alloc] init]; + _progressView = [[XPSlider alloc] init]; _progressView.enabled = NO; [_progressView setMinimumTrackImage:[UIImage gradientColorImageFromColors:@[[ThemeColor colorWithHexString:@"#FFA0C3"], [ThemeColor colorWithHexString:@"#C176FF"]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(1, 1)] forState:UIControlStateNormal]; _progressView.thumbTintColor = [UIColor clearColor]; - _progressView.value = 0.4l; + _progressView.minimumValue = 0; + _progressView.maximumValue = 1; + _progressView.value = 0.01; + _progressView.height = 5; + _progressView.layer.masksToBounds = YES; + _progressView.layer.cornerRadius = 2.5; [_progressView setMaximumTrackImage:[UIImage imageWithColor:[ThemeColor colorWithHexString:@"#17093E"]] forState:UIControlStateNormal]; } return _progressView; diff --git a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.m b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.m index c35bae9e..52d9c898 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.m +++ b/xplan-ios/Main/Room/View/WishGift/View/View/XPWishGiftInfoView.m @@ -12,6 +12,7 @@ #import "NetImageView.h" #import "ThemeColor.h" #import "UIImage+Utils.h" +#import "XPSlider.h" ///Model #import "WishGiftInfoModel.h" @@ -27,7 +28,7 @@ ///进度 @property (nonatomic,strong) UILabel *progressLabel; ///进度条 -@property (nonatomic,strong) UISlider *progressView; +@property (nonatomic,strong) XPSlider *progressView; ///赠送按钮 @property (nonatomic,strong) UIButton *senderButton; ///完成按钮 @@ -101,7 +102,7 @@ NSString * actualNum = (self.giftInfo.actualNum > self.giftInfo.targetNum) ? [NSString stringWithFormat:@"%ld+", self.giftInfo.targetNum] : [NSString stringWithFormat:@"%ld", self.giftInfo.actualNum]; NSString * title = [NSString stringWithFormat:@"%@%@", actualNum, targetNum]; NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10], NSForegroundColorAttributeName:[ThemeColor colorWithHexString:@"#FFA0C3"]}]; - if (self.giftInfo.targetNum == self.giftInfo.actualNum) { + if (self.giftInfo.targetNum <= self.giftInfo.actualNum) { [attribute addAttribute:NSForegroundColorAttributeName value:[ThemeColor colorWithHexString:@"#FFA0C3"] range:[title rangeOfString:targetNum]]; } else { [attribute addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithWhite:1 alpha:0.5] range:[title rangeOfString:targetNum]]; @@ -123,7 +124,11 @@ self.giftImageView.imageUrl = giftInfo.giftUrl; self.giftLabel.text = _giftInfo.giftName; self.priceLabel.text = [NSString stringWithFormat:@"%ld钻石", _giftInfo.goldPrice]; - self.progressView.value = (CGFloat)giftInfo.actualNum / (CGFloat)_giftInfo.targetNum; + CGFloat value = (CGFloat)giftInfo.actualNum / (CGFloat)giftInfo.targetNum; + if (value > 1) { + value = 1; + } + self.progressView.value = value; self.progressLabel.attributedText = [self createProgressAttribute]; self.progressLabel.textAlignment = NSTextAlignmentCenter; self.completionImageView.hidden = _giftInfo.targetNum != _giftInfo.actualNum; @@ -182,13 +187,18 @@ return _priceLabel; } -- (UISlider *)progressView { +- (XPSlider *)progressView { if(!_progressView) { - _progressView = [[UISlider alloc] init]; + _progressView = [[XPSlider alloc] init]; _progressView.enabled = NO; - [_progressView setMinimumTrackImage:[UIImage gradientColorImageFromColors:@[[ThemeColor colorWithHexString:@"#FFA0C3"], [ThemeColor colorWithHexString:@"#C176FF"]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(1, 1)] forState:UIControlStateNormal]; + [_progressView setMinimumTrackImage:[[UIImage gradientColorImageFromColors:@[[ThemeColor colorWithHexString:@"#FFA0C3"], [ThemeColor colorWithHexString:@"#C176FF"]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(1, 1)] resizableImageWithCapInsets:UIEdgeInsetsMake(0.1, 0.0, 0.1, 0.1) resizingMode:UIImageResizingModeStretch] forState:UIControlStateNormal]; _progressView.thumbTintColor = [UIColor clearColor]; - _progressView.value = 0.4l; + _progressView.minimumValue = 0; + _progressView.maximumValue = 1; + _progressView.height = 5; + _progressView.layer.masksToBounds = YES; + _progressView.layer.cornerRadius = 2.5; + _progressView.continuous = NO; [_progressView setMaximumTrackImage:[UIImage imageWithColor:[ThemeColor colorWithHexString:@"#17093E"]] forState:UIControlStateNormal]; } return _progressView; diff --git a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateViewController.h b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateViewController.h index cc25d717..21b20097 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateViewController.h +++ b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateViewController.h @@ -6,11 +6,11 @@ // #import "MvpViewController.h" - +#import "RoomHostDelegate.h" NS_ASSUME_NONNULL_BEGIN @interface XPWishGiftCreateViewController : MvpViewController -- (instancetype)initWithRoomUid:(NSString *)roomUid; +- (instancetype)initWithDelegate:(id)delegate; @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateViewController.m b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateViewController.m index 15cb5d4e..df4846b9 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateViewController.m +++ b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftCreateViewController.m @@ -15,6 +15,7 @@ #import "XPMacro.h" ///Model #import "WishGiftInfoModel.h" +#import "RoomInfoModel.h" ///View #import "XPWishGiftTableViewCell.h" #import "XPWishGiftHistoryViewController.h" @@ -37,6 +38,8 @@ @property (nonatomic,strong) NSArray *datasource; ///房主的uid @property (nonatomic,strong) NSString *roomUid; +///代理 +@property (nonatomic,weak) id delegate; @end @implementation XPWishGiftCreateViewController @@ -44,10 +47,10 @@ - (__kindof id)createPresenter { return [[XPWishGiftPresenter alloc] init]; } - -- (instancetype)initWithRoomUid:(NSString *)roomUid { +- (instancetype)initWithDelegate:(id)delegate{ if (self = [super init]) { - self.roomUid = roomUid; + self.delegate = delegate; + self.roomUid = [NSString stringWithFormat:@"%ld", [self.delegate getRoomInfo].uid]; [self initWishGiftList]; } return self; @@ -125,6 +128,10 @@ #pragma mark - XPWishGiftTableViewCellDelegate - (void)xPWishGiftTableViewCell:(XPWishGiftTableViewCell *)view didClearWishGift:(WishGiftInfoModel *)info { if (info) { + if (self.delegate.getRoomInfo.hasOpenWishGift) { + [self showErrorToast:@"心愿单一旦设置确认创建后,当日内不可再修改"]; + return; + } TTAlertConfig * config = [[TTAlertConfig alloc] init]; config.title = @""; config.message = @"确认删除该条数据?"; @@ -137,6 +144,10 @@ } - (void)xPWishGiftTableViewCell:(XPWishGiftTableViewCell *)view didUpdateWishGift:(WishGiftInfoModel *)info { + if (self.delegate.getRoomInfo.hasOpenWishGift) { + [self showErrorToast:@"心愿单一旦设置确认创建后,当日内不可再修改"]; + return; + } XPWishGiftCreateItemViewController * createItemVC = [[XPWishGiftCreateItemViewController alloc] init]; createItemVC.roomUid = self.roomUid; createItemVC.modifiGiftInfo = info; @@ -150,6 +161,10 @@ } #pragma mark - XPWishGiftProtocol +- (void)addWishGiftSuccess { + [self.navigationController popViewControllerAnimated:YES]; +} + - (void)getWishGiftListSuccess:(NSArray *)list { self.datasource = list; [self.tableView reloadData]; @@ -167,6 +182,10 @@ } - (void)clearButtonAction:(UIButton *)sender { + if (self.delegate.getRoomInfo.hasOpenWishGift) { + [self showErrorToast:@"心愿单一旦设置确认创建后,当日内不可再修改"]; + return; + } TTAlertConfig * config = [[TTAlertConfig alloc] init]; config.title = @""; config.message = @"确认清空当前数据?"; @@ -190,6 +209,11 @@ } - (void)createButtonAction:(UIButton *)sender { + if (self.delegate.getRoomInfo.hasOpenWishGift) { + [self showErrorToast:@"心愿单一旦设置确认创建后,当日内不可再修改"]; + return; + } + TTAlertConfig * config = [[TTAlertConfig alloc] init]; config.title = @""; config.message = @"确认创建当前心愿? \n创建后当日不可在编辑或删除"; diff --git a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.h b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.h index c9d2f054..c5912684 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.h +++ b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.h @@ -22,6 +22,8 @@ NS_ASSUME_NONNULL_BEGIN ///代理 @property (nonatomic,weak) id delegate; +- (void)getWishGiftListSuccess:(NSArray *)list; + @end NS_ASSUME_NONNULL_END diff --git a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.m b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.m index 84e4991e..7cb706a3 100644 --- a/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.m +++ b/xplan-ios/Main/Room/View/WishGift/View/XPWishGiftViewController.m @@ -39,6 +39,7 @@ @property (nonatomic,strong) NetImageView *secondAvatarImageView; ///第三个头像 @property (nonatomic,strong) NetImageView *thirdAvatarImageView; +@property (nonatomic,strong) NSArray * avatarViews; ///贡献的人数 @property (nonatomic,strong) UILabel *assistNumLabel; ///礼物 @@ -91,9 +92,9 @@ [self.backImageView addSubview:self.assistNumLabel]; [self.backImageView addSubview:self.giftStackView]; - [self.userStackView addArrangedSubview:self.firstView]; - [self.userStackView addArrangedSubview:self.secondView]; - [self.userStackView addArrangedSubview:self.thirdView]; + [self.userStackView addArrangedSubview:self.firstAvatarImageView]; + [self.userStackView addArrangedSubview:self.secondAvatarImageView]; + [self.userStackView addArrangedSubview:self.thirdAvatarImageView]; [self.giftStackView addArrangedSubview:self.firstView]; [self.giftStackView addArrangedSubview:self.secondView]; @@ -134,6 +135,18 @@ make.top.mas_equalTo(self.lineView.mas_bottom).offset(10); }]; + [self.firstAvatarImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(28); + }]; + + [self.secondAvatarImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(28); + }]; + + [self.thirdAvatarImageView mas_makeConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(28); + }]; + [self.assistNumLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(self.backImageView).offset(-15); make.centerY.mas_equalTo(self.userStackView); @@ -169,7 +182,7 @@ #pragma mark - XPWishGiftProtocol - (void)getWishGiftAssistUserListSuccess:(NSArray *)list { - for (int i = 0; i < self.userStackView.subviews.count; i++) { + for (int i = 0; i < self.userStackView.arrangedSubviews.count; i++) { NetImageView * imageView = [self.userStackView.subviews objectAtIndex:i]; if (i < list.count) { WishGiftUserModel * userInfo = [list objectAtIndex:i]; @@ -265,7 +278,7 @@ _userStackView = [[UIStackView alloc] init]; _userStackView.axis = UILayoutConstraintAxisHorizontal; _userStackView.distribution = UIStackViewDistributionFill; - _userStackView.alignment = UIStackViewAlignmentFill; + _userStackView.alignment = UIStackViewAlignmentCenter; _userStackView.spacing = 4; } return _userStackView; diff --git a/xplan-ios/Sources/room_wish_gift_sendCelebrate.svga b/xplan-ios/Sources/room_wish_gift_sendCelebrate.svga new file mode 100644 index 00000000..6cf263ab Binary files /dev/null and b/xplan-ios/Sources/room_wish_gift_sendCelebrate.svga differ