211 lines
9.0 KiB
Objective-C
211 lines
9.0 KiB
Objective-C
//
|
|
// QXUserHomePageViewController.m
|
|
// QXLive
|
|
//
|
|
// Created by 启星 on 2025/5/12.
|
|
//
|
|
|
|
#import "QXUserHomePageViewController.h"
|
|
#import "QXUserHomeHeaderView.h"
|
|
#import <JXPagingView/JXPagerView.h>
|
|
#import <JXCategoryView/JXCategoryView.h>
|
|
#import "QXUserDynamicView.h"
|
|
#import "QXUserGiftWallView.h"
|
|
#import "QXUserPhotosView.h"
|
|
#import <SDCycleScrollView/SDCycleScrollView.h>
|
|
#import "QXCreatPhotosViewController.h"
|
|
#import "QXMineNetwork.h"
|
|
#import "QXPhotosDetailVC.h"
|
|
#import "QXIntimateContentView.h"
|
|
#import "QXHeartBeatSpaceViewController.h"
|
|
|
|
@interface QXUserHomePageViewController ()<JXCategoryViewDelegate,JXPagerViewDelegate,SDCycleScrollViewDelegate>
|
|
@property (nonatomic,strong)UIImageView * backgourdImageView;
|
|
@property (nonatomic,strong)SDCycleScrollView * cycleScrollView;
|
|
@property (nonatomic,strong)UIButton *backBtn;
|
|
@property (nonatomic,strong)QXUserHomeHeaderView *headerView;
|
|
@property (nonatomic, strong) JXPagerView *pagingView;
|
|
@property (nonatomic, strong) UIView *sectionView;
|
|
@property (nonatomic, strong) JXCategoryTitleView *categoryView;
|
|
@property (nonatomic, strong) NSArray <NSString *> *titles;
|
|
@property (nonatomic, assign)CGRect cycleScrollViewFrame;
|
|
@property (nonatomic, strong)QXUserHomeModel *userModel;
|
|
@end
|
|
|
|
@implementation QXUserHomePageViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
// Do any additional setup after loading the view.
|
|
}
|
|
-(void)viewWillAppear:(BOOL)animated{
|
|
[super viewWillAppear:animated];
|
|
[self.navigationController setNavigationBarHidden:NO animated:YES];
|
|
[self.headerView headerStartPlay];
|
|
}
|
|
-(void)setNavgationItems{
|
|
[super setNavgationItems];
|
|
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];
|
|
}
|
|
- (void)initSubViews{
|
|
self.bgImageHidden = YES;
|
|
self.view.backgroundColor = RGB16(0xF3F3F3);
|
|
self.cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, self.view.width, 121+NavContentHeight+16) delegate:self placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]];
|
|
|
|
self.cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
|
|
self.cycleScrollView.imageURLStringsGroup = @[@"user_header_placehoulder"];
|
|
self.cycleScrollView.backgroundColor = QXConfig.themeColor;
|
|
[self.view addSubview:self.cycleScrollView];
|
|
|
|
self.backgourdImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"user_header_placehoulder"]];
|
|
self.backgourdImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
self.backgourdImageView.frame = CGRectMake(0, 0, self.view.width, 121+NavContentHeight+16);
|
|
self.cycleScrollViewFrame = self.backgourdImageView.frame;
|
|
[self.view addSubview:self.backgourdImageView];
|
|
|
|
self.titles = @[QXText(@"动态"),QXText(@"挚友"),QXText(@"我的相册")];
|
|
_categoryView = [[JXCategoryTitleView alloc] init];
|
|
self.categoryView.frame = CGRectMake(0, 0, 200, 48);
|
|
self.categoryView.titles = self.titles;
|
|
self.categoryView.delegate = self;
|
|
self.categoryView.titleSelectedColor = QXConfig.textColor;
|
|
self.categoryView.titleColor = RGB16(0x666666);
|
|
self.categoryView.titleFont = [UIFont boldSystemFontOfSize:14];
|
|
self.categoryView.titleSelectedFont = [UIFont boldSystemFontOfSize:16];
|
|
self.categoryView.titleColorGradientEnabled = YES;
|
|
self.categoryView.titleLabelZoomEnabled = YES;
|
|
self.categoryView.cellWidth = JXCategoryViewAutomaticDimension;
|
|
self.categoryView.cellSpacing = 12;
|
|
if (self.isGiftWall) {
|
|
self.categoryView.defaultSelectedIndex = 1;
|
|
}
|
|
self.categoryView.backgroundColor = [UIColor clearColor];
|
|
JXCategoryIndicatorImageView *indicatorView = [[JXCategoryIndicatorImageView alloc] init];
|
|
indicatorView.indicatorImageView.image = [UIImage imageNamed:@"home_slider"];
|
|
indicatorView.indicatorImageViewSize = CGSizeMake(30, 8);
|
|
indicatorView.verticalMargin = 11;
|
|
self.categoryView.indicators = @[indicatorView];
|
|
self.sectionView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 48)];
|
|
self.sectionView.backgroundColor = RGB16(0xf6f6f6);
|
|
[self.sectionView addSubview:self.categoryView];
|
|
_pagingView = [[JXPagerView alloc] initWithDelegate:self];
|
|
_pagingView.mainTableView.backgroundColor = [UIColor clearColor];
|
|
self.pagingView.backgroundColor = [UIColor clearColor];
|
|
[self.view addSubview:self.pagingView];
|
|
self.cycleScrollView.hidden = YES;
|
|
self.backgourdImageView.hidden = YES;
|
|
self.categoryView.hidden = YES;
|
|
self.categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagingView.listContainerView;
|
|
|
|
// self.navigationController.interactivePopGestureRecognizer.enabled = (self.categoryView.selectedIndex == 0);
|
|
|
|
|
|
// self.backBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, kSafeAreaTop, 40, 40)];
|
|
// [self.backBtn setImage:[UIImage imageNamed:@"back"] forState:(UIControlStateNormal)];
|
|
// [self.backBtn addTarget:self action:@selector(backAction) forControlEvents:(UIControlEventTouchUpInside)];
|
|
// [self.view addSubview:self.backBtn];
|
|
[self getUserInfo];
|
|
}
|
|
- (void)viewDidLayoutSubviews {
|
|
[super viewDidLayoutSubviews];
|
|
|
|
self.pagingView.frame = CGRectMake(0, NavContentHeight, SCREEN_WIDTH, SCREEN_HEIGHT-NavContentHeight);
|
|
}
|
|
-(void)getUserInfo{
|
|
MJWeakSelf
|
|
[QXMineNetwork userHomePageWithUserId:self.user_id successBlock:^(QXUserHomeModel * _Nonnull userModel) {
|
|
weakSelf.userModel = userModel;
|
|
weakSelf.headerView.hidden = NO;
|
|
weakSelf.headerView.model = userModel;
|
|
if (weakSelf.userModel.cp_info != nil) {
|
|
weakSelf.headerView.height = 243+ScaleWidth(40)+8+ScaleWidth(100)+14;
|
|
}else{
|
|
weakSelf.headerView.height = 243+ScaleWidth(40)+8;
|
|
}
|
|
[weakSelf.pagingView resizeTableHeaderViewHeightWithAnimatable:NO duration:0.1 curve:UIViewAnimationCurveLinear];
|
|
weakSelf.cycleScrollView.hidden = NO;
|
|
weakSelf.backgourdImageView.hidden = NO;
|
|
weakSelf.categoryView.hidden = NO;
|
|
NSArray *imgs;
|
|
if (userModel.home_bgimages.length > 0) {
|
|
imgs = [userModel.home_bgimages componentsSeparatedByString:@","];
|
|
}
|
|
if (imgs.count == 0) {
|
|
weakSelf.backgourdImageView.hidden = NO;
|
|
[weakSelf.backgourdImageView sd_setImageWithURL:[NSURL URLWithString:userModel.avatar] placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]];
|
|
weakSelf.cycleScrollView.hidden = YES;
|
|
}else if(imgs.count == 1){
|
|
weakSelf.backgourdImageView.hidden = NO;
|
|
[weakSelf.backgourdImageView sd_setImageWithURL:[NSURL URLWithString:imgs.firstObject] placeholderImage:[UIImage imageNamed:@"user_header_placehoulder"]];
|
|
weakSelf.cycleScrollView.hidden = YES;
|
|
}else{
|
|
weakSelf.cycleScrollView.hidden = NO;
|
|
weakSelf.backgourdImageView.hidden = YES;
|
|
weakSelf.cycleScrollView.imageURLStringsGroup = imgs;
|
|
}
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
|
showToast(msg);
|
|
}];
|
|
}
|
|
#pragma mark - JXPagingViewDelegate
|
|
|
|
- (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
|
|
return self.headerView;
|
|
}
|
|
- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
|
|
return self.headerView.height;
|
|
}
|
|
|
|
- (NSUInteger)heightForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
|
return 48;
|
|
}
|
|
- (UIView *)viewForPinSectionHeaderInPagerView:(JXPagerView *)pagerView {
|
|
return self.sectionView;
|
|
}
|
|
|
|
- (NSInteger)numberOfListsInPagerView:(JXPagerView *)pagerView {
|
|
return self.titles.count;
|
|
}
|
|
|
|
- (id<JXPagerViewListViewDelegate>)pagerView:(JXPagerView *)pagerView initListAtIndex:(NSInteger)index {
|
|
if (index == 0) {
|
|
QXUserDynamicView *dynamicView = [[QXUserDynamicView alloc] init];
|
|
dynamicView.user_id = self.user_id;
|
|
dynamicView.backgroundColor = RGB16(0xf6f6f6);
|
|
return dynamicView;
|
|
}else if(index == 1){
|
|
// QXUserGiftWallView *giftWallView = [[QXUserGiftWallView alloc] init];
|
|
// giftWallView.backgroundColor = RGB16(0xf6f6f6);
|
|
// giftWallView.user_id = self.user_id;
|
|
// return giftWallView;
|
|
QXIntimateContentView *intimateView = [[QXIntimateContentView alloc] init];
|
|
intimateView.userId = self.user_id;
|
|
return intimateView;
|
|
}else{
|
|
QXUserPhotosView *photosView = [[QXUserPhotosView alloc] init];
|
|
photosView.user_id = self.user_id;
|
|
photosView.backgroundColor = RGB16(0xf6f6f6);
|
|
return photosView;
|
|
}
|
|
}
|
|
-(void)pagerView:(JXPagerView *)pagerView mainTableViewDidScroll:(UIScrollView *)scrollView{
|
|
CGFloat contentOffsetY = scrollView.contentOffset.y;
|
|
if (contentOffsetY > 0) {
|
|
return;
|
|
}
|
|
CGRect frame = self.cycleScrollViewFrame;
|
|
frame.size.height -= contentOffsetY;
|
|
// frame.origin.y = contentOffsetY;
|
|
self.backgourdImageView.frame = frame;
|
|
}
|
|
-(QXUserHomeHeaderView *)headerView{
|
|
if (!_headerView) {
|
|
_headerView = [[QXUserHomeHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 215+26)];
|
|
_headerView.userId = self.user_id;
|
|
_headerView.hidden = YES;
|
|
}
|
|
return _headerView;
|
|
}
|
|
|
|
@end
|