Add padding below last row of media content

This commit is contained in:
Michael Kirk 2019-04-22 11:25:22 -07:00
parent a1e008f930
commit fbc0b5f8ee
2 changed files with 17 additions and 8 deletions

View File

@ -56,6 +56,9 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
collectionView.register(PhotoGridViewCell.self, forCellWithReuseIdentifier: PhotoGridViewCell.reuseIdentifier)
// ensure images at the end of the list can be scrolled above the bottom buttons
let bottomButtonInset = -1 * SendMediaNavigationController.bottomButtonsCenterOffset + SendMediaNavigationController.bottomButtonWidth / 2
collectionView.contentInset.bottom = bottomButtonInset + 8
view.backgroundColor = .ows_gray95
// The PhotoCaptureVC needs a shadow behind it's cancel button, so we use a custom icon.
@ -235,6 +238,10 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
// MARK:
var lastPageYOffset: CGFloat {
return collectionView.contentSize.height - collectionView.frame.height
}
func scrollToBottom(animated: Bool) {
self.view.layoutIfNeeded()
@ -243,12 +250,13 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
return
}
let lastSection = collectionView.numberOfSections - 1
let lastItem = collectionView.numberOfItems(inSection: lastSection) - 1
if lastSection >= 0 && lastItem >= 0 {
let lastIndex = IndexPath(item: lastItem, section: lastSection)
collectionView.scrollToItem(at: lastIndex, at: .bottom, animated: animated)
let yOffset = lastPageYOffset
guard yOffset > 0 else {
// less than 1 page of content. Do not offset.
return
}
collectionView.setContentOffset(CGPoint(x: 0, y: yOffset), animated: animated)
}
private func reloadDataAndRestoreSelection() {

View File

@ -135,6 +135,7 @@ class SendMediaNavigationController: OWSNavigationController {
}
// MARK: Views
public static let bottomButtonWidth: CGFloat = 44
private lazy var doneButton: DoneButton = {
let button = DoneButton()
@ -149,7 +150,7 @@ class SendMediaNavigationController: OWSNavigationController {
tintColor: .ows_gray60,
block: { [weak self] in self?.didTapBatchModeButton() })
let width: CGFloat = 44
let width: CGFloat = type(of: self).bottomButtonWidth
button.autoSetDimensions(to: CGSize(width: width, height: width))
button.layer.cornerRadius = width / 2
button.imageEdgeInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
@ -164,7 +165,7 @@ class SendMediaNavigationController: OWSNavigationController {
tintColor: .ows_gray60,
block: { [weak self] in self?.didTapCameraModeButton() })
let width: CGFloat = 44
let width: CGFloat = type(of: self).bottomButtonWidth
button.autoSetDimensions(to: CGSize(width: width, height: width))
button.layer.cornerRadius = width / 2
button.imageEdgeInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
@ -179,7 +180,7 @@ class SendMediaNavigationController: OWSNavigationController {
tintColor: .ows_gray60,
block: { [weak self] in self?.didTapMediaLibraryModeButton() })
let width: CGFloat = 44
let width: CGFloat = type(of: self).bottomButtonWidth
button.autoSetDimensions(to: CGSize(width: width, height: width))
button.layer.cornerRadius = width / 2
button.imageEdgeInsets = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)