diff --git a/YuMi/CustomUI/UIImageView/UIImageConstant.m b/YuMi/CustomUI/UIImageView/UIImageConstant.m index ea1d8c7f..b5249f4d 100644 --- a/YuMi/CustomUI/UIImageView/UIImageConstant.m +++ b/YuMi/CustomUI/UIImageView/UIImageConstant.m @@ -82,6 +82,7 @@ NSString * const kImageTypeMonentsPhoto = @"imageMogr2/auto-orient/thumbnail/400 break; case ImageTypeUserCardLevel: configUrl = kImageTypeUserCardLevel; + break; case ImageTypeMonentsPhoto: configUrl = kImageTypeMonentsPhoto; break; diff --git a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m index 15a949a4..10b2fa38 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m @@ -310,18 +310,8 @@ PIUniversalBannerViewDelegate> if (attachment.second == Custom_Message_Sub_Gift_EmbeddedStyle) { if (receiveInfo.giftVo) { receiveInfo.gift = receiveInfo.giftVo; -// receiveInfo.targetUid = receiveInfo.recvUserUid; -// receiveInfo.targetNick = receiveInfo.recvUserNick; -// receiveInfo.targetUids = @[receiveInfo.recvUserUid]; -// if (<#condition#>) { -// <#statements#> -// } -// [data setObject:[[obj objectForKey:@"uid"] stringValue] forKey:@"targetUid"]; -// [data setObject:[obj objectForKey:@"nick"] forKey:@"targetNick"]; -// [data setObject:[obj objectForKey:@"avatar"] forKey:@"targetAvatar"]; } - // TODO: 只送一个人时背包礼物有问题 receiveInfo.targetUid = [[attachment.data objectForKey:@"recvUserUid"] stringValue]; receiveInfo.targetNick = [attachment.data objectForKey:@"recvUserNick"]; receiveInfo.targetAvatar = [attachment.data objectForKey:@"recvUserAvatar"]; @@ -1751,6 +1741,20 @@ PIUniversalBannerViewDelegate> } } +#if DEBUG + for (NSInteger i=0;i<15;i++) { + endPoint = [self.delegate animationPointAtStageViewByIndex:i]; + BOOL isCombing = [[GiftComboManager sharedManager] isGiftCombing] && [sendUid isEqualToString:[AccountInfoStorage instance].getUid]; + CGFloat time = isCombing ? 0.25 : 0.5; + dispatch_time_t timer = dispatch_time(DISPATCH_TIME_NOW, time * NSEC_PER_SEC); + dispatch_after(timer, dispatch_get_main_queue(), ^{ + [self beginGiftAnimation:giftInfo.giftUrl + startPoint:starPoint + endPoint:endPoint + isGiftCombing:isCombing]; + }); + } +#else for (NSString *targetUid in targetUids) { NSString * userId = targetUid; if ([userId isKindOfClass:[NSNumber class]]) { @@ -1759,19 +1763,21 @@ PIUniversalBannerViewDelegate> endPoint = [self getGiftAnimationPoint:userId isEnd:YES]; dispatch_time_t timer = dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC); - BOOL isCombing = [[GiftComboManager sharedManager] isGiftCombing] && - [sendUid isEqualToString:[AccountInfoStorage instance].getUid]; + BOOL isCombing = [[GiftComboManager sharedManager] isGiftCombing] && [sendUid isEqualToString:[AccountInfoStorage instance].getUid]; if (isCombing) { timer = dispatch_time(DISPATCH_TIME_NOW, 0.25 * NSEC_PER_SEC); } dispatch_after(timer, dispatch_get_main_queue(), ^{ - [self beginGiftAnimation:giftInfo.giftUrl + [self beginGiftAnimation:giftInfo.giftUrl startPoint:starPoint - endPoint:endPoint + endPoint:endPoint isGiftCombing:isCombing]; }); } +#endif + + } ///起点 diff --git a/YuMi/Modules/YMRoom/View/RoomAnimationProtocol.h b/YuMi/Modules/YMRoom/View/RoomAnimationProtocol.h index 5a1d79ad..4aec6327 100644 --- a/YuMi/Modules/YMRoom/View/RoomAnimationProtocol.h +++ b/YuMi/Modules/YMRoom/View/RoomAnimationProtocol.h @@ -24,6 +24,8 @@ NS_ASSUME_NONNULL_BEGIN */ - (CGPoint)animationPointAtStageViewByUid:(NSString *)uid; +- (CGPoint)animationPointAtStageViewByIndex:(NSInteger)index; + @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboFlagView.m b/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboFlagView.m index 6c573cac..7c46959f 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboFlagView.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboFlagView.m @@ -22,12 +22,27 @@ @property (nonatomic, assign) NSInteger totalCount; @property (nonatomic, strong) NSTimer *timer; + +@property(nonatomic, copy) NSDictionary *stringAttributes; + +@property(nonatomic, copy) NSString *cacheAvatar; +@property(nonatomic, copy) NSString *cacheIcon; + @end @implementation GiftComboFlagView - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { + NSShadow *shadow = [[NSShadow alloc] init]; + shadow.shadowBlurRadius = 3; + shadow.shadowColor = [UIColor colorWithRed:255/255.0 green:153./255.0 blue:0/255.0 alpha:1]; + shadow.shadowOffset = CGSizeMake(0,1); + self.stringAttributes = @{NSFontAttributeName: kFontSemibold(30), + NSForegroundColorAttributeName: UIColorFromRGB(0xFFE07B), + NSShadowAttributeName: shadow + }; + [self setupUI]; } return self; @@ -38,73 +53,109 @@ [self endTimer]; } -- (void)startTimer { - if (_timer) { - [self endTimer]; +#pragma mark - 更新 UI +- (void)updateUIWithModel:(GiftReceiveInfoModel *)model { + if ([NSString isEmpty:self.cacheIcon]) { + self.cacheIcon = model.gift.giftUrl; + } else { + if ([self.cacheIcon isEqualToString:model.gift.giftUrl]) { + self.cacheIcon = model.gift.giftUrl; + self.giftIcon.imageUrl = model.gift.giftUrl; + } } + if ([NSString isEmpty:self.cacheAvatar]) { + self.cacheIcon = model.avatar; + self.giftGiverAvatar.imageUrl = model.avatar; + } else { + if (![self.cacheAvatar isEqualToString:model.avatar]) { + self.cacheIcon = model.avatar; + self.giftGiverAvatar.imageUrl = model.avatar; + } + } + self.giftGiverNameLabel.text = model.nick; + + self.giftReceiverNameLabel.text = [self receiverNameForModel:model]; + + NSInteger total = model.comboCount * model.giftNum * model.receiveUserCount; + NSString *countStr = [NSString stringWithFormat:@"x%ld", (long)total]; + self.giftCountLabel.attributedText = [self generateAttributedStringForCount:countStr]; +} + +- (NSMutableAttributedString *)generateAttributedStringForCount:(NSString *)countStr { + return [[NSMutableAttributedString alloc] initWithString:countStr + attributes:self.stringAttributes]; +} + +- (void)startTimer { + [self endTimer]; + @kWeakify(self); _timer = [NSTimer scheduledTimerWithTimeInterval:5.0 repeats:NO block:^(NSTimer * _Nonnull timer) { @kStrongify(self); - [self removeFromSuperview]; - if (self.timerEnd) { - self.timerEnd(); + if (self) { + [self handleTimerFired]; } }]; + + // 确保定时器在滚动时也能触发 + [[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes]; } - (void)endTimer { - [_timer invalidate]; - _timer = nil; + if (self.timer) { + [self.timer invalidate]; + self.timer = nil; + } +} + +#pragma mark - 定时器触发事件 +- (void)handleTimerFired { + [self removeFromSuperview]; + if (self.timerEnd) { + self.timerEnd(); + } +} + + +#pragma mark - 动画逻辑 +- (void)performCountLabelAnimationWithTotal:(NSInteger)total { + if (self.giftCountLabel.layer.animationKeys.count != 0) { + return; + } + CGFloat scale = 1.1 + (0.01 * total); + scale = MIN(3.0, scale); + + self.giftCountLabel.transform = CGAffineTransformIdentity; + [UIView animateWithDuration:0.25 animations:^{ + self.giftCountLabel.transform = CGAffineTransformMakeScale(scale, scale); + } completion:^(BOOL finished) { + self.giftCountLabel.transform = CGAffineTransformIdentity; + }]; } - (void)updateReceiveInfoModel:(GiftReceiveInfoModel *)model animationType:(NSInteger)type { _receiveInfo = model; - self.giftGiverAvatar.imageUrl = model.avatar; - self.giftIcon.imageUrl = model.gift.giftUrl; - self.giftGiverNameLabel.text = model.nick; + [self updateUIWithModel:model]; - if (model.isComboBatch) { - self.giftReceiverNameLabel.text = YMLocalizedString(@"Combo_1"); - } else { - if (model.targetUids.count == 1) { - self.giftReceiverNameLabel.text = model.targetNick; - } else if (model.targetUids.count > 1) { - self.giftReceiverNameLabel.text = YMLocalizedString(@"Combo_2"); - } else { - self.giftReceiverNameLabel.text = model.targetNick; - } - } - - NSInteger total = model.comboCount * model.giftNum * model.receiveUserCount; - - NSString *countStr = [NSString stringWithFormat:@"x%ld", (long)total]; - NSShadow *shadow = [[NSShadow alloc] init]; - shadow.shadowBlurRadius = 3; - shadow.shadowColor = [UIColor colorWithRed:255/255.0 green:153./255.0 blue:0/255.0 alpha:1]; - shadow.shadowOffset =CGSizeMake(0,1); - NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:countStr - attributes: @{NSFontAttributeName: kFontSemibold(30), - NSForegroundColorAttributeName: UIColorFromRGB(0xFFE07B), - NSShadowAttributeName: shadow}]; - self.giftCountLabel.attributedText = string; if (type == 1) { - CGFloat scale = 1.1 + (0.01 * total); - scale = MIN(3.0, scale); - - self.giftCountLabel.transform = CGAffineTransformIdentity; - [UIView animateWithDuration:0.25 - animations:^{ - self.giftCountLabel.transform = CGAffineTransformMakeScale(scale, scale); - } completion:^(BOOL finished) { - self.giftCountLabel.transform = CGAffineTransformIdentity; - }]; + [self performCountLabelAnimationWithTotal:model.comboCount * model.giftNum * model.receiveUserCount]; } [self startTimer]; } +- (NSString *)receiverNameForModel:(GiftReceiveInfoModel *)model { + if (model.isComboBatch) { + return YMLocalizedString(@"Combo_1"); + } + if (model.targetUids.count > 1) { + return YMLocalizedString(@"Combo_2"); + } + return model.targetNick; +} + - (void)setupUI { [self addSubview:self.backgroundImageView]; [self.backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) { @@ -179,9 +230,7 @@ if (!_giftIcon) { _giftIcon = [[NetImageView alloc] init]; _giftIcon.contentMode = UIViewContentModeScaleAspectFit; -// _giftIcon.layer.cornerRadius = kGetScaleWidth(24); - _giftIcon.layer.masksToBounds = YES; - _giftIcon.clipsToBounds = YES; + [_giftIcon setCornerRadius:kGetScaleWidth(24)]; } return _giftIcon; } @@ -207,7 +256,6 @@ return _giftReceiverNameLabel; } - - (UILabel *)giftCountLabel { if (!_giftCountLabel) { _giftCountLabel = [UILabel labelInitWithText:@"X 1" font:kFontSemibold(36) textColor:UIColorFromRGB(0xFFE07B)]; diff --git a/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboView.m b/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboView.m index 3c492068..5ce502c6 100644 --- a/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboView.m +++ b/YuMi/Modules/YMRoom/View/SendGiftView/View/GiftComboView.m @@ -191,14 +191,29 @@ } - (void)handleTap { - dispatch_async(dispatch_get_main_queue(), ^{ + static BOOL isHandlingTap = NO; + + if (isHandlingTap) { + NSLog(@"点击间隔过短,忽略此次点击"); + return; + } + + isHandlingTap = YES; + + // 处理点击事件 + NSLog(@"有效点击处理"); + @kWeakify(self); + // 延迟重置标志位 + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + @kStrongify(self); // 1521 连续震动 3 次 AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); - }); - [[GiftComboManager sharedManager] sendGift]; - [self.playImageView startAnimation]; - [self.countdownRingView resetCountdown]; + [[GiftComboManager sharedManager] sendGift]; + [self.playImageView startAnimation]; + [self.countdownRingView resetCountdown]; + isHandlingTap = NO; + }); } - (void)handleTapSpace { diff --git a/YuMi/Modules/YMRoom/View/StageView/FifteenMicStageView.m b/YuMi/Modules/YMRoom/View/StageView/FifteenMicStageView.m index 820f56e3..dd57b936 100644 --- a/YuMi/Modules/YMRoom/View/StageView/FifteenMicStageView.m +++ b/YuMi/Modules/YMRoom/View/StageView/FifteenMicStageView.m @@ -84,4 +84,23 @@ return point; } +- (CGPoint)animationPointAtStageViewByIndex:(NSInteger)index { + CGPoint point = CGPointZero; + + if (index >= 0 && index <= 4) { + point = CGPointMake(paddingH + (mcWidth + marginH) * (index) + mcWidth / 2, firstRowTopMargin + mcHeight / 2); + } + + if (index >= 5 && index < 10) { + point = CGPointMake(paddingH + (mcWidth + marginH) * (index - 5) + mcWidth / 2, sRowTop + mcHeight / 2); + } + + if (index >= 10 && index < 15) { + point = CGPointMake(paddingH + (mcWidth + marginH) * (index - 10) + mcWidth / 2, tRowTop + mcHeight / 2); + } + + point = [self convertPoint:point toView:nil]; + return point; +} + @end diff --git a/YuMi/Modules/YMRoom/View/XPRoomViewController.m b/YuMi/Modules/YMRoom/View/XPRoomViewController.m index e46235fa..030efad8 100644 --- a/YuMi/Modules/YMRoom/View/XPRoomViewController.m +++ b/YuMi/Modules/YMRoom/View/XPRoomViewController.m @@ -2471,6 +2471,10 @@ XPCandyTreeInsufficientBalanceViewDelegate> return [self.stageView animationPointAtStageViewByUid:uid]; } +- (CGPoint)animationPointAtStageViewByIndex:(NSInteger)index { + return [self.stageView animationPointAtStageViewByIndex:index]; +} + - (void)getRoomBoomInfoSuccess:(NSArray *)models { [[RoomBoomManager sharedManager] updateBoomDetailArray:models]; [self.activityContainerView updateForBoomDetailArray:models]; diff --git a/YuMi/Modules/YMWeb/XPWebViewController.m b/YuMi/Modules/YMWeb/XPWebViewController.m index aa71de6f..e1e4a765 100644 --- a/YuMi/Modules/YMWeb/XPWebViewController.m +++ b/YuMi/Modules/YMWeb/XPWebViewController.m @@ -346,7 +346,7 @@ NSString * const kJSOpenPaymentCallback = @"openPaymentCallback"; didReceiveScriptMessage:(WKScriptMessage *)message { [self.webview evaluateJavaScript:@"document.location.href" completionHandler:^(id _Nullable response, NSError * _Nullable error) { -// NSLog(@"%@", response); +// NSLog(@"-- -- - -- - - | -- -- - -- - -%@", response); // NSLog(@"-- -- - -- - -%@: %@", message.name, message.body); NSString *currentUrl = [NSString stringWithFormat:@"%@", response]; ///测试环境只要有host就执行,方便h5连接本地调试