Skip to content

Commit

Permalink
progress in SVWebViewController
Browse files Browse the repository at this point in the history
  • Loading branch information
pilot34 committed Jan 17, 2014
1 parent a4334c5 commit 74a889b
Show file tree
Hide file tree
Showing 7 changed files with 785 additions and 394 deletions.
2 changes: 2 additions & 0 deletions Demo/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
platform :ios, '6.0'
pod 'SVWebViewController', :git => 'https://github.com/pilot34/SVWebViewController.git'
14 changes: 14 additions & 0 deletions Demo/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
PODS:
- SVWebViewController (1.0)

DEPENDENCIES:
- SVWebViewController (from `https://github.com/pilot34/SVWebViewController.git`)

EXTERNAL SOURCES:
SVWebViewController:
:git: https://github.com/pilot34/SVWebViewController.git

SPEC CHECKSUMS:
SVWebViewController: e576371f7015bce92c97c304c32336700064847b

COCOAPODS: 0.29.0
1,092 changes: 698 additions & 394 deletions Demo/SVWeb.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Demo/SVWeb.xcworkspace/contents.xcworkspacedata

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

41 changes: 41 additions & 0 deletions Demo/SVWeb.xcworkspace/xcshareddata/SVWeb.xccheckout
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>7FBBD4B1-99D4-49D8-AF2C-0FE239469EDA</string>
<key>IDESourceControlProjectName</key>
<string>SVWeb</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>096512C9-BDD9-46BE-A961-EFE6E1D08FBB</key>
<string>https://github.com/pilot34/SVWebViewController.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>Demo/SVWeb.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>096512C9-BDD9-46BE-A961-EFE6E1D08FBB</key>
<string>../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>https://github.com/pilot34/SVWebViewController.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>096512C9-BDD9-46BE-A961-EFE6E1D08FBB</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>096512C9-BDD9-46BE-A961-EFE6E1D08FBB</string>
<key>IDESourceControlWCCName</key>
<string>SVWebViewController</string>
</dict>
</array>
</dict>
</plist>
1 change: 1 addition & 0 deletions SVWebViewController.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ Pod::Spec.new do |s|
s.source_files = 'SVWebViewController/**/*.{h,m}'
s.resources = 'SVWebViewController/**/*.{bundle,png}'
s.requires_arc = true
s.dependency = 'NJKWebViewProgress'
end
28 changes: 28 additions & 0 deletions SVWebViewController/SVWebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "SVWebViewControllerActivityChrome.h"
#import "SVWebViewControllerActivitySafari.h"
#import "SVWebViewController.h"
#import "NJKWebViewProgressView.h"

@interface SVWebViewController () <UIWebViewDelegate>

Expand All @@ -21,6 +22,9 @@ @interface SVWebViewController () <UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webView;
@property (nonatomic, strong) NSURL *URL;

@property (strong, nonatomic) NJKWebViewProgressView *progressView;
@property (strong, nonatomic) NJKWebViewProgress *progressProxy;

- (id)initWithAddress:(NSString*)urlString;
- (id)initWithURL:(NSURL*)URL;
- (void)loadURL:(NSURL*)URL;
Expand Down Expand Up @@ -73,6 +77,7 @@ - (void)loadView {
- (void)viewDidLoad {
[super viewDidLoad];
[self updateToolbarItems];
[self prepareProgress];
}

- (void)viewDidUnload {
Expand All @@ -93,6 +98,8 @@ - (void)viewWillAppear:(BOOL)animated {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self.navigationController setToolbarHidden:NO animated:animated];
}

[self.navigationController.navigationBar addSubview:self.progressView];
}

- (void)viewWillDisappear:(BOOL)animated {
Expand All @@ -101,6 +108,8 @@ - (void)viewWillDisappear:(BOOL)animated {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self.navigationController setToolbarHidden:YES animated:animated];
}

[self.progressView removeFromSuperview];
}

- (void)viewDidDisappear:(BOOL)animated {
Expand Down Expand Up @@ -169,6 +178,20 @@ - (UIBarButtonItem *)actionBarButtonItem {
return _actionBarButtonItem;
}

#pragma mark - Progress

- (void)prepareProgress {
self.progressProxy = [[NJKWebViewProgress alloc] init];
self.webView.delegate = self.progressProxy;
self.progressProxy.webViewProxyDelegate = self;
self.progressProxy.progressDelegate = self;

CGFloat progressBarHeight = 2.5f;
CGRect navigaitonBarBounds = self.navigationController.navigationBar.bounds;
CGRect barFrame = CGRectMake(0, navigaitonBarBounds.size.height - progressBarHeight, navigaitonBarBounds.size.width, progressBarHeight);
self.progressView = [[NJKWebViewProgressView alloc] initWithFrame:barFrame];
}

#pragma mark - Toolbar

- (void)updateToolbarItems {
Expand Down Expand Up @@ -272,4 +295,9 @@ - (void)doneButtonClicked:(id)sender {
[self dismissViewControllerAnimated:YES completion:NULL];
}

#pragma mark - NJKWebViewProgressDelegate
- (void)webViewProgress:(NJKWebViewProgress *)webViewProgress updateProgress:(float)progress {
[self.progressView setProgress:progress animated:YES];
}

@end

0 comments on commit 74a889b

Please sign in to comment.