-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from grigaci/features/infiniteTableView
Add infinite table view
- Loading branch information
Showing
181 changed files
with
5,349 additions
and
8,059 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// UIView+BILoadXib.h | ||
// Pods | ||
// | ||
// Created by Mihai Chifor on 7/16/15. | ||
// | ||
// Copyright © 2015 iGama Apps. All rights reserved. | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface UIView (BILoadXib) | ||
|
||
+ (nonnull instancetype)viewFromXib; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// UIView+BILoadXib.m | ||
// Pods | ||
// | ||
// Created by Mihai Chifor on 7/16/15. | ||
// | ||
// Copyright © 2015 iGama Apps. All rights reserved. | ||
|
||
#import "UIView+BILoadXib.h" | ||
|
||
@implementation UIView (BILoadXib) | ||
|
||
+ (nonnull instancetype)viewFromXib { | ||
NSString *className = NSStringFromClass(self); | ||
UIView *view = [[NSBundle mainBundle] loadNibNamed:className owner:nil options:nil][0]; | ||
|
||
NSAssert([view isKindOfClass:self], @"View class should match"); | ||
|
||
return view; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// BIBaseDefines.h | ||
// BIObjCHelpers | ||
// | ||
// Created by Mihai Chifor on 7/16/15. | ||
// Copyright © 2015 iGama Apps. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
typedef NS_OPTIONS(NSInteger, BIScrollDirection) { | ||
BIScrollDirectionNone = 0, | ||
BIScrollDirectionRight = 1 << 0, | ||
BIScrollDirectionLeft = 1 << 1, | ||
BIScrollDirectionUp = 1 << 2, | ||
BIScrollDirectionDown = 1 << 3 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
BIObjCHelpers/Views/ActivityIndicator/BIActivityIndicatorContainerView.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// BIActivityIndicatorContainerView.h | ||
// BIObjCHelpers | ||
// | ||
// Created by Bogdan Iusco on 20/07/15. | ||
// Copyright (c) 2015 iGama Apps. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface BIActivityIndicatorContainerView : UIView | ||
|
||
- (nonnull instancetype)initWithFrame:(CGRect)frame NS_DESIGNATED_INITIALIZER; | ||
|
||
@property (nonatomic, strong, nonnull, readonly) UIActivityIndicatorView *activityIndicatorView; | ||
|
||
@end |
53 changes: 53 additions & 0 deletions
53
BIObjCHelpers/Views/ActivityIndicator/BIActivityIndicatorContainerView.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// BIActivityIndicatorContainerView.m | ||
// BIObjCHelpers | ||
// | ||
// Created by Bogdan Iusco on 20/07/15. | ||
// Copyright (c) 2015 iGama Apps. All rights reserved. | ||
// | ||
|
||
#import "BIActivityIndicatorContainerView.h" | ||
|
||
@interface BIActivityIndicatorContainerView () | ||
|
||
@property (nonatomic, strong, nonnull, readwrite) UIActivityIndicatorView *activityIndicatorView; | ||
|
||
@end | ||
|
||
|
||
@implementation BIActivityIndicatorContainerView | ||
|
||
#pragma mark - Init methods | ||
|
||
- (nonnull instancetype)initWithFrame:(CGRect)frame { | ||
self = [super initWithFrame:frame]; | ||
if (self) { | ||
[self addSubview:self.activityIndicatorView]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)layoutSubviews { | ||
[super layoutSubviews]; | ||
CGPoint center = CGPointMake(CGRectGetWidth(self.bounds) / 2.f, CGRectGetHeight(self.bounds) / 2.f); | ||
self.activityIndicatorView.center = center; | ||
} | ||
|
||
#pragma mark - UIView methods | ||
|
||
- (void)setHidden:(BOOL)hidden { | ||
hidden? [self.activityIndicatorView stopAnimating] : [self.activityIndicatorView startAnimating]; | ||
[super setHidden:hidden]; | ||
} | ||
|
||
#pragma mark - Property methods | ||
|
||
- (UIActivityIndicatorView *)activityIndicatorView { | ||
if (!_activityIndicatorView) { | ||
_activityIndicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; | ||
[_activityIndicatorView startAnimating]; | ||
} | ||
return _activityIndicatorView; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// | ||
// BITableView.h | ||
// BIObjCHelpers | ||
// | ||
// Created by Mihai Chifor on 7/16/15. | ||
// Copyright © 2015 iGama Apps. All rights reserved. | ||
// | ||
|
||
#import "BIScrollDirection.h" | ||
#import "BITableViewCell.h" | ||
#import <UIKit/UIKit.h> | ||
|
||
/*! | ||
@typedef BIInfiniteScrollingState | ||
@abstract Represents the state of the tableView infinite scroll | ||
@field BIInfiniteScrollingStateStopped The tableView is currently not fetching any batches | ||
@field BIInfiniteScrollingStateLoading The tableView is currently fetching batches | ||
*/ | ||
typedef NS_OPTIONS(NSInteger, BIInfiniteScrollingState) { | ||
BIInfiniteScrollingStateStopped = 0, | ||
BIInfiniteScrollingStateLoading = 1 | ||
}; | ||
|
||
/*! | ||
@abstract Determine if batch fetching should begin based on the state of the parameters. | ||
@param scrollDirection The current scrolling direction of the scroll view. | ||
@param bounds The bounds of the scrollview. | ||
@param contentSize The content size of the scrollview. | ||
@param targetOffset The offset that the scrollview will scroll to. | ||
@param leadingScreens How many screens in the remaining distance will trigger batch fetching. | ||
@return Whether or not the current state should proceed with batch fetching. | ||
@discussion This method is broken into a category for unit testing purposes and should be used with the BITableView and | ||
* BICollectionView batch fetching API. | ||
*/ | ||
extern BOOL BIDisplayShouldFetchBatch(BIScrollDirection scrollDirection, | ||
CGRect bounds, | ||
CGSize contentSize, | ||
CGPoint targetOffset, | ||
CGFloat leadingScreens); | ||
|
||
extern const CGFloat kBILeadingScreens; | ||
extern const CGFloat kBITableFooterViewAnimationDuration; | ||
|
||
@class BIActivityIndicatorContainerView; | ||
|
||
/*! | ||
@brief Table view with infinite scrolling support. | ||
@note There is one limitation to this table view. Setting its delegate to nil causes the infinite scrolling | ||
to not work. | ||
*/ | ||
@interface BITableView : UITableView | ||
|
||
/*! | ||
@callback infiniteScrollingCallback Used to notify dataSource to fetch the next batch | ||
*/ | ||
@property (nonatomic, copy, nullable) void (^infiniteScrollingCallback)(); | ||
|
||
/*! | ||
@field enableInfiniteScrolling specifies whether the scrolling of the tableView is infinite or not | ||
@discussion If it is set to NO, no other batches are fetched. Default is YES | ||
*/ | ||
|
||
@property (nonatomic, assign) BOOL enableInfiniteScrolling; | ||
|
||
/*! | ||
@field leadingScreens Represents the number of screens left to scroll before triggering the fetch of the next batch | ||
@discussion Default is 0.5f (half of screen) | ||
*/ | ||
@property (nonatomic, assign) CGFloat leadingScreens; | ||
|
||
/*! | ||
@field activityIndicatorContainer Activity indicator that is displayed on the tableView footer while a new batch is fetched | ||
@discussion Used as table footer view. Override it for further customization | ||
*/ | ||
@property (nonatomic, strong, nonnull, readonly) BIActivityIndicatorContainerView *activityIndicatorContainer; | ||
|
||
@property (nonatomic, assign) BIInfiniteScrollingState infiniteScrollingState; | ||
|
||
- (void)triggerInfiniteScrolling; | ||
|
||
@end |
Oops, something went wrong.