forked from shadowfacts/Tusker
Fix gallery controls visibility not transferring between pages
Closes #511
This commit is contained in:
parent
50b84350d9
commit
47b9ac890a
|
@ -44,6 +44,7 @@ class GalleryItemViewController: UIViewController {
|
||||||
private(set) var scrollAndZoomEnabled = true
|
private(set) var scrollAndZoomEnabled = true
|
||||||
|
|
||||||
private var scrollViewSizeForLastZoomScaleUpdate: CGSize?
|
private var scrollViewSizeForLastZoomScaleUpdate: CGSize?
|
||||||
|
|
||||||
override var prefersHomeIndicatorAutoHidden: Bool {
|
override var prefersHomeIndicatorAutoHidden: Bool {
|
||||||
return !controlsVisible
|
return !controlsVisible
|
||||||
}
|
}
|
||||||
|
@ -227,6 +228,8 @@ class GalleryItemViewController: UIViewController {
|
||||||
updateZoomScale(resetZoom: true)
|
updateZoomScale(resetZoom: true)
|
||||||
}
|
}
|
||||||
centerContent()
|
centerContent()
|
||||||
|
// Ensure the transform is correct if the controls are hidden and their size changed.
|
||||||
|
setControlsVisible(controlsVisible, animated: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func viewDidAppear(_ animated: Bool) {
|
override func viewDidAppear(_ animated: Bool) {
|
||||||
|
@ -289,10 +292,12 @@ class GalleryItemViewController: UIViewController {
|
||||||
|
|
||||||
func setControlsVisible(_ visible: Bool, animated: Bool) {
|
func setControlsVisible(_ visible: Bool, animated: Bool) {
|
||||||
controlsVisible = visible
|
controlsVisible = visible
|
||||||
|
|
||||||
guard let topControlsView,
|
guard let topControlsView,
|
||||||
let bottomControlsView else {
|
let bottomControlsView else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateControlsViews() {
|
func updateControlsViews() {
|
||||||
topControlsView.transform = CGAffineTransform(translationX: 0, y: visible ? 0 : -topControlsView.bounds.height)
|
topControlsView.transform = CGAffineTransform(translationX: 0, y: visible ? 0 : -topControlsView.bounds.height)
|
||||||
bottomControlsView.transform = CGAffineTransform(translationX: 0, y: visible ? 0 : bottomControlsView.bounds.height)
|
bottomControlsView.transform = CGAffineTransform(translationX: 0, y: visible ? 0 : bottomControlsView.bounds.height)
|
||||||
|
|
|
@ -125,6 +125,8 @@ extension GalleryViewController: UIPageViewControllerDataSource {
|
||||||
extension GalleryViewController: UIPageViewControllerDelegate {
|
extension GalleryViewController: UIPageViewControllerDelegate {
|
||||||
public func pageViewController(_ pageViewController: UIPageViewController, willTransitionTo pendingViewControllers: [UIViewController]) {
|
public func pageViewController(_ pageViewController: UIPageViewController, willTransitionTo pendingViewControllers: [UIViewController]) {
|
||||||
currentItemViewController.content.galleryContentWillDisappear()
|
currentItemViewController.content.galleryContentWillDisappear()
|
||||||
|
let new = pendingViewControllers[0] as! GalleryItemViewController
|
||||||
|
new.setControlsVisible(currentItemViewController.controlsVisible, animated: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
|
public func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
|
||||||
|
|
Loading…
Reference in New Issue