diff --git a/DuckDuckGo/FavoritesHomeViewSectionRenderer.swift b/DuckDuckGo/FavoritesHomeViewSectionRenderer.swift index 673e6c4c37..0d1646f259 100644 --- a/DuckDuckGo/FavoritesHomeViewSectionRenderer.swift +++ b/DuckDuckGo/FavoritesHomeViewSectionRenderer.swift @@ -89,12 +89,20 @@ class FavoritesHomeViewSectionRenderer { } func sectionMargin(in collectionView: UICollectionView) -> CGFloat { - if isPad { + if controller is FavoritesOverlay { return Constants.largeModeMargin + } + + let margin: CGFloat + if isPad { + margin = (collectionView.frame.width - Constants.searchWidthPad) / 2 } else { let defaultMargin = FavoritesHomeViewSectionRenderer.Constants.sideInsets - return (collectionView.frame.width - Constants.searchWidth + defaultMargin) / 2 + let landscapeMargin = (collectionView.frame.width - Constants.searchWidth + defaultMargin) / 2 + margin = isPortrait ? defaultMargin : landscapeMargin } + + return margin } // Visible margin is adjusted for offset inside Favorite Cells @@ -180,7 +188,7 @@ class FavoritesHomeViewSectionRenderer { referenceSizeForHeaderInSection section: Int) -> CGSize? { return CGSize(width: 1, height: headerHeight) } - + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize? {