首页完成
This commit is contained in:
18
QXLive/HomePage(声播)/View/首页/QXHomeTopRoomCell.h
Normal file
18
QXLive/HomePage(声播)/View/首页/QXHomeTopRoomCell.h
Normal 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
|
||||
21
QXLive/HomePage(声播)/View/首页/QXHomeTopRoomCell.m
Normal file
21
QXLive/HomePage(声播)/View/首页/QXHomeTopRoomCell.m
Normal 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
|
||||
60
QXLive/HomePage(声播)/View/首页/QXHomeTopRoomCell.xib
Normal file
60
QXLive/HomePage(声播)/View/首页/QXHomeTopRoomCell.xib
Normal 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>
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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:)]) {
|
||||
|
||||
Reference in New Issue
Block a user