Skip to content
This repository has been archived by the owner on Jul 16, 2019. It is now read-only.

Commit

Permalink
Add progress view on grid cell
Browse files Browse the repository at this point in the history
  • Loading branch information
dineshflock committed Jan 18, 2018
1 parent 4fe9b3f commit 54c612d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions GMImagePicker/GMGridViewCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
@property (nonatomic) BOOL shouldShowSelection;
@property (nonatomic, strong) UIView *coverView;
@property (nonatomic, strong) UIButton *selectedButton;
@property (nonatomic, strong) UIActivityIndicatorView * progressView;

@property (nonatomic, assign, getter = isEnabled) BOOL enabled;


- (void)toggleProgressIndicatorToVisible:(BOOL)visible;
- (void)bind:(PHAsset *)asset;

@end
19 changes: 18 additions & 1 deletion GMImagePicker/GMGridViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ + (void)initialize
disabledColor = [UIColor colorWithWhite:1 alpha:0.9];
}

- (void)toggleProgressIndicatorToVisible:(BOOL)visible {
visible ? [self.progressView startAnimating] : [self.progressView stopAnimating];
}

- (void)awakeFromNib
{
[super awakeFromNib];
Expand Down Expand Up @@ -65,7 +69,7 @@ - (id)initWithFrame:(CGRect)frame
_imageView.clipsToBounds = YES;
_imageView.translatesAutoresizingMaskIntoConstraints = NO;
_imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self addSubview:_imageView];
[self.contentView addSubview:_imageView];


// The video gradient, label & icon
Expand Down Expand Up @@ -121,6 +125,14 @@ - (id)initWithFrame:(CGRect)frame
_selectedButton.hidden = NO;
_selectedButton.userInteractionEnabled = NO;
[self addSubview:_selectedButton];

_progressView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
[_progressView setFrame:self.bounds];
[_progressView setBackgroundColor:[UIColor colorWithWhite:0.3 alpha:0.5]];
_progressView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_progressView.hidden = YES;
[_progressView setHidesWhenStopped:YES];
[self.contentView addSubview:_progressView];
}

// Note: the views above are created in case this is toggled per cell, on the fly, etc.!
Expand All @@ -135,6 +147,11 @@ - (void)layoutSubviews {
_gradient.frame = _gradientView.bounds;
}

- (void)prepareForReuse {
[super prepareForReuse];
[_progressView stopAnimating];
}

- (void)bind:(PHAsset *)asset
{
self.asset = asset;
Expand Down

0 comments on commit 54c612d

Please sign in to comment.