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 iOS 11/iPhone X support #169

Merged
merged 2 commits into from Nov 22, 2017
Merged

Conversation

humblehacker
Copy link
Contributor

  • Use safeAreaInsets on iOS 11
  • compensate for erroneous 20 px top inset with hidden status bar on iOS 11
  • add missing .deleteLayout to handling of GalleryConfiguration

Closes #164

- Use safeAreaInsets on iOS 11
- compensate for erroneous 20 px top inset with hidden status bar on iOS 11
- add missing .deleteLayout to handling of GalleryConfiguration

Closes Krisiacik#164
@humblehacker humblehacker mentioned this pull request Nov 21, 2017
@humblehacker
Copy link
Contributor Author

Hmm, hold off on approving this one. Seems safeAreaInsets at the time layout is calculated is coming back empty. I'm investigating.

These changes correct behavior around status bar visibility and ensures that controls have identical placement between iOS 11 and iOS 10 (and below).

- remove laziness of `defaultInsets`.  It may return an empty set of insets early on.
- on iOS 10 and below, add a top inset of 20px when `statusBarHidden == false`, so it matches what we’d get on iOS 11
- on iOS 11, reduce the top inset by 20px when `statusBarHidden == true` or we’re running on an iPhone X (since the status bar is up in the “ears”, the status bar effectively takes up no space)
@humblehacker
Copy link
Contributor Author

Ok, this now works to my satisfaction. Please let me know what you think.

Note is probably a breaking change for anyone who was manually working around these issues.

@zfoltin
Copy link
Collaborator

zfoltin commented Nov 22, 2017

LGTM 👍

@RuiAAPeres
Copy link
Collaborator

@humblehacker do you mind adding a gif or an image of your work?

@zfoltin
Copy link
Collaborator

zfoltin commented Nov 22, 2017

Guess we can reuse the screenshot from #164 - maybe add a line to CHANGELOG.md too?

@humblehacker
Copy link
Contributor Author

humblehacker commented Nov 22, 2017

Ok, here's a collection of screenshots with various configurations:

without status bar with status bar
iPhone 6s - 10.1 iPhone 6s - 10.1 - statusBarHidden
iPhone 6s - 10.1 iPhone 6s - 10.1 - statusBarHidden
iPhone 6s - 11.1 iPhone 6s - 11.1 - statusBarHidden
iPhone 6s - 11.1 iPhone 6s - 11.1 - statusBarHidden
iPhone X - 11.1 iPhone X - 11.1 - statusBarHidden
iPhone X - 11.1 iPhone X - 11.1 - statusBarHidden

@RuiAAPeres RuiAAPeres merged commit a4de06a into Krisiacik:master Nov 22, 2017
@ugenlik
Copy link

ugenlik commented May 14, 2018

@humblehacker Do I have to do anything extra to activate this? This changes doesn't work for me in iPhone X.

self.presentImageGallery(galleryViewController)

and it is initiated like =

let galleryViewController = GalleryViewController(startIndex: 0, itemsDataSource: self, itemsDelegate: self, displacedViewsDataSource: self, configuration: galleryConfiguration())

            GalleryConfigurationItem.statusBarHidden(false),
            
            GalleryConfigurationItem.closeButtonMode(.builtIn),
            
            GalleryConfigurationItem.pagingMode(.standard),
            GalleryConfigurationItem.presentationStyle(.displacement),
            GalleryConfigurationItem.hideDecorationViewsOnLaunch(false),
            
            GalleryConfigurationItem.swipeToDismissMode(.vertical),
            GalleryConfigurationItem.toggleDecorationViewsBySingleTap(false),
            
            GalleryConfigurationItem.overlayColor(UIColor(white: 0.035, alpha: 1)),
            GalleryConfigurationItem.overlayColorOpacity(1),
            GalleryConfigurationItem.overlayBlurOpacity(1),
            GalleryConfigurationItem.overlayBlurStyle(UIBlurEffectStyle.light),
            
            GalleryConfigurationItem.videoControlsColor(.white),
            
            GalleryConfigurationItem.maximumZoomScale(8),
            GalleryConfigurationItem.swipeToDismissThresholdVelocity(500),
            
            GalleryConfigurationItem.doubleTapToZoomDuration(0.15),
            
            GalleryConfigurationItem.blurPresentDuration(0.5),
            GalleryConfigurationItem.blurPresentDelay(0),
            GalleryConfigurationItem.colorPresentDuration(0.25),
            GalleryConfigurationItem.colorPresentDelay(0),
            
            GalleryConfigurationItem.blurDismissDuration(0.1),
            GalleryConfigurationItem.blurDismissDelay(0.4),
            GalleryConfigurationItem.colorDismissDuration(0.45),
            GalleryConfigurationItem.colorDismissDelay(0),
            
            GalleryConfigurationItem.itemFadeDuration(0.3),
            GalleryConfigurationItem.decorationViewsFadeDuration(0.15),
            GalleryConfigurationItem.rotationDuration(0.15),
            
            GalleryConfigurationItem.displacementDuration(0.55),
            GalleryConfigurationItem.reverseDisplacementDuration(0.25),
            GalleryConfigurationItem.displacementTransitionStyle(.springBounce(0.7)),
            GalleryConfigurationItem.displacementTimingCurve(.linear),
            
            GalleryConfigurationItem.displacementKeepOriginalInPlace(false),
            GalleryConfigurationItem.displacementInsetMargin(50)
        ]

img_1184

@ugenlik
Copy link

ugenlik commented May 15, 2018

@humblehacker never mind, had to do pod 'ImageViewer', :git => 'https://github.com/MailOnline/ImageViewer.git', :commit => 'a4de06a08a78c4b0a65a48aa891f755b64ff03a because it is not in the release

@humblehacker
Copy link
Contributor Author

@ugenlik Glad you got it working. You can also use :branch => 'master' instead of a specific commit. That's what I'm using until a new release is available.

antipex pushed a commit to perrystreetsoftware/ImageViewer that referenced this pull request Sep 23, 2019
* Add iOS 11/iPhone X support

- Use safeAreaInsets on iOS 11
- compensate for erroneous 20 px top inset with hidden status bar on iOS 11
- add missing .deleteLayout to handling of GalleryConfiguration

Closes Krisiacik#164

* Improve handling of status bar

These changes correct behavior around status bar visibility and ensures that controls have identical placement between iOS 11 and iOS 10 (and below).

- remove laziness of `defaultInsets`.  It may return an empty set of insets early on.
- on iOS 10 and below, add a top inset of 20px when `statusBarHidden == false`, so it matches what we’d get on iOS 11
- on iOS 11, reduce the top inset by 20px when `statusBarHidden == true` or we’re running on an iPhone X (since the status bar is up in the “ears”, the status bar effectively takes up no space)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants