Git Product home page Git Product logo

cardslayout's People

Contributors

filletofish avatar lurein avatar nameghino 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  avatar

cardslayout's Issues

Animation

Can you add rotate in and rotate out animation just like tinder

Scroll cell on button click

cell is scroll by swiping left or right but i want to scroll on button click. can any one please help me out.

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;
        }
    });

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

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

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

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.

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?

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

how to make it auto scroll

how to make it auto scroll?
i use collectionView.scrollToItem(at: next, at: .centeredHorizontally, animated: true) but it's not work~

Cards Swipe Direction

Hi thanks for your excellent repository i just want to have this thing how to
change the swipe direction i want the cards to swipe up and down.

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?

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?

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.