CardsLayout is a lightweight Collection Layout.

Overview

CardsLayout

CardsLayout is a lightweight Collection Layout.

CocoaPods Platform Twitter GitHub license

Preview

Installation

CocoaPods

You can use CocoaPods to install CardsLayout by adding it to your Podfile:

platform :ios, '9.0'
use_frameworks!
pod 'CardsLayout'
import CardsLayout

Manual

  1. Add CardsCollectionViewLayout file to your project
  2. Configure collectionView:
    collectionView.collectionViewLayout = CardsCollectionViewLayout()
    collectionView.isPagingEnabled = true
    collectionView.showsHorizontalScrollIndicator = false
Comments
  • Move card programatically

    Move card programatically

    Hi, before all, awesome work.

    I will like to block the user to swipe the card manually and do it programmatically, when I considere necessary, like a stepper. is this possible?

    opened by bubudrc 6
  • Replace line that causes segueing errors

    Replace line that causes segueing errors

    Replaced the range-format visibleIndices line with a stride-format as it was causing crashes when returning from segues as minVisibleIndex could become greater than maxVisibleIndex

    opened by lurein 3
  • Infinite Scroll

    Infinite Scroll

    Hello and thanks for this great Collection Layout ! πŸ‘

    I have a question, is it being considered to handle infinite scroll ? By infinite scroll I mean, when you scroll a card to the left, it appears at the end of the list.

    Thanks in advance

    opened by mfamilariSnapp 2
  • Unable to resolve the pod

    Unable to resolve the pod

    Hi! I have tried to play with the pod in Xcode project, but it turned out that the pod can not be resolved. Here's output of pod install command:

    ➜ CardsTest pod install Analyzing dependencies [!] Unable to find a specification for CardsLayout

    Same for pod install --repo-update

    opened by anverbogatov 2
  • Shadow with cards

    Shadow with cards

    Hi, thanks for your repository. I just implemented this in my collectionView. And what I need is to add a shadow to the bottom of the highlighted card. I gave the shadow effect to the collectionViewCell, but it is not showing. Now it is coming like this , Screen Shot 2019-06-26 at 11 37 24 AM

    opened by hilajqinnovation 1
  • Cards Size issue

    Cards Size issue

    Hi, i have implemented your library in my collection view and when i run the app it shows cards size very small. How can library get the size my collection view cell size? This is my code, //Collection View Reload self.knowledgeCollectionView.collectionViewLayout = CardsCollectionViewLayout() self.knowledgeCollectionView.isPagingEnabled = true self.knowledgeCollectionView.showsHorizontalScrollIndicator = false

    opened by Hamza123Imran 1
  • Crash on Calling Collection Reload

    Crash on Calling Collection Reload

    Hi , i have used ur library in my collection view, i have mad my custom collection view have a single image on cell. I have passed all the data source and delegate this is my code, //Collection View Reload self.knowledgeCollectionView.collectionViewLayout = CardsCollectionViewLayout() self.knowledgeCollectionView.isPagingEnabled = true self.knowledgeCollectionView.showsHorizontalScrollIndicator = false self.knowledgeCollectionView.reloadData()

    ` override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return cardsArray.count }

    override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        let cell = knowledgeCollectionView.dequeueReusableCell(withReuseIdentifier: "knowledgeCell", for: indexPath) as! KnowledgeCVC
        
        cell.cardImage.image = cardsArray[indexPath.row]
        
        return cell
    }`
    

    But when i call my VC the app crashes on a delegate written in ur library, ` // MARK: - UICollectionViewDelegateFlowLayut

    @objc open func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
        guard let cellWidthValue = cachedCellWidths?[indexPath.row] else {
            fatalError("cachedCellWidths for \(indexPath.row) must not be nil")
        }
        return CGSize(width: cellWidthValue, height: collectionView.frame.size.height)
    }`
    

    Error is Thread 1: Fatal error: Index out of range . How i can get rid of this?

    opened by Hamza123Imran 1
  • Disable swipe to previous card

    Disable swipe to previous card

    Is there a way to only swipe to next card? The user should not be able to scroll back to previous card. Also, is there a way to swipe away the last card?

    opened by andynadheer 1
  • Wrong IndexPath on Cells via OjbC Bridging

    Wrong IndexPath on Cells via OjbC Bridging

    Not sure if this is up to your library but I'll try nevertheless.

    I'm using CardsCollectionViewLayout in my code via Swift Bridging for my CollectionView.

    Objective-C (Not Working)

    My issue is that IndexPath is returning wrong Item index. Here is the minimal code:

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        self.collectionViewEvents.collectionViewLayout = [[CardsCollectionViewLayout alloc] init];
        self.collectionViewEvents.dataSource = self;
        self.collectionViewEvents.delegate = self;
        self.collectionViewEvents.pagingEnabled = YES;
        self.collectionViewEvents.showsHorizontalScrollIndicator = NO;
    
        [self load];
    }
    
    // Issue visible here, the indexPath.item is not correct
    - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
    {
        for (UICollectionViewCell *cell in self.collectionViewEvents.visibleCells) {
            NSIndexPath *indexPath = [[self collectionViewEvents] indexPathForCell:cell];
            NSLog(@"Visible Cell IndexPath Item %ld", indexPath.item);
            return;
        }
    }
    
    - (void)load
    {
    
        // self.eventData is declares as: @property (nonatomic) NSArray *eventData;
        self.eventData = [[NSArray alloc] initWithObjects:UIColor.blackColor, UIColor.whiteColor, UIColor.brownColor, nil];
        [[self collectionViewEvents] reloadData];
    }
    
    - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
    {
        UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionViewCellReuseIdentifier"
                                                                               forIndexPath:indexPath];
    
        cell.layer.cornerRadius = 7.0;
        cell.backgroundColor = UIColor.blackColor;
    
        return cell;
    }
    
    - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
    {
        return self.eventData.count;
    }
    

    Result (notice how both 1st and 2nd cell has same IndexPath Item):

    2020-03-19 14:48:05.334905+0100 App[7422:2617858] Visible Cell IndexPath Item 2 # => 3rd cell
    2020-03-19 14:48:05.741805+0100 App[7422:2617858] Visible Cell IndexPath Item 1 # => 2nd cell
    2020-03-19 14:48:06.184932+0100 App[7422:2617858] Visible Cell IndexPath Item 1 # => 1st cell
    

    Swift (Working)

    I tried your Example from this code Repository, which has declared colors statically:

      var colors: [UIColor]  = [
        UIColor(red: 237, green: 37, blue: 78),
        UIColor(red: 249, green: 220, blue: 92),
        UIColor(red: 194, green: 234, blue: 189),
        UIColor(red: 1, green: 25, blue: 54),
        UIColor(red: 255, green: 184, blue: 209)
      ]
    ...
    
        func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "CollectionViewCellReuseIdentifier", for: indexPath)
    
            cell.layer.cornerRadius = 7.0
            cell.backgroundColor = .black
    
            return cell
        }
    

    And after implementing this code below, it returns proper IndexPath.

        // Issue NOT visible here, the indexPath.item IS correct
        func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
    
            for cell in collectionView.visibleCells {
                let indexPath = collectionView.indexPath(for: cell)
                print(indexPath?.item)
                return
            }
        }
    

    Result:

    2020-03-19 14:48:05.334905+0100 App[7422:2617858] Visible Cell IndexPath Item 2 # => 3rd cell
    2020-03-19 14:48:05.741805+0100 App[7422:2617858] Visible Cell IndexPath Item 1 # => 2nd cell
    2020-03-19 14:48:06.184932+0100 App[7422:2617858] Visible Cell IndexPath Item 0 # => 1st cell
    

    What am I doing wrong in my Objective-C code?

    Things I've tried

    // 1st cell has index 1, instead of 0
    - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
    {
        for (UICollectionViewCell *cell in [[self collectionViewEvents] visibleCells]) {
            NSIndexPath *indexPath = [[self collectionViewEvents] indexPathForCell:cell];
            NSLog(@"Visible Cell IndexPath Item %ld", indexPath.item);
            return;
        }
    
    // 1st cell has index 1, instead of 0
    - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
    {
        NSArray *visible = [self.collectionViewEvents indexPathsForVisibleItems];
        NSIndexPath *indexPath = [visible firstObject];
        NSLog(@"Visible Cell IndexPath Item %ld", indexPath.item);
        return;
    
    // Calling it in main thread, same result
    - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
    {
        dispatch_async(dispatch_get_main_queue(), ^{
            for (UICollectionViewCell *cell in [[self collectionViewEvents] visibleCells]) {
                NSIndexPath *indexPath = [[self collectionViewEvents] indexPathForCell:cell];
                NSLog(@"Visible Cell IndexPath Item %ld", indexPath.item);
                return;
            }
        });
    
    help wanted 
    opened by duraki 1
  • Card Swipe not working

    Card Swipe not working

    Hi, i have implemented lib in my app now when i try to swipe card they aren't working not even its selection function is working, it looks like it get stuck, other application is working fine but CardsLayout is stuck, how can i resolve this? My code for calling CardsLayout is this, //Collection View Reload self.knowledgeCollectionView.collectionViewLayout = CardsCollectionViewLayout() self.knowledgeCollectionView.isPagingEnabled = true self.knowledgeCollectionView.showsHorizontalScrollIndicator = false

    I have passed it to my collection view, at first it was working now i have tried code after a long time it get stuck. Please help me in this.

    opened by Hamza123Imran 0
Releases(0.0.1)
Owner
Filipp Fediakov
Software Developer Engineer at Amazon. MSc Management at University of Edinburgh. BS Computer Science at BMSTU.
Filipp Fediakov
An easy-to-use Collection View Layout for card-like animation.

CarLensCollectionViewLayout An easy-to-use Collection View Layout for card-like animation ?? CarLensCollectionViewLayout was created out of the implem

Netguru 530 Dec 16, 2022
Declaretive UICollectionViewCompositionalLayout interface to implement complex collection view layout.

CompositionalLayoutViewController Example To run the example project, clone the repo, and run pod install from the Example directory first. Requiremen

ONEinc 19 Dec 2, 2022
Blueprints is a collection of flow layouts that is meant to make your life easier when working with collection view flow layouts.

Blueprints is a collection of flow layouts that is meant to make your life easier when working with collection view flow layouts. It comes

Christoffer Winterkvist 982 Dec 7, 2022
Lightweight custom collection view inspired by Airbnb.

ASCollectionView Lightweight custom collection view inspired by Airbnb. Screenshots Requirements ASCollectionView Version Minimum iOS Target Swift Ver

Abdullah Selek 364 Nov 24, 2022
A CollectionView Layout displaying a slanted cells

CollectionViewSlantedLayout is a subclass of the UICollectionViewLayout allowing the display of slanted cells in a UICollectionView. Features Pure Swi

Yassir Barchi 2.2k Dec 27, 2022
πŸ”„ GravitySlider is a beautiful alternative to the standard UICollectionView flow layout.

GravitySliderFlowLayout Made by Applikey Solutions Find this project on Dribbble Table of Contents Purpose Supported OS & SDK Versions Installation Us

Applikey Solutions 958 Dec 23, 2022
Made in Swift - Tag layout for UICollectionView supporting 3 types of alignments - Left || Centre || Right

TagCellLayout About Its an ui-collection-view LAYOUT class that takes care of all the logic behind making tags like layout using UICollectionView. It

Ritesh Gupta 346 Jan 1, 2023
This component allows for the transfer of data items between collection views through drag and drop

Drag and Drop Collection Views Written for Swift 4.0, it is an implementation of Dragging and Dropping data across multiple UICollectionViews. Try it

Michael Michailidis 508 Dec 19, 2022
Gliding Collection is a smooth, flowing, customizable decision for a UICollectionView Swift Controller.

A smooth, flowing, customizable decision for a UICollectionView Swift Controller We specialize in the designing and coding of custo

Ramotion 1.5k Dec 19, 2022
Easy and type-safe iOS table and collection views in Swift.

Quick Start TL;DR? SimpleSource is a library that lets you populate and update table views and collection views with ease. It gives you fully typed cl

Squarespace 96 Dec 26, 2022
UICollectionViewSplitLayout makes collection view more responsive.

UICollectionViewSplitLayout makes collection view more responsive. What's this? UICollectionViewSplitLayout is a subclass of UICollectionViewLayout. I

Yahoo! JAPAN 239 Dec 6, 2022
A mirror of Apple's sample code for high performance collection views in iOS 15.

Building High-Performance Lists and Collection Views Improve the performance of lists and collections in your app with prefetching and image preparati

Tim Oliver 14 Nov 12, 2022
A lightweight UICollectionViewLayout that 'pages' and centers its cells 🎑 written in Swift

CenteredCollectionView CenteredCollectionView is a lightweight drop in place UICollectionViewFlowLayout that pages and keeps its cells centered, resul

Ben Emdon 1.2k Jan 6, 2023
↕️ VegaScroll is a lightweight animation flowlayout for UICollectionView completely written in Swift 4, compatible with iOS 11 and Xcode 9.

Made by Applikey Solutions Find this project on Dribbble Also check another flowlayout for UICollectionView: https://github.com/ApplikeySolutions/Grav

Applikey Solutions 2.8k Jan 1, 2023
Auto Layout (and manual layout) in one line.

Auto Layout (and manual layout) in one line. Quick Look view.bb.centerX().below(view2).size(100) It’s equivalent to iOS 9 API: view.centerXAnchor.cons

Javier Zhang 74 Oct 19, 2022
Auto Layout made easy with the Custom Layout.

Auto Layout made easy with the Custom Layout. Getting started CocoaPods CocoaPods is a dependency manager for Cocoa projects. You can install it with

Malith Nadeeshan 1 Jan 16, 2022
AppStoreClone - Understanding the complex layout of app store using UICompositional layout in swift

AppStoreClone Understanding the complex layout of app store using UICompositiona

Dheeraj Kumar Sharma 8 Dec 28, 2022
A custom layout built on top of SwiftUI's Layout API that lays elements out in multiple lines. Similar to flex-wrap in CSS, CollectionViewFlowLayout.

WrapLayout A custom layout built on top of SwiftUI's Layout API that lays elements out in multiple lines. Similar to flex-wrap in CSS, CollectionViewF

Hiroshi Kimura 6 Sep 27, 2022
BouncyLayout is a collection view layout that makes your cells bounce.

BouncyLayout is a collection view layout that makes your cells bounce. Features Pure Swift 5. Works with every UICollectionView. Horizontal and vertic

Robert-Hein Hooijmans 4.2k Jan 5, 2023
An easy-to-use Collection View Layout for card-like animation.

CarLensCollectionViewLayout An easy-to-use Collection View Layout for card-like animation ?? CarLensCollectionViewLayout was created out of the implem

Netguru 530 Dec 16, 2022