Permalink
Browse files

Added address bar

  • Loading branch information...
1 parent 5deb8cc commit e1414dd38da0c8bbdc684696f393454ab69d09c1 @soffes soffes committed Feb 8, 2011
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,21 @@
+//
+// SCAddressBarDemoViewController.h
+// SSCatalog
+//
+// Created by Sam Soffes on 2/8/11.
+// Copyright 2011 Sam Soffes. All rights reserved.
+//
+
+#import <SSToolkit/SSToolkit.h>
+
+@interface SCAddressBarDemoViewController : UIViewController <UITextFieldDelegate, SSWebViewDelegate> {
+
+ SSGradientView *_headerView;
+ UILabel *_titleLabel;
+ SSAddressBarTextField *_addressBar;
+ SSWebView *_webView;
+}
+
++ (NSString *)title;
+
+@end
@@ -0,0 +1,133 @@
+//
+// SCAddressBarDemoViewController.m
+// SSCatalog
+//
+// Created by Sam Soffes on 2/8/11.
+// Copyright 2011 Sam Soffes. All rights reserved.
+//
+
+#import "SCAddressBarDemoViewController.h"
+
+@implementation SCAddressBarDemoViewController
+
+#pragma mark Class Methods
+
++ (NSString *)title {
+ return @"Address bar";
+}
+
+
+#pragma mark NSObject
+
+- (void)dealloc {
+ _webView.delegate = nil;
+ [_webView release];
+ [_headerView release];
+ [_titleLabel release];
+ [_addressBar release];
+ [super dealloc];
+}
+
+
+#pragma mark UIViewController
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ self.title = [[self class] title];
+ self.view.backgroundColor = [UIColor colorWithRed:0.851 green:0.859 blue:0.882 alpha:1.0];
+
+ _headerView = [[SSGradientView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 58.0f)];
+ _headerView.topColor = [UIColor colorWithWhite:0.957f alpha:1.0f];
+ _headerView.bottomColor = [UIColor colorWithWhite:0.827f alpha:1.0f];
+ _headerView.bottomBorderColor = [UIColor colorWithWhite:0.369f alpha:1.0f];
+ _headerView.hasTopBorder = NO;
+ _headerView.hasBottomBorder = YES;
+
+ _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 300.0f, 21.0f)];
+ _titleLabel.backgroundColor = [UIColor clearColor];
+ _titleLabel.textColor = [UIColor colorWithWhite:0.404f alpha:1.0f];
+ _titleLabel.textAlignment = UITextAlignmentCenter;
+ _titleLabel.font = [UIFont boldSystemFontOfSize:12.0f];
+ _titleLabel.shadowColor = [UIColor whiteColor];
+ _titleLabel.shadowOffset = CGSizeMake(0.0f, 1.0f);
+ [_headerView addSubview:_titleLabel];
+
+ _addressBar = [[SSAddressBarTextField alloc] initWithFrame:CGRectMake(10.0f, 21.0f, 300.0f, 31.0f)];
+ _addressBar.delegate = self;
+ [_headerView addSubview:_addressBar];
+
+ [self.view addSubview:_headerView];
+
+ _webView = [[SSWebView alloc] initWithFrame:CGRectMake(0.0f, 58.0f, 320.0f, self.view.frame.size.height - 58.0f)];
+ _webView.scalesPageToFit = YES;
+ _webView.delegate = self;
+ [self.view addSubview:_webView];
+
+ [_addressBar.refreshButton addTarget:_webView action:@selector(reload) forControlEvents:UIControlEventTouchUpInside];
+ [_addressBar.stopButton addTarget:_webView action:@selector(stopLoading) forControlEvents:UIControlEventTouchUpInside];
+
+ [_webView loadURLString:@"http://samsoff.es"];
+}
+
+
+#pragma mark UITextFieldDelegate
+
+- (void)textFieldDidBeginEditing:(UITextField *)textField {
+ [[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(_removeGrayView) object:nil];
+
+ // Gray Button
+// UIButton *aGrayButton = [UIButton buttonWithType:UIButtonTypeCustom];
+// aGrayButton.frame = _webView.frame;
+// aGrayButton.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
+// aGrayButton.alpha = 0.0;
+// aGrayButton.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+// [aGrayButton addTarget:textField action:@selector(resignFirstResponder) forControlEvents:UIControlEventTouchDown];
+// self.grayButton = aGrayButton;
+// [self.view addSubview:grayButton];
+// [grayButton fadeIn];
+}
+
+
+- (void)textFieldDidEndEditing:(UITextField *)textField {
+// [self performSelector:@selector(_removeGrayView) withObject:nil afterDelay:0.1];
+}
+
+
+- (BOOL)textFieldShouldReturn:(UITextField *)textField {
+ [_webView loadURLString:textField.text];
+ [textField resignFirstResponder];
+ return YES;
+}
+
+
+#pragma mark SSWebViewDelegate
+
+- (void)webViewDidStartLoadingPage:(SSWebView *)aWebView {
+ _addressBar.loading = YES;
+ [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
+
+ NSString *urlString = [[[_webView lastRequest] mainDocumentURL] absoluteString];
+ NSString *addressBarUrlString = urlString; // [urlString stringByReplacingOccurrencesOfRegex:@"^https?://" withString:@""];
+ _addressBar.text = addressBarUrlString;
+ _titleLabel.text = urlString;
+}
+
+
+- (void)webViewDidFinishLoadingPage:(SSWebView *)aWebView {
+ _addressBar.loading = NO;
+ [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
+
+ NSString *title = [_webView stringByEvaluatingJavaScriptFromString:@"document.title"];
+ if (title) {
+ _titleLabel.text = title;
+ }
+}
+
+
+- (void)webView:(SSWebView *)aWebView didFailLoadWithError:(NSError *)error {
+ _addressBar.loading = NO;
+ [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
+}
+
+
+@end
@@ -50,6 +50,7 @@ - (void)viewDidLoad {
nil],
[NSDictionary dictionaryWithObjectsAndKeys:
[NSArray arrayWithObjects:
+ @"SCAddressBarDemoViewController",
@"SCSwitchDemoViewController",
nil], kClassesKey,
@"Controls", kTitleKey,
@@ -6,8 +6,6 @@
// Copyright 2010 Sam Soffes. All rights reserved.
//
-#import <SSToolkit/SSToolkit.h>
-
@interface SCSwitchDemoViewController : UIViewController {
}
@@ -7,6 +7,7 @@
//
#import "SCSwitchDemoViewController.h"
+#import <SSToolkit/SSSwitch.h>
@implementation SCSwitchDemoViewController
@@ -30,6 +30,7 @@
B2B3CEEF1296F78D001BAC94 /* SCSwitchDemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B2B3CEEE1296F78D001BAC94 /* SCSwitchDemoViewController.m */; };
B2B3CF561296FA76001BAC94 /* SSToolkit.bundle in Resources */ = {isa = PBXBuildFile; fileRef = B2B3CF551296FA76001BAC94 /* SSToolkit.bundle */; };
B2E0323F121DC49700D02434 /* libSSToolkit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B24E9ECA121DC3CF0085F81E /* libSSToolkit.a */; };
+ B2E241821301CE4900F7DC3B /* SCAddressBarDemoViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B2E241811301CE4900F7DC3B /* SCAddressBarDemoViewController.m */; };
B2E709AE12FF286E00DFF898 /* Icon-29.png in Resources */ = {isa = PBXBuildFile; fileRef = B2E709A812FF286E00DFF898 /* Icon-29.png */; };
B2E709B012FF286E00DFF898 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = B2E709AA12FF286E00DFF898 /* Icon-72.png */; };
B2E709B112FF286E00DFF898 /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = B2E709AB12FF286E00DFF898 /* Icon-114.png */; };
@@ -95,6 +96,8 @@
B2B3CEED1296F78D001BAC94 /* SCSwitchDemoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCSwitchDemoViewController.h; sourceTree = "<group>"; };
B2B3CEEE1296F78D001BAC94 /* SCSwitchDemoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCSwitchDemoViewController.m; sourceTree = "<group>"; };
B2B3CF551296FA76001BAC94 /* SSToolkit.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = SSToolkit.bundle; path = ../Resources/SSToolkit.bundle; sourceTree = SOURCE_ROOT; };
+ B2E241801301CE4900F7DC3B /* SCAddressBarDemoViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCAddressBarDemoViewController.h; sourceTree = "<group>"; };
+ B2E241811301CE4900F7DC3B /* SCAddressBarDemoViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCAddressBarDemoViewController.m; sourceTree = "<group>"; };
B2E709A812FF286E00DFF898 /* Icon-29.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-29.png"; sourceTree = "<group>"; };
B2E709AA12FF286E00DFF898 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = "<group>"; };
B2E709AB12FF286E00DFF898 /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-114.png"; sourceTree = "<group>"; };
@@ -248,6 +251,8 @@
children = (
B2B3CEED1296F78D001BAC94 /* SCSwitchDemoViewController.h */,
B2B3CEEE1296F78D001BAC94 /* SCSwitchDemoViewController.m */,
+ B2E241801301CE4900F7DC3B /* SCAddressBarDemoViewController.h */,
+ B2E241811301CE4900F7DC3B /* SCAddressBarDemoViewController.m */,
);
name = "Control Demos";
sourceTree = "<group>";
@@ -356,6 +361,7 @@
B2B3CEEF1296F78D001BAC94 /* SCSwitchDemoViewController.m in Sources */,
E7FD242712F4FFC5006A6691 /* SCBadgeTableViewCellDemoViewController.m in Sources */,
B28C6D0B12FBE96600667755 /* SSRatingDemoViewController.m in Sources */,
+ B2E241821301CE4900F7DC3B /* SCAddressBarDemoViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -94,6 +94,12 @@
B2AE1135126F963300534CF2 /* UIApplication+SSToolkitAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B2AE1133126F963300534CF2 /* UIApplication+SSToolkitAdditions.m */; };
B2B3CED81296F637001BAC94 /* SSSwitch.h in Headers */ = {isa = PBXBuildFile; fileRef = B2B3CED61296F637001BAC94 /* SSSwitch.h */; };
B2B3CED91296F637001BAC94 /* SSSwitch.m in Sources */ = {isa = PBXBuildFile; fileRef = B2B3CED71296F637001BAC94 /* SSSwitch.m */; };
+ B2E241541301C71400F7DC3B /* SSAddressBarTextField.h in Headers */ = {isa = PBXBuildFile; fileRef = B2E2414E1301C71400F7DC3B /* SSAddressBarTextField.h */; };
+ B2E241551301C71400F7DC3B /* SSAddressBarTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = B2E2414F1301C71400F7DC3B /* SSAddressBarTextField.m */; };
+ B2E241561301C71400F7DC3B /* SSAddressBarTextFieldBackgroundView.h in Headers */ = {isa = PBXBuildFile; fileRef = B2E241501301C71400F7DC3B /* SSAddressBarTextFieldBackgroundView.h */; };
+ B2E241571301C71400F7DC3B /* SSAddressBarTextFieldBackgroundView.m in Sources */ = {isa = PBXBuildFile; fileRef = B2E241511301C71400F7DC3B /* SSAddressBarTextFieldBackgroundView.m */; };
+ B2E241581301C71400F7DC3B /* SSAddressBarTextFieldBackgroundViewInnerView.h in Headers */ = {isa = PBXBuildFile; fileRef = B2E241521301C71400F7DC3B /* SSAddressBarTextFieldBackgroundViewInnerView.h */; };
+ B2E241591301C71400F7DC3B /* SSAddressBarTextFieldBackgroundViewInnerView.m in Sources */ = {isa = PBXBuildFile; fileRef = B2E241531301C71400F7DC3B /* SSAddressBarTextFieldBackgroundViewInnerView.m */; };
B2EA9F5E12F4A5C900C929D6 /* SSBadgeTableViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = B2EA9F5C12F4A5C900C929D6 /* SSBadgeTableViewCell.h */; };
B2EA9F5F12F4A5C900C929D6 /* SSBadgeTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = B2EA9F5D12F4A5C900C929D6 /* SSBadgeTableViewCell.m */; };
B2EA9F6212F4A5E100C929D6 /* SSBadgeView.h in Headers */ = {isa = PBXBuildFile; fileRef = B2EA9F6012F4A5E100C929D6 /* SSBadgeView.h */; };
@@ -189,6 +195,12 @@
B2AE1133126F963300534CF2 /* UIApplication+SSToolkitAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIApplication+SSToolkitAdditions.m"; sourceTree = "<group>"; };
B2B3CED61296F637001BAC94 /* SSSwitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSSwitch.h; sourceTree = "<group>"; };
B2B3CED71296F637001BAC94 /* SSSwitch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSSwitch.m; sourceTree = "<group>"; };
+ B2E2414E1301C71400F7DC3B /* SSAddressBarTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSAddressBarTextField.h; sourceTree = "<group>"; };
+ B2E2414F1301C71400F7DC3B /* SSAddressBarTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSAddressBarTextField.m; sourceTree = "<group>"; };
+ B2E241501301C71400F7DC3B /* SSAddressBarTextFieldBackgroundView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSAddressBarTextFieldBackgroundView.h; sourceTree = "<group>"; };
+ B2E241511301C71400F7DC3B /* SSAddressBarTextFieldBackgroundView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSAddressBarTextFieldBackgroundView.m; sourceTree = "<group>"; };
+ B2E241521301C71400F7DC3B /* SSAddressBarTextFieldBackgroundViewInnerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSAddressBarTextFieldBackgroundViewInnerView.h; sourceTree = "<group>"; };
+ B2E241531301C71400F7DC3B /* SSAddressBarTextFieldBackgroundViewInnerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSAddressBarTextFieldBackgroundViewInnerView.m; sourceTree = "<group>"; };
B2EA9F5C12F4A5C900C929D6 /* SSBadgeTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSBadgeTableViewCell.h; sourceTree = "<group>"; };
B2EA9F5D12F4A5C900C929D6 /* SSBadgeTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSBadgeTableViewCell.m; sourceTree = "<group>"; };
B2EA9F6012F4A5E100C929D6 /* SSBadgeView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSBadgeView.h; sourceTree = "<group>"; };
@@ -379,6 +391,8 @@
B2601A791223086D005506D5 /* Controls */ = {
isa = PBXGroup;
children = (
+ B2E2414E1301C71400F7DC3B /* SSAddressBarTextField.h */,
+ B2E2414F1301C71400F7DC3B /* SSAddressBarTextField.m */,
B24E9E2C121DC29A0085F81E /* SSTextField.h */,
B24E9E2D121DC29A0085F81E /* SSTextField.m */,
B24E9E2E121DC29A0085F81E /* SSTextView.h */,
@@ -409,6 +423,10 @@
children = (
B279539C12FC6C6F00FFE28D /* SSRatingPickerScrollView.h */,
B279539D12FC6C6F00FFE28D /* SSRatingPickerScrollView.m */,
+ B2E241501301C71400F7DC3B /* SSAddressBarTextFieldBackgroundView.h */,
+ B2E241511301C71400F7DC3B /* SSAddressBarTextFieldBackgroundView.m */,
+ B2E241521301C71400F7DC3B /* SSAddressBarTextFieldBackgroundViewInnerView.h */,
+ B2E241531301C71400F7DC3B /* SSAddressBarTextFieldBackgroundViewInnerView.m */,
);
name = Private;
sourceTree = "<group>";
@@ -475,6 +493,9 @@
B28C6D0712FBE5C400667755 /* SSRatingPickerViewController.h in Headers */,
B279539912FC67E300FFE28D /* UIScreen+SSToolkitAdditions.h in Headers */,
B279539E12FC6C6F00FFE28D /* SSRatingPickerScrollView.h in Headers */,
+ B2E241541301C71400F7DC3B /* SSAddressBarTextField.h in Headers */,
+ B2E241561301C71400F7DC3B /* SSAddressBarTextFieldBackgroundView.h in Headers */,
+ B2E241581301C71400F7DC3B /* SSAddressBarTextFieldBackgroundViewInnerView.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -573,6 +594,9 @@
B28C6D0812FBE5C400667755 /* SSRatingPickerViewController.m in Sources */,
B279539A12FC67E300FFE28D /* UIScreen+SSToolkitAdditions.m in Sources */,
B279539F12FC6C6F00FFE28D /* SSRatingPickerScrollView.m in Sources */,
+ B2E241551301C71400F7DC3B /* SSAddressBarTextField.m in Sources */,
+ B2E241571301C71400F7DC3B /* SSAddressBarTextFieldBackgroundView.m in Sources */,
+ B2E241591301C71400F7DC3B /* SSAddressBarTextFieldBackgroundViewInnerView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -0,0 +1,28 @@
+//
+// SSAddressBarTextField.h
+// SSToolkit
+//
+// Created by Sam Soffes on 2/8/11.
+// Copyright 2010 Sam Soffes. All rights reserved.
+//
+
+#import "SSTextField.h"
+
+@class SSAddressBarTextFieldBackgroundView;
+
+@interface SSAddressBarTextField : SSTextField {
+
+ BOOL _loading;
+ UIButton *_refreshButton;
+ UIButton *_stopButton;
+
+@private
+
+ SSAddressBarTextFieldBackgroundView *_textFieldBackgroundView;
+}
+
+@property (nonatomic, assign, getter=isLoading) BOOL loading;
+@property (nonatomic, retain) UIButton *refreshButton;
+@property (nonatomic, retain) UIButton *stopButton;
+
+@end
Oops, something went wrong.

0 comments on commit e1414dd

Please sign in to comment.