Skip to content

Commit

Permalink
release version
Browse files Browse the repository at this point in the history
  • Loading branch information
xcatsan committed Mar 30, 2011
1 parent 5152f80 commit 67f7384
Show file tree
Hide file tree
Showing 6 changed files with 397 additions and 37 deletions.
16 changes: 11 additions & 5 deletions FBProgressView.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
4CB3224E1342CDF1008FC946 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 4CB3224C1342CDF1008FC946 /* InfoPlist.strings */; };
4CB322511342CDF1008FC946 /* FBProgressViewTests.h in Resources */ = {isa = PBXBuildFile; fileRef = 4CB322501342CDF1008FC946 /* FBProgressViewTests.h */; };
4CB322531342CDF1008FC946 /* FBProgressViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CB322521342CDF1008FC946 /* FBProgressViewTests.m */; };
4CB3225E1342CE11008FC946 /* FBProgressView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4CB3225D1342CE11008FC946 /* FBProgressView.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -37,19 +38,21 @@
4CB322291342CDF0008FC946 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
4CB3222B1342CDF0008FC946 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
4CB3222D1342CDF0008FC946 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
4CB322311342CDF0008FC946 /* FBProgressView-Info.plist */ = {isa = PBXFileReference; path = "FBProgressView-Info.plist"; sourceTree = "<group>"; };
4CB322311342CDF0008FC946 /* FBProgressView-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "FBProgressView-Info.plist"; sourceTree = "<group>"; };
4CB322331342CDF0008FC946 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
4CB322351342CDF0008FC946 /* FBProgressView-Prefix.pch */ = {isa = PBXFileReference; path = "FBProgressView-Prefix.pch"; sourceTree = "<group>"; };
4CB322351342CDF0008FC946 /* FBProgressView-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FBProgressView-Prefix.pch"; sourceTree = "<group>"; };
4CB322361342CDF0008FC946 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
4CB322381342CDF0008FC946 /* FBProgressViewAppDelegate.h */ = {isa = PBXFileReference; path = FBProgressViewAppDelegate.h; sourceTree = "<group>"; };
4CB322381342CDF0008FC946 /* FBProgressViewAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBProgressViewAppDelegate.h; sourceTree = "<group>"; };
4CB322391342CDF0008FC946 /* FBProgressViewAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBProgressViewAppDelegate.m; sourceTree = "<group>"; };
4CB3223C1342CDF1008FC946 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainWindow.xib; sourceTree = "<group>"; };
4CB322431342CDF1008FC946 /* FBProgressViewTests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FBProgressViewTests.octest; sourceTree = BUILT_PRODUCTS_DIR; };
4CB3224B1342CDF1008FC946 /* FBProgressViewTests-Info.plist */ = {isa = PBXFileReference; path = "FBProgressViewTests-Info.plist"; sourceTree = "<group>"; };
4CB3224B1342CDF1008FC946 /* FBProgressViewTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "FBProgressViewTests-Info.plist"; sourceTree = "<group>"; };
4CB3224D1342CDF1008FC946 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
4CB3224F1342CDF1008FC946 /* FBProgressViewTests-Prefix.pch */ = {isa = PBXFileReference; path = "FBProgressViewTests-Prefix.pch"; sourceTree = "<group>"; };
4CB3224F1342CDF1008FC946 /* FBProgressViewTests-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FBProgressViewTests-Prefix.pch"; sourceTree = "<group>"; };
4CB322501342CDF1008FC946 /* FBProgressViewTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBProgressViewTests.h; sourceTree = "<group>"; };
4CB322521342CDF1008FC946 /* FBProgressViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBProgressViewTests.m; sourceTree = "<group>"; };
4CB3225C1342CE11008FC946 /* FBProgressView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBProgressView.h; sourceTree = "<group>"; };
4CB3225D1342CE11008FC946 /* FBProgressView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBProgressView.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -112,6 +115,8 @@
4CB322391342CDF0008FC946 /* FBProgressViewAppDelegate.m */,
4CB3223B1342CDF1008FC946 /* MainWindow.xib */,
4CB322301342CDF0008FC946 /* Supporting Files */,
4CB3225C1342CE11008FC946 /* FBProgressView.h */,
4CB3225D1342CE11008FC946 /* FBProgressView.m */,
);
path = FBProgressView;
sourceTree = "<group>";
Expand Down Expand Up @@ -253,6 +258,7 @@
files = (
4CB322371342CDF0008FC946 /* main.m in Sources */,
4CB3223A1342CDF0008FC946 /* FBProgressViewAppDelegate.m in Sources */,
4CB3225E1342CE11008FC946 /* FBProgressView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
32 changes: 32 additions & 0 deletions FBProgressView/FBProgressView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// FBProgressView.h
// FBProgressView
//
// Created by Hiroshi Hashiguchi on 11/03/30.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>

typedef enum {
FBProgressViewStyleDefault = 0,
FBProgressViewStyleGray,
FBProgressViewStyleWhite
} FBProgressViewStyle;

@interface FBProgressView : UIView {

UIColor* color_;
CGFloat lineWidth_;
UIBezierPath* outlinePath_;
FBProgressViewStyle progressViewStyle_;
float progress_;
BOOL hidesUntilStart_;
BOOL started_;
}
@property (nonatomic, assign) CGFloat lineWidth;
@property (nonatomic, assign) FBProgressViewStyle progressViewStyle;
@property (nonatomic, assign) float progress;
@property (nonatomic, assign) BOOL hidesUntilStart;

@end
167 changes: 167 additions & 0 deletions FBProgressView/FBProgressView.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
//
// FBProgressView.m
// FBProgressView
//
// Created by Hiroshi Hashiguchi on 11/03/30.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "FBProgressView.h"

@interface FBProgressView()
@property (nonatomic, retain) UIColor* color;
@end

@implementation FBProgressView

@synthesize color = color_;
@synthesize lineWidth = lineWidth_;
@synthesize progressViewStyle = progressViewStyle_;
@synthesize progress = progress_;
@synthesize hidesUntilStart = hidesUntilStart_;


#pragma mark -
#pragma mark Private Services
- (void)_createOutlinePath
{
[outlinePath_ release];
outlinePath_ = [[UIBezierPath bezierPath] retain];

CGSize size = self.bounds.size;
CGFloat unit = size.height/2.0 - self.lineWidth;

CGPoint c1 = CGPointMake(unit+self.lineWidth, unit+self.lineWidth);
[outlinePath_ addArcWithCenter:c1
radius:unit
startAngle:3*M_PI/2 endAngle:M_PI/2
clockwise:NO];

[outlinePath_ addLineToPoint:CGPointMake(size.width - c1.x,
size.height - self.lineWidth)];
CGPoint c2 = CGPointMake(size.width - unit - self.lineWidth,
unit+self.lineWidth);
[outlinePath_ addArcWithCenter:c2
radius:unit
startAngle:M_PI/2 endAngle:-M_PI/2
clockwise:NO];

[outlinePath_ addLineToPoint:CGPointMake(c1.x, self.lineWidth)];

[outlinePath_ setLineWidth:self.lineWidth];

}

- (void)_init
{
self.progressViewStyle = FBProgressViewStyleDefault;
self.lineWidth = 3.0;
self.backgroundColor = [UIColor clearColor];
[self _createOutlinePath];

self.hidesUntilStart = YES;
started_ = NO;
}


#define MARGIN_UNIT 3.0
- (void)_drawProgressBar
{
CGFloat margin = self.lineWidth + MARGIN_UNIT;
CGSize size = self.bounds.size;
size.width -= margin*2;
size.height -= margin*2;
CGFloat unit = size.height/2.0;

CGFloat progressWidth = size.width * self.progress;
if (progressWidth < unit*2) {
progressWidth = unit*2;
}

CGRect barRect = CGRectMake(margin,
margin,
progressWidth,
size.height);
UIBezierPath* path = [UIBezierPath bezierPathWithRoundedRect:barRect
cornerRadius:unit];
[path fill];

}


#pragma mark -
#pragma mark Initialization and deallocation

- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self _init];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
[self _init];
}
return self;
}
- (void)dealloc {
[outlinePath_ release];
[super dealloc];
}


#pragma mark -
#pragma mark UIView

- (void)drawRect:(CGRect)rect
{
if (!self.hidesUntilStart || started_) {
[self.color set];
[outlinePath_ stroke];

if (self.progress) {
[self _drawProgressBar];
}
}
}


#pragma mark -
#pragma mark Properties
- (void)setProgressViewStyle:(FBProgressViewStyle)progressViewStyle
{
progressViewStyle_ = progressViewStyle;

switch (progressViewStyle) {
case FBProgressViewStyleGray:
self.color = [UIColor lightGrayColor];
break;

case FBProgressViewStyleWhite:
self.color = [UIColor whiteColor];
break;

default:
self.color = [UIColor lightGrayColor];
break;
}
}

- (void)setProgress:(float)progress
{
if (progress > 1.0) {
progress = 1.0;
} else if (progress < 0.0) {
progress = 0.0;
}
progress_ = progress;
started_ = YES;

[self setNeedsDisplay];
}

@end
3 changes: 3 additions & 0 deletions FBProgressView/FBProgressViewAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@

#import <UIKit/UIKit.h>

@class FBProgressView;
@interface FBProgressViewAppDelegate : NSObject <UIApplicationDelegate> {

}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet FBProgressView* view1;
@property (nonatomic, retain) IBOutlet FBProgressView* view2;

@end
27 changes: 27 additions & 0 deletions FBProgressView/FBProgressViewAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,46 @@
//

#import "FBProgressViewAppDelegate.h"
#import "FBProgressView.h"

@implementation FBProgressViewAppDelegate


@synthesize window=_window;
@synthesize view1, view2;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[self.window makeKeyAndVisible];


self.view1.progress = 0;
self.view2.progress = 0;

self.view2.progressViewStyle = FBProgressViewStyleWhite;

[NSTimer scheduledTimerWithTimeInterval:0.1
target:self
selector:@selector(fire:)
userInfo:nil
repeats:YES];

return YES;
}

- (void)fire:(NSTimer*)timer
{
self.view1.progress = self.view1.progress + 0.01;
self.view2.progress = self.view2.progress + 0.01;
NSLog(@"fired: %f", self.view1.progress);

if (self.view1.progress >= 1.0) {
[timer invalidate];
NSLog(@"timer stopped");
}
}

- (void)applicationWillResignActive:(UIApplication *)application
{
/*
Expand Down
Loading

0 comments on commit 67f7384

Please sign in to comment.