房间贵族小喇叭UI调整

This commit is contained in:
chenguilong
2022-04-19 16:45:32 +08:00
parent 71939dfad0
commit da13ed72a8
5 changed files with 156 additions and 140 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 116 KiB

View File

@@ -10,6 +10,7 @@
#import <Masonry/Masonry.h>
#import <ReactiveObjC/ReactiveObjC.h>
#import <NIMSDK/NIMSDK.h>
#import <POP.h>
///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<RoomHostDelegate>)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

View File

@@ -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<RoomHostDelegate>)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

View File

@@ -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;
}