Skip to content

Commit

Permalink
Merge pull request #20 from mrackwitz/development
Browse files Browse the repository at this point in the history
Version 0.3
  • Loading branch information
mrackwitz committed Jan 13, 2014
2 parents a162c78 + b175f44 commit 96726c2
Show file tree
Hide file tree
Showing 18 changed files with 494 additions and 197 deletions.
83 changes: 70 additions & 13 deletions Example/Base.lproj/Main_iPhone.storyboard

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Example/MRActivityIndicatorViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@interface MRActivityIndicatorViewController () <MRColorPaletteDelegate>

@property (weak, nonatomic) IBOutlet MRActivityIndicatorView *activityIndicatorView;
@property (weak, nonatomic) IBOutlet UISwitch *stopButtonSwitch;

@end

Expand All @@ -33,6 +34,10 @@ - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
}
}

- (IBAction)onStopButtonSwitchValueChanged:(id)sender {
self.activityIndicatorView.mayStop = self.stopButtonSwitch.on;
}

- (void)colorPaletteViewController:(MRColorPaletteViewController *)colorPaletteViewController didSelectColor:(UIColor *)color {
self.activityIndicatorView.tintColor = color;
}
Expand Down
2 changes: 1 addition & 1 deletion Example/MRCircularProgressViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ @implementation MRCircularProgressViewController
- (void)viewDidLoad {
[super viewDidLoad];

[self.circularProgressView addTarget:self action:@selector(onCircularProgressViewTouchUpInside:) forControlEvents:UIControlEventTouchUpInside];
[self.circularProgressView.stopButton addTarget:self action:@selector(onCircularProgressViewTouchUpInside:) forControlEvents:UIControlEventTouchUpInside];
}

- (IBAction)onProgressSliderValueChanged:(id)sender {
Expand Down
20 changes: 20 additions & 0 deletions Example/MRProgressOverlayTableViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ - (IBAction)onShowIndeterminateProgressView:(id)sender {
} afterDelay:2.0];
}

- (IBAction)onShowIndeterminateMayStopProgressView:(id)sender {
MRProgressOverlayView *progressView = [MRProgressOverlayView new];
progressView.mode = MRProgressOverlayViewModeDeterminateCircular;
progressView.stopBlock = ^(MRProgressOverlayView *view){
[view dismiss:YES];
};
[self.rootView addSubview:progressView];
[self simulateProgressView:progressView];
}

- (IBAction)onShowIndeterminateNoTextProgressView:(id)sender {
MRProgressOverlayView *progressView = [MRProgressOverlayView new];
progressView.titleLabelText = @"";
Expand All @@ -51,6 +61,16 @@ - (IBAction)onShowDeterminateCircularProgressView:(id)sender {
[self simulateProgressView:progressView];
}

- (IBAction)onShowDeterminateCircularMayStopProgressView:(id)sender {
MRProgressOverlayView *progressView = [MRProgressOverlayView new];
progressView.mode = MRProgressOverlayViewModeDeterminateCircular;
progressView.stopBlock = ^(MRProgressOverlayView *view){
[view dismiss:YES];
};
[self.rootView addSubview:progressView];
[self simulateProgressView:progressView];
}

- (IBAction)onShowDeterminateCircularNoTextProgressView:(id)sender {
MRProgressOverlayView *progressView = [MRProgressOverlayView new];
progressView.titleLabelText = @"";
Expand Down
Binary file added Images/circular_determinate.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/circular_indeterminate.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions MRProgress.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Pod::Spec.new do |s|
s.version = '0.2.2'
s.summary = 'Collection of iOS drop-in components to visualize progress with different modes'
s.homepage = 'https://github.com/mrackwitz/MRProgress'
s.social_media_url = 'https://twitter.com/mrackwitz'
s.author = { 'Marius Rackwitz' => '[email protected]' }
s.license = 'MIT License'
s.source = { :git => 'https://github.com/mrackwitz/MRProgress.git', :tag => s.version.to_s }
Expand Down
10 changes: 10 additions & 0 deletions MRProgress.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
29CE9679186E0129006006B0 /* MRStopButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CE9677186E0129006006B0 /* MRStopButton.h */; settings = {ATTRIBUTES = (Public, ); }; };
29CE967A186E0129006006B0 /* MRStopButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 29CE9678186E0129006006B0 /* MRStopButton.m */; };
710BD58B1816AD3700654750 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 710BD58A1816AD3700654750 /* QuartzCore.framework */; };
710BD5AD1817353E00654750 /* MRBlurView.h in Headers */ = {isa = PBXBuildFile; fileRef = 710BD5961817353E00654750 /* MRBlurView.h */; settings = {ATTRIBUTES = (Public, ); }; };
710BD5AE1817353E00654750 /* MRBlurView.m in Sources */ = {isa = PBXBuildFile; fileRef = 710BD5971817353E00654750 /* MRBlurView.m */; };
Expand Down Expand Up @@ -35,6 +37,9 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
299730941881CB520022B27B /* MRStopableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MRStopableView.h; sourceTree = "<group>"; };
29CE9677186E0129006006B0 /* MRStopButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MRStopButton.h; sourceTree = "<group>"; };
29CE9678186E0129006006B0 /* MRStopButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MRStopButton.m; sourceTree = "<group>"; };
710BD58A1816AD3700654750 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
710BD5961817353E00654750 /* MRBlurView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MRBlurView.h; sourceTree = "<group>"; };
710BD5971817353E00654750 /* MRBlurView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MRBlurView.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -104,6 +109,9 @@
710BD5A41817353E00654750 /* MRNavigationBarProgressView.m */,
710BD5A51817353E00654750 /* MRProgressOverlayView.h */,
710BD5A61817353E00654750 /* MRProgressOverlayView.m */,
299730941881CB520022B27B /* MRStopableView.h */,
29CE9677186E0129006006B0 /* MRStopButton.h */,
29CE9678186E0129006006B0 /* MRStopButton.m */,
);
path = Components;
sourceTree = "<group>";
Expand Down Expand Up @@ -191,6 +199,7 @@
710BD5BD1817353E00654750 /* MRMessageInterceptor.h in Headers */,
710BD5B91817353E00654750 /* MRNavigationBarProgressView.h in Headers */,
710BD5C01817353E00654750 /* MRWeakProxy.h in Headers */,
29CE9679186E0129006006B0 /* MRStopButton.h in Headers */,
710BD5B31817353E00654750 /* MRCircularProgressView.h in Headers */,
710BD5B11817353E00654750 /* MRActivityIndicatorView.h in Headers */,
7197CF011816A1A10022A19D /* MRProgress.h in Headers */,
Expand Down Expand Up @@ -275,6 +284,7 @@
710BD5BC1817353E00654750 /* MRProgressOverlayView.m in Sources */,
710BD5B01817353E00654750 /* UIImage+MRImageEffects.m in Sources */,
710BD5AE1817353E00654750 /* MRBlurView.m in Sources */,
29CE967A186E0129006006B0 /* MRStopButton.m in Sources */,
710BD5B41817353E00654750 /* MRCircularProgressView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
67 changes: 35 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ MRProgress is a collection of drop-in components that display a dimmed overlay w
[![](Images/screenshot_009_2.jpg)](Images/screenshot_009.png)
[![](Images/screenshot_010_2.jpg)](Images/screenshot_010.png)

* **Component oriented**: You don't have to use all components or ```MRProgressOverlayView```. You can use just the custom activity indicators or progress views.
* **Component oriented**: You don't have to use all components or `MRProgressOverlayView`. You can use just the custom activity indicators or progress views.
* **Configurable**: All components implement tintColor.
* **Customizable**: You can replace the given blur implementation and hook into your own you are maybe already using in other places of your app. Or simply throw in an [UIToolbar's layer](https://github.com/JagCesar/iOS-blur), if you prefer Apple's implementation. (Current blur implementation is as given by sample code of WWDC 2013.)
* **Reusable**: The code is fragmented in small reusable pieces.
Expand All @@ -22,56 +22,59 @@ MRProgress is a collection of drop-in components that display a dimmed overlay w

## Components

The components used in ```MRProgressOverlayView``` could be used seperately.
The components used in `MRProgressOverlayView` could be used seperately.
The provided Example app demonstrates how they can be used.

### ```MRProgressOverlayView```
### `MRProgressOverlayView`

![](Images/screenshot_004_1.jpg)

* Supports different modes
* Animated show and hide
* Blured background
* With UIMotionEffects for tilting like ```UIAlertView```
* With UIMotionEffects for tilting like `UIAlertView`
* Supports multi-line title label text


### ```MRCircularProgressView```
### `MRCircularProgressView`

![](Images/screenshot_001_1.jpg)
![](Images/circular_determinate.gif)
![](Images/screenshot_002_1.jpg)

* Tint color can be changed
* Circular progress view like in AppStore
* Inherits from ```UIControl``` and can display a stop button
* Animated with ```CADisplayLink```
* Can display a stop button
* Animated with `CABasicAnimation`
* Percentage label change is animated over a `NSTimer`


### ```MRNavigationBarProgressView```
### `MRNavigationBarProgressView`

![](Images/screenshot_003_1.jpg)

* Display a progress view in a ```UINavigationController```
* Hooks ```UINavigationControllerDelegate``` and is automatically removed on push or pop
* Can be used in ```UINavigationBar``` or ```UIToolbar```
* Display a progress view in a `UINavigationController`
* Hooks `UINavigationControllerDelegate` and is automatically removed on push or pop
* Can be used in `UINavigationBar` or `UIToolbar`


### ```MRCheckmarkIconView``` and ```MRCrossIconView```
### `MRCheckmarkIconView` and `MRCrossIconView`

![](Images/screenshot_011_1.jpg)

* Tint color can be changed
* Scalable
* Animatable
* Backed by ```CAShapeLayer```
* Backed by `CAShapeLayer`


### ```MRActivityIndicatorView```
### `MRActivityIndicatorView`

![](Images/screenshot_012_1.jpg)
![](Images/circular_indeterminate.gif)

* Tint color can be changed
* Same API as ```UIActivityIndicatorView```
* Animated with ```CABasicAnimation```
* Same API as `UIActivityIndicatorView`
* Can display a stop button
* Animated with `CABasicAnimation`



Expand All @@ -81,24 +84,24 @@ The provided Example app demonstrates how they can be used.

[CocoaPods](http://www.cocoapods.org) is the recommended way to add MRProgress to your project.

1. Add a pod entry for MRProgress to your *Podfile* ```pod 'MRProgress', '~> 0.2'```.
2. Install the pod(s) by running ```pod install```.
3. Include MRProgress wherever you need it with ```#import "MRProgress.h"```.
1. Add a pod entry for MRProgress to your *Podfile* `pod 'MRProgress', '~> 0.3'`.
2. Install the pod(s) by running `pod install`.
3. Include MRProgress wherever you need it with `#import "MRProgress.h"`.


### Source files

1. Download the [latest code version](http://github.com/mrackwitz/MRProgress/archive/master.zip) or add the repository as a git submodule to your git-tracked project.
2. Drag and drop the **src** directory from the archive in your project navigator. Make sure to select *Copy items* when asked if you extracted the code archive outside of your project.
3. Include MRProgress wherever you need any component with ```#import "MRProgress.h"```.
3. Include MRProgress wherever you need any component with `#import "MRProgress.h"`.


### Static library

1. Drag and drop **MRProgress.xcodeproj** in your project navigator.
2. Select your target and go to the *Build Phases* tab. In the *Link Binary With Libraries* section select the add button. On the sheet find and add libMRProgress.a.
3. Add Target **MRProgress** to your *Target Dependencies* list.
4. ```import <MRProgress/MRProgress.h>``` whereever you want to use the components. You could add it to your Prefix header file, if you want.
4. `import <MRProgress/MRProgress.h>` whereever you want to use the components. You could add it to your Prefix header file, if you want.



Expand Down Expand Up @@ -164,15 +167,15 @@ Make sure you also see [MRProgress documentation on Cocoadocs](http://cocoadocs.

### Modes

Name (```MRProgressOverlayView<...>```) | Screenshot | Description
---------------------------------------- | --------------------------------------------------------------- | :-----------
**Indeterminate** | [![](Images/screenshot_004_2.jpg)](Images/screenshot_004.png) | Progress is shown using a large round activity indicator view. (```MRActivityIndicatorView```) This is the default.
**DeterminateCircular** | [![](Images/screenshot_005_2.jpg)](Images/screenshot_005.png) | Progress is shown using a round, pie-chart like, progress view. (```MRCircularProgressView```)
**DeterminateHorizontalBar** | [![](Images/screenshot_006_2.jpg)](Images/screenshot_006.png) | Progress is shown using a horizontal progress bar. (```UIProgressView```)
**IndeterminateSmall** | [![](Images/screenshot_007_2.jpg)](Images/screenshot_007.png) | Shows primarily a label. Progress is shown using a small activity indicator. (```MRActivityIndicatorView```)
**IndeterminateSmallDefault** | [![](Images/screenshot_008_2.jpg)](Images/screenshot_008.png) | Shows primarily a label. Progress is shown using a small activity indicator. (```UIActivityIndicatorView``` in ```UIActivityIndicatorViewStyleGray```)
**Checkmark** | [![](Images/screenshot_009_2.jpg)](Images/screenshot_009.png) | Shows a checkmark. (```MRCheckmarkIconView```)
**Cross** | [![](Images/screenshot_010_2.jpg)](Images/screenshot_010.png) | Shows a cross. (```MRCrossIconView```)
Name (`MRProgressOverlayView<...>`) | Screenshot | Description
------------------------------------ | ------------------------------------------------------------- | :-----------
**Indeterminate** | [![](Images/screenshot_004_2.jpg)](Images/screenshot_004.png) | Progress is shown using a large round activity indicator view. (`MRActivityIndicatorView`) This is the default.
**DeterminateCircular** | [![](Images/screenshot_005_2.jpg)](Images/screenshot_005.png) | Progress is shown using a round, pie-chart like, progress view. (`MRCircularProgressView`)
**DeterminateHorizontalBar** | [![](Images/screenshot_006_2.jpg)](Images/screenshot_006.png) | Progress is shown using a horizontal progress bar. (`UIProgressView`)
**IndeterminateSmall** | [![](Images/screenshot_007_2.jpg)](Images/screenshot_007.png) | Shows primarily a label. Progress is shown using a small activity indicator. (`MRActivityIndicatorView`)
**IndeterminateSmallDefault** | [![](Images/screenshot_008_2.jpg)](Images/screenshot_008.png) | Shows primarily a label. Progress is shown using a small activity indicator. (`UIActivityIndicatorView` in `UIActivityIndicatorViewStyleGray`)
**Checkmark** | [![](Images/screenshot_009_2.jpg)](Images/screenshot_009.png) | Shows a checkmark. (`MRCheckmarkIconView`)
**Cross** | [![](Images/screenshot_010_2.jpg)](Images/screenshot_010.png) | Shows a cross. (`MRCrossIconView`)



Expand Down
3 changes: 2 additions & 1 deletion src/Components/MRActivityIndicatorView.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
//

#import <UIKit/UIKit.h>
#import "MRStopableView.h"


/**
Use an activity indicator to show that a task is in progress. An activity indicator appears as a circle slice that is
either spinning or stopped.
*/
@interface MRActivityIndicatorView : UIControl {
@interface MRActivityIndicatorView : UIView<MRStopableView> {
@package
BOOL _animating;
}
Expand Down
54 changes: 38 additions & 16 deletions src/Components/MRActivityIndicatorView.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,24 @@

#import <QuartzCore/QuartzCore.h>
#import "MRActivityIndicatorView.h"
#import "MRStopButton.h"


NSString *const MRActivityIndicatorViewSpinAnimationKey = @"MRActivityIndicatorViewSpinAnimationKey";


@interface MRActivityIndicatorView ()

@property (nonatomic, weak) CAShapeLayer *shapeLayer;
@property (nonatomic, weak, readwrite) MRStopButton *stopButton;

@end


@implementation MRActivityIndicatorView

@synthesize stopButton = _stopButton;

- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
Expand All @@ -36,19 +42,21 @@ - (id)initWithCoder:(NSCoder *)aDecoder {
return self;
}

+ (Class)layerClass {
return CAShapeLayer.class;
}

- (CAShapeLayer *)shapeLayer {
return (CAShapeLayer *)self.layer;
}

- (void)commonInit {
self.hidesWhenStopped = YES;
self.layer.borderWidth = 0;
self.shapeLayer.lineWidth = 2.0f;
self.shapeLayer.fillColor = UIColor.clearColor.CGColor;

CAShapeLayer *shapeLayer = [CAShapeLayer new];
shapeLayer.borderWidth = 0;
shapeLayer.lineWidth = 2.0f;
shapeLayer.fillColor = UIColor.clearColor.CGColor;
[self.layer addSublayer:shapeLayer];
self.shapeLayer = shapeLayer;

MRStopButton *stopButton = [MRStopButton new];
[self addSubview:stopButton];
self.stopButton = stopButton;

self.mayStop = NO;
}

- (void)dealloc {
Expand Down Expand Up @@ -85,16 +93,18 @@ - (void)applicationWillEnterForeground:(NSNotificationCenter *)note {
- (void)layoutSubviews {
[super layoutSubviews];

CGRect frame = self.frame;
CGRect frame = self.bounds;
if (frame.size.width != frame.size.height) {
// Ensure that we have a square frame
CGFloat s = MAX(frame.size.width, frame.size.height);
CGFloat s = MIN(frame.size.width, frame.size.height);
frame.size.width = s;
frame.size.height = s;
self.frame = frame;
}
self.shapeLayer.frame = frame;

self.shapeLayer.path = [self layoutPath].CGPath;

self.stopButton.frame = [self.stopButton frameThatFits:self.bounds];
}

- (UIBezierPath *)layoutPath {
Expand All @@ -116,6 +126,7 @@ - (UIBezierPath *)layoutPath {
- (void)tintColorDidChange {
[super tintColorDidChange];
self.shapeLayer.strokeColor = self.tintColor.CGColor;
self.stopButton.tintColor = self.tintColor;
}


Expand All @@ -130,6 +141,17 @@ - (CGFloat)lineWidth {
}


#pragma mark - MRStopableView's implementation

- (void)setMayStop:(BOOL)mayStop {
self.stopButton.hidden = !mayStop;
}

- (BOOL)mayStop {
return !self.stopButton.hidden;
}


#pragma mark - Control animation

- (void)startAnimating {
Expand Down Expand Up @@ -177,11 +199,11 @@ - (void)addAnimation {
spinAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
spinAnimation.duration = 1.0;
spinAnimation.repeatCount = INFINITY;
[self.layer addAnimation:spinAnimation forKey:MRActivityIndicatorViewSpinAnimationKey];
[self.shapeLayer addAnimation:spinAnimation forKey:MRActivityIndicatorViewSpinAnimationKey];
}

- (void)removeAnimation {
[self.layer removeAnimationForKey:MRActivityIndicatorViewSpinAnimationKey];
[self.shapeLayer removeAnimationForKey:MRActivityIndicatorViewSpinAnimationKey];
}

@end
Loading

0 comments on commit 96726c2

Please sign in to comment.