Skip to content

Commit

Permalink
Show different number of apps in different orientations
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitschlag authored and r10s committed Jan 27, 2025
1 parent 61e9993 commit c3cb14f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions deltachat-ios/Chat/Apps/RecentWebxdcAppsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,17 @@ class RecentWebxdcAppsViewController: UIViewController {

private static func layout() -> UICollectionViewCompositionalLayout {

let layout = UICollectionViewCompositionalLayout { _, environment in
let itemsPerRow = environment.traitCollection.horizontalSizeClass == .compact ? 4 : 8
let layout = UICollectionViewCompositionalLayout { _, _ in
let itemsPerRow: Int
if UIDevice.current.userInterfaceIdiom == .phone {
if UIApplication.shared.orientation == .portrait {
itemsPerRow = 4
} else { // landscape
itemsPerRow = 8
}
} else {
itemsPerRow = 6
}
let fractionalWidth: CGFloat = 1 / CGFloat(itemsPerRow)

let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(fractionalWidth), heightDimension: .fractionalHeight(1))
Expand Down

0 comments on commit c3cb14f

Please sign in to comment.