Fix Photo Detail Screen Layout
This commit is contained in:
parent
696f7e0586
commit
85c686d0e9
|
|
@ -20,6 +20,7 @@ public protocol ActivityIndicatable {
|
|||
}
|
||||
|
||||
public extension ActivityIndicatable where Self: UIViewController {
|
||||
|
||||
func updateVisibilityOfActivityIndicator(activityIndicator: UIView) {
|
||||
if isProgressing() {
|
||||
if !view.subviews.contains(activityIndicator) {
|
||||
|
|
|
|||
|
|
@ -187,6 +187,7 @@ class AlbumListViewController: UITableViewController, EmptyIndicatable, Activity
|
|||
shouldShowEmptyAlbum: nohanaImagePickerController!.shouldShowEmptyAlbum,
|
||||
handler: { () -> Void in
|
||||
dispatch_async(dispatch_get_main_queue(), { [weak momentViewController] in
|
||||
momentViewController?.didProgressComplete()
|
||||
momentViewController?.isLoading = false
|
||||
momentViewController?.collectionView?.reloadData()
|
||||
momentViewController?.scrollCollectionViewToInitialPosition()
|
||||
|
|
|
|||
|
|
@ -47,13 +47,11 @@ class AssetDetailListViewController: AssetListViewController {
|
|||
}
|
||||
|
||||
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
|
||||
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
|
||||
let indexPath = currentIndexPath
|
||||
view.hidden = true
|
||||
coordinator.animateAlongsideTransition(nil) { _ in
|
||||
self.view.invalidateIntrinsicContentSize()
|
||||
for subView in self.view.subviews {
|
||||
subView.invalidateIntrinsicContentSize()
|
||||
}
|
||||
self.collectionView?.reloadData()
|
||||
self.scrollCollectionView(to: indexPath)
|
||||
self.view.hidden = false
|
||||
|
|
@ -75,11 +73,13 @@ class AssetDetailListViewController: AssetListViewController {
|
|||
}
|
||||
|
||||
override func scrollCollectionView(to indexPath: NSIndexPath) {
|
||||
guard photoKitAssetList.count > 0 else {
|
||||
guard photoKitAssetList?.count > 0 else {
|
||||
return
|
||||
}
|
||||
let toIndexPath = NSIndexPath(forItem: indexPath.item, inSection: 0)
|
||||
collectionView?.scrollToItemAtIndexPath(toIndexPath, atScrollPosition: UICollectionViewScrollPosition.CenteredHorizontally, animated: false)
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
let toIndexPath = NSIndexPath(forItem: indexPath.item, inSection: 0)
|
||||
self.collectionView?.scrollToItemAtIndexPath(toIndexPath, atScrollPosition: UICollectionViewScrollPosition.CenteredHorizontally, animated: false)
|
||||
}
|
||||
}
|
||||
|
||||
override func scrollCollectionViewToInitialPosition() {
|
||||
|
|
@ -113,7 +113,6 @@ class AssetDetailListViewController: AssetListViewController {
|
|||
nohanaImagePickerController = nohanaImagePickerController else {
|
||||
fatalError("failed to dequeueReusableCellWithIdentifier(\"AssetDetailCell\")")
|
||||
}
|
||||
cell.invalidateIntrinsicContentSize()
|
||||
cell.scrollView.zoomScale = 1
|
||||
cell.tag = indexPath.item
|
||||
|
||||
|
|
|
|||
|
|
@ -54,12 +54,7 @@ class AssetListViewController: UICollectionViewController {
|
|||
if let nohanaImagePickerController = nohanaImagePickerController {
|
||||
setToolbarTitle(nohanaImagePickerController)
|
||||
}
|
||||
view.invalidateIntrinsicContentSize()
|
||||
for subView in view.subviews {
|
||||
subView.invalidateIntrinsicContentSize()
|
||||
}
|
||||
collectionView?.reloadData()
|
||||
|
||||
scrollCollectionViewToInitialPosition()
|
||||
}
|
||||
|
||||
|
|
@ -84,7 +79,12 @@ class AssetListViewController: UICollectionViewController {
|
|||
}
|
||||
|
||||
func scrollCollectionView(to indexPath: NSIndexPath) {
|
||||
collectionView?.scrollToItemAtIndexPath(indexPath, atScrollPosition: .Bottom, animated: false)
|
||||
guard photoKitAssetList?.count > 0 else {
|
||||
return
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
self.collectionView?.scrollToItemAtIndexPath(indexPath, atScrollPosition: .Bottom, animated: false)
|
||||
}
|
||||
}
|
||||
|
||||
func scrollCollectionViewToInitialPosition() {
|
||||
|
|
@ -99,6 +99,7 @@ class AssetListViewController: UICollectionViewController {
|
|||
}
|
||||
|
||||
// MARK: - UICollectionViewDataSource
|
||||
|
||||
override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
|
||||
return photoKitAssetList.count
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class ExpandingAnimationController: NSObject, UIViewControllerAnimatedTransition
|
|||
containerView.addSubview(toVC.view)
|
||||
containerView.addSubview(expandingImageView)
|
||||
toVC.view.alpha = 0
|
||||
toVC.collectionView?.hidden = true
|
||||
toVC.collectionView?.alpha = 0
|
||||
toVC.view.backgroundColor = UIColor.blackColor()
|
||||
fromCell.alpha = 0
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ class ExpandingAnimationController: NSObject, UIViewControllerAnimatedTransition
|
|||
expandingImageView.frame = Size.expandingAnimationToCellRect(fromVC, toSize: expandingImageView.image!.size)
|
||||
}) { (_) -> Void in
|
||||
self.fromCell.alpha = 1
|
||||
toVC.collectionView?.hidden = false
|
||||
toVC.collectionView?.alpha = 1
|
||||
expandingImageView.removeFromSuperview()
|
||||
transitionContext.completeTransition(!transitionContext.transitionWasCancelled())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,14 +36,12 @@ class MomentViewController: AssetListViewController, ActivityIndicatable {
|
|||
guard isFirstAppearance else {
|
||||
return
|
||||
}
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
let lastSection = self.momentAlbumList.count - 1
|
||||
guard lastSection >= 0 else {
|
||||
return
|
||||
}
|
||||
let indexPath = NSIndexPath(forItem: self.momentAlbumList[lastSection].count - 1, inSection: lastSection)
|
||||
self.scrollCollectionView(to: indexPath)
|
||||
let lastSection = self.momentAlbumList.count - 1
|
||||
guard lastSection >= 0 else {
|
||||
return
|
||||
}
|
||||
let indexPath = NSIndexPath(forItem: momentAlbumList[lastSection].count - 1, inSection: lastSection)
|
||||
scrollCollectionView(to: indexPath)
|
||||
isFirstAppearance = false
|
||||
}
|
||||
|
||||
|
|
@ -127,6 +125,11 @@ class MomentViewController: AssetListViewController, ActivityIndicatable {
|
|||
return isLoading
|
||||
}
|
||||
|
||||
func didProgressComplete() {
|
||||
isFirstAppearance = true
|
||||
scrollCollectionViewToInitialPosition()
|
||||
}
|
||||
|
||||
// MARK: - UICollectionViewDelegate
|
||||
|
||||
override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="tkA-yz-hIq">
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="tkA-yz-hIq">
|
||||
<dependencies>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ struct Size {
|
|||
}
|
||||
|
||||
static func navigationBarHeight(viewController: UIViewController) -> CGFloat {
|
||||
return viewController.navigationController?.navigationBar.frame.size.height ?? CGFloat(44)
|
||||
return viewController.navigationController?.navigationBar.frame.size.height ?? CGFloat(0)
|
||||
}
|
||||
|
||||
static func appBarHeight(viewController: UIViewController) -> CGFloat {
|
||||
|
|
|
|||
Loading…
Reference in New Issue