Files
featherVoice/QXLive/Room(房间)/View/PK/QXRoomPKSetView.m
2025-10-20 10:29:42 +08:00

150 lines
5.8 KiB
Objective-C

//
// 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