From fee7bc74012423396e6825c8f5feea9ce431c0b2 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Sat, 23 May 2020 19:08:43 -0400 Subject: [PATCH] Resolve site cell sizing issues across window sizes. --- platform-darwin/Source/iOS/MPSitesViewController.m | 13 +++++++++++++ platform-darwin/Source/iOS/Storyboard.storyboard | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/platform-darwin/Source/iOS/MPSitesViewController.m b/platform-darwin/Source/iOS/MPSitesViewController.m index e94b7154..bbadc0cc 100644 --- a/platform-darwin/Source/iOS/MPSitesViewController.m +++ b/platform-darwin/Source/iOS/MPSitesViewController.m @@ -172,6 +172,19 @@ typedef NS_OPTIONS( NSUInteger, MPPasswordsTips ) { return cell; } +#pragma mark - UICollectionViewDelegateFlowLayout + +- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout + sizeForItemAtIndexPath:(NSIndexPath *)indexPath { + + UICollectionViewFlowLayout *layout = (UICollectionViewFlowLayout *)collectionViewLayout; + CGFloat availableWidth = collectionView.bounds.size.width + - collectionView.layoutMargins.left - collectionView.layoutMargins.right + - layout.sectionInset.left - layout.sectionInset.right; + CGFloat cells = MAX( 1, (int)((availableWidth + layout.minimumInteritemSpacing) / (318 + layout.minimumInteritemSpacing)) ); + return CGSizeMake( (availableWidth - layout.minimumInteritemSpacing * (cells - 1)) / cells, 100 ); +} + #pragma mark - UIScrollDelegate - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { diff --git a/platform-darwin/Source/iOS/Storyboard.storyboard b/platform-darwin/Source/iOS/Storyboard.storyboard index 517ea590..ef7ec33d 100644 --- a/platform-darwin/Source/iOS/Storyboard.storyboard +++ b/platform-darwin/Source/iOS/Storyboard.storyboard @@ -69,7 +69,7 @@ - +