Add padding below last row of media content

pull/2/head
Michael Kirk 6 years ago
parent a1e008f930
commit fbc0b5f8ee

@ -56,6 +56,9 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
collectionView.register(PhotoGridViewCell.self, forCellWithReuseIdentifier: PhotoGridViewCell.reuseIdentifier) 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 view.backgroundColor = .ows_gray95
// The PhotoCaptureVC needs a shadow behind it's cancel button, so we use a custom icon. // 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: // MARK:
var lastPageYOffset: CGFloat {
return collectionView.contentSize.height - collectionView.frame.height
}
func scrollToBottom(animated: Bool) { func scrollToBottom(animated: Bool) {
self.view.layoutIfNeeded() self.view.layoutIfNeeded()
@ -243,12 +250,13 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
return return
} }
let lastSection = collectionView.numberOfSections - 1 let yOffset = lastPageYOffset
let lastItem = collectionView.numberOfItems(inSection: lastSection) - 1 guard yOffset > 0 else {
if lastSection >= 0 && lastItem >= 0 { // less than 1 page of content. Do not offset.
let lastIndex = IndexPath(item: lastItem, section: lastSection) return
collectionView.scrollToItem(at: lastIndex, at: .bottom, animated: animated)
} }
collectionView.setContentOffset(CGPoint(x: 0, y: yOffset), animated: animated)
} }
private func reloadDataAndRestoreSelection() { private func reloadDataAndRestoreSelection() {

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

Loading…
Cancel
Save