Files
yinmeng-ios/xplan-ios/Main/Room/View/AnchorPK/View/XPAnchorPKViewController.m
2022-04-20 15:34:56 +08:00

674 lines
28 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// XPAnchorPKViewController.m
// xplan-ios
//
// Created by GreenLand on 2022/4/8.
//
#import "XPAnchorPKViewController.h"
///Third
#import <Masonry/Masonry.h>
#import <IQKeyboardManager/IQKeyboardManager.h>
///Tool
#import "ThemeColor.h"
#import "NetImageView.h"
#import "XPMacro.h"
#import "UIImage+Utils.h"
#import "TTPopup.h"
///Model
#import "AnchorPKInfoModel.h"
///View
#import "XPAnchorPKSelectRoomView.h"
#import "XPAcrossRoomPKRuleView.h"
///P
#import "XPAnchorPKPresenter.h"
#import "XPAnchorPKProtocol.h"
#define kContentHeight (404 + kSafeAreaBottomHeight)
@interface XPAnchorPKViewController ()<UITextFieldDelegate, XPAnchorPKSelectRoomViewDelegate, XPAnchorPKProtocol>
///顶部点击消失的view
@property (nonatomic, strong) UIView *topView;
///显示内容的view
@property (nonatomic, strong) UIView *contentView;
///标题
@property (nonatomic, strong) UILabel *titleLabel;
///帮助
@property (nonatomic, strong) UIButton *helpButton;
///PK对象的容器
@property (nonatomic,strong) UIStackView *userStackView;
///选择PK对象title
@property (nonatomic, strong) UILabel *selectPKLabel;
///选择PK对象
@property (nonatomic, strong) UIButton *selectPKButton;
///PK对象的容器
@property (nonatomic,strong) UIStackView *timeStackView;
///选择PK时长title
@property (nonatomic, strong) UILabel *selectPKTimeLabel;
///选择PK时间的容器
@property (nonatomic,strong) UIStackView *chooseTimeStackView;
@property (nonatomic, strong) UIButton *tenMinuteButton;
@property (nonatomic, strong) UIButton *twentyMinuteButton;
@property (nonatomic, strong) UIButton *thirtyMinuteButton;
///自定义PK时间
@property (nonatomic, strong) UITextField *customTimeTextField;
///玩法的容器
@property (nonatomic,strong) UIStackView *playStackView;
///PK玩法title
@property (nonatomic, strong) UILabel *pkPlayModeLabel;
///PK玩法
@property (nonatomic, strong) UITextField *pkPlayModeTextField;
///发起挑战按钮
@property (nonatomic, strong) UIButton *doneButton;
///选择房间的内容
@property (nonatomic, strong) UIView *selectRoomContentView;
///选中的房间头像
@property (nonatomic, strong) NetImageView *avatarImageView;
///房间标题
@property (nonatomic, strong) UILabel *roomTitleLabel;
//平台ID
@property (nonatomic, strong) UILabel *idLabel;
///取消选择房间
@property (nonatomic, strong) UIButton *cancelButon;
///选中的PK房间
@property (nonatomic, strong) AnchorPKInfoModel *selectRoomInfo;
///PK的时长
@property (nonatomic, assign) NSInteger pkDuration;
///选择PK房间
@property (nonatomic, strong) XPAnchorPKSelectRoomView *selectView;
///房间信息
@property (nonatomic,strong) NSString *roomUid;
@end
@implementation XPAnchorPKViewController
- (instancetype)initWithRoomUid:(NSString *)roomUid {
if (self = [super init]) {
self.roomUid = roomUid;
self.modalPresentationStyle = UIModalPresentationOverFullScreen;
}
return self;
}
- (XPAnchorPKPresenter *)createPresenter {
return [[XPAnchorPKPresenter alloc] init];;
}
- (void)viewDidLoad {
[super viewDidLoad];
[self initSubViews];
[self initSubViewConstraints];
self.pkDuration = 10;
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[IQKeyboardManager sharedManager].enable = YES;
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self.view endEditing:YES];
}
#pragma mark - Private Method
- (void)initSubViews {
self.view.backgroundColor = [UIColor clearColor];
[self.view addSubview:self.topView];
[self.view addSubview:self.contentView];
[self.contentView addSubview:self.titleLabel];
[self.contentView addSubview:self.helpButton];
[self.contentView addSubview:self.userStackView];
[self.contentView addSubview:self.timeStackView];
[self.contentView addSubview:self.playStackView];
[self.contentView addSubview:self.customTimeTextField];
[self.contentView addSubview:self.doneButton];
[self.userStackView addArrangedSubview:self.selectPKLabel];
[self.userStackView addArrangedSubview:self.selectPKButton];
[self.userStackView addArrangedSubview:self.selectRoomContentView];
[self.timeStackView addArrangedSubview:self.selectPKTimeLabel];
[self.timeStackView addArrangedSubview:self.chooseTimeStackView];
[self.chooseTimeStackView addArrangedSubview:self.tenMinuteButton];
[self.chooseTimeStackView addArrangedSubview:self.twentyMinuteButton];
[self.chooseTimeStackView addArrangedSubview:self.thirtyMinuteButton];
[self.playStackView addArrangedSubview:self.pkPlayModeLabel];
[self.playStackView addArrangedSubview:self.pkPlayModeTextField];
[self.selectRoomContentView addSubview:self.avatarImageView];
[self.selectRoomContentView addSubview:self.roomTitleLabel];
[self.selectRoomContentView addSubview:self.idLabel];
[self.selectRoomContentView addSubview:self.cancelButon];
}
- (void)initSubViewConstraints {
[self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.top.mas_equalTo(self.view);
make.bottom.mas_equalTo(self.contentView.mas_top);
}];
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.bottom.mas_equalTo(self.view);
make.height.mas_equalTo(kContentHeight);
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.contentView);
make.top.mas_equalTo(18);
}];
[self.helpButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.mas_equalTo(-12);
make.width.height.mas_equalTo(22);
make.centerY.mas_equalTo(self.titleLabel);
}];
[self.userStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(32);
make.left.mas_equalTo(self.contentView).offset(22);
make.top.mas_equalTo(self.titleLabel.mas_bottom).offset(20);
}];
[self.selectPKLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(90);
}];
[self.selectPKButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(22);
}];
[self.selectRoomContentView mas_updateConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(KScreenWidth - 85 - 12 * 2 - 16);
}];
[self.timeStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(32);
make.left.right.mas_equalTo(self.contentView).inset(22);
make.top.mas_equalTo(self.userStackView.mas_bottom).offset(30);
}];
[self.selectPKTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(self.selectPKLabel);
}];
[self.customTimeTextField mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(32);
make.width.mas_equalTo(170);
make.top.mas_equalTo(self.timeStackView.mas_bottom).offset(16);
make.left.mas_equalTo(self.tenMinuteButton);
}];
[self.playStackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.height.mas_equalTo(self.timeStackView);
make.top.mas_equalTo(self.customTimeTextField.mas_bottom).offset(30);
}];
[self.pkPlayModeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.mas_equalTo(self.selectPKLabel);
}];
[self.doneButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(40);
make.left.right.mas_equalTo(self.contentView).inset(40);
make.bottom.mas_equalTo(self.contentView.mas_bottom).offset(-34 - kSafeAreaBottomHeight);
}];
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.selectRoomContentView);
make.left.mas_equalTo(self.selectRoomContentView);
make.height.width.mas_equalTo(60);
}];
[self.roomTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.mas_equalTo(self.avatarImageView.mas_centerY).offset(-3);
make.left.mas_equalTo(self.avatarImageView.mas_right).mas_offset(6);
make.right.mas_lessThanOrEqualTo(self.cancelButon.mas_left);
}];
[self.idLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.avatarImageView.mas_centerY).mas_offset(3);
make.left.right.mas_equalTo(self.roomTitleLabel);
}];
[self.cancelButon mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.mas_equalTo(self.avatarImageView);
make.right.mas_equalTo(self.selectRoomContentView).offset(-12);
make.height.width.mas_equalTo(22);
}];
}
- (void)updateDoneButtonState {
if (self.selectRoomInfo && self.pkDuration >= 5 && self.pkDuration <= 180) {
self.doneButton.enabled = YES;
} else {
self.doneButton.enabled = NO;
}
}
#pragma mark - XPAcrossRoomProtocol
- (void)beginAcrossRoomPKSuccess {
[self showSuccessToast:@"pk已发起请等待对方接受"];
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)beginAcrossRoomPKFail:(NSString *)message {
if (message.length >0) {
TTAlertConfig * config = [[TTAlertConfig alloc] init];
config.actionStyle = TTAlertActionConfirmStyle;
config.cancelButtonConfig.title = @"知道了";
config.message = message;
[TTPopup alertWithConfig:config confirmHandler:^{
} cancelHandler:^{
}];
}
}
#pragma mark - XPAnchorPKSelectRoomViewDelegate
///选择要PK的对象按钮点击
- (void)XPAnchorPKSelectRoomView:(XPAnchorPKSelectRoomView *)view didChoosePKRoom:(AnchorPKInfoModel *)pkRoomInfo {
if (pkRoomInfo) {
[self.userStackView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(60);
}];
self.selectRoomContentView.hidden = NO;
self.selectPKButton.hidden= YES;
self.avatarImageView.imageUrl = pkRoomInfo.avatar;
self.roomTitleLabel.text = pkRoomInfo.title;
self.idLabel.text = [NSString stringWithFormat:@"大鹅号:%@", pkRoomInfo.erbanNo];
self.selectRoomInfo = pkRoomInfo;
[self updateDoneButtonState];
}
}
#pragma mark - UITextFieldDelegate
- (void)textFieldDidChanged:(UITextField *)textField {
if (textField == self.customTimeTextField) {
self.tenMinuteButton.selected = YES;
self.twentyMinuteButton.selected = YES;
self.thirtyMinuteButton.selected = YES;
NSString *countStr = [self.customTimeTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSInteger count = [countStr integerValue];
if (count > 180) {
[self showErrorToast:@"PK时长最长为180分钟"];
} else if(count < 5) {
[self showErrorToast:@"PK时长最短为5分钟"];
}
self.pkDuration = textField.text.integerValue;
[self updateDoneButtonState];
} else if(textField == self.pkPlayModeTextField) {
if (self.pkPlayModeTextField.text.length > 10) {
self.pkPlayModeTextField.text = [self.pkPlayModeTextField.text substringToIndex:10];
}
}
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
if (textField == self.customTimeTextField) {
NSString *regex =@"[0-9]*";
NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",regex];
if ([pred evaluateWithObject:string]) {
return YES;
}
return NO;
}
return YES;
}
#pragma mark - Event Response
- (void)helpButtonAction:(UIButton *)sender {
[self.customTimeTextField resignFirstResponder];
[self.pkPlayModeTextField resignFirstResponder];
XPAcrossRoomPKRuleView *view = [[XPAcrossRoomPKRuleView alloc] init];
[TTPopup popupView:view style:TTPopupStyleAlert];
}
- (void)selectPKButtonAction:(UIButton *)sender {
[self.customTimeTextField resignFirstResponder];
[self.pkPlayModeTextField resignFirstResponder];
self.selectView.roomUid = self.roomUid;
CATransition *transition = [CATransition animation];
transition.duration = 0.3f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.selectView.layer addAnimation:transition forKey:nil];
[self.contentView addSubview:self.selectView];
}
- (void)chooseTimeButtonAction:(UIButton *)sender {
[self.customTimeTextField resignFirstResponder];
[self.pkPlayModeTextField resignFirstResponder];
self.tenMinuteButton.selected = YES;
self.twentyMinuteButton.selected = YES;
self.thirtyMinuteButton.selected = YES;
sender.selected = NO;
self.pkDuration = sender.tag;
self.customTimeTextField.text = nil;
}
- (void)doneButtonAction:(UIButton *)sender {
[self.customTimeTextField resignFirstResponder];
[self.pkPlayModeTextField resignFirstResponder];
NSString * pkDes = self.pkPlayModeTextField.text.length > 0 ? self.pkPlayModeTextField.text : @"";
[self.presenter beginAnchorPK:self.roomUid duration:self.pkDuration acceptUid:self.selectRoomInfo.uid playDesc:pkDes];
}
- (void)cancelButtonAction:(UIButton *)sender {
self.selectRoomContentView.hidden = YES;
self.selectPKButton.hidden = NO;
self.selectRoomInfo = nil;
[self updateDoneButtonState];
self.avatarImageView.image = nil;
self.roomTitleLabel.text = nil;
self.idLabel.text = nil;
[self.userStackView mas_updateConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(32);
}];
}
- (void)onKeyBoardResign:(UITapGestureRecognizer *)ges {
[self.customTimeTextField resignFirstResponder];
[self.pkPlayModeTextField resignFirstResponder];
if (self.selectView.superview) {
CATransition *transition = [CATransition animation];
transition.duration = 0.3f;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[self.selectView.layer addAnimation:transition forKey:nil];
[self.selectView removeFromSuperview];
} else {
[self dismissViewControllerAnimated:YES completion:nil];
}
}
#pragma mark - Getters And Setters
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.textColor = UIColor.whiteColor;
_titleLabel.font = [UIFont boldSystemFontOfSize:18];
_titleLabel.text = @"主播PK";
}
return _titleLabel;
}
- (UIButton *)helpButton {
if (!_helpButton) {
_helpButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_helpButton setImage:[UIImage imageNamed:@"room_across_pk_help"] forState:UIControlStateNormal];
[_helpButton addTarget:self action:@selector(helpButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _helpButton;
}
- (UIStackView *)userStackView {
if (!_userStackView) {
_userStackView = [[UIStackView alloc] init];
_userStackView.axis = UILayoutConstraintAxisHorizontal;
_userStackView.distribution = UIStackViewDistributionFill;
_userStackView.alignment = UIStackViewAlignmentFill;
_userStackView.spacing = 16;
}
return _userStackView;
}
- (UILabel *)selectPKLabel {
if (!_selectPKLabel) {
_selectPKLabel = [[UILabel alloc] init];
_selectPKLabel.textColor = [UIColor whiteColor];
_selectPKLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
_selectPKLabel.text = @"选择PK对象";
[_selectPKLabel setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
}
return _selectPKLabel;
}
- (UIButton *)selectPKButton {
if (!_selectPKButton) {
_selectPKButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_selectPKButton setImage:[UIImage imageNamed:@"room_across_pk_add_room"] forState:UIControlStateNormal];
[_selectPKButton addTarget:self action:@selector(selectPKButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _selectPKButton;
}
- (UIStackView *)timeStackView {
if (!_timeStackView) {
_timeStackView = [[UIStackView alloc] init];
_timeStackView.axis = UILayoutConstraintAxisHorizontal;
_timeStackView.distribution = UIStackViewDistributionFill;
_timeStackView.alignment = UIStackViewAlignmentFill;
_timeStackView.spacing = 16;
}
return _timeStackView;
}
- (UILabel *)selectPKTimeLabel {
if (!_selectPKTimeLabel) {
_selectPKTimeLabel = [[UILabel alloc] init];
_selectPKTimeLabel.textColor =[UIColor whiteColor];
_selectPKTimeLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
_selectPKTimeLabel.text = @"选择PK时长";
}
return _selectPKTimeLabel;
}
- (UIStackView *)chooseTimeStackView {
if (!_chooseTimeStackView) {
_chooseTimeStackView = [[UIStackView alloc] init];
_chooseTimeStackView.axis = UILayoutConstraintAxisHorizontal;
_chooseTimeStackView.distribution = UIStackViewDistributionFillEqually;
_chooseTimeStackView.alignment = UIStackViewAlignmentFill;
_chooseTimeStackView.spacing = 5;
}
return _chooseTimeStackView;
}
- (UIButton *)tenMinuteButton {
if (!_tenMinuteButton) {
_tenMinuteButton = [[UIButton alloc] init];
[_tenMinuteButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x1CD7FD), UIColorFromRGB(0x9377FF), UIColorFromRGB(0xFF6BA3)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
[_tenMinuteButton setBackgroundImage:[UIImage imageWithColor:UIColorFromRGB(0x4C4C6A)] forState:UIControlStateSelected];
[_tenMinuteButton setTitle:@"10分钟" forState:UIControlStateNormal];
_tenMinuteButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
[_tenMinuteButton setTitleColor:[ThemeColor confirmButtonTextColor] forState:UIControlStateNormal];
[_tenMinuteButton setTitleColor:[ThemeColor disableButtonTextColor] forState:UIControlStateSelected];
_tenMinuteButton.tag = 10;
[_tenMinuteButton addTarget:self action:@selector(chooseTimeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_tenMinuteButton.selected = NO;
_tenMinuteButton.layer.masksToBounds = YES;
_tenMinuteButton.layer.cornerRadius = 32 / 2;
}
return _tenMinuteButton;
}
- (UIButton *)twentyMinuteButton {
if (!_twentyMinuteButton) {
_twentyMinuteButton = [[UIButton alloc] init];
[_twentyMinuteButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x1CD7FD), UIColorFromRGB(0x9377FF), UIColorFromRGB(0xFF6BA3)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
[_twentyMinuteButton setBackgroundImage:[UIImage imageWithColor:UIColorFromRGB(0x4C4C6A)] forState:UIControlStateSelected];
[_twentyMinuteButton setTitle:@"20分钟" forState:UIControlStateNormal];
_twentyMinuteButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
[_twentyMinuteButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_twentyMinuteButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
_twentyMinuteButton.tag = 20;
[_twentyMinuteButton addTarget:self action:@selector(chooseTimeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_twentyMinuteButton.selected = YES;
_twentyMinuteButton.layer.masksToBounds = YES;
_twentyMinuteButton.layer.cornerRadius = 32 / 2;
}
return _twentyMinuteButton;
}
- (UIButton *)thirtyMinuteButton {
if (!_thirtyMinuteButton) {
_thirtyMinuteButton = [[UIButton alloc] init];
[_thirtyMinuteButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x1CD7FD), UIColorFromRGB(0x9377FF), UIColorFromRGB(0xFF6BA3)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
[_thirtyMinuteButton setBackgroundImage:[UIImage imageWithColor:UIColorFromRGB(0x4C4C6A)] forState:UIControlStateSelected];
[_thirtyMinuteButton setTitle:@"30分钟" forState:UIControlStateNormal];
_thirtyMinuteButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightMedium];
[_thirtyMinuteButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_thirtyMinuteButton setTitleColor:[UIColor whiteColor] forState:UIControlStateSelected];
_thirtyMinuteButton.tag = 30;
_thirtyMinuteButton.layer.masksToBounds = YES;
_thirtyMinuteButton.layer.cornerRadius = 32 / 2;
[_thirtyMinuteButton addTarget:self action:@selector(chooseTimeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_thirtyMinuteButton.selected = YES;
}
return _thirtyMinuteButton;
}
- (UITextField *)customTimeTextField {
if (!_customTimeTextField) {
_customTimeTextField = [[UITextField alloc] init];
_customTimeTextField.layer.cornerRadius = 15;
_customTimeTextField.layer.masksToBounds = YES;
_customTimeTextField.backgroundColor = UIColorFromRGB(0x4C4C6A);
_customTimeTextField.textColor = [UIColor whiteColor];
_customTimeTextField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 19, 0)];
_customTimeTextField.leftViewMode = UITextFieldViewModeAlways;
_customTimeTextField.delegate = self;
_customTimeTextField.keyboardType = UIKeyboardTypeNumberPad;
_customTimeTextField.tintColor = [UIColor whiteColor];
_customTimeTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"自定义(5-180)分钟" attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15], NSForegroundColorAttributeName: UIColorFromRGB(0xC6C6E9)}];
[_customTimeTextField addTarget:self action:@selector(textFieldDidChanged:) forControlEvents:UIControlEventEditingChanged];
}
return _customTimeTextField;
}
- (UIStackView *)playStackView {
if (!_playStackView) {
_playStackView = [[UIStackView alloc] init];
_playStackView.axis = UILayoutConstraintAxisHorizontal;
_playStackView.distribution = UIStackViewDistributionFill;
_playStackView.alignment = UIStackViewAlignmentFill;
_playStackView.spacing = 16;
}
return _playStackView;
}
- (UILabel *)pkPlayModeLabel {
if (!_pkPlayModeLabel) {
_pkPlayModeLabel = [[UILabel alloc] init];
_pkPlayModeLabel.textColor = [UIColor whiteColor];
_pkPlayModeLabel.textAlignment = NSTextAlignmentRight;
_pkPlayModeLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
_pkPlayModeLabel.text = @"PK玩法";
}
return _pkPlayModeLabel;
}
- (UITextField *)pkPlayModeTextField {
if (!_pkPlayModeTextField) {
_pkPlayModeTextField = [[UITextField alloc] init];
_pkPlayModeTextField.layer.cornerRadius = 15;
_pkPlayModeTextField.layer.masksToBounds = YES;
_pkPlayModeTextField.backgroundColor = UIColorFromRGB(0x4C4C6A);
_pkPlayModeTextField.textColor = [UIColor whiteColor];
_pkPlayModeTextField.leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 19, 0)];
_pkPlayModeTextField.leftViewMode = UITextFieldViewModeAlways;
_pkPlayModeTextField.delegate = self;
_pkPlayModeTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"选填10个字以内" attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:15], NSForegroundColorAttributeName: UIColorFromRGB(0x43BDFF)}];
[_pkPlayModeTextField addTarget:self action:@selector(textFieldDidChanged:) forControlEvents:UIControlEventEditingChanged];
}
return _pkPlayModeTextField;
}
- (UIButton *)doneButton {
if (!_doneButton) {
_doneButton = [[UIButton alloc] init];
[_doneButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0x1CD7FD), UIColorFromRGB(0x9377FF), UIColorFromRGB(0xFF6BA3)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)] forState:UIControlStateNormal];
[_doneButton setBackgroundImage:[UIImage imageWithColor:UIColorFromRGB(0x4C4C6A)] forState:UIControlStateDisabled];
[_doneButton setTitle:@"发起挑战" forState:UIControlStateNormal];
_doneButton.layer.masksToBounds = YES;
_doneButton.layer.cornerRadius = 20;
_doneButton.titleLabel.font = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
[_doneButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[_doneButton setTitleColor:[UIColor whiteColor] forState:UIControlStateDisabled];
[_doneButton addTarget:self action:@selector(doneButtonAction:) forControlEvents:UIControlEventTouchUpInside];
_doneButton.enabled = NO;
}
return _doneButton;
}
- (UIView *)selectRoomContentView {
if (!_selectRoomContentView) {
_selectRoomContentView = [[UIView alloc] init];
_selectRoomContentView.hidden = YES;
}
return _selectRoomContentView;
}
- (NetImageView *)avatarImageView {
if (!_avatarImageView) {
NetImageConfig * config = [[NetImageConfig alloc]init];
config.imageType = ImageTypeUserIcon;
config.placeHolder = [UIImageConstant defaultAvatarPlaceholder];
_avatarImageView = [[NetImageView alloc] initWithConfig:config];
_avatarImageView.layer.masksToBounds = YES;
_avatarImageView.layer.cornerRadius = 60 / 2;
_avatarImageView.layer.borderColor = [UIColor whiteColor].CGColor;
_avatarImageView.layer.borderWidth = 1;
}
return _avatarImageView;
}
- (UILabel *)roomTitleLabel {
if (!_roomTitleLabel) {
_roomTitleLabel = [[UILabel alloc] init];
_roomTitleLabel.textColor = [UIColor whiteColor];
_roomTitleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
}
return _roomTitleLabel;
}
- (UILabel *)idLabel {
if (!_idLabel) {
_idLabel = [[UILabel alloc] init];
_idLabel.textColor = [UIColor whiteColor];
_idLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
}
return _idLabel;
}
- (UIButton *)cancelButon {
if (!_cancelButon) {
_cancelButon = [UIButton buttonWithType:UIButtonTypeCustom];
[_cancelButon setImage:[UIImage imageNamed:@"room_across_delete_pk_room"] forState:UIControlStateNormal];
[_cancelButon addTarget:self action:@selector(cancelButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _cancelButon;
}
- (UIView *)contentView {
if (!_contentView) {
_contentView = [[UIView alloc] init];
_contentView.backgroundColor = UIColorFromRGB(0x2A2A39);
CAShapeLayer * layer = [CAShapeLayer layer];
layer.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, KScreenWidth,kContentHeight) byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii:CGSizeMake(12, 12)].CGPath;
_contentView.layer.mask = layer;
}
return _contentView;
}
- (UIView *)topView {
if (!_topView) {
_topView = [[UIView alloc] init];
_topView.backgroundColor = UIColor.blackColor;
_topView.alpha = 0.3;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onKeyBoardResign:)];
[_topView addGestureRecognizer:tap];
}
return _topView;
}
- (XPAnchorPKSelectRoomView *)selectView {
if (!_selectView) {
_selectView = [[XPAnchorPKSelectRoomView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, kContentHeight)];
_selectView.delegate = self;
}
return _selectView;
}
@end