完成版本需求

This commit is contained in:
edwinQQQ
2024-12-04 21:22:38 +08:00
parent 2637ae065e
commit 2b4de25c80
35 changed files with 857 additions and 349 deletions

View File

@@ -46,7 +46,6 @@
uID:(NSString *)UID
{
LuckyGiftWinningFlagViewModel *model = [LuckyGiftWinningFlagViewModel modelWithDictionary:attachment.data];
// LuckyGiftWinningFlagViewModel *model = [LuckyGiftWinningFlagViewModel modelWithJSON:attachment.data];
if (model.roomId != roomID || model.uid != UID.integerValue) {
return;
}
@@ -146,6 +145,8 @@
self.winPriceLabel.text = model.coins;
self.winTimesLabel.text = model.times;
self.backgroundImageView.image = model.level == 1 ? kImage(@"luck_gift_gold") : kImage(@"luck_gift_pruple");
[[NSNotificationCenter defaultCenter] postNotificationName:@"receiveLuckGiftWinning" object:model.coins];
}
- (void)display {

View File

@@ -367,6 +367,11 @@ PIUniversalBannerViewDelegate>
receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
receiveInfo.isComboBatch = attachment.second == Custom_Message_Sub_AllMicroSend;
receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
if (receiveInfo.gift.notifyFull) {
return;
}
[self receiveGiftHandleSendGiftAnimation:attachment];
if (receiveInfo.isLuckyBagGift) {
if (!self.delegate.getRoomInfo.hasAnimationEffect) {return;}
@@ -506,7 +511,6 @@ PIUniversalBannerViewDelegate>
#pragma mark -
- (void)receiveLuckGiftWinning:(AttachmentModel *)attachment {
RoomInfoModel *roomInfo = self.delegate.getRoomInfo;
[LuckyGiftWinningFlagView display:self
with:attachment
roomID:roomInfo.roomId
@@ -1138,10 +1142,6 @@ PIUniversalBannerViewDelegate>
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:26], NSForegroundColorAttributeName:[UIColor whiteColor]}];
[attribute setYy_alignment:NSTextAlignmentLeft];
#if DEBUG
effectPath = @"";
#endif
if (effectPath.length > 0) {
@kWeakify(self);
[self.parser parseWithURL:[NSURL URLWithString:effectPath] completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {

View File

@@ -92,18 +92,10 @@
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(self.leftBigImageView.mas_centerX);
make.top.mas_equalTo(0);
// make.bottom.mas_equalTo(-self.messageInfo.contentBottomMargin);
make.bottom.mas_equalTo(self.leftBigImageView).offset(6);
make.trailing.mas_equalTo(-8);
}];
// [self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
// make.leading.mas_equalTo(self.leftBigImageView.mas_trailing);
// make.trailing.mas_equalTo(self.contentView).offset(-8);
//// make.centerY.mas_equalTo(self.contentView);
// make.centerY.mas_equalTo(self.leftBigImageView);
// }];
[self.contentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.mas_equalTo(self.bubbleImageView);
make.leading.mas_equalTo(self.leftBigImageView.mas_trailing);
@@ -114,17 +106,6 @@
make.edges.mas_equalTo(self.bubbleImageView);
}];
self.blurEffectView.hidden = NO;
// [self.contentLabel mas_updateConstraints:^(MASConstraintMaker *make) {
// make.leading.mas_equalTo(self.leftBigImageView.mas_trailing);
// make.trailing.mas_equalTo(-self.messageInfo.contentRightMargin - 8);
// make.top.mas_equalTo(self.bubbleImageView).offset(self.messageInfo.contentTopMargin);
// make.bottom.mas_equalTo(self.bubbleImageView).offset(-self.messageInfo.contentBottomMargin);
//// if (isMSRTL()) {
//// make.width.mas_equalTo([self RTLLabelWidth] - 65);
//// }
// }];
}
}
@@ -171,7 +152,6 @@
self.leftBigImageView.imageUrl = messageInfo.boomImageUrl;
} else {
[self updateLayout];
[self layoutIfNeeded];
}
}
}
@@ -229,8 +209,9 @@
}];
[self.bubbleImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
make.center.mas_equalTo(self.contentLabel);
make.size.mas_equalTo(self.contentLabel).multipliedBy(1.1);
make.top.bottom.mas_equalTo(self.contentLabel);
make.leading.mas_equalTo(self.contentLabel).offset(-self.messageInfo.contentLeftMargin);
make.trailing.mas_equalTo(self.contentLabel).offset(self.messageInfo.contentLeftMargin);
}];
}
@@ -240,7 +221,7 @@
context:nil].size;
}
- (CGFloat)RTLLabelWidth {
return MIN(ceil([self RTLLabelSize].width),// + self.messageInfo.contentLeftMargin + self.messageInfo.contentRightMargin + 8,
return MIN(ceil([self RTLLabelSize].width) + self.messageInfo.contentLeftMargin,
kRoomMessageMaxWidth - self.messageInfo.contentLeftMargin);
}
@@ -299,15 +280,12 @@
- (UIVisualEffectView *)blurEffectView {
if (!_blurEffectView) {
//
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark]; // Light, Dark, ExtraLight
//
UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
_blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
//
_blurEffectView.frame = CGRectMake(0, 0, KScreenWidth, 200);
_blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; // 使
_blurEffectView.frame = CGRectMake(0, 0, KScreenWidth*2/3, 200);
_blurEffectView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_blurEffectView.hidden = YES;
[_blurEffectView setCornerRadius:8];

View File

@@ -104,8 +104,10 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
}
- (void)changeType:(NSInteger)type {
if (self.displayType == type) {
return;
}
self.displayType = type;
// [self updateAllDataSource];
[self.messageTableView reloadData];
if (self.displayType == 1) {
@@ -164,126 +166,295 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
///
- (void)appendAndScrollToAtUser {
if (self.incomingMessages.count < 1) {
NSInteger rows = self.datasource.count;
if (!self.locationArray.count) {
[self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
self.messageTipsBtn.hidden = YES;
self.isPending = NO;
self.atCount = 0;
self.atTipBtn.hidden = YES;
// 1. incomingMessages
if (self.incomingMessages.count < 1) {
NSInteger rows = self.datasource.count;
// 2. locationArray
if (self.locationArray.count == 0) {
[self scrollToBottomWithTipsHidden:YES];
return;
}
// 3. @
int index = [self safeGetIndexFromLocationArrayAt:0];
if (index == NSNotFound) {
[self scrollToBottomWithTipsHidden:YES];
return;
}
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
if (rows > indexPath.row) {
[self.messageTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
if (rows == indexPath.row + 1) {
self.messageTipsBtn.hidden = YES;
self.isPending = NO;
}
} else {
[self scrollToBottomWithTipsHidden:YES];
}
[self safelyRemoveLocationAtIndex:0];
[self updateAtTipButton];
return;
}
int index = [self.locationArray[0] intValue];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
if (rows > indexPath.row) {
[self.messageTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
if (rows == indexPath.row + 1) {
self.messageTipsBtn.hidden = YES;
self.isPending = NO;
}
} else {
[self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
//@
self.messageTipsBtn.hidden = YES;
}
if (self.locationArray.count) {
[self.locationArray removeObjectAtIndex:0];
self.atCount -= 1;
[self.atTipBtn setTitle:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageContainerView0"), (unsigned long)self.locationArray.count] forState:UIControlStateNormal];
if (self.locationArray.count == 0) {
self.atTipBtn.hidden = YES;
}
} else {
self.atTipBtn.hidden = YES;
}
} else {
// 4.
if (self.datasource.count > kRoomMessageMaxLength) {
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
[self.datasource removeObjectsInArray:needRemoveMsgArray];
[self updateAllDataSource:nil];
NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
for (int i = 0; i<self.locationArray.count; i++) {///at
NSNumber *number = self.locationArray[i];
if (number.integerValue < kRoomMessageMaxLength / 2) {
self.atCount--;
[indexSet addIndex:i];
}
}
[self.locationArray removeObjectsAtIndexes:indexSet];
for (int i = 0; i<self.locationArray.count; i++) {//at,at
NSNumber *number = self.locationArray[i];
number = @(number.integerValue - kRoomMessageMaxLength / 2);
[self.locationArray replaceObjectAtIndex:i withObject:number];
}
NSInteger removedCount = kRoomMessageMaxLength / 2;
[self safelyRemoveMessages:removedCount];
}
//
// 5.
NSMutableArray *indexPaths = @[].mutableCopy;
NSMutableArray *tempNewDatas = @[].mutableCopy;
for (id item in self.incomingMessages) {
XPMessageInfoModel *model = nil;
if ([item isKindOfClass:[NIMMessage class]]) {
model = [self.messageParser parseMessageAttribute:item];
} else if ([item isKindOfClass:[NIMBroadcastMessage class]]) {
model = [self.messageParser parseBroadcastMessageAttribute:item];
}
if (!model) {
continue;
}
XPMessageInfoModel *model = [self parseMessage:item];
if (!model) continue;
[tempNewDatas addObject:model];
[self.datasource addObject:model];
[indexPaths addObject:[NSIndexPath indexPathForRow:self.datasource.count - 1 inSection:0]];
if ([item isKindOfClass:[NIMMessage class]]) {
id nickNameInfos = [(NIMMessage*)item remoteExt][@"atUids"];
if ([nickNameInfos isKindOfClass:[NSArray class]]) {
for (NSString *nick in nickNameInfos) {
if ([nick isEqualToString:[AccountInfoStorage instance].getUid]) {
[self.locationArray addObject:@(self.datasource.count-1)];
}
}
}
}
[self processAtMentionsForMessage:item];
}
[self updateAllDataSource:tempNewDatas];
[self.incomingMessages removeAllObjects];
[self.messageTableView reloadData];
NSInteger rows = self.datasource.count;
if (!self.locationArray.count) {
[self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
self.messageTipsBtn.hidden = YES;
self.isPending = NO;
self.atCount = 0;
self.atTipBtn.hidden = YES;
return;
}
int index = [self.locationArray[0] intValue];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
if (rows > indexPath.row) {
[self.messageTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
if (rows == indexPath.row + 1) {
self.messageTipsBtn.hidden = YES;
self.isPending = NO;
}
} else {
[self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
//@
self.messageTipsBtn.hidden = YES;
}
if (self.locationArray.count) {
[self.locationArray removeObjectAtIndex:0];
self.atCount -= 1;
[self.atTipBtn setTitle:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageContainerView1"), (unsigned long)self.locationArray.count] forState:UIControlStateNormal];
if (self.locationArray.count == 0) {
self.atTipBtn.hidden = YES;
}
} else {
self.atTipBtn.hidden = YES;
// 6.
[self scrollToFirstLocationOrBottom];
// if (self.incomingMessages.count < 1) {
// NSInteger rows = self.datasource.count;
// if (!self.locationArray.count) {
// [self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
// self.messageTipsBtn.hidden = YES;
// self.isPending = NO;
// self.atCount = 0;
// self.atTipBtn.hidden = YES;
// return;
// }
// int index = [self.locationArray[0] intValue];
// NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
// if (rows > indexPath.row) {
// [self.messageTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
// if (rows == indexPath.row + 1) {
// self.messageTipsBtn.hidden = YES;
// self.isPending = NO;
// }
// } else {
// [self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
// //@
// self.messageTipsBtn.hidden = YES;
// }
// if (self.locationArray.count) {
// [self.locationArray removeObjectAtIndex:0];
// self.atCount -= 1;
// [self.atTipBtn setTitle:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageContainerView0"), (unsigned long)self.locationArray.count] forState:UIControlStateNormal];
// if (self.locationArray.count == 0) {
// self.atTipBtn.hidden = YES;
// }
// } else {
// self.atTipBtn.hidden = YES;
// }
// } else {
// if (self.datasource.count > kRoomMessageMaxLength) {
// NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
// NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
// [self.datasource removeObjectsInArray:needRemoveMsgArray];
// [self updateAllDataSource:nil];
// NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
// for (int i = 0; i<self.locationArray.count; i++) {///at
// NSNumber *number = self.locationArray[i];
// if (number.integerValue < kRoomMessageMaxLength / 2) {
// self.atCount--;
// [indexSet addIndex:i];
// }
// }
// [self.locationArray removeObjectsAtIndexes:indexSet];
// for (int i = 0; i<self.locationArray.count; i++) {//at,at
// NSNumber *number = self.locationArray[i];
// number = @(number.integerValue - kRoomMessageMaxLength / 2);
// [self.locationArray replaceObjectAtIndex:i withObject:number];
// }
// }
//
// //
// NSMutableArray *indexPaths = @[].mutableCopy;
// NSMutableArray *tempNewDatas = @[].mutableCopy;
// for (id item in self.incomingMessages) {
// XPMessageInfoModel *model = nil;
// if ([item isKindOfClass:[NIMMessage class]]) {
// model = [self.messageParser parseMessageAttribute:item];
// } else if ([item isKindOfClass:[NIMBroadcastMessage class]]) {
// model = [self.messageParser parseBroadcastMessageAttribute:item];
// }
// if (!model) {
// continue;
// }
// [tempNewDatas addObject:model];
// [self.datasource addObject:model];
// [indexPaths addObject:[NSIndexPath indexPathForRow:self.datasource.count - 1 inSection:0]];
// if ([item isKindOfClass:[NIMMessage class]]) {
// id nickNameInfos = [(NIMMessage*)item remoteExt][@"atUids"];
// if ([nickNameInfos isKindOfClass:[NSArray class]]) {
// for (NSString *nick in nickNameInfos) {
// if ([nick isEqualToString:[AccountInfoStorage instance].getUid]) {
// [self.locationArray addObject:@(self.datasource.count-1)];
// }
// }
// }
// }
// }
// [self updateAllDataSource:tempNewDatas];
// [self.incomingMessages removeAllObjects];
// [self.messageTableView reloadData];
//
// NSInteger rows = self.datasource.count;
// if (!self.locationArray.count) {
// [self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
// self.messageTipsBtn.hidden = YES;
// self.isPending = NO;
// self.atCount = 0;
// self.atTipBtn.hidden = YES;
// return;
// }
//
// int index = [self.locationArray[0] intValue];
// NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
// if (rows > indexPath.row) {
// [self.messageTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
// if (rows == indexPath.row + 1) {
// self.messageTipsBtn.hidden = YES;
// self.isPending = NO;
// }
// } else {
// [self.messageTableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:(rows-1) inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:YES];
// //@
// self.messageTipsBtn.hidden = YES;
// }
// if (self.locationArray.count) {
// [self.locationArray removeObjectAtIndex:0];
// self.atCount -= 1;
// [self.atTipBtn setTitle:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageContainerView1"), (unsigned long)self.locationArray.count] forState:UIControlStateNormal];
// if (self.locationArray.count == 0) {
// self.atTipBtn.hidden = YES;
// }
// } else {
// self.atTipBtn.hidden = YES;
// }
// }
}
- (void)scrollToBottomWithTipsHidden:(BOOL)hidden {
NSInteger rows = self.datasource.count;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:(rows - 1) inSection:0];
[self.messageTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
self.messageTipsBtn.hidden = hidden;
self.isPending = NO;
self.atCount = 0;
self.atTipBtn.hidden = hidden;
}
- (void)updateLocationArrayForMessageRemoval:(NSInteger)removedCount {
NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
for (int i = 0; i < self.locationArray.count; i++) {
NSNumber *number = self.locationArray[i];
if (number.integerValue < removedCount) {
self.atCount--;
[indexSet addIndex:i];
}
}
[self.locationArray removeObjectsAtIndexes:indexSet];
for (int i = 0; i < self.locationArray.count; i++) {
NSNumber *number = self.locationArray[i];
self.locationArray[i] = @(number.integerValue - removedCount);
}
}
- (void)updateAtTipButton {
if (self.locationArray.count == 0) {
self.atTipBtn.hidden = YES;
} else {
[self.atTipBtn setTitle:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageContainerView0"), (unsigned long)self.locationArray.count] forState:UIControlStateNormal];
self.atTipBtn.hidden = NO;
}
}
- (int)safeGetIndexFromLocationArrayAt:(NSUInteger)index {
if (index < self.locationArray.count) {
NSNumber *number = self.locationArray[index];
return [number intValue];
}
return NSNotFound; //
}
- (void)safelyRemoveLocationAtIndex:(NSUInteger)index {
if (index < self.locationArray.count) {
[self.locationArray removeObjectAtIndex:index];
self.atCount = MAX(0, self.atCount - 1);
}
}
- (void)safelyRemoveMessages:(NSInteger)count {
if (self.datasource.count >= count) {
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, count)];
[self.datasource removeObjectsAtIndexes:set];
[self updateAllDataSource:nil];
// locationArray
NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet];
for (NSUInteger i = 0; i < self.locationArray.count; i++) {
NSNumber *number = self.locationArray[i];
if (number.integerValue < count) {
[indexSet addIndex:i];
} else {
self.locationArray[i] = @(number.integerValue - count);
}
}
[self.locationArray removeObjectsAtIndexes:indexSet];
}
}
- (XPMessageInfoModel *)parseMessage:(id)item {
if ([item isKindOfClass:[NIMMessage class]]) {
return [self.messageParser parseMessageAttribute:item];
} else if ([item isKindOfClass:[NIMBroadcastMessage class]]) {
return [self.messageParser parseBroadcastMessageAttribute:item];
}
return nil;
}
- (void)processAtMentionsForMessage:(id)item {
if ([item isKindOfClass:[NIMMessage class]]) {
NSArray *nickNameInfos = [(NIMMessage *)item remoteExt][@"atUids"];
if ([nickNameInfos isKindOfClass:[NSArray class]]) {
for (NSString *nick in nickNameInfos) {
if ([nick isEqualToString:[AccountInfoStorage instance].getUid]) {
[self.locationArray addObject:@(self.datasource.count - 1)];
}
}
}
}
}
- (void)scrollToFirstLocationOrBottom {
NSInteger rows = self.datasource.count;
if (self.locationArray.count == 0) {
[self scrollToBottomWithTipsHidden:YES];
return;
}
int index = [self safeGetIndexFromLocationArrayAt:0];
if (index == NSNotFound || index >= rows) {
[self scrollToBottomWithTipsHidden:YES];
} else {
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:index inSection:0];
[self.messageTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionBottom animated:YES];
[self safelyRemoveLocationAtIndex:0];
}
[self updateAtTipButton];
}
#pragma mark - @
@@ -366,6 +537,20 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
if(self.isLoadHistoryMessage == YES)return;
[self.incomingMessages addObject:messageData];
NSInteger messageCount = 0;
switch (self.displayType) {
case 1:
messageCount = self.datasource.count;
break;
case 2:
messageCount = self.datasource_chat.count;
break;
case 3:
messageCount = self.datasource_gift.count;
break;
default:
break;
}
if ([messageData isKindOfClass:[NIMBroadcastMessage class]]) {
NIMBroadcastMessage *broadcastMessage = (NIMBroadcastMessage *)messageData;
[[XPRoomMiniManager shareManager] saveRoomMessage:broadcastMessage];
@@ -388,6 +573,19 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
}
if (self.isPending) {
// switch (self.displayType) {
// case 1:
// self.messageTipsBtn.hidden = self.datasource.count == messageCount;
// break;
// case 2:
// self.messageTipsBtn.hidden = self.datasource_chat.count == messageCount;
// break;
// case 3:
// self.messageTipsBtn.hidden = self.datasource_gift.count == messageCount;
// break;
// default:
// break;
// }
self.messageTipsBtn.hidden = NO;
[self findAtMeNumber];
} else {

View File

@@ -166,11 +166,6 @@
indexOfRoomAlbum += 1;
}
if (isOnMic) {
[array addObject:musicPanel];
indexOfRoomAlbum += 1;
}
if (isCreator && roomInfo.type != RoomType_MiniGame) {
if(roomInfo.type != RoomType_Anchor){
[array addObject:acrossRoomPK];
@@ -178,6 +173,11 @@
}
}
if (isOnMic) {
[array addObject:musicPanel];
indexOfRoomAlbum += 1;
}
if (isCreator && roomInfo.type == RoomType_Anchor) {
[array addObject:anchorRoomPK];
indexOfRoomAlbum += 1;
@@ -194,11 +194,11 @@
}
[array addObject:trumpet];
[array addObject:giftEffect];
[array addObject:roomSetting];
if (isCreator || isManager || isSuperAdmin) {
[array addObject:bgValue];
indexOfRoomAlbum += 1;
}
[array addObject:roomSetting];
[array addObject:clearScreen];
} else {
[array addObject:trumpet];

View File

@@ -17,7 +17,8 @@ typedef enum : NSUInteger {
ComboAction_RemovePanel,
ComboAction_Error,
ComboAction_Combo_Count_Update,
ComboAction_Update_After_Send_Success
ComboAction_Update_After_Send_Success,
ComboAction_SendGift_Gold_Update
} ComboActionType;
typedef enum : NSUInteger {
@@ -31,8 +32,11 @@ NS_ASSUME_NONNULL_BEGIN
@interface GiftComboManager : NSObject
@property (nonatomic, assign, readonly) BOOL enableCombo;
//@property(nonatomic, strong, nullable) GiftComboView *comboView;
@property (nonatomic, strong) GiftReceiveInfoModel *sendGiftReceiveInfo;
@property(nonatomic, copy) void(^handleComboSuccess)(GiftReceiveInfoModel *receiveModel, NSMutableDictionary *originDic);
@property(nonatomic, copy) void(^handleRoomUIChanged)(BOOL comboViewDisplay);
// 单例方法
+ (instancetype)sharedManager;

View File

@@ -72,6 +72,8 @@
return sharedInstance;
}
//// GiftReceiveInfoModel metadata
- (void)addGiftComboWithInfo:(GiftReceiveInfoModel *)info andMetadata:(NSDictionary *)metadata {
if (info && metadata) {
@@ -104,6 +106,10 @@
self.actionCallback(ComboAction_ShowPanel);
self.isCombing = YES;
}
if (self.handleRoomUIChanged) {
self.handleRoomUIChanged(YES);
}
}
- (void)registerActions:(void (^)(ComboActionType))action {
@@ -116,6 +122,9 @@
if (self.actionCallback) {
self.actionCallback(ComboAction_RemovePanel);
}
if (self.handleRoomUIChanged) {
self.handleRoomUIChanged(NO);
}
self.isCombing = NO;
}
@@ -419,33 +428,6 @@
[self.requestQueue addObject:dic];
[self startProcessingQueue];
// @kWeakify(self);
// [Api requestSendGift:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
// @kStrongify(self);
// if (!self) {
// return;
// }
// if (code == 200) {
// GiftReceiveInfoModel *receive = [GiftReceiveInfoModel modelWithJSON:data.data];
// receive.sourceType = self.giftSourceType;
// receive.roomSendGiftType = self.roomSendGiftType;
// [self handleSendGiftSuccess:data];
// } else {
// self.errorMessage = msg;
// self.actionCallback(ComboAction_RemovePanel);
// self.actionCallback(ComboAction_Error);
// }
// }
// targetUids:allUIDs
// giftNum:self.giftNumPerTimes
// sendType:[NSString stringWithFormat:@"%ld", GiftSendType_OnMic]
// giftId:[NSString stringWithFormat:@"%ld", self.giftInfo.giftId]
// giftSource:[NSString stringWithFormat:@"%ld", self.giftSourceType]
// giftType:[NSString stringWithFormat:@"%ld", self.roomSendGiftType]
// roomUid:self.roomUID
// msg:@""
// uid:[AccountInfoStorage instance].getUid];
}
- (void)handleSendGift:(NSDictionary *)dic {
@@ -463,6 +445,10 @@
NSArray *array = [allUIDs componentsSeparatedByString:@","];
receive.receiveGiftNumberUser = array.count;
[self handleSendGiftSuccess:receive sourceData:data];
[[NSNotificationCenter defaultCenter] postNotificationName:@"receiveLuckGiftWinning"
object:@{@"CurrentGold": receive.userPurse.diamonds,
@"Price": @(receive.gift.goldPrice * receive.giftNum * array.count),
@"isFromWinning":@(NO)}];
} else {
self.errorMessage = msg;
self.actionCallback(ComboAction_RemovePanel);
@@ -482,9 +468,6 @@
- (void)handleSendGiftSuccess:(GiftReceiveInfoModel *)receive
sourceData:(BaseModel *)response {
// self.combo += 1;
if (self.actionCallback) {
self.actionCallback(ComboAction_Combo_Count_Update);
}
@@ -495,55 +478,6 @@
if (self.handleComboSuccess) {
self.handleComboSuccess(receive, dic);
}
return;
self.sendGiftReceiveInfo = receive;
if (self.actionCallback) {
self.actionCallback(ComboAction_Update_After_Send_Success);
}
NSDictionary *tempDic = response.data;
NSMutableDictionary *data = [NSMutableDictionary dictionary];
[data addEntriesFromDictionary:tempDic];
AttachmentModel *attachment = [[AttachmentModel alloc] init];
switch (self.roomSendGiftType) {
case RoomSendGiftType_AllMic: {
attachment.first = CustomMessageType_AllMicroSend;
attachment.second = Custom_Message_Sub_AllMicroSend;
[data setObject:[tempDic valueForKeyPath:@"targetUsers.uid"] forKey:@"targetUids"];
attachment.data = data;
}
break;
case RoomSendGiftType_MutableOnMic: {
attachment.first = CustomMessageType_AllMicroSend;
attachment.second = Custom_Message_Sub_AllBatchSend;
attachment.data = data;
}
break;
case RoomSendGiftType_ToOne: {
attachment.first = CustomMessageType_Gift;
attachment.second = Custom_Message_Sub_Gift_Send;
NSDictionary *targetUsers = ((NSArray *)[data objectForKey:@"targetUsers"]).firstObject;
NSString *avatar = [targetUsers valueForKeyPath:@"avatar"];
[data setObject:[targetUsers valueForKeyPath:@"uid"] forKey:@"targetUid"];
[data setObject:[targetUsers valueForKeyPath:@"nick"] forKey:@"targetNick"];
if (avatar.length > 0) {
[data setObject:avatar forKey:@"targetAvatar"];
}
attachment.data = data;
}
break;
default:
attachment = nil;
break;
}
if (attachment) {
[attachment.data setObject:@(self.combo) forKey:@"comboCount"];
[self sendCustomMessage:attachment];
}
}
- (void)sendCustomMessage:(AttachmentModel *)attachment {

View File

@@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithFrame:(CGRect)frame duration:(NSInteger)duration;
- (void)startCountdown;
- (void)resetCountdown; // 重置功能
- (void)stopCountdown;
- (void)setCompletionHandler:(void (^__nullable)(void))completionHandler; // 计时结束的回调
@end

View File

@@ -23,9 +23,7 @@
- (void)dealloc
{
self.completionHandler = nil;
[self.timer invalidate];
self.timer = nil;
[self stopCountdown];
}
- (instancetype)initWithFrame:(CGRect)frame duration:(NSInteger)duration {
@@ -51,14 +49,6 @@
endAngle:(M_PI * 2) - M_PI_2
clockwise:YES];
//
// self.backgroundLayer = [CAShapeLayer layer];
// self.backgroundLayer.path = circularPath.CGPath;
// self.backgroundLayer.strokeColor = UIColorFromRGB(0x04D5C6).CGColor;
// self.backgroundLayer.lineWidth = 7;
// self.backgroundLayer.fillColor = [UIColor clearColor].CGColor;
// [self.layer addSublayer:self.backgroundLayer];
//
self.foregroundLayer = [CAShapeLayer layer];
self.foregroundLayer.path = circularPath.CGPath;
@@ -119,6 +109,9 @@
self.remainingTime -= 0.1;
if (self.remainingTime <= 0) {
// TODO: timer manager timer
[self.timer invalidate];
self.timer = nil;
@@ -128,6 +121,12 @@
}
}
- (void)stopCountdown {
self.completionHandler = nil;
[self.timer invalidate];
self.timer = nil;
}
//
- (void)animateRing {
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];

View File

@@ -12,9 +12,10 @@
NS_ASSUME_NONNULL_BEGIN
@interface GiftComboView : UIView
- (void)setupCurrentGold:(double)gold;
- (void)updateCurrentGold:(double)gold giftPrice:(double)price isFromWinning:(BOOL)isFromWinning;
- (void)updateCount;
- (void)stopTimer;
@end
NS_ASSUME_NONNULL_END

View File

@@ -12,23 +12,39 @@
#import <SVGA.h>
#import <AudioToolbox/AudioToolbox.h>
@interface GiftComboView ()<SVGAPlayerDelegate>
@interface GiftComboView ()<SVGAPlayerDelegate, UIGestureRecognizerDelegate>
@property (nonatomic, strong) UIView *container;
@property (nonatomic, strong) UILabel *comboCountLabel;
@property(nonatomic, strong) UILabel *comboGoldLabel;
@property(nonatomic, strong) UILabel *updateGoldLabel;
@property (nonatomic, strong) SVGAImageView *playImageView;
@property (nonatomic, strong) SVGAVideoEntity *svgaVideoEntity;
@property (nonatomic, strong) CountdownRingView *countdownRingView;
@property(nonatomic, strong) NSMutableArray *updateGoldQueue;
@property(nonatomic, assign) BOOL isAnimatingUpdateGold;
@end
@implementation GiftComboView
- (void)dealloc
{
[self.countdownRingView stopCountdown];
[self.countdownRingView removeFromSuperview];
self.countdownRingView = nil;
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (instancetype)init {
if (self = [super init]) {
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapSpace)];
[self addGestureRecognizer:tap];
self.updateGoldQueue = @[].mutableCopy;
[self setupNotification];
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapSpace)];
tap.delegate = self;
[self addGestureRecognizer:tap];
[self setupUI];
[self setupTimer];
[self updateCount];
@@ -50,6 +66,30 @@
return self;
}
- (void)setupNotification {
[[NSNotificationCenter defaultCenter] addObserverForName:@"receiveLuckGiftWinning"
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification * _Nonnull notification) {
if ([notification.object isKindOfClass:[NSString class]]) {
NSString *coin = (NSString *)notification.object;
if (![NSString isEmpty:coin]) {
[self updateCurrentGold:coin.doubleValue giftPrice:0 isFromWinning:YES];
}
} else if ([notification.object isKindOfClass:[NSDictionary class]]) {
NSDictionary *dic = (NSDictionary *)notification.object;
double coin = [[dic objectForKey:@"CurrentGold"] doubleValue];
double price = [[dic objectForKey:@"Price"] doubleValue];
BOOL isFromWinning = [[dic objectForKey:@"isFromWinning"] boolValue];
[self updateCurrentGold:coin giftPrice:price isFromWinning:isFromWinning];
// [[NSNotificationCenter defaultCenter] postNotificationName:@"receiveLuckGiftWinning"
// object:@{@"CurrentGold": receive.userPurse.diamonds,
// @"Price": @(receive.gift.goldPrice),
// @"isFromWinning":@(NO)}];
}
}];
}
- (void)updateCount {
NSString *countStr = [NSString stringWithFormat:@"x%ld", [[GiftComboManager sharedManager] loadComboCount]];
NSShadow *shadow = [[NSShadow alloc] init];
@@ -63,11 +103,15 @@
self.comboCountLabel.attributedText = string;
}
- (void)stopTimer {
[self.countdownRingView stopCountdown];
}
- (void)setupUI {
[self addSubview:self.container];
[self.container mas_makeConstraints:^(MASConstraintMaker *make) {
make.trailing.mas_equalTo(self).offset(-16);
make.bottom.mas_equalTo(self).offset(-20);
make.bottom.mas_equalTo(self).offset(-26);
make.size.mas_equalTo(CGSizeMake(kGetScaleWidth(170), kGetScaleWidth(310)));
}];
@@ -90,6 +134,41 @@
make.bottom.mas_equalTo(self.playImageView.mas_bottom).offset(4);
make.width.height.mas_equalTo(kGetScaleWidth(90));
}];
[self setupGoldArea];
}
- (void)setupGoldArea {
[self addSubview:self.comboGoldLabel];
[self.comboGoldLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(44);
make.bottom.mas_equalTo(-74);
}];
UIImageView *coin = [[UIImageView alloc] initWithImage:kImage(@"moli_money_icon")];
[self addSubview:coin];
[coin mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.comboGoldLabel);
make.trailing.mas_equalTo(self.comboGoldLabel.mas_leading).offset(-4);
make.size.mas_equalTo(CGSizeMake(22, 22));
}];
UIView *bg = [[UIView alloc] init];
bg.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
[bg setCornerRadius:18];
[self insertSubview:bg belowSubview:self.comboGoldLabel];
[bg mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(coin.mas_leading).offset(-8);
make.trailing.mas_equalTo(self.comboGoldLabel.mas_trailing).offset(8);
make.centerY.mas_equalTo(self.comboGoldLabel);
make.height.mas_equalTo(36);
}];
[self addSubview:self.updateGoldLabel];
[self.updateGoldLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(bg);
make.bottom.mas_equalTo(self.comboGoldLabel.mas_bottom).offset(0);
}];
}
- (void)setupTimer {
@@ -103,10 +182,10 @@
}
- (void)handleTap {
// dispatch_async(dispatch_get_main_queue(), ^{
dispatch_async(dispatch_get_main_queue(), ^{
// 1521 3
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
// });
});
[[GiftComboManager sharedManager] sendGift];
[self.playImageView startAnimation];
@@ -114,7 +193,7 @@
}
- (void)handleTapSpace {
[[GiftComboManager sharedManager] forceRemove];
}
// SVGAPlayerDelegate:
@@ -122,6 +201,71 @@
[self.playImageView stepToPercentage:0 andPlay:NO];
}
#pragma mark -
- (void)setupCurrentGold:(double)gold {
self.comboGoldLabel.text = @(gold).stringValue;
}
- (void)updateCurrentGold:(double)gold giftPrice:(double)price isFromWinning:(BOOL)isFromWinning {
if (isFromWinning) {
[self.updateGoldQueue addObject:[NSString stringWithFormat:@"+ %@", @(gold)]];
} else {
[self.updateGoldQueue addObject:@(-price).stringValue];
self.comboGoldLabel.text = @(gold).stringValue;
}
if (!self.isAnimatingUpdateGold) {
[self processNextUpdateGold];
}
}
- (void)processNextUpdateGold {
if (self.updateGoldQueue.count == 0) {
self.isAnimatingUpdateGold = NO;
return;
}
NSNumber *goldNum = [self.updateGoldQueue xpSafeObjectAtIndex:0];
[self.updateGoldQueue removeObjectAtIndex:0];
self.isAnimatingUpdateGold = YES;
self.updateGoldLabel.text = goldNum.stringValue;
self.updateGoldLabel.alpha = 0;
[UIView animateWithDuration:0.25 animations:^{
[self.updateGoldLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.comboGoldLabel.mas_bottom).offset(-40);
}];
self.updateGoldLabel.alpha = 1;
[self layoutIfNeeded];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.25
delay:0.25
options:UIViewAnimationOptionCurveLinear
animations:^{
[self.updateGoldLabel mas_updateConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.comboGoldLabel.mas_bottom).offset(0);
}];
self.updateGoldLabel.alpha = 0;
[self layoutIfNeeded];
} completion:^(BOOL finished) {
self.isAnimatingUpdateGold = NO;
[self processNextUpdateGold];
}];
}];
}
#pragma mark -
#pragma mark -
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
// UITextView UICollectionView
if (touch.view == self.container || touch.view == self.playImageView) {
return NO;
}
return YES; //
}
#pragma mark -
- (UIView *)container {
if (!_container) {
@@ -142,6 +286,20 @@
return _comboCountLabel;
}
- (UILabel *)comboGoldLabel {
if (!_comboGoldLabel) {
_comboGoldLabel = [UILabel labelInitWithText:@"" font:kFontSemibold(20) textColor:UIColorFromRGB(0xffd54c)];
}
return _comboGoldLabel;
}
- (UILabel *)updateGoldLabel {
if (!_updateGoldLabel) {
_updateGoldLabel = [UILabel labelInitWithText:@"" font:kFontSemibold(24) textColor:UIColorFromRGB(0xffd54c)];
}
return _updateGoldLabel;
}
- (SVGAImageView *)playImageView {
if (_playImageView == nil) {
_playImageView = [[SVGAImageView alloc]init];
@@ -155,7 +313,8 @@
- (CountdownRingView *)countdownRingView {
if (!_countdownRingView) {
_countdownRingView = [[CountdownRingView alloc] initWithFrame:CGRectMake(0, 0, kGetScaleWidth(90), kGetScaleWidth(90))
duration:555];
duration:5];
_countdownRingView.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap)];
[_countdownRingView addGestureRecognizer:tap];
}

View File

@@ -345,7 +345,6 @@
diamondAtt.image = iconImage;
NSAttributedString *diamondAttribute = [NSMutableAttributedString attributedStringWithAttachment:(NSTextAttachment *)diamondAtt];
if (_walletInfoModel.canGoldSendGift == NO){
NSString * title = [NSString stringWithFormat:@" %@",diamonds];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14], NSForegroundColorAttributeName:highlightColor}];

View File

@@ -174,6 +174,7 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
if (self->_luckyBroadcastView) {
self.luckyBroadcastView.hidden = NO;
}
[self.comboView stopTimer];
[self.comboView removeFromSuperview];
self.comboView = nil;
}
@@ -194,6 +195,10 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
} else {
self.giftBarView.walletInfoModel = receiveInfo.userPurse;
}
}
break;
case ComboAction_SendGift_Gold_Update: {
}
break;
default:
@@ -928,12 +933,15 @@ UIKIT_EXTERN NSString * kShowFirstRechargeView;
@kStrongify(self);
if (self) {
[self sendCustomMessage:receiveInfo oringinDic:originDic];
[[GiftComboManager sharedManager] resetCombo];
@kWeakify(self);
[[GiftComboManager sharedManager] setHandleComboSuccess:^(GiftReceiveInfoModel * _Nonnull receiveModel, NSMutableDictionary * _Nonnull originDic) {
@kStrongify(self);
[self sendCustomMessage:receiveInfo oringinDic:originDic.copy];
}];
if ([GiftComboManager sharedManager].enableCombo) {
[[GiftComboManager sharedManager] resetCombo];
[self.comboView setupCurrentGold:receiveInfo.userPurse.diamonds.doubleValue];
@kWeakify(self);
[[GiftComboManager sharedManager] setHandleComboSuccess:^(GiftReceiveInfoModel * _Nonnull receiveModel, NSMutableDictionary * _Nonnull originDic) {
@kStrongify(self);
[self sendCustomMessage:receiveInfo oringinDic:originDic.copy];
}];
}
}
});