首页完成

This commit is contained in:
启星
2025-10-21 10:29:06 +08:00
parent 412e8be86b
commit c0502d1f7b
25 changed files with 326 additions and 40 deletions

View File

@@ -26,8 +26,10 @@
#import "QXNiceGiftPopView.h" //
#import "QXFirstRechargeView.h" //
#import "QXHomeTopView.h"
#import "QXSystemNoticeViewController.h"
#import "QXHotRoomViewController.h"
@interface QXHomeViewController ()<JXPagerViewDelegate,JXCategoryViewDelegate,GKCycleScrollViewDataSource,GKCycleScrollViewDelegate,QXGiftScrollViewDelegate,SDCycleScrollViewDelegate>
@interface QXHomeViewController ()<JXPagerViewDelegate,JXCategoryViewDelegate,GKCycleScrollViewDataSource,GKCycleScrollViewDelegate,QXGiftScrollViewDelegate,SDCycleScrollViewDelegate,QXHomeTopViewDelegate>
@property (nonatomic, strong) JXPagerView *pagingView;
@property (nonatomic,strong)JXCategoryTitleView *categoryView;
@property (nonatomic,strong)NSMutableArray <UIViewController*>*listVCArray;
@@ -401,7 +403,7 @@
self.appStoreView.hidden = YES;
}
// weakSelf.appStoreView.dataArray = list;
[self.topView reloadData];
self.topView.dataArray = list;
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
}];
@@ -483,6 +485,31 @@
[self.navigationController pushViewController:userHomePage animated:YES];
}
}
#pragma mark - QXHomeTopViewDelegate
-(void)didClickTopViewType:(QXHomeTopClickType)type{
switch (type) {
case QXHomeTopClickTypeHotRoom:{
QXHotRoomViewController *vc = [[QXHotRoomViewController alloc] init];
vc.list = self.topView.dataArray;
[self.navigationController pushViewController:vc animated:YES];
}
break;
case QXHomeTopClickTypeMyRoom:
[self gotoRoom];
break;
case QXHomeTopClickTypeRank:
[self gotoRankVC];
break;
case QXHomeTopClickTypeNotice:{
QXSystemNoticeViewController *vc = [[QXSystemNoticeViewController alloc] init];
vc.type = 0;
[self.navigationController pushViewController:vc animated:YES];
}
break;
default:
break;
}
}
-(void)gotoRoom{
@@ -602,6 +629,7 @@
-(QXHomeTopView *)topView{
if (!_topView) {
_topView = [[QXHomeTopView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScaleWidth(184))];
_topView.delegate = self;
}
return _topView;
}

View File

@@ -0,0 +1,16 @@
//
// QXHotRoomViewController.h
// QXLive
//
// Created by 启星 on 2025/10/21.
//
#import "QXBaseViewController.h"
#import "QXRoomListModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface QXHotRoomViewController : QXBaseViewController
@property (nonatomic,strong)NSArray<QXRoomListModel *>*list;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,87 @@
//
// QXHotRoomViewController.m
// QXLive
//
// Created by on 2025/10/21.
//
#import "QXHotRoomViewController.h"
#import "QXHomeRoomCell.h"
@interface QXHotRoomViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
@property (nonatomic,strong)UICollectionView *collectionView;
@end
@implementation QXHotRoomViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
-(void)setNavgationItems{
[super setNavgationItems];
self.navigationItem.title = @"热门房间";
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
-(void)initSubViews{
[self.view addSubview:self.collectionView];
}
#pragma mark - UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
return 1;
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
return self.list.count;
}
-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
QXHomeRoomCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXHomeRoomCell" forIndexPath:indexPath];
cell.model = self.list[indexPath.row];
return cell;
}
-(void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath{
QXHomeRoomCell *roomCell = (QXHomeRoomCell *)cell;
[roomCell startAnimating];
}
- (void)collectionView:(UICollectionView *)collectionView didEndDisplayingCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath{
QXHomeRoomCell *roomCell = (QXHomeRoomCell *)cell;
[roomCell endAnimating];
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
return CGSizeMake((SCREEN_WIDTH-15*3-1)/2.0, (SCREEN_WIDTH-15*3-1)/2.0);
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
QXRoomListModel *model = self.list[indexPath.row];
[[QXGlobal shareGlobal] joinRoomWithRoomId:model.room_id isRejoin:NO navagationController:self.navigationController];
}
-(UICollectionView *)collectionView{
if (!_collectionView) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.minimumLineSpacing = 15;
layout.minimumInteritemSpacing = 15;
layout.sectionInset = UIEdgeInsetsMake(0, 15, 0, 15);
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 16, SCREEN_WIDTH, SCREEN_HEIGHT-NavContentHeight) collectionViewLayout:layout];
_collectionView.delegate = self;
_collectionView.dataSource = self;
_collectionView.bounces = YES;
_collectionView.backgroundColor = [UIColor clearColor];
[_collectionView registerNib:[UINib nibWithNibName:@"QXHomeRoomCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"QXHomeRoomCell"];
}
return _collectionView;
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end

View File

@@ -0,0 +1,18 @@
//
// QXHomeTopRoomCell.h
// QXLive
//
// Created by 启星 on 2025/10/20.
//
#import <UIKit/UIKit.h>
#import "QXRoomListModel.h"
NS_ASSUME_NONNULL_BEGIN
@interface QXHomeTopRoomCell : UICollectionViewCell
@property (weak, nonatomic) IBOutlet UIImageView *roomImageView;
@property (weak, nonatomic) IBOutlet UILabel *roomNameLabel;
@property (strong, nonatomic)QXRoomListModel *model ;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,21 @@
//
// QXHomeTopRoomCell.m
// QXLive
//
// Created by on 2025/10/20.
//
#import "QXHomeTopRoomCell.h"
@implementation QXHomeTopRoomCell
-(void)setModel:(QXRoomListModel *)model{
_model = model;
[self.roomImageView sd_setImageWithURL:[NSURL URLWithString:model.room_cover]];
self.roomNameLabel.text = model.room_name;
}
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
}
@end

View File

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23504" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23506"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="gTV-IL-0wX" customClass="QXHomeTopRoomCell">
<rect key="frame" x="0.0" y="0.0" width="290" height="267"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="290" height="267"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="AMc-ga-z0u">
<rect key="frame" x="8" y="245" width="274" height="14"/>
<constraints>
<constraint firstAttribute="height" constant="14" id="nBP-t1-aMb"/>
</constraints>
<fontDescription key="fontDescription" type="system" pointSize="12"/>
<color key="textColor" red="1" green="1" blue="1" alpha="0.84999999999999998" colorSpace="custom" customColorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="IPW-qC-f1g">
<rect key="frame" x="26.666666666666657" y="0.0" width="236.99999999999997" height="237"/>
<constraints>
<constraint firstAttribute="width" secondItem="IPW-qC-f1g" secondAttribute="height" multiplier="1:1" id="cRg-9h-L36"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="layer.masksToBounds" value="YES"/>
<userDefinedRuntimeAttribute type="number" keyPath="layer.cornerRadius">
<integer key="value" value="8"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</imageView>
</subviews>
</view>
<viewLayoutGuide key="safeArea" id="SEy-5g-ep8"/>
<constraints>
<constraint firstItem="AMc-ga-z0u" firstAttribute="top" secondItem="IPW-qC-f1g" secondAttribute="bottom" constant="8" id="1ZJ-sM-LA1"/>
<constraint firstItem="IPW-qC-f1g" firstAttribute="centerX" secondItem="SEy-5g-ep8" secondAttribute="centerX" id="6SI-qJ-0va"/>
<constraint firstItem="IPW-qC-f1g" firstAttribute="top" secondItem="gTV-IL-0wX" secondAttribute="top" id="Jl7-NF-LFZ"/>
<constraint firstAttribute="trailing" secondItem="AMc-ga-z0u" secondAttribute="trailing" constant="8" id="hbX-iy-3L1"/>
<constraint firstAttribute="bottom" secondItem="AMc-ga-z0u" secondAttribute="bottom" constant="8" id="lMB-en-E1D"/>
<constraint firstItem="AMc-ga-z0u" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" constant="8" id="zX4-9M-96x"/>
</constraints>
<size key="customSize" width="290" height="267"/>
<connections>
<outlet property="roomImageView" destination="IPW-qC-f1g" id="Aub-Kv-UEF"/>
<outlet property="roomNameLabel" destination="AMc-ga-z0u" id="3nx-VQ-OCq"/>
</connections>
<point key="canvasLocation" x="320.61068702290078" y="96.126760563380287"/>
</collectionViewCell>
</objects>
</document>

View File

@@ -6,7 +6,7 @@
//
#import <UIKit/UIKit.h>
#import "QXRoomListModel.h"
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger) {
/// 热门房间
@@ -29,7 +29,7 @@ typedef NS_ENUM(NSInteger) {
@end
@interface QXHomeTopView : UIView
@property (weak,nonatomic)id<QXHomeTopViewDelegate>delegate;
-(void)reloadData;
@property (nonatomic,strong)NSArray<QXRoomListModel*> *dataArray;
@end

View File

@@ -6,12 +6,17 @@
//
#import "QXHomeTopView.h"
@interface QXHomeTopView()<QXHomeTopViewDelegate>
#import "SDCycleScrollView.h"
#import "QXHomeTopRoomCell.h"
@interface QXHomeTopView()<QXHomeTopViewDelegate,SDCycleScrollViewDelegate>
@property (nonatomic,strong)UIImageView *hotRoomImageView;
@property (nonatomic,strong)UIImageView *hotIconImageView;
@property (nonatomic,strong)UILabel *hotLabel;
@property (nonatomic,strong)UIButton *hotRoomBtn;
@property (nonatomic,strong)SDCycleScrollView *roomView;
@property (nonatomic,strong)QXHomeTopSubView *myRoomView;
@property (nonatomic,strong)QXHomeTopSubView *rankView;
@@ -49,6 +54,20 @@
make.width.height.mas_equalTo(ScaleWidth(18));
}];
self.roomView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(16, ScaleWidth(48), (int)ScaleWidth(164), ScaleWidth(184-48)) delegate:self placeholderImage:nil];
self.roomView.backgroundColor = [UIColor clearColor];
self.roomView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
[self.roomView addRoundedCornersWithRadius:8] ;
// self.roomView.pageControlBottomOffset = -10;
self.roomView.showPageControl = NO;
[self addSubview:self.roomView];
[self.roomView mas_makeConstraints:^(MASConstraintMaker *make) {
make.bottom.equalTo(self);
make.top.equalTo(self.hotIconImageView.mas_bottom).offset(10);
make.width.equalTo(self.hotRoomImageView);
make.centerX.equalTo(self.hotRoomImageView);
}];
self.hotRoomBtn = [[UIButton alloc] init];
[self.hotRoomBtn setImage:[UIImage imageNamed:@"home_hot_room_goto"] forState:(UIControlStateNormal)];
[self.hotRoomBtn addTarget:self action:@selector(hotRoomAction) forControlEvents:(UIControlEventTouchUpInside)];
@@ -104,9 +123,24 @@
make.height.mas_equalTo(ScaleWidth(56));
}];
}
-(void)reloadData{
- (UINib *)customCollectionViewCellNibForCycleScrollView:(SDCycleScrollView *)view{
return [UINib nibWithNibName:@"QXHomeTopRoomCell" bundle:[NSBundle mainBundle]];
}
- (void)setupCustomCell:(UICollectionViewCell *)cell forIndex:(NSInteger)index cycleScrollView:(SDCycleScrollView *)view{
QXHomeTopRoomCell *roomCell = (QXHomeTopRoomCell*)cell;
roomCell.model = self.dataArray[index];
}
-(void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index{
QXRoomListModel *model = self.dataArray[index];
[[QXGlobal shareGlobal] joinRoomWithRoomId:model.room_id isRejoin:NO navagationController:self.viewController.navigationController];
}
-(void)setDataArray:(NSArray *)dataArray{
_dataArray = dataArray;
NSMutableArray *arr = [NSMutableArray array];
for (QXRoomListModel *md in dataArray) {
[arr addObject:md.room_cover];
}
self.roomView.imageURLStringsGroup = arr;
}
-(void)didClickTopViewType:(QXHomeTopClickType)type{
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickTopViewType:)]) {