Skip to content

Commit

Permalink
Don't allow customizing displayed activities.
Browse files Browse the repository at this point in the history
  • Loading branch information
samvermette committed Nov 12, 2013
1 parent 56bccac commit da0491f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 76 deletions.
1 change: 0 additions & 1 deletion Demo/Classes/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ - (void)presentWebViewController {
NSURL *URL = [NSURL URLWithString:@"http://samvermette.com"];
SVModalWebViewController *webViewController = [[SVModalWebViewController alloc] initWithURL:URL];
webViewController.modalPresentationStyle = UIModalPresentationPageSheet;
webViewController.availableActions = SVWebViewControllerAvailableActionsOpenInSafari | SVWebViewControllerAvailableActionsOpenInChrome | SVWebViewControllerAvailableActionsCopyLink | SVWebViewControllerAvailableActionsMailLink;
[self presentViewController:webViewController animated:YES completion:NULL];
}

Expand Down
12 changes: 0 additions & 12 deletions SVWebViewController/SVModalWebViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@

#import <UIKit/UIKit.h>

enum {
SVWebViewControllerAvailableActionsNone = 0,
SVWebViewControllerAvailableActionsOpenInSafari = 1 << 0,
SVWebViewControllerAvailableActionsMailLink = 1 << 1,
SVWebViewControllerAvailableActionsCopyLink = 1 << 2,
SVWebViewControllerAvailableActionsOpenInChrome = 1 << 3
};

typedef NSUInteger SVWebViewControllerAvailableActions;


@class SVWebViewController;

@interface SVModalWebViewController : UINavigationController
Expand All @@ -27,6 +16,5 @@ typedef NSUInteger SVWebViewControllerAvailableActions;
- (id)initWithURL:(NSURL *)URL;

@property (nonatomic, strong) UIColor *barsTintColor;
@property (nonatomic, readwrite) SVWebViewControllerAvailableActions availableActions;

@end
6 changes: 1 addition & 5 deletions SVWebViewController/SVModalWebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ @interface SVModalWebViewController ()

@implementation SVModalWebViewController

@synthesize barsTintColor, availableActions, webViewController;
@synthesize barsTintColor, webViewController;

#pragma mark - Initialization

Expand All @@ -42,8 +42,4 @@ - (void)viewWillAppear:(BOOL)animated {
self.navigationBar.tintColor = self.barsTintColor;
}

- (void)setAvailableActions:(SVWebViewControllerAvailableActions)newAvailableActions {
self.webViewController.availableActions = newAvailableActions;
}

@end
5 changes: 0 additions & 5 deletions SVWebViewController/SVWebViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@

@interface SVWebViewController : UIViewController

// For "Open in Chrome" action if you are using it
@property (strong, nonatomic) NSURL *callbackURL;

- (id)initWithAddress:(NSString*)urlString;
- (id)initWithURL:(NSURL*)URL;

@property (nonatomic, readwrite) SVWebViewControllerAvailableActions availableActions;

@end
75 changes: 22 additions & 53 deletions SVWebViewController/SVWebViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ - (void)actionButtonClicked:(UIBarButtonItem *)sender;

@implementation SVWebViewController

@synthesize availableActions;

#pragma mark - Initialization

- (void)dealloc {
Expand All @@ -56,7 +54,6 @@ - (id)initWithURL:(NSURL*)pageURL {

if(self = [super init]) {
self.URL = pageURL;
self.availableActions = SVWebViewControllerAvailableActionsOpenInSafari | SVWebViewControllerAvailableActionsOpenInChrome | SVWebViewControllerAvailableActionsMailLink;
}

return self;
Expand Down Expand Up @@ -186,33 +183,19 @@ - (void)updateToolbarItems {
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
NSArray *items;
CGFloat toolbarWidth = 250.0f;

if(self.availableActions == 0) {
toolbarWidth = 200.0f;
items = [NSArray arrayWithObjects:
fixedSpace,
refreshStopBarButtonItem,
flexibleSpace,
self.backBarButtonItem,
flexibleSpace,
self.forwardBarButtonItem,
fixedSpace,
nil];
} else {
items = [NSArray arrayWithObjects:
fixedSpace,
refreshStopBarButtonItem,
flexibleSpace,
self.backBarButtonItem,
flexibleSpace,
self.forwardBarButtonItem,
flexibleSpace,
self.actionBarButtonItem,
fixedSpace,
nil];
}
NSArray *items = [NSArray arrayWithObjects:
fixedSpace,
refreshStopBarButtonItem,
flexibleSpace,
self.backBarButtonItem,
flexibleSpace,
self.forwardBarButtonItem,
flexibleSpace,
self.actionBarButtonItem,
fixedSpace,
nil];

UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, toolbarWidth, 44.0f)];
toolbar.items = items;
Expand All @@ -222,31 +205,17 @@ - (void)updateToolbarItems {
}

else {
NSArray *items;

if(self.availableActions == 0) {
items = [NSArray arrayWithObjects:
flexibleSpace,
self.backBarButtonItem,
flexibleSpace,
self.forwardBarButtonItem,
flexibleSpace,
refreshStopBarButtonItem,
flexibleSpace,
nil];
} else {
items = [NSArray arrayWithObjects:
fixedSpace,
self.backBarButtonItem,
flexibleSpace,
self.forwardBarButtonItem,
flexibleSpace,
refreshStopBarButtonItem,
flexibleSpace,
self.actionBarButtonItem,
fixedSpace,
nil];
}
NSArray *items = [NSArray arrayWithObjects:
fixedSpace,
self.backBarButtonItem,
flexibleSpace,
self.forwardBarButtonItem,
flexibleSpace,
refreshStopBarButtonItem,
flexibleSpace,
self.actionBarButtonItem,
fixedSpace,
nil];

self.navigationController.toolbar.barStyle = self.navigationController.navigationBar.barStyle;
self.navigationController.toolbar.tintColor = self.navigationController.navigationBar.tintColor;
Expand Down

0 comments on commit da0491f

Please sign in to comment.