Git Product home page Git Product logo

admozaiccollectionviewlayout's People

Contributors

antondomashnev avatar cyrilchandelier avatar pawlowskialex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

admozaiccollectionviewlayout's Issues

How to add sticky header?

Hi! In default collection view layout we can use 'sectionHeadersPinToVisibleBounds'. How can I pin header in this layout?

Header workaround

Great pod, thanks! Do you plan to implement headers/footers anytime soon? Do you have a workaround solution for a header until this is implemented?

I'm stuck here. Thanks!

how to get width dynamically ?

hi there,
Due to the device size & orientation, how can i get proper width dynamically ?
i divide column count with collection-view width size but results not as expected.

Build error

I'm getting a build error (only in our CI tool, not in XCode):

Pods/ADMozaicCollectionViewLayout/ADMozaikCollectionViewLayout/Private/ADMozaikLayoutAttributes.swift:[102,39] 'Error' is not convertible to 'CustomStringConvertible'; did you mean to use 'as!' to force downcast? » fatalError((error as CustomStringConvertible).description)

use in UIViewController, but The ViewController not deinit,please help me, thanks

private lazy var collectionView : UICollectionView = {
let view = UICollectionView.init(frame: .zero, collectionViewLayout: ADMozaikLayout(delegate: self))
view.backgroundColor = UIColor.white
view.delegate = self
view.dataSource = self
view.register(OwohThemePlazaCollectionViewCell.self,
forCellWithReuseIdentifier: NSStringFromClass(OwohThemePlazaCollectionViewCell.self))
view.addRefreshEffect(headerRefreshBlock: { [weak self] in
self?.loadData()
}) { [weak self] in
self?.loadMore()
}
return view
}()

// MARK: - ADMozaikLayoutDelegate
extension OwohThemePlazaViewController : ADMozaikLayoutDelegate {
func collectonView(_ collectionView: UICollectionView,
mozaik layoyt: ADMozaikLayout,
geometryInfoFor section: ADMozaikLayoutSection) -> ADMozaikLayoutSectionGeometryInfo {
let rowHeight: CGFloat = itemSize.height
let columns = [ADMozaikLayoutColumn(width: itemSize.width),
ADMozaikLayoutColumn(width: itemSize.width),
ADMozaikLayoutColumn(width: itemSize.width)]
let geometryInfo = ADMozaikLayoutSectionGeometryInfo(rowHeight: rowHeight,
columns: columns,
minimumInteritemSpacing: itemSpacing,
minimumLineSpacing: itemSpacing,
sectionInset: .zero,
headerHeight: 0,
footerHeight: 0)
return geometryInfo
}

func collectionView(_ collectionView: UICollectionView,
                    mozaik layout: ADMozaikLayout,
                    mozaikSizeForItemAt indexPath: IndexPath) -> ADMozaikLayoutSize {
    if self.bigCellIndexs.contains(indexPath.item){
        return ADMozaikLayoutSize(numberOfColumns: 2, numberOfRows: 2)
    }
    return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 1)
}

}

Create ADMozaikLayout in xib or Storyboard

It would be great to have posibility to create ADMozaikLayout from xib or Storyboard.

Now, we have init?(coder aDecoder: NSCoder) but then we are not able to set up correctly rowHeight and columns.

Crash on ADMozaikLayoutSectionMatrixError.rowOutOfBounds

`fileprivate var mosaicLayout: ADMozaikLayout {
let layout = ADMozaikLayout(delegate: self)
return layout
}
func setupCollection() {

    self.collection.collectionViewLayout.invalidateLayout()
    self.collection.setCollectionViewLayout(self.mosaicLayout, animated: true)
    
    collection.delegate = self
    collection.dataSource = self
    collection.reloadData()
    
}

extension PostGridCell: ADMozaikLayoutDelegate {

func collectionView(_ collectionView: UICollectionView, mozaik layout: ADMozaikLayout, mozaikSizeForItemAt indexPath: IndexPath) -> ADMozaikLayoutSize {
    
    
    if indexPath.item == 0 {
        return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 1)
    }
    if indexPath.item % 8 == 0 {
        return ADMozaikLayoutSize(numberOfColumns: 2, numberOfRows: 2)
    }
    else if indexPath.item % 6 == 0 {
        return ADMozaikLayoutSize(numberOfColumns: 3, numberOfRows: 1)
    }
    else if indexPath.item % 4 == 0 {
        return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 3)
    }
    else {
        return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 1)
    }
}

func collectonView(_ collectionView: UICollectionView, mozaik layoyt: ADMozaikLayout, geometryInfoFor section: ADMozaikLayoutSection) -> ADMozaikLayoutSectionGeometryInfo {
    let width = UIScreen.main.bounds.width/5
    
    let rowHeight: CGFloat = width//layoutType == .portrait ? 93 : 110
    let columns = [ADMozaikLayoutColumn(width: width), ADMozaikLayoutColumn(width: width), ADMozaikLayoutColumn(width: width), ADMozaikLayoutColumn(width: width)]
    
    let geometryInfo = ADMozaikLayoutSectionGeometryInfo(rowHeight: rowHeight, columns: columns,  minimumInteritemSpacing: 5,minimumLineSpacing: 5,sectionInset: UIEdgeInsets(top: 5, left: 0, bottom: 5, right: 0),headerHeight: 0, footerHeight: 0)
    return geometryInfo
}

}
extension PostGridCell : UICollectionViewDataSource,UICollectionViewDelegate{

func numberOfSections(in collectionView: UICollectionView) -> Int {
    return 1
}

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return 100
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PostCell.reuseIdentifier, for: indexPath)
    cell.backgroundColor = .red
    return cell
}

}
`

This is how i configured the collectionview the library crashes on Crash on ADMozaikLayoutSectionMatrixError.rowOutOfBounds

Horizontal layout?

Hello,

I really like the layout. However, is there a way to make this layout horizontal instead of vertical?

Thank you.

My regards.

If you want to create cell as per you image aspect ratio

func collectonView(_ collectionView: UICollectionView, mozaik layoyt: ADMozaikLayout, geometryInfoFor section: ADMozaikLayoutSection) -> ADMozaikLayoutSectionGeometryInfo {
let W = self.view.frame.size.width/2 // - 10
let rowHeight: CGFloat = self.view.frame.size.width/12 //W //93
let columns = [ADMozaikLayoutColumn(width: W), ADMozaikLayoutColumn(width: W), ADMozaikLayoutColumn(width: W), ADMozaikLayoutColumn(width: W)]
let geometryInfo = ADMozaikLayoutSectionGeometryInfo(rowHeight: rowHeight,
columns: columns,
minimumInteritemSpacing: 1,
minimumLineSpacing: 1,
sectionInset: UIEdgeInsets(top: 5, left: 0, bottom: 5, right: 0),
headerHeight: 1, footerHeight: 1)
return geometryInfo
}

func collectionView(_ collectionView: UICollectionView, mozaik layout: ADMozaikLayout, mozaikSizeForItemAt indexPath: IndexPath) -> ADMozaikLayoutSize {
    let image = photos[indexPath.row].image
    let aspectratio = image.size.width/image.size.height
    
    if aspectratio == 1/1 {
        return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 6)
    }
    if aspectratio == 2/3 {
        return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 9)
    }
    if aspectratio == 3/2 {
        return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 4)
    }
    if aspectratio == 2/1 {
        return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 3)
    }
    if aspectratio == 1/2 {
        return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 12)
    }
    else {
        return ADMozaikLayoutSize(numberOfColumns: 1, numberOfRows: 6)
    }
}

Cells keep getting deallocated while scrolling

I noticed flickering in cells during scrolling. It wasn't happening while using default flow layout so I started debugging and found out that while using layout from this library, the cells are getting deallocated randomly and sometimes they just don't appear.
I placed a print statement in the deinit of my custom cell class to catch it

Compilation warning on collectionView(_:layout:mozaikSizeForItemAtIndexPath:)

Since a couple versions of Xcode (probably after migration to Swift 3.0), I have this warning that I can not silent:

Instance method 'collectionView(_:layout:mozaikSizeForItemAtIndexPath:)' nearly matches optional requirement 'collectionView(_:layout:sizeForItemAt:)' of protocol 'UICollectionViewDelegateFlowLayout'

Any idea how to fix that?

Thanks,
Cyril

Support orientation changes

The original issue is addressed #4 .
Initial idea is to ask the user before orientation is changed for the new ADMozaikLayoutColumn, so then we can reload layout either with or without animation.

Cells are disappearing

I have implemented the layout in my app but in some cases the cells are disappearing, like in the picture below:

IMG_1241

I noticed that only bigger cells disappear. It would be great if you could take a look at this bug

The Order of Cells changes.

I have data in a particular order and want to show three types of cell i.e Full, Half and Quarter. The collectionView works fine most of the times but sometimes the quarter cell which should be shown at last appears at some random place in collection view.

Slow performance issues

Currently, the way of position calculation is way not optimized. I need to find a way to speed up the process, otherwise, in a big list the layout is slow

Carthage can't build library

The library needs some pods installed, but by default, it's downloaded without pods, and build crashes. If I try to install pods manually in carthage checkouts folder, it still crashes with "The sandbox is not in sync with the Podfile.lock." error.
There is no cache for swift 4 version, so, carthage doesn't use it too

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.