Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 'statusBarMode' to drive whether the status bar is hidden or not. #336

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Examples/Sources/ObjC/NYTViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ - (IBAction)imageButtonTapped:(id)sender {

NYTPhotosViewController *photosViewController = [[NYTPhotosViewController alloc] initWithDataSource:self.dataSource initialPhoto:nil delegate:self];

photosViewController.underStatusBar = TristateBoolTrue;

[self presentViewController:photosViewController animated:YES completion:nil];

[self updateImagesOnPhotosViewController:photosViewController afterDelayWithDataSource:self.dataSource];
Expand Down
15 changes: 7 additions & 8 deletions NYTPhotoViewer/NYTPhotosViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ extern NSString * const NYTPhotosViewControllerDidDismissNotification;

@interface NYTPhotosViewController : UIViewController

typedef NS_ENUM(NSUInteger, TristateBool) {
TristateBoolDefault,
TristateBoolFalse,
TristateBoolTrue
typedef NS_ENUM(NSUInteger, NYTPhotoViewerStatusBarMode) {
NYTPhotoViewerStatusBarModeDynamic, /* hide statusbar when view.safeArea.top == 0 */
NYTPhotoViewerStatusBarModeHidden,
NYTPhotoViewerStatusBarModeShown
};

/**
Expand Down Expand Up @@ -82,11 +82,10 @@ typedef NS_ENUM(NSUInteger, TristateBool) {
@property (nonatomic, readonly, nullable) NYTPhotosOverlayView *overlayView;

/**
* Shows all content under status bar frame. Defaults TristateBoolDefault.
* If 'TristateBoolTrue' or 'TristateBoolFalse', prefersStatusBarHidden returns the inverse.
* If 'TristateBoolDefault', prefersStatusBarHidden returns view.safeArea.top == 0.
* This determines whether we display the status bar or not
* Defaults to NYTPhotoViewerStatusBarModeDynamic.
*/
@property (nonatomic) TristateBool underStatusBar;
@property (nonatomic) NYTPhotoViewerStatusBarMode statusBarMode;

/**
* The left bar button item overlaying the photo.
Expand Down
15 changes: 11 additions & 4 deletions NYTPhotoViewer/NYTPhotosViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,27 @@ - (void)viewWillLayoutSubviews {

- (BOOL)prefersStatusBarHidden {
BOOL result;
switch (self.underStatusBar) {
case TristateBoolDefault:
switch (self.statusBarMode) {
case NYTPhotoViewerStatusBarModeDynamic:
result = self.view.safeAreaInsets.top == 0;
break;
case TristateBoolFalse:
case NYTPhotoViewerStatusBarModeHidden:
result = true;
break;
case TristateBoolTrue:
case NYTPhotoViewerStatusBarModeShown:
result = false;
break;
}
return result;
}

- (void)viewSafeAreaInsetsDidChange {
if (self.statusBarMode == NYTPhotoViewerStatusBarModeDynamic) {
[self setNeedsStatusBarAppearanceUpdate];
}
[super viewSafeAreaInsetsDidChange];
}

- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
mr-fixit marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
4 changes: 3 additions & 1 deletion scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ fi

cd "$(dirname "$0")/../Examples"

bundle config set path 'vendor/bundle'
# uncomment the following if you get errors about not having access to the system's install
mr-fixit marked this conversation as resolved.
Show resolved Hide resolved
# bundle config --local path 'vendor/bundle'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually pretty rare to mention this stuff in a script like this. If we want to guide people on their ruby setup, maybe we should do it in the readme instead, under a "Contributing" section?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm happy to delete it. it's probably wrong-advice anyway.


bundle install
bundle exec pod install