217 lines
7.6 KiB
Objective-C
217 lines
7.6 KiB
Objective-C
//
|
|
// MewPartyViewController.m
|
|
// mew-ios
|
|
//
|
|
// Created by 触海 on 2023/11/13.
|
|
//
|
|
|
|
#import "MewPartyViewController.h"
|
|
#import "MewMineCollectionViewController.h"
|
|
/// View
|
|
#import "MewPartyListCollectionViewCell.h"
|
|
#import "MewRoomViewController.h"
|
|
/// Third
|
|
#import <Masonry/Masonry.h>
|
|
/// Tool
|
|
#import "MewMacro.h"
|
|
/// Model
|
|
#import "MewPartyModel.h"
|
|
#import "MewHomeRecommendRoomModel.h"
|
|
/// Presenter
|
|
#import "MewPartyPresenter.h"
|
|
#import "MewHomeProtocol.h"
|
|
|
|
@interface MewPartyViewController ()<UICollectionViewDelegate, UICollectionViewDataSource, MewHomeProtocol>
|
|
|
|
|
|
@property (nonatomic, strong) UIImageView *contentBgImageView;
|
|
// 多人派对
|
|
@property (nonatomic, strong) UIImageView *partyBgImageView;
|
|
// 收藏背景
|
|
@property (nonatomic, strong) UIImageView *collectBgImageView;
|
|
// 收藏
|
|
@property (nonatomic, strong) UIImageView *mineCollectImageView;
|
|
// 收藏文字
|
|
@property (nonatomic, strong) UILabel *mineCollectLabel;
|
|
@property (nonatomic, strong) UIView *partyMineCollectView;
|
|
@property (nonatomic, strong) UICollectionView *partyCollectionView;
|
|
|
|
@property (nonatomic, strong) NSArray<MewPartyModel *> *collectModels;
|
|
@property (nonatomic, assign) CGSize itemSizes;
|
|
@property (nonatomic, assign) CGFloat itemMargin;
|
|
|
|
@property (nonatomic, strong) NSArray<MewHomeRecommendRoomModel *> *homeRecommendModels;
|
|
|
|
@end
|
|
|
|
@implementation MewPartyViewController
|
|
|
|
- (BOOL)mew_isHiddenNavBar {
|
|
return YES;
|
|
}
|
|
|
|
- (MewPartyPresenter *)createPresenter {
|
|
return [[MewPartyPresenter alloc] init];
|
|
|
|
}
|
|
|
|
#pragma mark - Life Cycle
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
self.view.backgroundColor = UIColor.whiteColor;
|
|
self.collectModels = [MewPartyModel getMewPartyModels];
|
|
self.itemMargin = 17.0;
|
|
CGFloat itemWidth = (KScreenWidth - 3 * self.itemMargin)/2;
|
|
CGSize imageSize = [UIImage imageNamed:self.collectModels[0].imageName].size;
|
|
CGFloat itemHeight = (itemWidth * imageSize.height)/imageSize.width;
|
|
self.itemSizes = CGSizeMake(itemWidth, itemHeight);
|
|
[self mew_initView];
|
|
[self mew_loadData];
|
|
|
|
}
|
|
|
|
#pragma mark - Load Data
|
|
- (void)mew_loadData {
|
|
[self.presenter mew_partyRecommendRoomList];
|
|
}
|
|
|
|
#pragma mark - YMHomeProtocol
|
|
|
|
- (void)mew_partyRecommendRoomListSuccess:(NSArray *)list {
|
|
self.homeRecommendModels = list;
|
|
[self.partyCollectionView reloadData];
|
|
}
|
|
|
|
#pragma mark - UICollectionViewDelegate, UICollectionViewDataSource
|
|
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
|
|
return self.collectModels.count;
|
|
}
|
|
|
|
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
|
|
MewPartyListCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([MewPartyListCollectionViewCell class]) forIndexPath:indexPath];
|
|
cell.model = self.collectModels[indexPath.row];
|
|
return cell;
|
|
}
|
|
|
|
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
|
|
if (indexPath.row >= self.homeRecommendModels.count) { return; }
|
|
|
|
|
|
NSString *roomId = self.homeRecommendModels[indexPath.row].roomUid;
|
|
[MewRoomViewController openRoom:roomId viewController:self];
|
|
}
|
|
|
|
- (void)mew_gotoWithMineCollection:(UITapGestureRecognizer *)tap {
|
|
MewMineCollectionViewController *controller = [[MewMineCollectionViewController alloc] init];
|
|
[self.navigationController pushViewController:controller animated:NO];
|
|
}
|
|
|
|
#pragma mark - Init
|
|
- (void)mew_initView {
|
|
[self.view addSubview:self.contentBgImageView];
|
|
[self.view addSubview:self.partyBgImageView];
|
|
[self.view addSubview:self.collectBgImageView];
|
|
[self.collectBgImageView addSubview:self.mineCollectImageView];
|
|
[self.collectBgImageView addSubview:self.mineCollectLabel];
|
|
[self.view addSubview:self.partyCollectionView];
|
|
[self mew_initLayout];
|
|
}
|
|
|
|
- (void)mew_initLayout {
|
|
[self.contentBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.edges.equalTo(self.view);
|
|
}];
|
|
CGFloat bgHeight = [UIImage imageNamed:@"mew_party_header_bg"].size.height;
|
|
[self.partyBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.mas_equalTo(14);
|
|
make.top.mas_equalTo(kStatusBarHeight+25);
|
|
make.height.mas_equalTo(bgHeight);
|
|
}];
|
|
|
|
[self.collectBgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerY.equalTo(self.partyBgImageView);
|
|
make.right.mas_equalTo(-20);
|
|
}];
|
|
|
|
[self.mineCollectImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.equalTo(self.collectBgImageView);
|
|
make.top.equalTo(self.collectBgImageView).offset(10);
|
|
|
|
}];
|
|
[self.mineCollectLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.mineCollectImageView.mas_bottom).offset(4);
|
|
make.centerX.equalTo(self.collectBgImageView);
|
|
make.height.mas_equalTo(16);
|
|
}];
|
|
|
|
|
|
[self.partyCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.collectBgImageView.mas_bottom).offset(28.0);
|
|
make.left.right.equalTo(self.view);
|
|
make.bottom.mas_equalTo(-kTabBarHeight);
|
|
}];
|
|
}
|
|
|
|
|
|
#pragma mark - Get
|
|
- (UIImageView *)contentBgImageView {
|
|
if (!_contentBgImageView) {
|
|
_contentBgImageView = [[UIImageView alloc] init];
|
|
_contentBgImageView.image = [UIImage imageNamed:@"mew_home_bg"];
|
|
}
|
|
return _contentBgImageView;
|
|
}
|
|
- (UIImageView *)partyBgImageView {
|
|
if (!_partyBgImageView) {
|
|
_partyBgImageView = [[UIImageView alloc] init];
|
|
_partyBgImageView.image = [UIImage imageNamed:@"mew_party_header_bg"];
|
|
}
|
|
return _partyBgImageView;
|
|
}
|
|
|
|
- (UIImageView *)collectBgImageView {
|
|
if (!_collectBgImageView) {
|
|
_collectBgImageView = [[UIImageView alloc] init];
|
|
_collectBgImageView.image = [UIImage imageNamed:@"mew_party_collection_bg"];
|
|
_collectBgImageView.userInteractionEnabled = YES;
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(mew_gotoWithMineCollection:)];
|
|
[_collectBgImageView addGestureRecognizer:tap];
|
|
}
|
|
return _collectBgImageView;
|
|
}
|
|
- (UIImageView *)mineCollectImageView {
|
|
if (!_mineCollectImageView) {
|
|
_mineCollectImageView = [[UIImageView alloc] init];
|
|
_mineCollectImageView.image = [UIImage imageNamed:@"mew_party_mine_collect"];
|
|
}
|
|
return _mineCollectImageView;
|
|
}
|
|
- (UILabel *)mineCollectLabel {
|
|
if (!_mineCollectLabel) {
|
|
_mineCollectLabel = [[UILabel alloc] init];
|
|
_mineCollectLabel.text = @"我的收藏";
|
|
_mineCollectLabel.textColor = UIColor.whiteColor;
|
|
_mineCollectLabel.font = kFontRegular(11);
|
|
}
|
|
return _mineCollectLabel;
|
|
}
|
|
|
|
- (UICollectionView *)partyCollectionView {
|
|
if (!_partyCollectionView) {
|
|
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
|
|
layout.itemSize = self.itemSizes;
|
|
layout.minimumInteritemSpacing = 17.0;
|
|
layout.minimumLineSpacing = 20.0;
|
|
layout.sectionInset = UIEdgeInsetsMake(0, 17.0, 0, 17.0);
|
|
_partyCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
|
|
_partyCollectionView.backgroundColor = UIColor.clearColor;
|
|
_partyCollectionView.delegate = self;
|
|
_partyCollectionView.dataSource = self;
|
|
_partyCollectionView.showsVerticalScrollIndicator = NO;
|
|
[_partyCollectionView registerClass:[MewPartyListCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([MewPartyListCollectionViewCell class])];
|
|
}
|
|
return _partyCollectionView;
|
|
}
|
|
|
|
@end
|