//
//  GHRefreshCollectionView.h
//  GameHelper
//
//  Created by 青秀斌 on 16/12/29.
//  Copyright © 2016年 kylincc. All rights reserved.
//

#import <UIKit/UIKit.h>
@protocol GHRefreshCollectionViewDelegate;

NS_ASSUME_NONNULL_BEGIN

@interface GHRefreshCollectionView : UICollectionView
@property (weak, nonatomic) IBOutlet id<GHRefreshCollectionViewDelegate> refreshDelegate;

@property (strong, nonatomic, readonly) NSMutableArray *dataArray;
@property (assign, nonatomic, readonly) NSUInteger pageIndex;
@property (nonatomic, copy) void (^reloadView)(NSArray *list);  //自定义加载数据方法

@property (assign, nonatomic) BOOL allowShowMore;               //是否显示加载更多(默认显示)
@property (assign, nonatomic) BOOL allowShowBlank;              //是否显示占位图(默认显示)
@property (assign, nonatomic) BOOL allowShowNoNetworkBlank;     //是否显示无网占位图(默认显示)
@property (nullable, strong, nonatomic) NSString *blankImage;
@property (nullable, strong, nonatomic) NSString *blankTitle;
@property (nullable, strong, nonatomic) NSString *blankMessage;
@property (assign, nonatomic) CGFloat offsetY;
//针对个人中心主页 - 后台没有查询出数据时,默认加一条数据标记,此参数目的是为了此时依然展示占位图
@property (assign, nonatomic) BOOL noDataShowBlankByAddFakeDataFlag;

//针对个人中心主页 - 先出现一个暂无数据的空白页,之后才出现正确的空白页
-(void)closeBlankView;

- (void)refreshData;
@end

@protocol GHRefreshCollectionViewDelegate <NSObject>
@required
/**
 *  @author Jayla, 16-07-21 14:07:11
 *
 *  @brief 上拉加载和下拉刷新回调事件
 *
 *  @param collectionView   当前TableView
 *  @param pageIndex        加载页号(为0是即为下拉刷新)
 *  @param success          成功回调(传入当前页数据,页面将自动刷新)
 *  @param failure          失败回调(传入失败信息,页面将自动提示)
 */
- (void)collectionView:(GHRefreshCollectionView *)collectionView
             pageIndex:(NSUInteger)pageIndex
                offset:(NSInteger)offset
               success:(void (^)(NSArray * _Nullable list, BOOL hasNext))success
               failure:(void (^)(NSError *error))failure;

@end

NS_ASSUME_NONNULL_END