diff --git a/xplan-ios/Assets.xcassets/Room/Trumpet/rooom_trumpet_bgImage.imageset/rooom_trumpet_bgImage@2x.png b/xplan-ios/Assets.xcassets/Room/Trumpet/rooom_trumpet_bgImage.imageset/rooom_trumpet_bgImage@2x.png index 34cab75e..b4a03045 100644 Binary files a/xplan-ios/Assets.xcassets/Room/Trumpet/rooom_trumpet_bgImage.imageset/rooom_trumpet_bgImage@2x.png and b/xplan-ios/Assets.xcassets/Room/Trumpet/rooom_trumpet_bgImage.imageset/rooom_trumpet_bgImage@2x.png differ diff --git a/xplan-ios/Assets.xcassets/Room/Trumpet/rooom_trumpet_bgImage.imageset/rooom_trumpet_bgImage@3x.png b/xplan-ios/Assets.xcassets/Room/Trumpet/rooom_trumpet_bgImage.imageset/rooom_trumpet_bgImage@3x.png index 4571dd73..c8409f41 100644 Binary files a/xplan-ios/Assets.xcassets/Room/Trumpet/rooom_trumpet_bgImage.imageset/rooom_trumpet_bgImage@3x.png and b/xplan-ios/Assets.xcassets/Room/Trumpet/rooom_trumpet_bgImage.imageset/rooom_trumpet_bgImage@3x.png differ diff --git a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m index f3fba3b0..5d79dc99 100644 --- a/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m +++ b/xplan-ios/Main/Room/View/BaseUIContainerView/XPRoomFunctionContainerView.m @@ -10,6 +10,7 @@ #import #import #import +#import ///Tool #import "XPMacro.h" #import "AccountInfoStorage.h" @@ -58,6 +59,7 @@ #import "XPLittleGameMiniStageView.h" #import "XPLittleGameRoomListView.h" #import "AcrossRoomPKPrizeModel.h" +#import "XPRoomTrumpetView.h" ///个播PK #import "XPAnchorFansTeamEntranceView.h" #import "XPAnchorFansTeamViewController.h" @@ -96,6 +98,12 @@ @property (nonatomic, strong) XPAnchorFansRelationModel *relationFansModel; ///个播PK面板 @property (nonatomic, strong) XPAnchorPkPanelView *anchorPKPanelView; +///小喇叭 +@property (nonatomic, strong) XPRoomTrumpetView *trumpetView; +///小喇叭队列 +@property (nonatomic, strong) NSMutableArray *trumpetQueue; +///小喇叭动画定时器 +@property (nonatomic, strong) dispatch_source_t trumpetTimer; @end @@ -105,6 +113,9 @@ if (self.followAnchorTimer != nil) { dispatch_source_cancel(self.followAnchorTimer); } + if (self.trumpetTimer != nil) { + dispatch_source_cancel(self.trumpetTimer); + } } - (instancetype)initWithdelegate:(id)delegate { @@ -140,6 +151,7 @@ [self addSubview:self.anchorGiftValueView]; [self addSubview:self.topicStackView]; [self addSubview:self.fansTeamEntranceView]; +// [self addSubview:self.trumpetView]; [self.topicStackView addArrangedSubview:self.topicLabel]; [self.topicStackView addArrangedSubview:self.editButton]; } @@ -172,6 +184,12 @@ make.height.mas_equalTo(15); make.top.mas_equalTo(58 + 5 + 6 + 12 + 3 + kNavigationHeight); }]; +// [self.trumpetView mas_makeConstraints:^(MASConstraintMaker *make) { +// make.top.mas_equalTo(kNavigationHeight); +// make.left.mas_equalTo(0); +// make.right.mas_equalTo(0); +// make.height.mas_equalTo(152.5); +// }]; } - (void)showLittleGameMiniView:(RoomType)type { @@ -638,6 +656,8 @@ } } else if (attachment.first == CustomMessageType_Anchor_FansTeam) { [self handleAnchorFansTeam:attachment]; + } else if (attachment.first == CustomMessageType_Noble_VIP && attachment.second == Custom_Message_Sub_Room_Trumpet) { + [self handleTrumpet:attachment]; } } } @@ -1077,6 +1097,97 @@ self.delegate.getRoomInfo.winUid = nil; } +#pragma mark - 房间贵族小喇叭 +- (void)handleTrumpet:(AttachmentModel *)attachment { + if (self.trumpetQueue.count) { + [self.trumpetQueue addObject:attachment.data]; + } else { + [self.trumpetQueue addObject:attachment.data]; + __block NSInteger time = 5.0; //倒计时时间 + if (_trumpetTimer == nil) { + dispatch_queue_t queue = dispatch_get_global_queue(0, 0); + _trumpetTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); + dispatch_source_set_timer(_trumpetTimer,dispatch_walltime(NULL, 0), time*NSEC_PER_SEC, 0); //每秒执行 + @weakify(self); + dispatch_source_set_event_handler(_trumpetTimer, ^{ + @strongify(self); + if (self.trumpetQueue.count) { + dispatch_sync(dispatch_get_main_queue(), ^{ + [self createTrumpetAnimation:self.trumpetQueue.firstObject]; + [self.trumpetQueue removeObjectAtIndex:0]; + }); + } else { + dispatch_sync(dispatch_get_main_queue(), ^{ + [self.trumpetView removeFromSuperview]; + }); + + if (self.trumpetTimer != nil) { + dispatch_source_cancel(self.trumpetTimer); + self.trumpetTimer = nil; + } + } + }); + dispatch_resume(_trumpetTimer); + } + } +} + +- (void)createTrumpetAnimation:(NSDictionary *)attatchment { + if (!self.trumpetView.superview) { + [self addSubview:self.trumpetView]; + [self.trumpetView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.delegate.getRoomInfo.type == RoomType_MiniGame ? kNavigationHeight: kNavigationHeight + 110); + make.left.mas_equalTo(0); + make.right.mas_equalTo(0); + make.height.mas_equalTo(153); + }]; + } + self.trumpetView.data = attatchment; + POPBasicAnimation *animation2 = [POPBasicAnimation animationWithPropertyNamed:kPOPViewFrame]; + animation2.beginTime = CACurrentMediaTime(); + animation2.duration = 0.1; + CGFloat width = self.frame.size.width - 15; + CGFloat height = 28; + animation2.fromValue = [NSValue valueWithCGRect:CGRectMake(0, 153-34-28, width, height)]; + animation2.toValue = [NSValue valueWithCGRect:CGRectMake(0, 153-34-28-14, width, height)]; + animation2.removedOnCompletion = NO; + animation2.repeatCount = 1; + + POPBasicAnimation *animation3 = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerOpacity]; + animation3.duration = 0.1; + animation3.beginTime = CACurrentMediaTime(); + animation3.fromValue = @1; + animation3.toValue = @0; + animation3.repeatCount = 1; + animation3.removedOnCompletion = NO; + + [animation2 setCompletionBlock:^(POPAnimation *anim, BOOL finished) { + if (finished) { + POPBasicAnimation *animation2 = [POPBasicAnimation animationWithPropertyNamed:kPOPViewFrame]; + animation2.beginTime = CACurrentMediaTime(); + animation2.duration = 0.1; + CGFloat width = self.frame.size.width - 15; + CGFloat height = 28; + animation2.fromValue = [NSValue valueWithCGRect:CGRectMake(0, 153 - 34 - 14, width, height)]; + animation2.toValue = [NSValue valueWithCGRect:CGRectMake(0, 153 - 34 - 28, width, height)]; + animation2.removedOnCompletion = NO; + animation2.repeatCount = 1; + + POPBasicAnimation *animation3 = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerOpacity]; + animation3.duration = 0.1; + animation3.beginTime = CACurrentMediaTime(); + animation3.fromValue = @0; + animation3.toValue = @1; + animation3.repeatCount = 1; + animation3.removedOnCompletion = NO; + [self.trumpetView.mainView.layer pop_addAnimation:animation2 forKey:@"animation4"]; + [self.trumpetView.mainView.layer pop_addAnimation:animation3 forKey:@"animation5"]; + } + }]; + [self.trumpetView.mainView.layer pop_addAnimation:animation2 forKey:@"animation2"]; + [self.trumpetView.mainView.layer pop_addAnimation:animation3 forKey:@"animation3"]; +} + #pragma mark - XPRoomLittleGameListViewDelegate - (void)xPRoomLittleGameListView:(XPLittleGameRoomListView *)view didSelectItem:(LittleGameInfoModel *)itemInfo { RoomInfoModel * roomInfo = self.delegate.getRoomInfo; @@ -1260,4 +1371,19 @@ return _anchorPKPanelView; } +- (XPRoomTrumpetView *)trumpetView { + if (!_trumpetView) { + _trumpetView = [[XPRoomTrumpetView alloc] init]; +// _trumpetView.hidden = YES; + } + return _trumpetView; +} + +- (NSMutableArray *)trumpetQueue { + if (!_trumpetQueue) { + _trumpetQueue = [NSMutableArray array]; + } + return _trumpetQueue; +} + @end diff --git a/xplan-ios/Main/Room/View/MessageContainerView/XPRoomMessageContainerView.m b/xplan-ios/Main/Room/View/MessageContainerView/XPRoomMessageContainerView.m index dd838936..bda088ea 100644 --- a/xplan-ios/Main/Room/View/MessageContainerView/XPRoomMessageContainerView.m +++ b/xplan-ios/Main/Room/View/MessageContainerView/XPRoomMessageContainerView.m @@ -29,7 +29,6 @@ #import "XPRoomMessageTableViewCell.h" #import "XPRoomMessageHeaderView.h" #import "View/XPRoomMessageHeaderView.h" -#import "XPRoomTrumpetView.h" NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; @@ -55,12 +54,6 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; @property (nonatomic, strong) NSMutableArray *messageBubbles; ///messageView 持有这个工具类 进行数据的分发操作 TODO: 有需要在改 @property (nonatomic,strong) XPRoomMessageParser *messageParser; -///小喇叭 -@property (nonatomic, strong) XPRoomTrumpetView *trumpetView; -///小喇叭队列 -@property (nonatomic, strong) NSMutableArray *trumpetQueue; -///小喇叭动画定时器 -@property (nonatomic, strong) dispatch_source_t trumpetTimer; ///是否是大的 只有在小游戏的时候有用 @property (nonatomic,assign) BOOL isLarge; @end @@ -70,9 +63,6 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; - (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; - if (self.trumpetTimer != nil) { - dispatch_source_cancel(self.trumpetTimer); - } } - (instancetype)initWithDelegate:(id)delegate { @@ -98,14 +88,13 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; [self addSubview:self.messageTableView]; [self addSubview:self.messageTipsBtn]; self.messageTableView.tableHeaderView = self.headerView; - [self addSubview:self.trumpetView]; } - (void)initSubViewConstraints { [self.messageTableView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self).offset(15); make.bottom.right.mas_equalTo(self); - make.top.mas_equalTo(self.trumpetView.mas_bottom); + make.top.mas_equalTo(self); }]; [self.messageTipsBtn mas_makeConstraints:^(MASConstraintMaker *make) { @@ -114,12 +103,6 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; make.bottom.mas_equalTo(self.mas_bottom).offset(-5); make.left.mas_equalTo(self); }]; - [self.trumpetView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self); - make.left.mas_equalTo(15); - make.right.mas_equalTo(0); - make.height.mas_equalTo(0); - }]; } ///是否是当前房间 @@ -357,43 +340,6 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; [[XPRoomMiniManager shareManager] resetLocalMessage]; [self addRoomMessage:message]; return; - } else if (attachment.first == CustomMessageType_Noble_VIP && attachment.second == Custom_Message_Sub_Room_Trumpet) { - if (self.trumpetQueue.count) { - [self.trumpetQueue addObject:attachment.data]; - } else { - [self.trumpetQueue addObject:attachment.data]; - __block NSInteger time = 5.0; //倒计时时间 - if (_trumpetTimer != nil) { - dispatch_source_cancel(_trumpetTimer); - } - dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); - _trumpetTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); - dispatch_source_set_timer(_trumpetTimer,dispatch_walltime(NULL, 0),time*NSEC_PER_SEC, 0); //每秒执行 - dispatch_source_set_event_handler(_trumpetTimer, ^{ - if (self.trumpetQueue.count) { - dispatch_sync(dispatch_get_main_queue(), ^{ - [self createTrumpetAnimation:self.trumpetQueue.firstObject]; - [self.trumpetQueue removeObjectAtIndex:0]; - }); - } else { - dispatch_sync(dispatch_get_main_queue(), ^{ - self.trumpetView.hidden = YES; - [self.trumpetView mas_updateConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(0); - }]; - [self.messageTableView mas_updateConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self.trumpetView.mas_bottom); - }]; - }); - - if (self->_trumpetTimer != nil) { - dispatch_source_cancel(self->_trumpetTimer); - } - } - }); - dispatch_resume(_trumpetTimer); - } - return; } } if (self.hostDelegate.getRoomInfo.isCloseScreen) { @@ -546,59 +492,6 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; } -- (void)createTrumpetAnimation:(NSDictionary *)attatchment { - self.trumpetView.data = attatchment; - self.trumpetView.hidden = NO; - [self.trumpetView mas_updateConstraints:^(MASConstraintMaker *make) { - make.height.mas_equalTo(32); - }]; - [self.messageTableView mas_updateConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(self.trumpetView.mas_bottom).mas_offset(4); - }]; - POPBasicAnimation *animation2 = [POPBasicAnimation animationWithPropertyNamed:kPOPViewFrame]; - animation2.beginTime = CACurrentMediaTime(); - animation2.duration = 0.1; - CGFloat width = self.frame.size.width - 15; - CGFloat height = 32; - animation2.fromValue = [NSValue valueWithCGRect:CGRectMake(0, 0, width, height)]; - animation2.toValue = [NSValue valueWithCGRect:CGRectMake(0, -height/2, width, height)]; - animation2.removedOnCompletion = NO; - animation2.repeatCount = 1; - - POPBasicAnimation *animation3 = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerOpacity]; - animation3.duration = 0.1; - animation3.beginTime = CACurrentMediaTime(); - animation3.fromValue = @1; - animation3.toValue = @0; - animation3.repeatCount = 1; - animation3.removedOnCompletion = NO; - - [animation2 setCompletionBlock:^(POPAnimation *anim, BOOL finished) { - if (finished) { - POPBasicAnimation *animation2 = [POPBasicAnimation animationWithPropertyNamed:kPOPViewFrame]; - animation2.beginTime = CACurrentMediaTime(); - animation2.duration = 0.1; - CGFloat width = self.frame.size.width - 15; - CGFloat height = 32; - animation2.fromValue = [NSValue valueWithCGRect:CGRectMake(0, height/2, width, height)]; - animation2.toValue = [NSValue valueWithCGRect:CGRectMake(0, 0, width, height)]; - animation2.removedOnCompletion = NO; - animation2.repeatCount = 1; - - POPBasicAnimation *animation3 = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerOpacity]; - animation3.duration = 0.1; - animation3.beginTime = CACurrentMediaTime(); - animation3.fromValue = @0; - animation3.toValue = @1; - animation3.repeatCount = 1; - animation3.removedOnCompletion = NO; - [self.trumpetView.mainView.layer pop_addAnimation:animation2 forKey:@"animation4"]; - [self.trumpetView.mainView.layer pop_addAnimation:animation3 forKey:@"animation5"]; - } - }]; - [self.trumpetView.mainView.layer pop_addAnimation:animation2 forKey:@"animation2"]; - [self.trumpetView.mainView.layer pop_addAnimation:animation3 forKey:@"animation3"]; -} #pragma mark - XPRoomMessageTableViewCellDelegate - (void)xPRoomMessageTableViewCellDidTapEmpty:(XPRoomMessageTableViewCell *)view { if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) { @@ -679,19 +572,4 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; return _messageParser; } -- (XPRoomTrumpetView *)trumpetView { - if (!_trumpetView) { - _trumpetView = [[XPRoomTrumpetView alloc] init]; - _trumpetView.hidden = YES; - } - return _trumpetView; -} - -- (NSMutableArray *)trumpetQueue { - if (!_trumpetQueue) { - _trumpetQueue = [NSMutableArray array]; - } - return _trumpetQueue; -} - @end diff --git a/xplan-ios/Main/Room/View/NobleTrumpet/View/XPRoomTrumpetView.m b/xplan-ios/Main/Room/View/NobleTrumpet/View/XPRoomTrumpetView.m index 47022375..213839e2 100644 --- a/xplan-ios/Main/Room/View/NobleTrumpet/View/XPRoomTrumpetView.m +++ b/xplan-ios/Main/Room/View/NobleTrumpet/View/XPRoomTrumpetView.m @@ -41,6 +41,10 @@ return self; } +- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { + return nil; +} + - (void)initSubViews { [self addSubview:self.backView]; [self addSubview:self.mainView]; @@ -52,27 +56,33 @@ - (void)initContraints { [self.mainView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(0); + make.left.mas_equalTo(self); + make.right.mas_equalTo(self.backView); + make.height.mas_equalTo(28); + make.bottom.mas_equalTo(self.backView).mas_offset(-34); }]; [self.backView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(0); + make.centerX.centerY.mas_equalTo(self); + make.width.mas_equalTo(375); + make.height.mas_equalTo(153); }]; [self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(8); - make.width.height.mas_equalTo(24); - make.centerY.mas_equalTo(self); + make.left.mas_equalTo(self.backView).mas_offset(58); + make.width.height.mas_equalTo(28); + make.centerY.mas_equalTo(self.mainView); }]; [self.nobleImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.avatarImageView.mas_right).mas_offset(4); - make.width.height.mas_equalTo(20); - make.centerY.mas_equalTo(self); + make.width.mas_equalTo(25); + make.height.mas_equalTo(22); + make.centerY.mas_equalTo(self.mainView); }]; [self.nickLabel mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.mas_equalTo(self.nobleImageView.mas_right).mas_offset(2); - make.centerY.mas_equalTo(self); + make.left.mas_equalTo(self.nobleImageView.mas_right).mas_offset(5); + make.centerY.mas_equalTo(self.mainView); make.width.mas_greaterThanOrEqualTo(40).priority(500); }]; // 水平方向别扯我 @@ -80,7 +90,7 @@ [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.nickLabel.mas_right).mas_offset(2); make.right.mas_equalTo(0); - make.centerY.mas_equalTo(self); + make.centerY.mas_equalTo(self.mainView); }]; [self.contentLabel setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal]; } @@ -90,8 +100,8 @@ self.avatarImageView.imageUrl = data[@"avatar"]; self.nobleImageView.imageUrl = data[@"vipIcon"]; NSString *nickStr = data[@"nick"]; - if (nickStr.length > 10) { - nickStr = [NSString stringWithFormat:@"%@…", [nickStr substringToIndex:5]]; + if (nickStr.length > 5) { + nickStr = [NSString stringWithFormat:@"%@…:", [nickStr substringToIndex:5]]; } else { nickStr = [NSString stringWithFormat:@"%@:", nickStr]; } @@ -113,7 +123,7 @@ _backView = [[UIImageView alloc] init]; _backView.userInteractionEnabled = YES; _backView.image = [UIImage imageNamed:@"rooom_trumpet_bgImage"]; - _backView.contentMode = UIViewContentModeTopLeft; + _backView.contentMode = UIViewContentModeScaleAspectFit; } return _backView; } @@ -124,8 +134,10 @@ config.imageType = ImageTypeUserIcon; _avatarImageView = [[NetImageView alloc] initWithConfig:config]; _avatarImageView.contentMode = UIViewContentModeScaleAspectFit; - _avatarImageView.layer.cornerRadius = 12; + _avatarImageView.layer.cornerRadius = 14; _avatarImageView.layer.masksToBounds = YES; + _avatarImageView.layer.borderWidth = 0.75; + _avatarImageView.layer.borderColor = [UIColor whiteColor].CGColor; } return _avatarImageView; } @@ -143,8 +155,8 @@ - (UILabel *)nickLabel { if (!_nickLabel) { UILabel *label = [[UILabel alloc] init]; - label.font = [UIFont systemFontOfSize:12]; - label.textColor = [ThemeColor hightNobleLightTextColor]; + label.font = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium]; + label.textColor = UIColorFromRGB(0x392700); [label sizeToFit]; _nickLabel = label; } @@ -157,7 +169,7 @@ _contentLabel.scrollDuration = 5.0; _contentLabel.fadeLength = 6.0f; _contentLabel.font = [UIFont systemFontOfSize:12]; - _contentLabel.textColor = [ThemeColor appCellBackgroundColor]; + _contentLabel.textColor = UIColorFromRGB(0x392700); } return _contentLabel; }