Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ActivityIndicatorView and fixed bug that breaks contentInsets #20

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions CBStoreHouseRefreshControl.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/* Begin PBXBuildFile section */
0BFB9BAA1A084144008C790A /* CBStoreHouseRefreshControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 0BFB9BA91A084144008C790A /* CBStoreHouseRefreshControl.m */; };
38C679AD1A948C9F00AE1465 /* CBStoreHouseActivityIndicatorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 38C679AC1A948C9F00AE1465 /* CBStoreHouseActivityIndicatorView.m */; };
FF6F542D1A086CC200BE5C52 /* storehouse.plist in Resources */ = {isa = PBXBuildFile; fileRef = FF6F542C1A086CC200BE5C52 /* storehouse.plist */; };
FFB290C919FCC1320058F2BF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = FFB290C819FCC1320058F2BF /* main.m */; };
FFB290CC19FCC1320058F2BF /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = FFB290CB19FCC1320058F2BF /* AppDelegate.m */; };
Expand All @@ -31,6 +32,8 @@

/* Begin PBXFileReference section */
0BFB9BA91A084144008C790A /* CBStoreHouseRefreshControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CBStoreHouseRefreshControl.m; path = Class/CBStoreHouseRefreshControl.m; sourceTree = "<group>"; };
38C679AB1A948C9F00AE1465 /* CBStoreHouseActivityIndicatorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CBStoreHouseActivityIndicatorView.h; path = Class/CBStoreHouseActivityIndicatorView.h; sourceTree = "<group>"; };
38C679AC1A948C9F00AE1465 /* CBStoreHouseActivityIndicatorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CBStoreHouseActivityIndicatorView.m; path = Class/CBStoreHouseActivityIndicatorView.m; sourceTree = "<group>"; };
FF6F542C1A086CC200BE5C52 /* storehouse.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = storehouse.plist; sourceTree = "<group>"; };
FFB290C319FCC1320058F2BF /* CBStoreHouseRefreshControl.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CBStoreHouseRefreshControl.app; sourceTree = BUILT_PRODUCTS_DIR; };
FFB290C719FCC1320058F2BF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
Expand Down Expand Up @@ -137,6 +140,8 @@
FFFB8C951A02044C0007988E /* BarItem.m */,
FFFB8C981A02F7DC0007988E /* CBStoreHouseRefreshControl.h */,
0BFB9BA91A084144008C790A /* CBStoreHouseRefreshControl.m */,
38C679AB1A948C9F00AE1465 /* CBStoreHouseActivityIndicatorView.h */,
38C679AC1A948C9F00AE1465 /* CBStoreHouseActivityIndicatorView.m */,
);
name = Class;
sourceTree = "<group>";
Expand Down Expand Up @@ -247,6 +252,7 @@
FFB290CC19FCC1320058F2BF /* AppDelegate.m in Sources */,
0BFB9BAA1A084144008C790A /* CBStoreHouseRefreshControl.m in Sources */,
FFB290C919FCC1320058F2BF /* main.m in Sources */,
38C679AD1A948C9F00AE1465 /* CBStoreHouseActivityIndicatorView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -360,6 +366,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
);
INFOPLIST_FILE = CBStoreHouseRefreshControl/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand All @@ -371,6 +381,10 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)",
);
INFOPLIST_FILE = CBStoreHouseRefreshControl/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
Expand Down
48 changes: 39 additions & 9 deletions CBStoreHouseRefreshControl/ContentViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@

#import "ContentViewController.h"
#import "CBStoreHouseRefreshControl.h"
#import "CBStoreHouseActivityIndicatorView.h"

@interface ContentViewController ()

@property (nonatomic, weak) CBStoreHouseActivityIndicatorView* activityView;

@end

@implementation ContentViewController
Expand All @@ -35,31 +38,58 @@ - (void)viewDidLoad {
self.tableView.tableFooterView = footer;

// Let the show begins
self.storeHouseRefreshControl = [CBStoreHouseRefreshControl attachToScrollView:self.tableView target:self refreshAction:@selector(refreshTriggered:) plist:@"storehouse" color:[UIColor whiteColor] lineWidth:1.5 dropHeight:80 scale:1 horizontalRandomness:150 reverseLoadingAnimation:YES internalAnimationFactor:0.5];
self.storeHouseRefreshControl = [CBStoreHouseRefreshControl attachToScrollView:self.tableView target:self refreshAction:@selector(refreshTriggered:) plist:@"AKTA" color:[UIColor whiteColor] lineWidth:1.5 dropHeight:80 scale:1 horizontalRandomness:150 reverseLoadingAnimation:YES internalAnimationFactor:0.5];

//self.storeHouseRefreshControl = [CBStoreHouseRefreshControl attachToScrollView:self.tableView target:self refreshAction:@selector(refreshTriggered:) plist:@"AKTA" color:[UIColor whiteColor] lineWidth:2 dropHeight:80 scale:0.7 horizontalRandomness:300 reverseLoadingAnimation:NO internalAnimationFactor:0.7];
}

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];

UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cell"]];
image.translatesAutoresizingMaskIntoConstraints = NO;
[cell.contentView addSubview:image];

[cell.contentView addConstraint:[NSLayoutConstraint constraintWithItem:image attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]];
[cell.contentView addConstraint:[NSLayoutConstraint constraintWithItem:image attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]];
if (indexPath.row == 1)
{
UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"cell"]];
image.translatesAutoresizingMaskIntoConstraints = NO;
[cell.contentView addSubview:image];

[cell.contentView addConstraint:[NSLayoutConstraint constraintWithItem:image attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeCenterX multiplier:1 constant:0]];
[cell.contentView addConstraint:[NSLayoutConstraint constraintWithItem:image attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:cell.contentView attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]];
}
else
{
CBStoreHouseActivityIndicatorView *activityIndicator = [[CBStoreHouseActivityIndicatorView alloc] initWithPlist:@"AKTA"];

CGRect frame = activityIndicator.frame;
frame.origin.y = 100.0;
activityIndicator.frame = frame;

[cell.contentView addSubview:activityIndicator];

activityIndicator.hasLoadingAnimation = YES;
activityIndicator.animating = YES;

self.activityView = activityIndicator;

[self performSelector:@selector(stopActivity) withObject:nil afterDelay:5.0];

}

cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.backgroundColor = [UIColor clearColor];

return cell;
}

- (void)stopActivity
{
self.activityView.animating = NO;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
Expand Down
62 changes: 62 additions & 0 deletions Class/CBStoreHouseActivityIndicatorView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
//
// CBStoreHouseActivityIndicatorView.h
// CBStoreHouseRefreshControl
//
// Created by Dal Rupnik on 18/02/15.
// Copyright (c) 2015 Suyu Zhang. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface CBStoreHouseActivityIndicatorView : UIView

/*!
* Color of the shape provided on constructor
*/
@property (nonatomic, strong) UIColor* color;

@property (nonatomic, assign) CGFloat lineWidth;
@property (nonatomic, assign) CGFloat scale;
@property (nonatomic, assign) CGFloat pointScale;

@property (nonatomic, assign) CGFloat animationHeight;
@property (nonatomic, assign) CGFloat horizontalRandomness;

@property (nonatomic, assign) BOOL reverseLoadingAnimation;

/*!
* Loading animation will first construct the item and deconstuct
*/
@property (nonatomic, assign) BOOL hasLoadingAnimation;

@property (nonatomic, assign) NSTimeInterval loadingAnimationDuration;
@property (nonatomic, assign) NSTimeInterval indeterminateAnimationTiming;
@property (nonatomic, assign) NSTimeInterval indeterminateAnimationOffset;

@property (nonatomic, assign, getter = isAnimating) BOOL animating;

/*!
* Loads points from Plist
*
* @param frame to display
* @param plist to render
*
* @return instance of view
*/
- (instancetype)initWithPlist:(NSString *)plist;

/*!
* Designated initializer: Shape of made from CGPoint structs
*
* @param startPoints array of points
* @param endPoints array of points
*
* @return instance
*/
- (instancetype)initWithStartPoints:(NSArray *)startPoints endPoints:(NSArray *)endPoints;

- (void)setStartPoints:(NSArray *)startPoints endPoints:(NSArray *)endPoints;

- (void)setPointsWithPlist:(NSString *)plist;

@end
Loading