增加换肤功能

This commit is contained in:
启星
2025-08-14 10:07:49 +08:00
parent f6964c1e89
commit 4f9318d98e
8789 changed files with 978530 additions and 2 deletions

View File

@@ -0,0 +1,34 @@
//
// QXRoomPKResultView.h
// QXLive
//
// Created by 启星 on 2025/7/3.
//
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger) {
/// pk胜利
QXRoomPKResulttTypeVictory = 0,
/// pk失败
QXRoomPKResulttTypeDefeated,
/// 平局
QXRoomPKResulttTypeTie,
}QXRoomPKResulttType;
NS_ASSUME_NONNULL_BEGIN
@interface QXRoomPKResultView : UIView
-(instancetype)initWithType:(QXRoomPKResulttType)type;
@property (nonatomic,assign)QXRoomPKResulttType type;
-(void)setResultWithVictory_name:(NSString*)victory_name
victory_cover:(NSString*)victory_cover
defeated_name:(NSString*)defeated_name
defeated_cover:(NSString*)defeated_cover;
-(void)showInView:(UIView *)view;
-(void)hide;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,176 @@
//
// QXRoomPKResultView.m
// QXLive
//
// Created by on 2025/7/3.
//
#import "QXRoomPKResultView.h"
#import "QXTimer.h"
@interface QXRoomPKResultView()
@property (nonatomic,strong)UIView *bgView;
@property (nonatomic,strong)UIImageView *bgImageView;
@property (nonatomic,strong)UIImageView *victoryHeader;
@property (nonatomic,strong)UILabel *victoryNameLabel;
@property (nonatomic,strong)UIImageView *victoryImageView;
@property (nonatomic,strong)UIImageView *defeatedHeader;
@property (nonatomic,strong)UILabel *defeatedNameLabel;
@property (nonatomic,strong)UIImageView *defeatedImageView;
@property (nonatomic,strong)QXTimer *timer;
@end
@implementation QXRoomPKResultView
- (instancetype)initWithType:(QXRoomPKResulttType)type
{
self = [super init];
if (self) {
_type = type;
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, (SCREEN_HEIGHT-SCREEN_WIDTH)/2, SCREEN_WIDTH, SCREEN_WIDTH)];
[self addSubview:self.bgView];
self.bgImageView = [[UIImageView alloc] init];
self.bgImageView.frame = CGRectMake(0, 0, self.bgView.width, ScaleWidth(248));
[self.bgView addSubview:self.bgImageView];
self.victoryHeader = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"user_header_placehoulder"]];
self.victoryHeader.contentMode = UIViewContentModeScaleAspectFill;
self.victoryHeader.frame = CGRectMake(ScaleWidth(34), ScaleWidth(85), ScaleWidth(50), ScaleWidth(50));
[self.victoryHeader addRoundedCornersWithRadius:ScaleWidth(25)];
[self.bgView addSubview:self.victoryHeader];
// room_pk_victory
self.victoryNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.victoryHeader.left-ScaleWidth(18), self.victoryHeader.bottom+5, ScaleWidth(50+36), 20)];
self.victoryNameLabel.font = [UIFont systemFontOfSize:12];
self.victoryNameLabel.textColor = [UIColor whiteColor];
self.victoryNameLabel.textAlignment = NSTextAlignmentCenter;
self.victoryNameLabel.text = @"张三";
[self.bgView addSubview:self.victoryNameLabel];
self.victoryImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, self.victoryHeader.bottom-ScaleWidth(17)+5, ScaleWidth(15), ScaleWidth(17))];
self.victoryImageView.image = [UIImage imageNamed:@"room_pk_victory"];
[self.bgView addSubview:self.victoryImageView];
self.victoryImageView.centerX = self.victoryHeader.centerX;
self.defeatedHeader = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"user_header_placehoulder"]];
self.defeatedHeader.contentMode = UIViewContentModeScaleAspectFill;
self.defeatedHeader.frame = CGRectMake(self.bgView.width-ScaleWidth(34+50), self.bgImageView.bottom-ScaleWidth(50+55), ScaleWidth(50), ScaleWidth(50));
[self.defeatedHeader addRoundedCornersWithRadius:ScaleWidth(25)];
[self.bgView addSubview:self.defeatedHeader];
self.defeatedNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.defeatedHeader.left-ScaleWidth(18), self.defeatedHeader.bottom+5, ScaleWidth(50+36), 20)];
self.defeatedNameLabel.font = [UIFont systemFontOfSize:12];
self.defeatedNameLabel.textColor = [UIColor whiteColor];
self.defeatedNameLabel.textAlignment = NSTextAlignmentCenter;
self.defeatedNameLabel.text = @"李四";
[self.bgView addSubview:self.defeatedNameLabel];
self.defeatedImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, self.defeatedHeader.bottom-ScaleWidth(17)+5, ScaleWidth(15), ScaleWidth(17))];
self.defeatedImageView.image = [UIImage imageNamed:@"room_pk_defeated"];
self.defeatedImageView.centerX = self.defeatedHeader.centerX;
[self.bgView addSubview:self.defeatedImageView];
[self setType:_type];
}
-(void)setType:(QXRoomPKResulttType)type{
_type = type;
NSString *imageName = @"";
switch (_type) {
case QXRoomPKResulttTypeVictory:
imageName = @"room_pk_result_victory";
break;
case QXRoomPKResulttTypeDefeated:
imageName = @"room_pk_result_defeated";
break;
case QXRoomPKResulttTypeTie:
imageName = @"room_pk_result_tie";
break;
default:
break;
}
self.bgImageView.image = [UIImage imageNamed:imageName];
}
-(void)setResultWithVictory_name:(NSString *)victory_name
victory_cover:(NSString *)victory_cover
defeated_name:(NSString *)defeated_name
defeated_cover:(NSString *)defeated_cover{
switch (self.type) {
case QXRoomPKResulttTypeVictory:{
[self.victoryHeader sd_setImageWithURL:[NSURL URLWithString:victory_cover]];
self.victoryNameLabel.text = victory_name;
self.victoryImageView.hidden = NO;
self.victoryImageView.image = [UIImage imageNamed:@"room_pk_victory"];
[self.defeatedHeader sd_setImageWithURL:[NSURL URLWithString:defeated_cover]];
self.defeatedNameLabel.text = defeated_name;
self.defeatedImageView.hidden = NO;
self.defeatedImageView.image = [UIImage imageNamed:@"room_pk_defeated"];
}
break;
case QXRoomPKResulttTypeDefeated:{
[self.victoryHeader sd_setImageWithURL:[NSURL URLWithString:defeated_cover]];
self.victoryNameLabel.text = defeated_name;
self.victoryImageView.hidden = NO;
self.victoryImageView.image = [UIImage imageNamed:@"room_pk_defeated"];
[self.defeatedHeader sd_setImageWithURL:[NSURL URLWithString:victory_cover]];
self.defeatedNameLabel.text = victory_name;
self.defeatedImageView.hidden = NO;
self.defeatedImageView.image = [UIImage imageNamed:@"room_pk_victory"];
}
break;
case QXRoomPKResulttTypeTie:{
[self.victoryHeader sd_setImageWithURL:[NSURL URLWithString:victory_cover]];
self.victoryNameLabel.text = victory_name;
self.victoryImageView.hidden = YES;
[self.defeatedHeader sd_setImageWithURL:[NSURL URLWithString:defeated_cover]];
self.defeatedNameLabel.text = defeated_name;
self.defeatedImageView.hidden = YES;
}
break;
default:
break;
}
}
-(void)showInView:(UIView *)view{
MJWeakSelf
__block int timeCount = 3;
_timer = [QXTimer scheduledTimerWithTimeInterval:1 repeats:YES queue:dispatch_get_main_queue() block:^{
timeCount--;
if (timeCount<=0) {
[weakSelf hide];
}
}];
self.bgView.alpha = 0;
[view addSubview:self];
[UIView animateWithDuration:0.2 animations:^{
self.bgView.alpha = 1;
}];
}
-(void)hide{
if (_timer) {
[self->_timer invalidate];
_timer = nil;
}
[UIView animateWithDuration:0.3 animations:^{
self.bgView.alpha = 0;
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
@end

View File

@@ -0,0 +1,19 @@
//
// QXRoomPKSearchView.h
// QXLive
//
// Created by 启星 on 2025/7/2.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface QXRoomPKSearchView : UIView
@property (nonatomic,strong)NSString *roomId;
-(void)showInView:(UIView *)view;
-(void)hide;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,227 @@
//
// QXRoomPKSearchView.m
// QXLive
//
// Created by on 2025/7/2.
//
#import "QXRoomPKSearchView.h"
#import "QXMineNetwork.h"
#import "QXAddDirectCell.h"
#import "UIButton+QX.h"
#import "QXRoomPKSetView.h"
@interface QXRoomPKSearchView()<UIGestureRecognizerDelegate,UITextFieldDelegate,UITableViewDelegate,UITableViewDataSource,QXDirectDelegate>
@property (nonatomic,strong)UIView *bgView;
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UIButton *setBtn;
@property (nonatomic,strong)UIButton *pkBtn;
@property (nonatomic,strong)UIView *seachBgView;
@property (nonatomic,strong)UIImageView *searchImageView;
@property (nonatomic,strong)UITextField *textField;
@property (nonatomic,strong)UILabel*sectionLabel;
@property (nonatomic,strong)UITableView*tableView;
@property (nonatomic,strong)NSMutableArray*dataArray;
@property (nonatomic,assign)NSInteger page;
@property (nonatomic,strong)QXRoomPKSetView *pkSetView;
@end
@implementation QXRoomPKSearchView
- (instancetype)init
{
self = [super init];
if (self) {
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
[self initSubviews];
}
return self;
}
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
return touch.view == self;
}
-(void)initSubviews{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
tap.delegate = self;
[self addGestureRecognizer:tap];
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, ScaleWidth(144), SCREEN_WIDTH, ScaleWidth(429)+kSafeAreaBottom)];
self.bgView.backgroundColor = UIColor.whiteColor;
[self.bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
[self addSubview:self.bgView];
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 16, 300, 24)];
self.titleLabel.text = @"发起直播对战";
self.titleLabel.font = [UIFont boldSystemFontOfSize:16];
self.titleLabel.textColor = [UIColor colorWithHexString:@"#333333"];
[self.bgView addSubview:self.titleLabel];
self.setBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.bgView.width-50-6, 7, 50, 44)];
[self.setBtn setTitle:@"设置" forState:(UIControlStateNormal)];
self.setBtn.titleLabel.font = [UIFont systemFontOfSize:12];
[self.setBtn setTitleColor:RGB16(0x999999) forState:(UIControlStateNormal)];
[self.setBtn setImage:[[UIImage imageNamed:@"arrowRight"] imageByTintColor:RGB16(0x999999)] forState:(UIControlStateNormal)];
[self.setBtn qx_layoutButtonNOSizeToFitWithEdgeInsetsStyle:(QXButtonEdgeInsetsStyleRight) imageTitleSpace:2];
[self.setBtn addTarget:self action:@selector(setAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.bgView addSubview:self.setBtn];
self.pkBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.bgView.width-50-16, self.titleLabel.bottom+12, 50, 35)];
[self.pkBtn setBackgroundImage:[UIImage imageNamed:@"room_pk_random_icon"] forState:(UIControlStateNormal)];
[self.pkBtn addTarget:self action:@selector(pkAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.bgView addSubview:self.pkBtn];
self.seachBgView = [[UIView alloc] initWithFrame:CGRectMake(16, self.titleLabel.bottom+12, SCREEN_WIDTH-16-74, 35)];
self.seachBgView.backgroundColor = [UIColor colorWithHexString:@"#EFF2F8"];
self.seachBgView.layer.masksToBounds = YES;
self.seachBgView.layer.cornerRadius = 17.5;
[self.bgView addSubview:self.seachBgView];
self.searchImageView = [[UIImageView alloc] initWithFrame:CGRectMake(8, 5.5, 24, 24)];
self.searchImageView.image = [UIImage imageNamed:@"room_song_search"];
[self.seachBgView addSubview:self.searchImageView];
self.textField = [[UITextField alloc] initWithFrame:CGRectMake(self.searchImageView.right+6, 0, self.seachBgView.width-self.searchImageView.right-6-8, 35)];
self.textField.placeholder = @"请根据房间ID搜索";
self.textField.font = [UIFont systemFontOfSize:14];
[self.textField addTarget:self action:@selector(textDidChange:) forControlEvents:(UIControlEventEditingChanged)];
self.textField.returnKeyType = UIReturnKeyDone;
self.textField.delegate = self;
self.textField.textColor = [UIColor colorWithHexString:@"#333333"];
[self.seachBgView addSubview:self.textField];
self.sectionLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, self.seachBgView.bottom+5, 300, 20)];
self.sectionLabel.text = @"为你推荐";
self.sectionLabel.font = [UIFont boldSystemFontOfSize:16];
self.sectionLabel.textColor = [UIColor colorWithHexString:@"#333333"];
[self.bgView addSubview:self.sectionLabel];
self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.sectionLabel.bottom+5, self.width, self.bgView.height-5-self.sectionLabel.bottom) style:(UITableViewStylePlain)];
if (@available(iOS 15.0, *)) {
self.tableView.sectionHeaderTopPadding = 0;
} else {
// Fallback on earlier versions
}
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.tableFooterView = [UIView new];
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.bgView addSubview:self.tableView];
MJWeakSelf
[QXMineNetwork roomPkSearchWithRoomId:@"" page:1 successBlock:^(NSArray<QXRoomListModel *> * _Nonnull list) {
[weakSelf.dataArray removeAllObjects];
[weakSelf.dataArray addObjectsFromArray:list];
[weakSelf.tableView reloadData];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
}
-(void)setAction{
[self hide];
[self.pkSetView showInView:self.viewController.view];
}
-(void)pkAction{
[self hide];
[self sendPKWithRoomId:@""];;
}
-(void)textDidChange:(UITextField*)textField{
MJWeakSelf
self.sectionLabel.hidden = YES;
self.page = 1;
[QXMineNetwork roomPkSearchWithRoomId:textField.text page:self.page successBlock:^(NSArray<QXRoomListModel *> * _Nonnull list) {
[weakSelf.dataArray removeAllObjects];
[weakSelf.dataArray addObjectsFromArray:list];
[weakSelf.tableView reloadData];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
}
#pragma mark - UITextFieldDelegate
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
[textField resignFirstResponder];
return YES;
}
-(void)textFieldDidBeginEditing:(UITextField *)textField{
[UIView animateWithDuration:0.3 animations:^{
self.bgView.y = kSafeAreaTop+90;
} completion:^(BOOL finished) {
}];
}
-(void)textFieldDidEndEditing:(UITextField *)textField{
[UIView animateWithDuration:0.3 animations:^{
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(429);
} completion:^(BOOL finished) {
}];
}
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
return YES;
}
#pragma mark - UITableViewDelegate,UITableViewDataSource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.dataArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
QXAddDirectCell *cell = [QXAddDirectCell cellWithTableView:tableView];
QXRoomListModel *model = self.dataArray[indexPath.row];
cell.roomModel = model;
cell.delegate = self;
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 52;
}
- (void)sendPKWithRoomId:(NSString *)roomId{
MJWeakSelf
[QXMineNetwork roomSendPkRoomId:self.roomId create_user_id:[QXGlobal shareGlobal].loginModel.user_id room_id_b:roomId successBlock:^(NSDictionary * _Nonnull dict) {
[weakSelf hide];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
showToast(msg);
}];
}
-(void)showInView:(UIView *)view{
MJWeakSelf
[QXMineNetwork roomPkSearchWithRoomId:@"" page:1 successBlock:^(NSArray<QXRoomListModel *> * _Nonnull list) {
[weakSelf.dataArray removeAllObjects];
[weakSelf.dataArray addObjectsFromArray:list];
[weakSelf.tableView reloadData];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
self.bgView.y = SCREEN_HEIGHT;
[view addSubview:self];
[UIView animateWithDuration:0.3 animations:^{
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(429)-kSafeAreaBottom;
}];
}
-(void)hide{
[UIView animateWithDuration:0.3 animations:^{
self.bgView.y = SCREEN_HEIGHT;
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
-(NSMutableArray *)dataArray{
if (!_dataArray) {
_dataArray = [NSMutableArray array];
}
return _dataArray;
}
-(QXRoomPKSetView *)pkSetView{
if (!_pkSetView) {
_pkSetView = [[QXRoomPKSetView alloc] init];
}
return _pkSetView;
}
@end

View File

@@ -0,0 +1,19 @@
//
// QXRoomPKSetView.h
// QXLive
//
// Created by 启星 on 2025/7/3.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface QXRoomPKSetView : UIView
@property (nonatomic,strong)NSString *roomId;
@property (nonatomic,strong)NSString *is_pk;
-(void)showInView:(UIView *)view;
-(void)hide;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,149 @@
//
// QXRoomPKSetView.m
// QXLive
//
// Created by on 2025/7/3.
//
#import "QXRoomPKSetView.h"
#import "QXMineNetwork.h"
@interface QXRoomPKSetView()
@property (nonatomic,strong)UIView *bgView;
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UIButton *closeBtn;
@property (nonatomic,strong)UILabel *firstLabel;
@property (nonatomic,strong)UISwitch *firstSwitch;
@property (nonatomic,strong)UILabel *secondLabel;
@property (nonatomic,strong)UISwitch *secondSwitch;
@end
@implementation QXRoomPKSetView
- (instancetype)init
{
self = [super init];
if (self) {
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.bgView = [[UIView alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-ScaleWidth(300))/2, -self.height, ScaleWidth(300), ScaleWidth(200))];
self.bgView.backgroundColor = UIColor.whiteColor;
[self.bgView addRoundedCornersWithRadius:16];
[self addSubview:self.bgView];
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 16, self.bgView.width-32, 24)];
self.titleLabel.text = @"发起直播对战";
self.titleLabel.textAlignment = NSTextAlignmentCenter;
self.titleLabel.font = [UIFont boldSystemFontOfSize:16];
self.titleLabel.textColor = [UIColor colorWithHexString:@"#333333"];
[self.bgView addSubview:self.titleLabel];
self.closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.bgView.width-50, 0, 50, 50)];
[self.closeBtn setImage:[UIImage imageNamed:@"wallet_close"] forState:(UIControlStateNormal)];
[self.closeBtn addTarget:self action:@selector(hide) forControlEvents:UIControlEventTouchUpInside];
[self.bgView addSubview:self.closeBtn];
self.firstSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(self.bgView.width-50-16, self.titleLabel.bottom+27, 50, 31)];
self.firstSwitch.backgroundColor = RGB16A(0xffffff, 0.2);
[self.firstSwitch addRoundedCornersWithRadius:15.5];
self.firstSwitch.onTintColor = QXConfig.themeColor;
self.firstSwitch.thumbTintColor = [UIColor whiteColor];
[self.firstSwitch addTarget:self action:@selector(eventSwitch:) forControlEvents:(UIControlEventValueChanged)];
[self.bgView addSubview:self.firstSwitch];
self.firstLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, self.titleLabel.bottom+27, self.firstSwitch.left-16, 31)];
self.firstLabel.text = @"不再接收好友邀请";
self.firstLabel.textAlignment = NSTextAlignmentLeft;
self.firstLabel.font = [UIFont boldSystemFontOfSize:14];
self.firstLabel.textColor = [UIColor colorWithHexString:@"#333333"];
[self.bgView addSubview:self.firstLabel];
// self.secondSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(self.bgView.width-50-16, self.firstSwitch.bottom+20, 50, 31)];
// self.secondSwitch.backgroundColor = RGB16A(0xffffff, 0.2);
// [self.secondSwitch addRoundedCornersWithRadius:15.5];
// self.secondSwitch.onTintColor = QXConfig.themeColor;
// self.secondSwitch.thumbTintColor = [UIColor whiteColor];
// [self.secondSwitch addTarget:self action:@selector(eventSwitch:) forControlEvents:(UIControlEventValueChanged)];
// [self.bgView addSubview:self.secondSwitch];
//
// self.secondLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, self.firstSwitch.bottom+20, self.secondSwitch.left-16, 31)];
// self.secondLabel.text = @"不再接收推荐邀请";
// self.secondLabel.textAlignment = NSTextAlignmentLeft;
// self.secondLabel.font = [UIFont boldSystemFontOfSize:14];
// self.secondLabel.textColor = [UIColor colorWithHexString:@"#333333"];
// [self.bgView addSubview:self.secondLabel];
}
-(void)setIs_pk:(NSString *)is_pk{
_is_pk = is_pk;
if (is_pk.intValue == 1) {
[self.firstSwitch setOn:YES animated:YES];
}else{
[self.firstSwitch setOn:NO animated:YES];
}
}
-(void)eventSwitch:(UISwitch*)sender{
// BOOL isLock = NO;
// if (self.settingType == QXRoomSeatSettingMuteMic || self.settingType == QXRoomSeatSettingHugMic) {
// isLock = NO;
// }else{
// isLock = YES;
// }
// MJWeakSelf
BOOL isOn = sender.isOn;
// [QXMineNetwork roomPitLockOrMuteIsLock:isLock roomId:self.roomId pit_number:self.pitModel.pit_number.integerValue is_mute:isOn successBlock:^(NSDictionary * _Nonnull dict) {
// if (isOn) {
// [sender setOn:YES animated:YES];
// }else{
// [sender setOn:NO animated:YES];
// }
// if (isLock) {
// weakSelf.pitModel.is_lock = isOn?@"1":@"0";
// }else{
// weakSelf.pitModel.is_mute = isOn?@"1":@"0";
// }
// if (weakSelf.setSuccessBlock) {
// weakSelf.setSuccessBlock(weakSelf.pitModel);
// }
// } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
// [self.eventSwitch setOn:self.isOn animated:YES];
// }];
//
[QXMineNetwork noAgreePKInvite:isOn?@"1":@"2" room_id:self.roomId successBlock:^(NSString * _Nonnull token) {
if (isOn) {
[sender setOn:YES animated:YES];
}else{
[sender setOn:NO animated:YES];
}
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
}
-(void)showInView:(UIView *)view{
[view addSubview:self];
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.bgView.y = (SCREEN_HEIGHT-ScaleWidth(200))/2.0;
} completion:^(BOOL finished) {
}];
}
-(void)hide{
[UIView animateWithDuration:0.3 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:1.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.bgView.y = SCREEN_HEIGHT;
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
@end

View File

@@ -0,0 +1,18 @@
//
// QXRoomPKTimeSetView.h
// QXLive
//
// Created by 启星 on 2025/7/3.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface QXRoomPKTimeSetView : UIView
@property (nonatomic,strong)NSString *pkId;
-(void)showInView:(UIView *)view;
-(void)hide;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,229 @@
//
// QXRoomPKTimeSetView.m
// QXLive
//
// Created by on 2025/7/3.
//
#import "QXRoomPKTimeSetView.h"
#import "QXSelectAuctionInfoView.h"
#import "QXMineNetwork.h"
@interface QXRoomPKTimeSetView()<UIGestureRecognizerDelegate,UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,UITextFieldDelegate>
@property (nonatomic,strong)UIView *bgView;
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UICollectionView *collectionView;
@property (nonatomic,strong)NSMutableArray *dataArray;
@property (nonatomic,strong)QXRoomRelationModel *timeModel;
@property (nonatomic,strong)UITextField *textField;
@property (nonatomic,strong)UIView *line;
@property (nonatomic,strong)UIButton *commitBtn;
@property (nonatomic,strong)UIButton *cancelBtn;
@end
@implementation QXRoomPKTimeSetView
- (instancetype)init
{
self = [super init];
if (self) {
self.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
[self initSubviews];
}
return self;
}
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
return touch.view == self;
}
-(void)initSubviews{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
tap.delegate = self;
[self addGestureRecognizer:tap];
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, ScaleWidth(144), SCREEN_WIDTH, ScaleWidth(429)+kSafeAreaBottom)];
self.bgView.backgroundColor = UIColor.whiteColor;
[self.bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
[self addSubview:self.bgView];
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 16, 300, 24)];
self.titleLabel.text = @"请选择PK时长";
self.titleLabel.font = [UIFont boldSystemFontOfSize:16];
self.titleLabel.textColor = [UIColor colorWithHexString:@"#333333"];
[self.bgView addSubview:self.titleLabel];
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.minimumLineSpacing = 12;
layout.minimumInteritemSpacing = 12;
layout.sectionInset = UIEdgeInsetsMake(0, 16, 0, 16);
// layout.scrollDirection = UICollectionViewScrollDirectionVertical;
self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, self.titleLabel.bottom+12, self.bgView.width,self.bgView.height-12-42-self.titleLabel.bottom ) collectionViewLayout:layout];
[self.collectionView registerClass:[QXSelectAuctionInfoCell class] forCellWithReuseIdentifier:@"QXSelectAuctionInfoCell"];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
self.collectionView.showsHorizontalScrollIndicator = NO;
self.collectionView.showsVerticalScrollIndicator = NO;
self.collectionView.bounces = NO;
self.collectionView.backgroundColor = [UIColor clearColor];
[self.bgView addSubview:self.collectionView];
QXRoomRelationModel *time1 = [[QXRoomRelationModel alloc] init];
time1.name = @"5分钟";
time1.relation_id = @"5";
[self.dataArray addObject:time1];
QXRoomRelationModel *time2 = [[QXRoomRelationModel alloc] init];
time2.name = @"10分钟";
time2.relation_id = @"10";
[self.dataArray addObject:time2];
QXRoomRelationModel *time3 = [[QXRoomRelationModel alloc] init];
time3.name = @"15分钟";
time3.relation_id = @"15";
[self.dataArray addObject:time3];
QXRoomRelationModel *time4 = [[QXRoomRelationModel alloc] init];
time4.name = @"20分钟";
time4.relation_id = @"20";
[self.dataArray addObject:time4];
QXRoomRelationModel *time5 = [[QXRoomRelationModel alloc] init];
time5.name = @"25分钟";
time5.relation_id = @"25";
[self.dataArray addObject:time5];
QXRoomRelationModel *time6 = [[QXRoomRelationModel alloc] init];
time6.name = @"30分钟";
time6.relation_id = @"30";
[self.dataArray addObject:time6];
QXRoomRelationModel *time7 = [[QXRoomRelationModel alloc] init];
time7.name = @"35分钟";
time7.relation_id = @"35";
[self.dataArray addObject:time7];
QXRoomRelationModel *time8 = [[QXRoomRelationModel alloc] init];
time8.name = @"40分钟";
time8.relation_id = @"40";
[self.dataArray addObject:time8];
// self.textField = [[UITextField alloc] initWithFrame:CGRectMake(16, self.collectionView.bottom+10, self.bgView.width-32, 30)];
// self.textField.font = [UIFont systemFontOfSize:14];
// self.textField.textColor = RGB16(0x333333);
// self.textField.placeholder = @"请输入自定义时间最少5分钟";
// self.textField.delegate = self;
// self.textField.returnKeyType = UIReturnKeyDone;
// [self.bgView addSubview:self.textField];
//
// self.line = [[UIView alloc] initWithFrame:CGRectMake(16, self.textField.bottom, self.bgView.width-32, 1)];
// self.line.backgroundColor = RGB16(0x999999);
// [self.bgView addSubview:self.line];
self.cancelBtn = [[UIButton alloc] initWithFrame:CGRectMake(38, self.bgView.height-kSafeAreaBottom-42, 95 , 42)];
[self.cancelBtn setTitle:QXText(@"取消") forState:(UIControlStateNormal)];
[self.cancelBtn setTitleColor:UIColor.whiteColor forState:(UIControlStateNormal)];
[self.cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.cancelBtn addRoundedCornersWithRadius:21];
self.cancelBtn.titleLabel.font = [UIFont systemFontOfSize:14];
self.cancelBtn.backgroundColor = RGB16(0x333333);
[self.bgView addSubview:self.cancelBtn];
self.commitBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.cancelBtn.right+16, self.bgView.height-kSafeAreaBottom-42, self.bgView.width-38-self.cancelBtn.right-16, 42)];
[self.commitBtn setTitle:QXText(@"确认") forState:(UIControlStateNormal)];
[self.commitBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
[self.commitBtn addTarget:self action:@selector(commitAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.commitBtn addRoundedCornersWithRadius:21];
self.commitBtn.titleLabel.font = [UIFont systemFontOfSize:14];
self.commitBtn.backgroundColor = QXConfig.themeColor;
[self.bgView addSubview:self.commitBtn];
}
-(void)commitAction{
if (self.timeModel == nil) {
showToast(@"请选择PK时长");
return;
}
MJWeakSelf
[QXMineNetwork roomPkStartWithPk_id:self.pkId pk_times:self.timeModel.relation_id successBlock:^(NSDictionary * _Nonnull dict) {
[weakSelf hide];
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
showToast(msg);
}];
}
-(void)cancelAction{
[self hide];
}
#pragma mark - UITextFieldDelegate
//-(BOOL)textFieldShouldReturn:(UITextField *)textField{
// [textField resignFirstResponder];
// return YES;
//}
//-(void)textFieldDidBeginEditing:(UITextField *)textField{
// [UIView animateWithDuration:0.3 animations:^{
// self.bgView.y = kSafeAreaTop+90;
// } completion:^(BOOL finished) {
//
// }];
//}
//-(void)textFieldDidEndEditing:(UITextField *)textField{
// [UIView animateWithDuration:0.3 animations:^{
// self.bgView.y = SCREEN_HEIGHT-ScaleWidth(429);
// } completion:^(BOOL finished) {
//
// }];
//}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return self.dataArray.count;
}
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
QXSelectAuctionInfoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXSelectAuctionInfoCell" forIndexPath:indexPath];
cell.timeModel = self.dataArray[indexPath.row];
return cell;
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
CGFloat width = (SCREEN_WIDTH-16*2-12*3)/4;
return CGSizeMake(width, 44);
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
QXRoomRelationModel *model = self.dataArray[indexPath.row];
if (model.isSelected) {
return;
}
self.timeModel.isSelected = NO;
model.isSelected = YES;
self.timeModel = model;
[collectionView reloadData];
}
-(NSMutableArray *)dataArray{
if (!_dataArray) {
_dataArray = [NSMutableArray array];
}
return _dataArray;
}
-(void)showInView:(UIView *)view{
self.bgView.y = SCREEN_HEIGHT;
[view addSubview:self];
[UIView animateWithDuration:0.3 animations:^{
self.bgView.y = SCREEN_HEIGHT-ScaleWidth(429)-kSafeAreaBottom;
}];
}
-(void)hide{
[UIView animateWithDuration:0.3 animations:^{
self.bgView.y = SCREEN_HEIGHT;
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
@end