Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
rhussmann committed May 13, 2011
1 parent 404065e commit 1d3ce05
Show file tree
Hide file tree
Showing 10 changed files with 876 additions and 204 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
xcuserdata
25 changes: 25 additions & 0 deletions LRStatusView.h
@@ -0,0 +1,25 @@
//
// LRStatusView.h
// ModalStatusOverlay
//
// Created by Ricky Hussmann on 5/6/11.
// Copyright 2011 LovelyRide. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface LRStatusView : UIView {

UIView *_backgroundView;
UILabel *_statusLabel;
UIActivityIndicatorView *_activityIndicator;
}

- (id)initWithFrame:(CGRect)frame labelText:(NSString*)text indicatorVisible:(BOOL)indicatorVisible;

@property (nonatomic, retain) UIView *_backgroundView;
@property (nonatomic, retain) UILabel *_statusLabel;
@property (nonatomic, retain) UIActivityIndicatorView *_activityIndicator;

@end
110 changes: 110 additions & 0 deletions LRStatusView.m
@@ -0,0 +1,110 @@
//
// LRStatusView.m
// ModalStatusOverlay
//
// Created by Ricky Hussmann on 5/6/11.
// Copyright 2011 LovelyRide. All rights reserved.
//

#import <QuartzCore/QuartzCore.h>
#import "LRStatusView.h"

UIView* createBackgroundViewForFrame(CGRect frame) {

CGRect bgRect = CGRectMake(0,
0,
frame.size.width,
frame.size.height);

UIView *background = [[[UIView alloc] initWithFrame:bgRect] autorelease];
background.backgroundColor = [UIColor blackColor];
background.alpha = 0.2;
background.layer.cornerRadius = 7;

return background;
}

UILabel* createStatusLabelWithTextForFrame(NSString *text, CGRect frame) {

UILabel *statusLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)] autorelease];
statusLabel.numberOfLines = 0;
statusLabel.lineBreakMode = UILineBreakModeWordWrap;
statusLabel.text = text;
[statusLabel sizeToFit];

CGFloat labelHeight = statusLabel.bounds.size.height;
CGFloat labelWidth = statusLabel.bounds.size.width;

CGRect labelRect = CGRectMake(frame.size.width/2.0 - labelWidth/2.0,
frame.size.height/2.0 - labelHeight/2.0,
labelWidth,
labelHeight);
statusLabel.frame = labelRect;
statusLabel.backgroundColor = [UIColor clearColor];
statusLabel.textColor = [UIColor whiteColor];
statusLabel.shadowColor = [UIColor blackColor];
statusLabel.shadowOffset = CGSizeMake(-1, 1);

return statusLabel;
}

@implementation LRStatusView
@synthesize _backgroundView;
@synthesize _statusLabel;
@synthesize _activityIndicator;

- (id)initWithFrame:(CGRect)frame labelText:(NSString*)text indicatorVisible:(BOOL)indicatorVisible
{
self = [super initWithFrame:frame];
if (self) {

self.clipsToBounds = YES;
self._backgroundView = createBackgroundViewForFrame(frame);
self._statusLabel = createStatusLabelWithTextForFrame(text, frame);

UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];

CGPoint statusLabelCenter = self._statusLabel.center;
CGRect indicatorRect = CGRectMake(statusLabelCenter.x - 20.0/2.0,
statusLabelCenter.y - self._statusLabel.frame.size.height/2.0 - 20,
20,
20);
indicator.frame = indicatorRect;
indicator.hidden = NO;
[indicator startAnimating];

self._activityIndicator = indicator;
[indicator release];

[self addSubview:self._backgroundView];
[self addSubview:self._statusLabel];

if (indicatorVisible) {
[self addSubview:self._activityIndicator];
}
}
return self;
}

- (id)initWithFrame:(CGRect)frame
{
return [self initWithFrame:frame labelText:@"Label" indicatorVisible:YES];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
*/

- (void)dealloc
{
self._statusLabel = nil;
self._activityIndicator = nil;
[super dealloc];
}

@end
53 changes: 30 additions & 23 deletions StatusOverlay.xcodeproj/project.pbxproj
Expand Up @@ -14,25 +14,28 @@
F4974C2A137DCBEB00015426 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = F4974C29137DCBEB00015426 /* main.m */; };
F4974C2D137DCBEB00015426 /* StatusOverlayAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = F4974C2C137DCBEB00015426 /* StatusOverlayAppDelegate.m */; };
F4974C30137DCBEB00015426 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4974C2E137DCBEB00015426 /* MainWindow.xib */; };
F4974C33137DCBEB00015426 /* StatusOverlayViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F4974C32137DCBEB00015426 /* StatusOverlayViewController.m */; };
F4974C36137DCBEB00015426 /* StatusOverlayViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4974C34137DCBEB00015426 /* StatusOverlayViewController.xib */; };
F4974C3F137DCC1800015426 /* LRStatusView.m in Sources */ = {isa = PBXBuildFile; fileRef = F4974C3E137DCC1800015426 /* LRStatusView.m */; };
F4974C43137DCECE00015426 /* StatusOverlayViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F4974C41137DCECE00015426 /* StatusOverlayViewController.m */; };
F4974C44137DCECE00015426 /* StatusOverlayViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4974C42137DCECE00015426 /* StatusOverlayViewController.xib */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
F4974C18137DCBEB00015426 /* StatusOverlay.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = StatusOverlay.app; sourceTree = BUILT_PRODUCTS_DIR; };
F4974C1C137DCBEB00015426 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
F4974C1E137DCBEB00015426 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
F4974C20137DCBEB00015426 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
F4974C24137DCBEB00015426 /* StatusOverlay-Info.plist */ = {isa = PBXFileReference; path = "StatusOverlay-Info.plist"; sourceTree = "<group>"; };
F4974C24137DCBEB00015426 /* StatusOverlay-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "StatusOverlay-Info.plist"; sourceTree = "<group>"; };
F4974C26137DCBEB00015426 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
F4974C28137DCBEB00015426 /* StatusOverlay-Prefix.pch */ = {isa = PBXFileReference; path = "StatusOverlay-Prefix.pch"; sourceTree = "<group>"; };
F4974C28137DCBEB00015426 /* StatusOverlay-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "StatusOverlay-Prefix.pch"; sourceTree = "<group>"; };
F4974C29137DCBEB00015426 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
F4974C2B137DCBEB00015426 /* StatusOverlayAppDelegate.h */ = {isa = PBXFileReference; path = StatusOverlayAppDelegate.h; sourceTree = "<group>"; };
F4974C2B137DCBEB00015426 /* StatusOverlayAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = StatusOverlayAppDelegate.h; sourceTree = "<group>"; };
F4974C2C137DCBEB00015426 /* StatusOverlayAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StatusOverlayAppDelegate.m; sourceTree = "<group>"; };
F4974C2F137DCBEB00015426 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainWindow.xib; sourceTree = "<group>"; };
F4974C31137DCBEB00015426 /* StatusOverlayViewController.h */ = {isa = PBXFileReference; path = StatusOverlayViewController.h; sourceTree = "<group>"; };
F4974C32137DCBEB00015426 /* StatusOverlayViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = StatusOverlayViewController.m; sourceTree = "<group>"; };
F4974C35137DCBEB00015426 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/StatusOverlayViewController.xib; sourceTree = "<group>"; };
F4974C3D137DCC1800015426 /* LRStatusView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LRStatusView.h; sourceTree = "<group>"; };
F4974C3E137DCC1800015426 /* LRStatusView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LRStatusView.m; sourceTree = "<group>"; };
F4974C40137DCECE00015426 /* StatusOverlayViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; path = StatusOverlayViewController.h; sourceTree = "<group>"; };
F4974C41137DCECE00015426 /* StatusOverlayViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StatusOverlayViewController.m; sourceTree = "<group>"; };
F4974C42137DCECE00015426 /* StatusOverlayViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = StatusOverlayViewController.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -52,7 +55,8 @@
F4974C0D137DCBEB00015426 = {
isa = PBXGroup;
children = (
F4974C22137DCBEB00015426 /* StatusOverlay */,
F4974C3C137DCC0000015426 /* src */,
F4974C22137DCBEB00015426 /* Sample Application */,
F4974C1B137DCBEB00015426 /* Frameworks */,
F4974C19137DCBEB00015426 /* Products */,
);
Expand All @@ -76,17 +80,18 @@
name = Frameworks;
sourceTree = "<group>";
};
F4974C22137DCBEB00015426 /* StatusOverlay */ = {
F4974C22137DCBEB00015426 /* Sample Application */ = {
isa = PBXGroup;
children = (
F4974C2B137DCBEB00015426 /* StatusOverlayAppDelegate.h */,
F4974C2C137DCBEB00015426 /* StatusOverlayAppDelegate.m */,
F4974C2E137DCBEB00015426 /* MainWindow.xib */,
F4974C31137DCBEB00015426 /* StatusOverlayViewController.h */,
F4974C32137DCBEB00015426 /* StatusOverlayViewController.m */,
F4974C34137DCBEB00015426 /* StatusOverlayViewController.xib */,
F4974C40137DCECE00015426 /* StatusOverlayViewController.h */,
F4974C41137DCECE00015426 /* StatusOverlayViewController.m */,
F4974C42137DCECE00015426 /* StatusOverlayViewController.xib */,
F4974C23137DCBEB00015426 /* Supporting Files */,
);
name = "Sample Application";
path = StatusOverlay;
sourceTree = "<group>";
};
Expand All @@ -101,6 +106,15 @@
name = "Supporting Files";
sourceTree = "<group>";
};
F4974C3C137DCC0000015426 /* src */ = {
isa = PBXGroup;
children = (
F4974C3D137DCC1800015426 /* LRStatusView.h */,
F4974C3E137DCC1800015426 /* LRStatusView.m */,
);
name = src;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -153,7 +167,7 @@
files = (
F4974C27137DCBEB00015426 /* InfoPlist.strings in Resources */,
F4974C30137DCBEB00015426 /* MainWindow.xib in Resources */,
F4974C36137DCBEB00015426 /* StatusOverlayViewController.xib in Resources */,
F4974C44137DCECE00015426 /* StatusOverlayViewController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -166,7 +180,8 @@
files = (
F4974C2A137DCBEB00015426 /* main.m in Sources */,
F4974C2D137DCBEB00015426 /* StatusOverlayAppDelegate.m in Sources */,
F4974C33137DCBEB00015426 /* StatusOverlayViewController.m in Sources */,
F4974C3F137DCC1800015426 /* LRStatusView.m in Sources */,
F4974C43137DCECE00015426 /* StatusOverlayViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -189,14 +204,6 @@
name = MainWindow.xib;
sourceTree = "<group>";
};
F4974C34137DCBEB00015426 /* StatusOverlayViewController.xib */ = {
isa = PBXVariantGroup;
children = (
F4974C35137DCBEB00015426 /* en */,
);
name = StatusOverlayViewController.xib;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 24 additions & 5 deletions StatusOverlay/StatusOverlayViewController.h
@@ -1,15 +1,34 @@
//
// StatusOverlayViewController.h
// StatusOverlay
// ModalStatusOverlayViewController.h
// ModalStatusOverlay
//
// Created by Ricky Hussmann on 5/13/11.
// Created by Ricky Hussmann on 5/6/11.
// Copyright 2011 LovelyRide. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface StatusOverlayViewController : UIViewController {

@interface StatusOverlayViewController : UIViewController <UITextFieldDelegate> {

UIButton *_toggleStatusViewButton;
UISwitch *_activitySwitch;
UITextField *_widthField;
UITextField *_heightFied;
UITextField *_statusText;

BOOL _isEditingTextField;
UITextField *_activeTextField;
}

@property (nonatomic, retain) IBOutlet UIButton *_toggleStatusViewButton;
@property (nonatomic, retain) IBOutlet UISwitch *_activitySwitch;
@property (nonatomic, retain) IBOutlet UITextField *_widthField;
@property (nonatomic, retain) IBOutlet UITextField *_heightFied;
@property (nonatomic, retain) IBOutlet UITextField *_statusText;

@property (nonatomic, assign) BOOL _isEditingTextField;
@property (nonatomic, retain) UITextField *_activeTextField;

- (IBAction)showLoadingOverlay;

@end

0 comments on commit 1d3ce05

Please sign in to comment.