Files

128 lines
4.0 KiB
Mathematica
Raw Permalink Normal View History

2025-08-11 10:43:19 +08:00
//
// PkListVC.m
// romantic
//
// Created by DLAN on 2023/2/13.
// Copyright © 2023 romantic. All rights reserved.
//
#import "PkListVC.h"
#import "SPPKPickPeopleModel.h"
#import "PkItemList.h"
@interface PkListVC ()<UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
@property (weak, nonatomic) IBOutlet UITextField *pkMessage;
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (weak, nonatomic) IBOutlet UIButton *quitBtn;
@property (nonatomic, assign) NSInteger seleItem;
@property (nonatomic, assign) NSInteger pk_time;//
@property (nonatomic, strong) NSMutableArray *itemViewsArr;
@end
@implementation PkListVC
- (void)viewDidLoad {
[super viewDidLoad];
self.itemViewsArr = [NSMutableArray arrayWithArray:@[@"10", @"30", @"50"]];
self.pk_time = 10;
[self createUI];
}
-(void)createUI {
[self.quitBtn styleGradiBlueColor];
self.pkMessage.attributedPlaceholder = [[NSMutableAttributedString alloc] initWithString:@"请输入PK内容" attributes:@{NSForegroundColorAttributeName:HEXCOLOR(0x47475B)}];
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
// CGFloat itemW = (ScreenViewWidth-15*2-10*3)/4;
CGFloat itemW = 79;
CGFloat itemH = 40;
flowLayout.itemSize = CGSizeMake(itemW, itemH);
flowLayout.minimumLineSpacing = 10;
flowLayout.minimumInteritemSpacing = 0;
flowLayout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 15);
flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
_collectionView.collectionViewLayout = flowLayout;
_collectionView.delegate = self;
_collectionView.dataSource = self;
_collectionView.showsHorizontalScrollIndicator = NO;
[_collectionView registerNib:[UINib nibWithNibName:@"PkItemList" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"PkItemList"];
}
#pragma mark - UICollectionViewDelegate && UICollectionViewDataSource
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return self.itemViewsArr.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
PkItemList *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"PkItemList" forIndexPath:indexPath];
cell.titleLab.text = [NSString stringWithFormat:@"%@分钟",self.itemViewsArr[indexPath.row]];
if(self.seleItem == indexPath.row){
cell.bgview.backgroundColor = mainDeepColor;
cell.titleLab.textColor = HEXCOLOR(0x333333);
}else{
cell.bgview.backgroundColor = HEXCOLOR(0x565675);
cell.titleLab.textColor = HEXCOLOR(0xFFFFFF);
}
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
NSString *time = self.itemViewsArr[indexPath.row];
self.pk_time = [time integerValue];
self.seleItem = indexPath.row;
[self.collectionView reloadData];
}
- (IBAction)onStarPKOclk:(id)sender {
if(self.pkMessage.text.length <= 0){
[MBManager showBriefAlert:@"请输入PK内容"];
return;
}
// if(_otherTF.text.length > 0){
// self.pk_time = [self.otherTF.text integerValue];
// }
NSDictionary *params = @{@"rid":C_string(self.roomId), @"pk_type":@(self.type), @"pk_time":@(self.pk_time*60),@"pk_theme":self.pkMessage.text};
[[AFNetworkRequset shared] postRequestWithParams:params Path:@"api/room/launch_room_pk" Loading:YES Hud:YES Success:^(id _Nonnull responseDic) {
if(self.quitPkSet){
self.quitPkSet();
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self.navigationController popViewControllerAnimated:YES];
});
} Failure:^(id _Nonnull errorData) {
}];
}
#pragma mark - JXCategoryListContentViewDelegate
- (UIView *)listView {
return self.view;
}
@end