2025-11-11 17:19:21 +08:00
|
|
|
|
//
|
|
|
|
|
|
// QXDrifNobilityJoinRoomView.m
|
|
|
|
|
|
// QXLive
|
|
|
|
|
|
//
|
|
|
|
|
|
// Created by 启星 on 2025/11/11.
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#import "QXDrifNobilityJoinRoomView.h"
|
|
|
|
|
|
//nobility_drif_join_room_bg
|
|
|
|
|
|
@interface QXDrifNobilityJoinRoomView()
|
2025-11-21 16:17:05 +08:00
|
|
|
|
@property (nonatomic,weak)UIView* containerView;
|
2025-11-11 17:19:21 +08:00
|
|
|
|
@property (nonatomic,assign)BOOL isPlaying;
|
|
|
|
|
|
@property (nonatomic,assign)BOOL isClose;
|
2025-12-01 18:42:49 +08:00
|
|
|
|
@property (nonatomic,assign)BOOL isBackgroud;
|
2025-11-11 17:19:21 +08:00
|
|
|
|
@end
|
|
|
|
|
|
@implementation QXDrifNobilityJoinRoomView
|
|
|
|
|
|
|
|
|
|
|
|
- (instancetype)init
|
|
|
|
|
|
{
|
|
|
|
|
|
self = [super init];
|
|
|
|
|
|
if (self) {
|
|
|
|
|
|
self.frame = CGRectMake(SCREEN_WIDTH, 340, 208, 60);
|
|
|
|
|
|
BOOL isClose = [[NSUserDefaults standardUserDefaults] boolForKey:kIsCloseDrifNobility];
|
|
|
|
|
|
self.isClose = isClose;
|
|
|
|
|
|
[self initSubviews];
|
|
|
|
|
|
}
|
|
|
|
|
|
return self;
|
|
|
|
|
|
}
|
|
|
|
|
|
+(instancetype)shareView{
|
|
|
|
|
|
static QXDrifNobilityJoinRoomView *manager = nil;
|
|
|
|
|
|
static dispatch_once_t predicate;
|
|
|
|
|
|
dispatch_once(&predicate, ^{
|
|
|
|
|
|
manager = [[QXDrifNobilityJoinRoomView alloc] init];
|
|
|
|
|
|
});
|
|
|
|
|
|
return manager;
|
|
|
|
|
|
}
|
2025-11-21 16:17:05 +08:00
|
|
|
|
- (void)setupDisplayViewInContainer:(UIView *)container {
|
|
|
|
|
|
self.containerView = container;
|
|
|
|
|
|
}
|
2025-11-11 17:19:21 +08:00
|
|
|
|
-(void)initSubviews{
|
|
|
|
|
|
self.bgImageView = [[UIImageView alloc] init];
|
|
|
|
|
|
self.bgImageView.contentMode = UIViewContentModeScaleToFill;
|
|
|
|
|
|
[self addSubview:self.bgImageView];
|
|
|
|
|
|
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.width.mas_equalTo(208);
|
|
|
|
|
|
make.height.mas_equalTo(60);
|
|
|
|
|
|
make.centerY.centerX.equalTo(self);
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
self.titleLabel = [[UILabel alloc] init];
|
|
|
|
|
|
self.titleLabel.font = [UIFont systemFontOfSize:12];
|
|
|
|
|
|
self.titleLabel.textColor = RGB16(0xFFFFFF);
|
|
|
|
|
|
[self addSubview:self.titleLabel];;
|
|
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.left.equalTo(self.bgImageView).offset(57);
|
|
|
|
|
|
make.centerY.equalTo(self.bgImageView);
|
|
|
|
|
|
}];
|
|
|
|
|
|
self.userInteractionEnabled = YES;
|
|
|
|
|
|
// MJWeakSelf
|
|
|
|
|
|
// [self addTapBlock:^(id _Nonnull obj) {
|
|
|
|
|
|
// if ([weakSelf.model.room_id isExist]) {
|
|
|
|
|
|
// [[QXGlobal shareGlobal] joinRoomWithRoomId:weakSelf.model.room_id isRejoin:NO navagationController:weakSelf.viewController.navigationController];
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }];
|
|
|
|
|
|
}
|
|
|
|
|
|
-(void)addNobilityUserModel:(QXRoomChatListModel *)model{
|
|
|
|
|
|
if (self.isClose) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
[self.dataArray addObject:model];
|
|
|
|
|
|
[self giftAction];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-(void)giftAction{
|
|
|
|
|
|
if (self.isPlaying) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-12-01 18:42:49 +08:00
|
|
|
|
if (self.isBackgroud) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-11-11 17:19:21 +08:00
|
|
|
|
MJWeakSelf
|
|
|
|
|
|
[QXDrifNobilityJoinRoomView shareView].isPlaying = YES;
|
|
|
|
|
|
[QXDrifNobilityJoinRoomView shareView].model = [QXDrifNobilityJoinRoomView shareView].dataArray.firstObject;
|
2025-11-21 16:17:05 +08:00
|
|
|
|
// [KEYWINDOW addSubview:[QXDrifNobilityJoinRoomView shareView]];
|
|
|
|
|
|
[self.containerView addSubview:[QXDrifNobilityJoinRoomView shareView]];
|
2025-11-11 17:19:21 +08:00
|
|
|
|
// [UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
|
|
|
|
|
|
// [QXDrifNobilityJoinRoomView shareView].x = (SCREEN_WIDTH-ScaleWidth(358))/2;
|
|
|
|
|
|
// } completion:^(BOOL finished) {
|
|
|
|
|
|
// [weakSelf performSelector:@selector(dissmissAnimate) afterDelay:5];
|
|
|
|
|
|
// }];
|
|
|
|
|
|
[QXDrifNobilityJoinRoomView shareView].alpha = 0;
|
|
|
|
|
|
// 第一阶段:快速进入(0.3秒)
|
2025-11-21 16:17:05 +08:00
|
|
|
|
[UIView animateWithDuration:0.3
|
2025-11-11 17:19:21 +08:00
|
|
|
|
delay:0
|
|
|
|
|
|
options:UIViewAnimationOptionCurveEaseOut
|
|
|
|
|
|
animations:^{
|
|
|
|
|
|
[QXDrifNobilityJoinRoomView shareView].x = 36;
|
|
|
|
|
|
[QXDrifNobilityJoinRoomView shareView].alpha = 1;
|
|
|
|
|
|
} completion:^(BOOL finished) {
|
|
|
|
|
|
if (finished) {
|
|
|
|
|
|
// 第二阶段:非常慢速停留
|
2025-11-21 16:17:05 +08:00
|
|
|
|
[UIView animateWithDuration:1.8
|
2025-11-11 17:19:21 +08:00
|
|
|
|
delay:0
|
|
|
|
|
|
options:UIViewAnimationOptionCurveLinear
|
|
|
|
|
|
animations:^{
|
|
|
|
|
|
// 微小的水平移动,创造缓慢移动效果
|
|
|
|
|
|
[QXDrifNobilityJoinRoomView shareView].x = 16;
|
|
|
|
|
|
} completion:^(BOOL finished) {
|
|
|
|
|
|
if (finished) {
|
|
|
|
|
|
[self dissmissAnimate];
|
|
|
|
|
|
}
|
|
|
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
|
|
-(void)dissmissAnimate{
|
|
|
|
|
|
[UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
|
|
|
|
|
|
[QXDrifNobilityJoinRoomView shareView].x = -SCREEN_WIDTH;
|
|
|
|
|
|
} completion:^(BOOL finished) {
|
|
|
|
|
|
[QXDrifNobilityJoinRoomView shareView].x = SCREEN_WIDTH;
|
|
|
|
|
|
[[QXDrifNobilityJoinRoomView shareView] removeFromSuperview];
|
|
|
|
|
|
[[QXDrifNobilityJoinRoomView shareView].dataArray removeFirstObject];
|
|
|
|
|
|
[QXDrifNobilityJoinRoomView shareView].isPlaying = NO;
|
|
|
|
|
|
if ([QXDrifNobilityJoinRoomView shareView].dataArray.count>0) {
|
|
|
|
|
|
[[QXDrifNobilityJoinRoomView shareView] giftAction];
|
|
|
|
|
|
}
|
|
|
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-(void)setModel:(QXRoomChatListModel *)model{
|
|
|
|
|
|
_model = model;
|
|
|
|
|
|
self.titleLabel.text = model.FromUserInfo.enter_text;
|
|
|
|
|
|
[self.bgImageView sd_setImageWithURL:[NSURL URLWithString:model.FromUserInfo.enter_image]];
|
|
|
|
|
|
}
|
|
|
|
|
|
-(void)drifPopIsClose:(BOOL)isClose{
|
|
|
|
|
|
_isClose = isClose;
|
|
|
|
|
|
self.hidden = self.isClose;
|
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setBool:isClose forKey:kIsCloseDrifNobility];
|
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
|
|
|
if (isClose) {
|
|
|
|
|
|
[QXDrifNobilityJoinRoomView shareView].x = SCREEN_WIDTH;
|
|
|
|
|
|
[[QXDrifNobilityJoinRoomView shareView] removeFromSuperview];
|
|
|
|
|
|
[[QXDrifNobilityJoinRoomView shareView].dataArray removeAllObjects];
|
|
|
|
|
|
[QXDrifNobilityJoinRoomView shareView].isPlaying = NO;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-21 16:17:05 +08:00
|
|
|
|
-(void)dirfViewDidToBackground{
|
2025-12-01 18:42:49 +08:00
|
|
|
|
self.isBackgroud = YES;
|
2025-11-21 16:17:05 +08:00
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
|
[QXDrifNobilityJoinRoomView shareView].x = SCREEN_WIDTH;
|
|
|
|
|
|
[[QXDrifNobilityJoinRoomView shareView] removeFromSuperview];
|
|
|
|
|
|
[[QXDrifNobilityJoinRoomView shareView].dataArray removeAllObjects];
|
|
|
|
|
|
[QXDrifNobilityJoinRoomView shareView].isPlaying = NO;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-(void)dirfViewBecomeToFront{
|
2025-12-01 18:42:49 +08:00
|
|
|
|
self.isBackgroud = NO;
|
2025-11-21 16:17:05 +08:00
|
|
|
|
if ([QXDrifNobilityJoinRoomView shareView].isPlaying == NO) {
|
|
|
|
|
|
[QXDrifNobilityJoinRoomView shareView].x = SCREEN_WIDTH;
|
|
|
|
|
|
[[QXDrifNobilityJoinRoomView shareView] removeFromSuperview];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-11 17:19:21 +08:00
|
|
|
|
|
|
|
|
|
|
-(NSMutableArray *)dataArray{
|
|
|
|
|
|
if (!_dataArray) {
|
|
|
|
|
|
_dataArray = [NSMutableArray array];
|
|
|
|
|
|
}
|
|
|
|
|
|
return _dataArray;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|