12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import Foundation
- import UIKit
- import NextcloudKit
- extension NCCollectionViewCommon: NCMediaLayoutDelegate {
- func getColumnCount() -> Int {
- if self.numberOfColumns == 0,
- let layoutForView = database.getLayoutForView(account: session.account, key: NCGlobal.shared.layoutViewFiles, serverUrl: self.serverUrl) {
- if layoutForView.columnPhoto > 0 {
- self.numberOfColumns = layoutForView.columnPhoto
- } else {
- self.numberOfColumns = 3
- }
- }
- return self.numberOfColumns
- }
- func getLayout() -> String? {
- return self.layoutType
- }
- func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, heightForHeaderInSection section: Int) -> Float {
- return Float(sizeForHeaderInSection(section: section).height)
- }
- func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, heightForFooterInSection section: Int) -> Float {
- return Float(sizeForFooterInSection(section: section).height)
- }
- func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, insetForSection section: Int) -> UIEdgeInsets {
- return .zero
- }
- func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, insetForHeaderInSection section: Int) -> UIEdgeInsets {
- return .zero
- }
- func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, insetForFooterInSection section: Int) -> UIEdgeInsets {
- return .zero
- }
- func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, minimumInteritemSpacingForSection section: Int) -> Float {
- return 1.0
- }
- func collectionView(_ collectionView: UICollectionView, layout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath, columnCount: Int, typeLayout: String) -> CGSize {
- if typeLayout == NCGlobal.shared.layoutPhotoSquare {
- return CGSize(width: collectionView.frame.width / CGFloat(columnCount), height: collectionView.frame.width / CGFloat(columnCount))
- } else {
- guard let metadata = dataSource.getMetadata(indexPath: indexPath) else { return .zero }
- if metadata.imageSize != CGSize.zero {
- return metadata.imageSize
- } else {
- return CGSize(width: collectionView.frame.width / CGFloat(columnCount), height: collectionView.frame.width / CGFloat(columnCount))
- }
- }
- }
- }
|