完善动态页面

This commit is contained in:
chenshuanglin
2023-03-07 15:13:07 +08:00
parent 21c6b8497a
commit cba078eab2
16 changed files with 771 additions and 35 deletions

View File

@@ -18,6 +18,10 @@
14EDBBBC29B6034C001D3E16 /* XPMomentListCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 14EDBBBA29B6034B001D3E16 /* XPMomentListCollectionViewCell.m */; };
14EDBBBF29B60A52001D3E16 /* XPMomentTopicHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 14EDBBBE29B60A52001D3E16 /* XPMomentTopicHeaderView.m */; };
14EDBBC229B60FFE001D3E16 /* XPPartyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 14EDBBC129B60FFE001D3E16 /* XPPartyViewController.m */; };
14F9795E29B6D03B004BBFEB /* ZBCycleVerticalView.m in Sources */ = {isa = PBXBuildFile; fileRef = 14F9795A29B6D03B004BBFEB /* ZBCycleVerticalView.m */; };
14F9795F29B6D03B004BBFEB /* ZBCycleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 14F9795D29B6D03B004BBFEB /* ZBCycleView.m */; };
14F9796229B6E1DE004BBFEB /* XPMomentTopicHeaderCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 14F9796129B6E1DE004BBFEB /* XPMomentTopicHeaderCell.m */; };
14F9796529B71189004BBFEB /* XPMonentsEmptyCollectionViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 14F9796429B71189004BBFEB /* XPMonentsEmptyCollectionViewCell.m */; };
180116F9279E8C4C00F2CBC0 /* PLTimeUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 180116F8279E8C4C00F2CBC0 /* PLTimeUtil.m */; };
180116FC279E8CCE00F2CBC0 /* NVDate.m in Sources */ = {isa = PBXBuildFile; fileRef = 180116FA279E8CCE00F2CBC0 /* NVDate.m */; };
180806D827293794001FD836 /* NSObject+MJExtension.m in Sources */ = {isa = PBXBuildFile; fileRef = 180806D727293794001FD836 /* NSObject+MJExtension.m */; };
@@ -1300,6 +1304,14 @@
14EDBBBE29B60A52001D3E16 /* XPMomentTopicHeaderView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMomentTopicHeaderView.m; sourceTree = "<group>"; };
14EDBBC029B60FFE001D3E16 /* XPPartyViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPPartyViewController.h; sourceTree = "<group>"; };
14EDBBC129B60FFE001D3E16 /* XPPartyViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPPartyViewController.m; sourceTree = "<group>"; };
14F9795A29B6D03B004BBFEB /* ZBCycleVerticalView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZBCycleVerticalView.m; sourceTree = "<group>"; };
14F9795B29B6D03B004BBFEB /* ZBCycleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZBCycleView.h; sourceTree = "<group>"; };
14F9795C29B6D03B004BBFEB /* ZBCycleVerticalView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZBCycleVerticalView.h; sourceTree = "<group>"; };
14F9795D29B6D03B004BBFEB /* ZBCycleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZBCycleView.m; sourceTree = "<group>"; };
14F9796029B6E1DE004BBFEB /* XPMomentTopicHeaderCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMomentTopicHeaderCell.h; sourceTree = "<group>"; };
14F9796129B6E1DE004BBFEB /* XPMomentTopicHeaderCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMomentTopicHeaderCell.m; sourceTree = "<group>"; };
14F9796329B71189004BBFEB /* XPMonentsEmptyCollectionViewCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPMonentsEmptyCollectionViewCell.h; sourceTree = "<group>"; };
14F9796429B71189004BBFEB /* XPMonentsEmptyCollectionViewCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPMonentsEmptyCollectionViewCell.m; sourceTree = "<group>"; };
180116F7279E8C4C00F2CBC0 /* PLTimeUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PLTimeUtil.h; sourceTree = "<group>"; };
180116F8279E8C4C00F2CBC0 /* PLTimeUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PLTimeUtil.m; sourceTree = "<group>"; };
180116FA279E8CCE00F2CBC0 /* NVDate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NVDate.m; sourceTree = "<group>"; };
@@ -3640,6 +3652,17 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
14F9795929B6D020004BBFEB /* CycleVerticalView */ = {
isa = PBXGroup;
children = (
14F9795C29B6D03B004BBFEB /* ZBCycleVerticalView.h */,
14F9795A29B6D03B004BBFEB /* ZBCycleVerticalView.m */,
14F9795B29B6D03B004BBFEB /* ZBCycleView.h */,
14F9795D29B6D03B004BBFEB /* ZBCycleView.m */,
);
path = CycleVerticalView;
sourceTree = "<group>";
};
180116F6279E8C3100F2CBC0 /* Date */ = {
isa = PBXGroup;
children = (
@@ -3974,6 +3997,7 @@
189DD56C26DF5B5400AB55B1 /* UI */ = {
isa = PBXGroup;
children = (
14F9795929B6D020004BBFEB /* CycleVerticalView */,
E81E09C6290F719C00A1F410 /* Adbvertise */,
E80EC74A28ACD84000D133C5 /* InputView */,
E8998D932859DD3F00C68558 /* UIViewCorner */,
@@ -6112,8 +6136,12 @@
14EDBBB829B60341001D3E16 /* XPMomentListViewController.m */,
14EDBBBD29B60A52001D3E16 /* XPMomentTopicHeaderView.h */,
14EDBBBE29B60A52001D3E16 /* XPMomentTopicHeaderView.m */,
14F9796029B6E1DE004BBFEB /* XPMomentTopicHeaderCell.h */,
14F9796129B6E1DE004BBFEB /* XPMomentTopicHeaderCell.m */,
14EDBBBB29B6034C001D3E16 /* XPMomentListCollectionViewCell.h */,
14EDBBBA29B6034B001D3E16 /* XPMomentListCollectionViewCell.m */,
14F9796329B71189004BBFEB /* XPMonentsEmptyCollectionViewCell.h */,
14F9796429B71189004BBFEB /* XPMonentsEmptyCollectionViewCell.m */,
);
path = View;
sourceTree = "<group>";
@@ -9726,6 +9754,7 @@
9B1B72BC28003E06003FACE9 /* XPAnchorPKTableViewCell.m in Sources */,
E8E70D7A26F2F16600F03460 /* XPMinePresent.m in Sources */,
E81A653C2834E9AE00F55894 /* MonentsListInfoModel.m in Sources */,
14F9796229B6E1DE004BBFEB /* XPMomentTopicHeaderCell.m in Sources */,
E855516128059228005F293F /* XPMineGuildIncomeDetailViewController.m in Sources */,
9B42869C28C1FD3D009034D2 /* XPOpenRedPacketCell.m in Sources */,
E8A1E45B27620F4900B294CA /* XPRoomHalfWebView.m in Sources */,
@@ -9888,6 +9917,7 @@
E816C11527608A7500C84014 /* XPRoomMiniManager.m in Sources */,
E8EEB91726FC7B35007C6EBA /* XPMineUserInfoDesViewController.m in Sources */,
9B1B72AC280031DB003FACE9 /* XPAnchorPKViewController.m in Sources */,
14F9795F29B6D03B004BBFEB /* ZBCycleView.m in Sources */,
E80CBDED27D0D899001E1EC2 /* XPHomeLikeEmptyTableViewCell.m in Sources */,
9BEBBF4329384BB20024E0B4 /* HomeSearchHijackBaseModel.m in Sources */,
180806FB2729A354001FD836 /* ThemeColor+Room.m in Sources */,
@@ -10076,6 +10106,7 @@
E86596542701A55500846EBD /* StatisticsServiceHelper.m in Sources */,
E8E21A9B28B4BD92008F7C9D /* XPRoomGraffitiGiftAnimationView.m in Sources */,
E8E70D8C26F2F5A500F03460 /* XPMineHeadItemCollectionViewCell.m in Sources */,
14F9796529B71189004BBFEB /* XPMonentsEmptyCollectionViewCell.m in Sources */,
E883E82E28153BDF0000005D /* XPGuildAnchorIncomeSectionView.m in Sources */,
9B17F71827BD150600440843 /* SVGAParserManager.m in Sources */,
E8751E5928A62A390056EF44 /* Api+Sailing.m in Sources */,
@@ -10179,6 +10210,7 @@
E81AF32527F1D5B8003B9E43 /* XPRoomPKProgressView.m in Sources */,
E8DEC99527648FA50078CB70 /* ClientConfig.m in Sources */,
9B6E8577281ABECC0041A321 /* XPRoomInsideRecommendEmptyCell.m in Sources */,
14F9795E29B6D03B004BBFEB /* ZBCycleVerticalView.m in Sources */,
E8E859D628264C2300EE4857 /* DispatchQueueLogFormatter.m in Sources */,
E880B3A6278BD69900A83B0D /* XPAcrossRoomPKTableViewCell.m in Sources */,
E8EEB90926FC579A007C6EBA /* XPMineUserInfoEditTableViewCell.m in Sources */,

View File

@@ -0,0 +1,33 @@
//
// ZBCycleVerticalView.h
// DeRong
//
// Created by 周博 on 2019/1/7.
// Copyright © 2019 周博. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, ZBCycleVerticalViewScrollDirection) {
ZBCycleVerticalViewScrollDirectionUp = 0,
ZBCycleVerticalViewScrollDirectionDown
};
typedef void(^ClickBlock)(NSInteger index);
@interface ZBCycleVerticalView : UIView
@property (assign, nonatomic) ZBCycleVerticalViewScrollDirection direction;
@property (strong, nonatomic) NSArray *dataArray; // 数据源
@property (copy, nonatomic) ClickBlock block;
// 开启动画(默认是开启的)
- (void)startAnimation;
// 关闭动画
- (void)stopAnimation;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,179 @@
//
// ZBCycleVerticalView.m
// DeRong
//
// Created by on 2019/1/7.
// Copyright © 2019 . All rights reserved.
//
#import "ZBCycleVerticalView.h"
#import "ZBCycleView.h"
@interface ZBCycleVerticalView ()
{
CGRect _topRect; //View
CGRect _middleRect;//View
CGRect _btmRect; //View
double _showTime; //timer
double _animationTime;//
UIButton *_button; //
NSTimer *_timer; //
NSInteger _indexNow; //
}
@property (strong, nonatomic) ZBCycleView *view1;
@property (strong, nonatomic) ZBCycleView *view2;
@property (strong, nonatomic) ZBCycleView *tmpTopView;
@property (strong, nonatomic) ZBCycleView *tmpMiddleView;
@property (strong, nonatomic) ZBCycleView *tmpBtmView;
@end
@implementation ZBCycleVerticalView
- (instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
_showTime = 3;
_animationTime = 0.3;
[self initUI];
}
return self;
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder{
self = [super initWithCoder:aDecoder];
if (self) {
_showTime = 3;
_animationTime = 0.3;
[self initUI];
}
return self;
}
- (void)layoutSubviews{
[super layoutSubviews];
_middleRect = self.bounds;
_topRect = CGRectMake(0, -CGRectGetHeight(self.frame), CGRectGetWidth(self.frame), CGRectGetHeight(self.frame));
_btmRect = CGRectMake(0, CGRectGetHeight(self.frame), CGRectGetWidth(self.frame), CGRectGetHeight(self.frame));
self.view1.frame = _middleRect;
self.view2.frame = self.direction == ZBCycleVerticalViewScrollDirectionDown ? self->_topRect : self->_btmRect;
_button.frame = _middleRect;
}
- (void)initUI{
self.view1 = [[ZBCycleView alloc]init];
// self.view1.backgroundColor = [UIColor clearColor];
self.view2 = [[ZBCycleView alloc]init];
// self.view2.backgroundColor = [UIColor clearColor];
[self addSubview:self.view1];
[self addSubview:self.view2];
_button = [UIButton buttonWithType:UIButtonTypeCustom];
_button.backgroundColor = [UIColor clearColor];
[_button addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_button];
self.clipsToBounds = YES;
}
//
- (void)executeAnimation{
[self setViewInfo];
[UIView animateWithDuration:_animationTime delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.tmpMiddleView.frame = self.direction == ZBCycleVerticalViewScrollDirectionDown ? self->_btmRect : self->_topRect;
if (self->_direction == ZBCycleVerticalViewScrollDirectionDown) {
self.tmpTopView.frame = self->_middleRect;
} else {
self.tmpBtmView.frame = self->_middleRect;
}
}completion:^(BOOL finished) {
self.tmpMiddleView.frame = self->_direction == ZBCycleVerticalViewScrollDirectionDown ? self->_topRect : self->_btmRect;
if (self->_indexNow < self.dataArray.count - 1) {
self->_indexNow ++;
}else{
self->_indexNow = 0;
}
}];
}
#pragma mark - set
- (void)setDirection:(ZBCycleVerticalViewScrollDirection)direction{
_direction = direction;
self.view2.frame = _direction == ZBCycleVerticalViewScrollDirectionDown ? _topRect : _btmRect;
}
- (void)setDataArray:(NSArray *)dataArray{
_dataArray = dataArray;
if (![_timer isValid]) {
_indexNow = 0;
[self startAnimation];
}
}
- (void)setViewInfo{
if (_direction == ZBCycleVerticalViewScrollDirectionDown) {
if (self.view1.frame.origin.y == 0) {
_tmpMiddleView = self.view1;
_tmpTopView = self.view2;
} else {
_tmpMiddleView = self.view2;
_tmpTopView = self.view1;
}
} else {
if (self.view1.frame.origin.y == 0) {
_tmpMiddleView = self.view1;
_tmpBtmView = self.view2;
} else {
_tmpMiddleView = self.view2;
_tmpBtmView = self.view1;
}
}
_tmpMiddleView.dicData = _dataArray[_indexNow%(_dataArray.count)];
if(_dataArray.count > 1){
if (_direction == ZBCycleVerticalViewScrollDirectionDown) {
_tmpTopView.dicData = _dataArray[(_indexNow+1)%(_dataArray.count)];
} else {
_tmpBtmView.dicData = _dataArray[(_indexNow+1)%(_dataArray.count)];
}
}
}
- (void)startAnimation{
[self setViewInfo];
if (_dataArray.count > 1) {
[self stopTimer];
_timer = [NSTimer scheduledTimerWithTimeInterval:_showTime target:self selector:@selector(executeAnimation) userInfo:nil repeats:YES];
[[NSRunLoop currentRunLoop] addTimer:_timer forMode:UITrackingRunLoopMode];
}
}
- (void)stopAnimation{
[self stopTimer];
[self.layer removeAllAnimations];
[NSObject cancelPreviousPerformRequestsWithTarget:self];
}
#pragma mark -
- (void)stopTimer{
if(_timer){
if([_timer isValid]){
[_timer invalidate];
}
_timer = nil;
}
}
- (void)btnClick{
if (self.block) {
self.block(_indexNow);
}
}
@end

View File

@@ -0,0 +1,19 @@
//
// ZBCycleView.h
// CycleVerticalView
//
// Created by 周博 on 2019/1/8.
// Copyright © 2019 EL. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface ZBCycleView : UIView
@property (strong, nonatomic) NSDictionary *dicData;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,39 @@
//
// ZBCycleView.m
// CycleVerticalView
//
// Created by on 2019/1/8.
// Copyright © 2019 EL. All rights reserved.
//
#import "ZBCycleView.h"
@interface ZBCycleView ()
@property (strong, nonatomic) UILabel *titleLabel;
@end
@implementation ZBCycleView
- (instancetype)initWithFrame:(CGRect)frame{
self = [super initWithFrame:frame];
if (self) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.font = [UIFont systemFontOfSize:15];
_titleLabel.textColor = [UIColor blackColor];
[self addSubview:_titleLabel];
}
return self;
}
- (void)layoutSubviews{
[super layoutSubviews];
_titleLabel.frame = CGRectMake(15, 0, CGRectGetWidth(self.frame)-30, CGRectGetHeight(self.frame));
}
- (void)setDicData:(NSDictionary *)dicData{
_dicData = dicData;
_titleLabel.text = dicData[@"TITLE"];
}
@end

View File

@@ -8,6 +8,7 @@
#import "XPNewHomeHeaderView.h"
///Third
#import <Masonry.h>
#import "ZBCycleVerticalView.h"
///Tool
#import "XPMacro.h"
#import "ThemeColor.h"
@@ -26,7 +27,7 @@
///
@property (nonatomic, strong) UIImageView *hotView;
@property (nonatomic, strong) UILabel *hotTextLabel;
@property (nonatomic, strong) UIView *messageView;
@property (nonatomic, strong) ZBCycleVerticalView *messageView;
@end
@@ -38,6 +39,7 @@
if (self) {
[self initSubViews];
[self initSubViewConstraints];
[self setMessageScroll];
}
return self;
}
@@ -151,6 +153,26 @@
#pragma mark - Getters And Setters
- (void)setMessageScroll {
//
NSArray *array = @[
@{
@"TITLE" : @"1华为冀今年香港手机市场占有率提高至24 7月开首间旗舰店",
},
@{
@"TITLE" : @"2北京大兴国际机场迎来第一架飞机",
},
@{
@"TITLE" : @"3春运首日 零陵汽车站客运平稳有序",
},
@{
@"TITLE" : @"4吴秀波出轨风波后和白百何主演的《情圣2》突然提档",
}
];
self.messageView.dataArray = array;
}
- (UIButton *)partyView {
if (!_partyView) {
_partyView = [UIButton buttonWithType:UIButtonTypeCustom];
@@ -207,9 +229,10 @@
return _hotTextLabel;
}
- (UIView *)messageView {
- (ZBCycleVerticalView *)messageView {
if (!_messageView) {
_messageView = [[UIView alloc] init];
_messageView = [[ZBCycleVerticalView alloc] init];
_messageView.direction = ZBCycleVerticalViewScrollDirectionUp;
}
return _messageView;
}

View File

@@ -182,7 +182,7 @@
[self.topGradientImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.right.mas_equalTo(0);
make.top.mas_equalTo(125);
make.height.mas_equalTo(125);
}];
[self.homeNavView mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.top.right.mas_equalTo(0);

View File

@@ -10,7 +10,18 @@
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, XPMomentListType) {
/// 推荐
XPMomentListRecommend,
/// 最新
XPMomentListTypeLatest,
/// 关注
XPMomentListTypeAttent,
};
@interface XPMomentListViewController : MvpViewController<JXCategoryListContentViewDelegate>
/// 列表类型
@property (nonatomic, assign) XPMomentListType listType;
@end

View File

@@ -12,19 +12,23 @@
#import "ThemeColor.h"
#import "NSArray+Safe.h"
#import "ClientConfig.h"
/// Model
#import "MonentsListInfoModel.h"
/// View
#import "XPMomentListCollectionViewCell.h"
#import "XPButton.h"
#import "XPMonentsEmptyCollectionViewCell.h"
/// P
#import "XPMonentsLatestPresenter.h"
#import "XPMonentsLatestProtocol.h"
#import "XPMonentsRecommendPresenter.h"
#import "XPMonentsRecommendProtocol.h"
#import "XPMonentsAttentionPresenter.h"
#import "XPMonentsAttentionProtocol.h"
/// VC
#import "XPMonentsDetailViewController.h"
#import "XPMonentsPublishViewController.h"
@interface XPMomentListViewController ()<UICollectionViewDelegate, UICollectionViewDataSource, XPMonentsLatestProtocol, XPMonentsDetailViewControllerDelegate>
@interface XPMomentListViewController ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, XPMonentsLatestProtocol, XPMonentsRecommendProtocol, XPMonentsAttentionProtocol, XPMonentsDetailViewControllerDelegate>
@property (nonatomic, strong) UICollectionView *collectionView;
@property (nonatomic, copy) void(^scrollCallback)(UIScrollView *scrollView);
@@ -47,7 +51,13 @@
}
- (__kindof id)createPresenter {
return [[XPMonentsLatestPresenter alloc] init];
if (self.listType == XPMomentListRecommend) {
return [[XPMonentsRecommendPresenter alloc] init];
}else if (self.listType == XPMomentListTypeLatest) {
return [[XPMonentsLatestPresenter alloc] init];
}else{
return [[XPMonentsAttentionPresenter alloc] init];
}
}
- (void)viewDidLoad {
@@ -89,7 +99,14 @@
#pragma mark - fangfa
- (void)headerRefresh {
self.page = 1;
[self.presenter getMonentsLatestListPageSize:20 dynamicId:@"" state:0];
if (self.listType == XPMomentListRecommend) {
[self.presenter getMonentsRecommendList:self.page pageSize:20 state:0];
}else if (self.listType == XPMomentListTypeLatest) {
[self.presenter getMonentsLatestListPageSize:20 dynamicId:@"" state:0];
}else{
[self.presenter getMonentsAttentionListPageSize:20 dynamicId:@"" state:0];
}
}
- (void)footerRefresh {
@@ -99,7 +116,14 @@
return;
}
self.page++;
[self.presenter getMonentsLatestListPageSize:20 dynamicId:self.listInfo.nextDynamicId state:1];
if (self.listType == XPMomentListRecommend) {
[self.presenter getMonentsRecommendList:self.page pageSize:20 state:1];
}else if (self.listType == XPMomentListTypeLatest) {
[self.presenter getMonentsLatestListPageSize:20 dynamicId:self.listInfo.nextDynamicId state:1];
}else{
[self.presenter getMonentsAttentionListPageSize:20 dynamicId:self.listInfo.nextDynamicId state:1];
}
}
#pragma mark - XPMonentsLatestProtocol
@@ -134,6 +158,69 @@
}
}
#pragma mark - XPMonentsRecommendProtocol
- (void)getMonentsRecommendListSuccess:(NSArray *)array state:(int)state {
if (state == 0) {
[self.datasource removeAllObjects];
}
if (array.count > 0) {
[self.datasource addObjectsFromArray:array];
}
if (state == 0) {
self.hasNoMoreData = NO;
[self.collectionView.mj_header endRefreshing];
} else {
if (array.count > 0) {
self.hasNoMoreData = NO;
} else {
self.hasNoMoreData = YES;
}
[self.collectionView.mj_footer endRefreshing];
}
[self.collectionView reloadData];
}
- (void)getMonentsRecommendListFail:(NSString *)msg state:(int)state {
if (state == 0) {
[self.collectionView.mj_header endRefreshing];
} else {
[self.collectionView.mj_footer endRefreshing];
}
}
#pragma mark - XPMonentsRecommendProtocol
- (void)getMonentsAttentionListSuccess:(MonentsListInfoModel *)listInfo state:(int)state {
self.listInfo = listInfo;
if (state == 0) {
[self.datasource removeAllObjects];
}
if (listInfo.dynamicList.count > 0) {
[self.datasource addObjectsFromArray:listInfo.dynamicList];
}
if (state == 0) {
self.hasNoMoreData = NO;
[self.collectionView.mj_header endRefreshing];
} else {
if (listInfo.dynamicList.count > 0) {
self.hasNoMoreData = NO;
} else {
self.hasNoMoreData = YES;
}
[self.collectionView.mj_footer endRefreshing];
}
[self.collectionView reloadData];
}
- (void)getMonentsAttentionListFail:(NSString *)msg state:(int)state {
if (state == 0) {
[self.collectionView.mj_header endRefreshing];
} else {
[self.collectionView.mj_footer endRefreshing];
}
}
#pragma mark - XPMonentsDetailViewControllerDelegate
- (void)xPMonentsDetailViewController:(XPMonentsDetailViewController *)view deleteMonents:(NSString *)dynamicId {
__block MonentsInfoModel * deleteInfo;
@@ -152,13 +239,36 @@
#pragma mark - UICollectionView
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.datasource.count;
if (self.datasource.count > 0) {
return self.datasource.count;
}
return 1;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
if (self.datasource.count > 0) {
CGFloat width = (KScreenWidth - 16 -13 -16)/2.0;
CGFloat height = 220.0/165.0*width;
return CGSizeMake(width, height);
}
return collectionView.frame.size;
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
if (self.datasource.count > 0) {
return UIEdgeInsetsMake(12, 16, 12, 16);
}
return UIEdgeInsetsZero;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
XPMomentListCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass(XPMomentListCollectionViewCell.self) forIndexPath:indexPath];
MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.monentsInfo = monentsInfo;
if (self.datasource.count > 0) {
XPMomentListCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass(XPMomentListCollectionViewCell.self) forIndexPath:indexPath];
MonentsInfoModel * monentsInfo = [self.datasource safeObjectAtIndex1:indexPath.row];
cell.monentsInfo = monentsInfo;
return cell;
}
XPMonentsEmptyCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMonentsEmptyCollectionViewCell class]) forIndexPath:indexPath];
return cell;
}
@@ -196,17 +306,14 @@
if (!_collectionView) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
CGFloat width = (KScreenWidth - 16 -13 -16)/2.0;
CGFloat height = 220.0/165.0*width;
layout.itemSize = CGSizeMake(width, height);
layout.minimumLineSpacing = 12.0;
layout.minimumInteritemSpacing = 13.0;
layout.sectionInset = UIEdgeInsetsMake(12, 16, 12, 16);
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.backgroundColor = UIColor.clearColor;
_collectionView.alwaysBounceVertical = YES;
[_collectionView registerClass:[XPMomentListCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass(XPMomentListCollectionViewCell.self)];
[_collectionView registerClass:[XPMonentsEmptyCollectionViewCell class] forCellWithReuseIdentifier:NSStringFromClass([XPMonentsEmptyCollectionViewCell class])];
_collectionView.delegate = self;
_collectionView.dataSource = self;
_collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;

View File

@@ -0,0 +1,20 @@
//
// XPMomentTopicHeaderCell.h
// xplan-ios
//
// Created by XY on 2023/3/7.
//
#import <UIKit/UIKit.h>
@class MonentsTopicModel;
NS_ASSUME_NONNULL_BEGIN
@interface XPMomentTopicHeaderCell : UICollectionViewCell
@property (nonatomic, strong) MonentsTopicModel *topicModel;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,80 @@
//
// XPMomentTopicHeaderCell.m
// xplan-ios
//
// Created by XY on 2023/3/7.
//
#import "XPMomentTopicHeaderCell.h"
///Third
#import <Masonry.h>
///Tool
#import "NetImageView.h"
///Model
#import "MonentsTopicModel.h"
@interface XPMomentTopicHeaderCell()
///
@property (nonatomic, strong) NetImageView *bgImageView;
///
@property (nonatomic, strong) UILabel *topicLabel;
@end
@implementation XPMomentTopicHeaderCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.bgImageView];
[self addSubview:self.topicLabel];
}
- (void)initSubViewConstraints {
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self.contentView);
}];
[self.topicLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(0);
make.centerY.mas_equalTo(0);
}];
}
#pragma mark - Getters And Setters
- (void)setTopicModel:(MonentsTopicModel *)topicModel {
_topicModel = topicModel;
if (_topicLabel) {
self.bgImageView.imageUrl = _topicModel.icon;
self.topicLabel.text = [NSString stringWithFormat:@"#%@",_topicModel.name];
}
}
- (NetImageView *)bgImageView {
if (!_bgImageView) {
_bgImageView = [[NetImageView alloc] init];
_bgImageView.contentMode = UIViewContentModeScaleAspectFill;
_bgImageView.clipsToBounds = YES;
}
return _bgImageView;
}
- (UILabel *)topicLabel {
if (!_topicLabel) {
_topicLabel = [[UILabel alloc] init];
_topicLabel.textColor = UIColor.whiteColor;
_topicLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
}
return _topicLabel;
}
@end

View File

@@ -6,10 +6,23 @@
//
#import <UIKit/UIKit.h>
#import "MonentsTopicModel.h"
NS_ASSUME_NONNULL_BEGIN
@protocol XPMomentTopicHeaderViewDelegate <NSObject>
/// 点击了主题
- (void)momentTopicHeaderViewClickTopic:(MonentsTopicModel *)topicModel;
@end
@interface XPMomentTopicHeaderView : UIView
/// 主题列表
@property (nonatomic, strong) NSArray *topicList;
@property (nonatomic, weak) id<XPMomentTopicHeaderViewDelegate> delegate;
/// 获取头部高度
+ (CGFloat)getTopicHeaderViewHeight;
@end

View File

@@ -8,10 +8,16 @@
#import "XPMomentTopicHeaderView.h"
#import "ThemeColor.h"
#import <Masonry.h>
#import "XPMacro.h"
#import "NSArray+Safe.h"
///View
#import "XPMomentTopicHeaderCell.h"
@interface XPMomentTopicHeaderView()
@property (nonatomic, strong) UIView *contentView;
@interface XPMomentTopicHeaderView()<UICollectionViewDelegate, UICollectionViewDataSource>
///
@property (nonatomic, strong) UIView *bgView;
///
@property (nonatomic, strong) UICollectionView *collectionView;
@end
@@ -28,28 +34,84 @@
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.contentView];
[self addSubview:self.bgView];
[self.bgView addSubview:self.collectionView];
}
- (void)initSubViewConstraints {
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(10);
make.left.mas_equalTo(15);
make.right.mas_equalTo(-15);
make.bottom.mas_equalTo(-10);
}];
[self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.left.right.bottom.mas_equalTo(0);
}];
}
+ (CGFloat)getTopicHeaderViewHeight {
CGFloat width = KScreenWidth-15*2;
CGFloat height = 74.0/345.0*width;
return height+20;
}
#pragma mark - UICollectionViewDelegate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.topicList.count;
}
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
XPMomentTopicHeaderCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([XPMomentTopicHeaderCell class]) forIndexPath:indexPath];
MonentsTopicModel *model = [self.topicList safeObjectAtIndex1:indexPath.row];
cell.topicModel = model;
return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
if (self.delegate && [self.delegate respondsToSelector:@selector(momentTopicHeaderViewClickTopic:)]) {
MonentsTopicModel *topicModel = [self.topicList safeObjectAtIndex1:indexPath.row];
[self.delegate momentTopicHeaderViewClickTopic:topicModel];
}
}
#pragma mark - Getters And Setters
- (UIView *)contentView {
if (!_contentView) {
_contentView = [[UIView alloc] init];
_contentView.backgroundColor = [ThemeColor appCellBackgroundColor];
_contentView.layer.cornerRadius = 12;
_contentView.clipsToBounds = YES;
- (void)setTopicList:(NSArray *)topicList {
_topicList = topicList;
[self.collectionView reloadData];
}
- (UIView *)bgView {
if (!_bgView) {
_bgView = [[UIView alloc] init];
_bgView.backgroundColor = [ThemeColor appCellBackgroundColor];
_bgView.layer.cornerRadius = 12;
_bgView.clipsToBounds = YES;
}
return _contentView;
return _bgView;
}
- (UICollectionView *)collectionView {
if (!_collectionView) {
UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
CGFloat width = KScreenWidth-15*2;
CGFloat height = 74.0/345.0*width;
layout.itemSize = CGSizeMake(width, height);
layout.minimumLineSpacing = 0;
layout.minimumInteritemSpacing = 0;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.delegate = self;
_collectionView.dataSource = self;
_collectionView.pagingEnabled = YES;
_collectionView.showsVerticalScrollIndicator = NO;
_collectionView.showsHorizontalScrollIndicator = NO;
[_collectionView registerClass:[XPMomentTopicHeaderCell class] forCellWithReuseIdentifier:NSStringFromClass([XPMomentTopicHeaderCell class])];
}
return _collectionView;
}
@end

View File

@@ -0,0 +1,16 @@
//
// XPMonentsEmptyCollectionViewCell.h
// xplan-ios
//
// Created by XY on 2023/3/7.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPMonentsEmptyCollectionViewCell : UICollectionViewCell
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,75 @@
//
// XPMonentsEmptyCollectionViewCell.m
// xplan-ios
//
// Created by XY on 2023/3/7.
//
#import "XPMonentsEmptyCollectionViewCell.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor.h"
#import "UIImageConstant.h"
@interface XPMonentsEmptyCollectionViewCell()
@property (nonatomic,strong) UIImageView *emptyImageView;
@property (nonatomic,strong) UILabel *titleLabel;
@end
@implementation XPMonentsEmptyCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:self.emptyImageView];
[self.contentView addSubview:self.titleLabel];
}
- (void)initSubViewConstraints {
[self.emptyImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.contentView).offset(150);
make.centerX.mas_equalTo(self.contentView);
make.size.mas_equalTo(CGSizeMake(200, 200));
}];
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(self.emptyImageView.mas_bottom).offset(20);
make.left.right.mas_equalTo(self.contentView);
}];
}
#pragma mark - Getters And Setters
- (UIImageView *)emptyImageView {
if (!_emptyImageView) {
_emptyImageView = [[UIImageView alloc] init];
_emptyImageView.userInteractionEnabled = YES;
_emptyImageView.image = [UIImageConstant defalutEmptyPlaceholder];
_emptyImageView.layer.masksToBounds = YES;
_emptyImageView.contentMode = UIViewContentModeScaleAspectFit;
}
return _emptyImageView;
}
- (UILabel *)titleLabel {
if (!_titleLabel) {
_titleLabel = [[UILabel alloc] init];
_titleLabel.text = @"暂无数据";
_titleLabel.font = [UIFont systemFontOfSize:16];
_titleLabel.textAlignment = NSTextAlignmentCenter;
_titleLabel.textColor = [ThemeColor secondTextColor];
}
return _titleLabel;
}
@end

View File

@@ -18,8 +18,12 @@
/// VC
#import "XPMomentListViewController.h"
#import "XPMonentsPublishViewController.h"
#import "XPMonentTopicContainerViewController.h"
///P
#import "XPMonentsRecommendPresenter.h"
#import "XPMonentsRecommendProtocol.h"
@interface XPNewMomentsViewController ()<JXCategoryViewDelegate,JXPagerViewDelegate>
@interface XPNewMomentsViewController ()<JXCategoryViewDelegate,JXPagerViewDelegate,XPMonentsRecommendProtocol,XPMomentTopicHeaderViewDelegate>
///
@property (nonatomic, strong) JXCategoryTitleView *titleView;
@@ -38,6 +42,10 @@
@implementation XPNewMomentsViewController
- (__kindof id)createPresenter {
return [[XPMonentsRecommendPresenter alloc] init];
}
- (BOOL)isHiddenNavBar {
return YES;
}
@@ -45,6 +53,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
[self initSubViews];
[self.presenter getMonentsTopicList:1 pageSize:20];
}
#pragma mark - Private Method
@@ -73,9 +82,23 @@
[self.navigationController pushViewController:publishVC animated:YES];
}
#pragma mark - XPMomentTopicHeaderViewDelegate
- (void)momentTopicHeaderViewClickTopic:(MonentsTopicModel *)topicModel {
XPMonentTopicContainerViewController * topicVC = [[XPMonentTopicContainerViewController alloc] init];
topicVC.worldId = topicModel.tId;
[self.navigationController pushViewController:topicVC animated:YES];
}
#pragma mark - XPMonentsRecommendProtocol
- (void)monentsTopicListSuccess:(NSArray *)array {
self.headerView.topicList = array;
}
#pragma mark - JXCategoryViewDelegate
- (NSUInteger)tableHeaderViewHeightInPagerView:(JXPagerView *)pagerView {
return 100;
return [XPMomentTopicHeaderView getTopicHeaderViewHeight];
}
- (UIView *)tableHeaderViewInPagerView:(JXPagerView *)pagerView {
@@ -160,6 +183,7 @@
- (XPMomentTopicHeaderView *)headerView {
if (!_headerView) {
_headerView = [[XPMomentTopicHeaderView alloc] init];
_headerView.delegate = self;
}
return _headerView;
}
@@ -177,6 +201,7 @@
- (XPMomentListViewController *)recommandVC {
if (!_recommandVC) {
_recommandVC = [[XPMomentListViewController alloc] init];
_recommandVC.listType = XPMomentListRecommend;
}
return _recommandVC;
}
@@ -184,6 +209,7 @@
- (XPMomentListViewController *)latestVC {
if (!_latestVC) {
_latestVC = [[XPMomentListViewController alloc] init];
_latestVC.listType = XPMomentListTypeLatest;
}
return _latestVC;
}
@@ -191,6 +217,7 @@
- (XPMomentListViewController *)attentionVC {
if (!_attentionVC) {
_attentionVC = [[XPMomentListViewController alloc] init];
_attentionVC.listType = XPMomentListTypeAttent;
}
return _attentionVC;
}