Skip to content

Commit

Permalink
Tidied up properties and ivars.
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaterfall committed Oct 3, 2013
1 parent 618b51a commit 9fd9b27
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 42 deletions.
3 changes: 1 addition & 2 deletions MWPhotoBrowser/Classes/MWCaptionView.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

// Private
@interface MWCaptionView () {
id<MWPhoto> _photo;
id <MWPhoto> _photo;
UILabel *_label;
}
@end
Expand Down Expand Up @@ -74,7 +74,6 @@ - (void)setupCaption {
if ([_photo respondsToSelector:@selector(caption)]) {
_label.text = [_photo caption] ? [_photo caption] : @" ";
}

[self addSubview:_label];
}

Expand Down
2 changes: 0 additions & 2 deletions MWPhotoBrowser/Classes/MWPhoto.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// Private
@interface MWPhoto () {

// Other
NSString *_caption;
BOOL _loadingInProgress;

}
Expand Down
57 changes: 20 additions & 37 deletions MWPhotoBrowser/Classes/MWPhotoBrowser.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ @interface MWPhotoBrowser () {
UIToolbar *_toolbar;
NSTimer *_controlVisibilityTimer;
UIBarButtonItem *_previousButton, *_nextButton, *_actionButton;
UIActionSheet *_actionsSheet;
MBProgressHUD *_progressHUD;
UIActionSheet *_actionsSheet;

// Appearance
UIImage *_navigationBarBackgroundImageDefault,
*_navigationBarBackgroundImageLandscapePhone;
BOOL _previousNavBarHidden;
BOOL _previousNavToolbarHidden;
UIColor *_previousNavBarTintColor;
UIColor *_previousNavBarBarTintColor;
UIBarStyle _previousNavBarStyle;
UIStatusBarStyle _previousStatusBarStyle;
UIColor *_previousNavBarTintColor;
UIColor *_previousNavBarBarTintColor;
UIBarButtonItem *_previousViewControllerBackButton;
UIImage *_previousNavigationBarBackgroundImageDefault;
UIImage *_previousNavigationBarBackgroundImageLandscapePhone;

// Misc
BOOL _isVCBasedStatusBarAppearance;
Expand All @@ -63,16 +63,8 @@ @interface MWPhotoBrowser () {

}

// Private Properties
@property (nonatomic, strong) UIColor *previousNavBarTintColor;
@property (nonatomic, strong) UIColor *previousNavBarBarTintColor;
@property (nonatomic, strong) UIBarButtonItem *previousViewControllerBackButton;
@property (nonatomic, strong) UIImage *navigationBarBackgroundImageDefault, *navigationBarBackgroundImageLandscapePhone;
@property (nonatomic, strong) UIActionSheet *actionsSheet;
@property (nonatomic, strong) MBProgressHUD *progressHUD;
@property (nonatomic, strong) UIActivityViewController *activityViewController;

// Private Methods
// Private
@property (nonatomic) UIActivityViewController *activityViewController;

// Layout
- (void)performLayout;
Expand Down Expand Up @@ -130,15 +122,6 @@ - (void)emailPhoto;
// MWPhotoBrowser
@implementation MWPhotoBrowser

// Properties
@synthesize previousNavBarTintColor = _previousNavBarTintColor;
@synthesize navigationBarBackgroundImageDefault = _navigationBarBackgroundImageDefault,
navigationBarBackgroundImageLandscapePhone = _navigationBarBackgroundImageLandscapePhone;
@synthesize displayActionButton = _displayActionButton, actionsSheet = _actionsSheet;
@synthesize progressHUD = _progressHUD;
@synthesize previousViewControllerBackButton = _previousViewControllerBackButton;
@synthesize currentIndex = _currentPageIndex;

#pragma mark - NSObject

- (id)init {
Expand Down Expand Up @@ -226,7 +209,7 @@ - (void)releaseAllUnderlyingPhotos:(BOOL)preserveCurrent {
}

- (void)didReceiveMemoryWarning {

// Release any cached data, images, etc that aren't in use.
[self releaseAllUnderlyingPhotos:YES];
[_recycledPages removeAllObjects];
Expand Down Expand Up @@ -328,7 +311,7 @@ - (void)performLayout {
[newBackButton setTitleTextAttributes:[NSDictionary dictionary] forState:UIControlStateNormal];
[newBackButton setTitleTextAttributes:[NSDictionary dictionary] forState:UIControlStateHighlighted];
}
self.previousViewControllerBackButton = previousViewController.navigationItem.backBarButtonItem; // remember previous
_previousViewControllerBackButton = previousViewController.navigationItem.backBarButtonItem; // remember previous
previousViewController.navigationItem.backBarButtonItem = newBackButton;
}

Expand Down Expand Up @@ -387,7 +370,7 @@ - (void)viewDidUnload {
_toolbar = nil;
_previousButton = nil;
_nextButton = nil;
self.progressHUD = nil;
_progressHUD = nil;
[super viewDidUnload];
}

Expand Down Expand Up @@ -500,14 +483,14 @@ - (void)setNavBarAppearance:(BOOL)animated {
- (void)storePreviousNavBarAppearance {
_didSavePreviousStateOfNavBar = YES;
if ([UINavigationBar instancesRespondToSelector:@selector(barTintColor)]) {
self.previousNavBarBarTintColor = self.navigationController.navigationBar.barTintColor;
_previousNavBarBarTintColor = self.navigationController.navigationBar.barTintColor;
}
self.previousNavBarTintColor = self.navigationController.navigationBar.tintColor;
_previousNavBarTintColor = self.navigationController.navigationBar.tintColor;
_previousNavBarHidden = self.navigationController.navigationBarHidden;
_previousNavBarStyle = self.navigationController.navigationBar.barStyle;
if ([[UINavigationBar class] respondsToSelector:@selector(appearance)]) {
self.navigationBarBackgroundImageDefault = [self.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault];
self.navigationBarBackgroundImageLandscapePhone = [self.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsLandscapePhone];
_previousNavigationBarBackgroundImageDefault = [self.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault];
_previousNavigationBarBackgroundImageLandscapePhone = [self.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsLandscapePhone];
}
}

Expand All @@ -521,14 +504,14 @@ - (void)restorePreviousNavBarAppearance:(BOOL)animated {
}
navBar.barStyle = _previousNavBarStyle;
if ([[UINavigationBar class] respondsToSelector:@selector(appearance)]) {
[navBar setBackgroundImage:_navigationBarBackgroundImageDefault forBarMetrics:UIBarMetricsDefault];
[navBar setBackgroundImage:_navigationBarBackgroundImageLandscapePhone forBarMetrics:UIBarMetricsLandscapePhone];
[navBar setBackgroundImage:_previousNavigationBarBackgroundImageDefault forBarMetrics:UIBarMetricsDefault];
[navBar setBackgroundImage:_previousNavigationBarBackgroundImageLandscapePhone forBarMetrics:UIBarMetricsLandscapePhone];
}
// Restore back button if we need to
if (_previousViewControllerBackButton) {
UIViewController *previousViewController = [self.navigationController topViewController]; // We've disappeared so previous is now top
previousViewController.navigationItem.backBarButtonItem = _previousViewControllerBackButton;
self.previousViewControllerBackButton = nil;
_previousViewControllerBackButton = nil;
}
}
}
Expand Down Expand Up @@ -1231,11 +1214,11 @@ - (void)actionButtonPressed:(id)sender {

// Old handling of activities with action sheet
if ([MFMailComposeViewController canSendMail]) {
self.actionsSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self
_actionsSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self
cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:nil
otherButtonTitles:NSLocalizedString(@"Save", nil), NSLocalizedString(@"Copy", nil), NSLocalizedString(@"Email", nil), nil];
} else {
self.actionsSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self
_actionsSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self
cancelButtonTitle:NSLocalizedString(@"Cancel", nil) destructiveButtonTitle:nil
otherButtonTitles:NSLocalizedString(@"Save", nil), NSLocalizedString(@"Copy", nil), nil];
}
Expand Down Expand Up @@ -1290,7 +1273,7 @@ - (void)actionButtonPressed:(id)sender {
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (actionSheet.tag == ACTION_SHEET_OLD_ACTIONS) {
// Old Actions
self.actionsSheet = nil;
_actionsSheet = nil;
if (buttonIndex != actionSheet.cancelButtonIndex) {
if (buttonIndex == actionSheet.firstOtherButtonIndex) {
[self savePhoto]; return;
Expand Down
1 change: 0 additions & 1 deletion MWPhotoBrowser/Classes/MWPreprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//
// Created by Michael Waterfall on 01/10/2013.
//
//

#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
Expand Down

0 comments on commit 9fd9b27

Please sign in to comment.