Fix large image view top controls on iPhone Xs Max & Xr

This commit is contained in:
Shadowfacts 2018-09-12 22:29:58 -04:00
parent 6f424666d8
commit 76972237ba
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
3 changed files with 22 additions and 12 deletions

View File

@ -25,9 +25,9 @@ class MastodonController {
client = Client(baseURL: url)
if let accessToken = LocalData.shared.accessToken {
client.accessToken = accessToken
}
client.clientID = LocalData.shared.clientID
client.clientSecret = LocalData.shared.clientSecret
client.accessToken = LocalData.shared.accessToken
}
func registerApp(completion: @escaping () -> Void) {

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.13.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="8pH-Ao-p7G">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="8pH-Ao-p7G">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.9"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>

View File

@ -47,6 +47,8 @@ class LargeImageViewController: UIViewController, UIScrollViewDelegate {
@IBOutlet weak var bottomControlsView: UIView!
@IBOutlet weak var descriptionLabel: UILabel!
var initializedTopControlsConstrains = false
var image: UIImage?
var imageDescription: String?
@ -82,23 +84,31 @@ class LargeImageViewController: UIViewController, UIScrollViewDelegate {
bottomControlsView.isHidden = true
}
// if running on iPhone X
if UIScreen.main.nativeBounds.height == 2436 {
topControlsHeightConstraint.constant = 35
downloadButtonLeadingConstraint.constant = 35
closeButtonTrailingConstraint.constant = 35
}
dismissInteractionController = LargeImageInteractionController(viewController: self)
}
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
let widthScale = view.bounds.size.width / imageView.bounds.width
let heightScale = view.bounds.size.height / imageView.bounds.height
let minScale = min(widthScale, heightScale)
scrollView.minimumZoomScale = minScale
scrollView.zoomScale = minScale
scrollView.maximumZoomScale = minScale >= 1 ? minScale + 2 : 2
if !initializedTopControlsConstrains {
initializedTopControlsConstrains = true
if view.safeAreaInsets.top == 44 {
// running on iPhone X style notched device
let notchWidth: CGFloat = 209
let earWidth = (view.bounds.width - notchWidth) / 2
let offset = (earWidth - downloadButton.bounds.width) / 2
downloadButtonLeadingConstraint.constant = offset
closeButtonTrailingConstraint.constant = offset
}
}
}
func viewForZooming(in scrollView: UIScrollView) -> UIView? {