Giter Site home page Giter Site logo

jonivr / verticalcardswiper Goto Github PK

View Code? Open in Web Editor NEW
1.4K 1.4K 101.0 1.74 MB

A marriage between the Shazam Discover UI and Tinder, built with UICollectionView in Swift.

License: MIT License

Swift 95.72% Objective-C 1.82% Ruby 2.46%
animation cards collectionview discover help-wanted ios shazam shazam-discover-ui swift swipe tinder tinder-style tinder-ui uicollectionview uikit

verticalcardswiper's People

Contributors

darnfish avatar elfanek avatar fabdurso avatar jonivr avatar milannosal avatar mkhakpaki avatar stfnhdr 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

verticalcardswiper's Issues

Shazam effect

I cloned the project in the attempt to include the stack effect for the vertical collection as in Shazam. I managed to do so except the fact that sometimes the stack displays two cards behind, sometimes three. Did you came across this problem when trying to implement this effect ? I think the problem is the third cell (which should be displayed in the background always when the indexPath is greater or equal to 2) sometimes gets deallocated, sometimes it doesn't. Do you have any guess on this ?

Thank you.

Strange behaviour of CardCell layout

New Issue Checklist

Issue Description

Steps to reproduce:

  1. Create UIViewController and add UILabel inside of it, stretch label to edges with constraints
  2. Add VC's view as subview to CardView, stretch VC's view to edges of CardView with constraints
  3. Run app and try to scroll, it seems that glitch depends on size of text

output

Environment

  • iOS Version: iOS 12.1
  • Device(s): iPhone 5S Simulator
  • Xcode Version: 10.1 (10B61)

reloadData() is not working

medias.observe(.value) { (snapshot) in guard let postsSnapshot = PostMedias(with: snapshot) else { return } self.medias = postsSnapshot.medias self.cardSwiper.reloadData() }

my code is working but when I want to add Card Wiper using reload data, nothing is there.

UITapGestureRecognizer in card not working

I’m trying to add a UITapGestureRecognizer to one of the cards in order to present a modal when the card is tapped, but the recognizer isn’t working.

It works fine when VerticalCardSwiper isn’t being used.

[Question] How to check properly if CardCell subview is visible?

Hi,
I have a AVPlayerLayer in CardCell, and when I check different approaches like if the AVPlayerLayer is visible, I get true even if the CardCell is not on top of stack, but behind another card (ex. ImageCardCell).

I would like to pause the video when CardCell goes back when scrolling, but I always get value true or a full height when I check in didEndScroll if the AVPlayerLayer is visible. Is there a way to check this?

I hope my question was clear.

Thanks for your help.

[Question] how to forbid the sliding gestures in subview

New Issue Checklist

Question

i have a view struct likes

JPMain(extends VerticalCardSwiperDelegate)  -->  JPCell(CardCell)  -->  Canvas(UIView in JPCell)

i try to control the cell gesture, hope to forbid the sliding up or down. then i find a nice solution that modify the below function

func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool 

but i failed. so i want to know how to forbid the sliding gestures for VerticalCardSwiper. looks like it’s here

extension VerticalCardSwiper: UIGestureRecognizerDelegate

expected:
i want the VerticalCardSwiper can't slide up or down when i handle some gesture in Canvas
Can you help me?

Value of type 'VerticalCardSwiper' has no member 'focussedIndex'

New Issue Checklist

Issue Description

The document shows that:

Get the current focussed card index
cardSwiper.focussedIndex

But when I use cardSwiper.focussedIndex, Xcode shows an error:

Value of type 'VerticalCardSwiper' has no member 'focussedIndex'

Is there something wrong with me ?

Environment

  • iOS Version: 12.1
  • Xcode Version: 10.14.3
  • VerticalCardSwiper Version: 0.1.0-beta7

Animate card on button press [Feature]

It would be cool if we could animate the card off the screen based on a button press. If anyone has done this already, please help.

This would be kind of like scrollToCard.

New Issue Checklist

Is your feature request related to a problem? Please describe.

A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like

A clear and concise description of what you want to happen.

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

[Bug] `scrollToCard` animation doesn't look right with custom duration

New Issue Checklist

Question

Is it possible to slow down the animation of scrollToCard(at:animated) method ?
I was trying to slow it done with:

UIView.animate(withDuration: 2.0, animations: {
         self.view.setContentOffset(point, animated: false)
 })

and

UIView.animate(withDuration: 2.0, animations: {
         self.view.scrollToCard(at: cards.count, animated: false)
 })

and both of the methods don't seem to work for me.

Refresh Card View on view resize

New Issue Checklist

Issue Description

Right now If I am resizing the cardView the card cells are not adjusting to the new frame.

Steps:

  • Create a cardView Height constraint
  • Assign a new value to height constraint. -- (Cell will not update its frame)

on reloading the CardView it is still giving me some random behavior because of the previous collection view height.

Environment

  • iOS Version: 12.0
  • Device(s): iPhone XR Simulator
  • Xcode Version: 10.2

Programmatic Implementation

I have tried a few different methods, but do you have an entirely programmatic to load (and lazy load) and cardSwipe view controller?

Rather than

@IBOutlet var cardSwiper: VerticalCardSwiper!

It would be something like

var cardSwiper: VerticalCardSwiper = VerticalCardSwiper()

Thanks!

Bug where sliding a card all the way to the side and releasing doesn't call "UIGestureRecognizerStateEnded".

Sliding a card all the way to the side and releasing doesn't call "UIGestureRecognizerStateEnded".

This causes the card to be stuck on the side. Reason for this bug is because the finger that is dragging the card is not in the card area anymore.

code inside

if let swipedCardIndex = collectionView.indexPathForItem(at: locationInCollectionView)

is not reached, which is why code inside .ended never gets executed.

Switching Orientation

When switching between portrait and landscape the layout does not update. If however I remove a card by swiping left or right, it then updates.

Is there a way to force this layout update on orientation change?

Swiping away last card on the stack causes the animation to glitch

New Issue Checklist

Issue Description

When you are at the end of the stack and still have some cards left, swiping away the last card will cause the animation to glitch. This is probably something that needs to be fixed inside the updateCellAttributes function.

Example:
example gif

Environment

  • iOS Version: any
  • Device(s): any
  • Xcode Version: 10.1

edit:
Stackoverflow Question

Unexpectedly found nil while unwrapping an Optional Value

After following the steps outlined in the readme, I get the following error in viewDidLoad on the line: cardSwiper.datasource = self

Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
causing the app to crash on startup.

Number of visible cards on the stack

Is there anyway I can change the number of visible cards on the stack? The default is 2, the card that is showing and another one behind, and I need more than that. Help would be appreciated.

Reverse approach of cards stack?

Is there a possibility to reverse the approach, like have a stack of cards and then either swipe left/right or just scroll card to bottom, and swipe up if you want to bring back the scrolled card?

CardSwiper.reloadData () does not work

CardSwiper.reloadData() does not work

New problem checklist

Description of the problem

CardSwiper.reloadData() does not work
Attempt to download data from the database and load before the card number function and do not reload after displaying the number of letters,
Please help !!
Thank you

Ambient

  • Version for iOS: 10.13.6
  • Device(s): Mac Mini
  • Xcode Version: Version 10.1

Hiding previous card

Is there a way to hide a previous card after scrolling up. I have tried to implement isPreviousCardVisible: Bool = false both in code and in IB, but previous card is always visible

Thanks!

Universal app - iPad display cell size

Hi Joni,

I came across little problem, not a bug. I want to make my app universal using your repo and everything works just fine, except I am not sure if I like the large cells on iPad display. It's too chunky for my app and what it offers. I tried to make the cell smaller just for the iPad in layoutSubviews() method in the UICollectionViewCell class:

if Device.isIpad() == true{
            let screenSize: CGRect = UIScreen.main.bounds
            self.frame = CGRect(x: (screenSize.width / 2) - 185, y: 0, width: 370, height: 700)
        }

As you can see, I want to keep the cell size on the iPad similar to what's on the iPhone, just slightly larger. It resizes to what I am intending to do, but only the first cell. The rest of the cells are back to the original specs - almost full screen. Where do I need to make the necessary changes in the code, so all the cells will be affected please?

Thank you for your time and advice

A.

I have problems adding the library to my podfile

I have problems adding the library to my podfile

Issue Description

captura de pantalla 2018-11-18 a las 18 54 36

I enter pod 'VerticalCardSwiper', '0.1.0-beta6' in my podfile and it gives me an error [!] Unable to find a specification for VerticalCardSwiper (= 0.1.0-beta6)

Environment

  • iOS Version: [12.1]
  • Device(s): [mac mini]
  • Xcode Version: [10.1]

Changing cards to swipe horizontally instead of vertically

Hello,

I do not have a bug to report but more of a request for help with the use of this project.

I discovered this repo earlier tonight and I love it so far. For my own project, I am trying to get the cards to swipe on a horizontal plane (from left to right and vice versa). I do not need the functionality to swipe away cards, simply to scroll horizontally.

I've been playing around with VerticalCardSwiperFlowLayout but am getting all kinds of wacky animations. Any help would be appreciated.

[Feature Request] Show next cards at top instead of bottom

When isStackOnBottom is set to false, I scroll to the last card so I simulate the stack of cards from top and then either score left/right or just skip the card. But if there are cards on bottom and I swipe the focusedCard, card from bottom comes up. Is it possible to change this to when I swipe a card the next card scroll from the top?

Scrolling empty list causes crash

New Issue Checklist

Issue Description

Steps to reproduce:

  1. return numberOfCards equal to 0
  2. try to scroll
  3. Fatal error: Unexpectedly found nil while unwrapping an Optional value of swipeAbleArea in VerticalCardSwiper.swift on line 258

Temporary solution for other developers:

  • disable user interaction if numberOfCards equal to 0

Environment

  • iOS Version: iOS 12.1
  • Device(s): iPhone 5S Simulator
  • Xcode Version: 10.1 (10B61)

Disable scrolling

Is there a way to disable scrolling to the next card? For instance if tapped the first card, then you are allowed to scroll to next card. After you have scrolled to the second card, you have to tap that card to be able to scroll to third card, etc.

[Bug] [UICollectionView] Invalid update: invalid number of items in section 0.

[28933:533995] [UICollectionView] Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (20) must be equal to the number of items contained in that section before the update (20), plus or minus the number of items inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out). - will perform reloadData. UICollectionView instance: <VerticalCardSwiper.VerticalCardSwiperView: 0x7f966c912000; baseClass = UICollectionView; frame = (0 0; 414 482.333); clipsToBounds = YES; userInteractionEnabled = NO; gestureRecognizers = <NSArray: 0x6000016ca5b0>; layer = <CALayer: 0x600001888ac0>; contentOffset: {-20, 3921.3333333333335}; contentSize: {374, 4361.3793103448279}; adjustedContentInset: {40, 20, 90, 20}; layout: <VerticalCardSwiper.VerticalCardSwiperFlowLayout: 0x7f966c42d390>; dataSource: <VerticalCardSwiper.VerticalCardSwiper: 0x7f966c452760; frame = (0 0; 414 482.333); layer = <CALayer: 0x600001888900>>>; currentUpdate: [UICollectionViewUpdate - 0x7f966c48e5c0: old:<UICollectionViewData: 0x6000021a5880> new<UICollectionViewData: 0x6000021216c0> items:<(
"D(0,18)"
)>]

Ability to add cards at runtime

Hello,

There is a tiny bug that prevents users to add item at a runtime.

In order to fix this, I have changed

this;

public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        
    return self.numberOfCards
}

to this:

public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        
     return datasource?.numberOfCards(verticalCardSwiperView: verticalCardSwiperView) ?? 0
}

BR,

Erdem

Can I off the animation when the previous card goes behind?

New Issue Checklist

Issue Description

Can I off the animation when the previous card goes behind?

I tried to find an option so that I can on/off the scale&fade animation when the cards goes behind but I couldn't.
So I triedn to comment out the codes regards animation and changing scale in the file CardCell.swift, but it seems disable animation is not working.
I commented out the logic in the function named resetToCenterPosition(), and animateCard(angle:, horizontalTranslation:)

Please point out if anything wrong, or anything that I missed.

Environment

  • iOS Version: [12.1.4]
  • Device(s): [iPhoneX]
  • Xcode Version: [10.2.1]

Method func didSwipeCardAway not called

New Issue Checklist

Bug Description

In spite cardSwiper.delegate is set to self correctly, the method willSwipeCardAway and didSwipeCardAway are not called while didEndScroll and didScroll are called.
Is there a dependency on some properties at a base of this behaviour? Any idea?

Environment

  • iOS Version: [IOS 12.3.1]
  • Device(s): [Iphone XS]
  • Xcode Version: [10.2.1]

Additional context

Add any other context about the problem here.

Animation bug caused by anchorPoint?

General

I'm just going to use this issue to document this bug, so people know I'm aware of it and looking for fixes. The bug is a visual animation glitch that sometimes happens when the user swipes away a card. I personally think it's related to resetting the anchorPoint of the CardCell, but I'm not sure about it yet.

Steps to reproduce

  1. Scroll down a few cards
  2. Swipe away some cards (left, right or both)
  3. Scroll back to first card
  4. Try swiping away the first card.
  5. Notice the wrong animation (might take a couple of tries)

Description

After some testing I think this bug is caused by calling
self.layer.anchorPoint = CGPoint(x: 0.5, y: 0.5) inside of layoutSubviews()
in the CardCell. We have to do this to reset the anchorPoint (x: 0.5, y: 0.5 is the default anchorPoint).

The problem is that we're manipulating the anchorPoint to animate the card, but need to reset the anchorPoint after calling resetToCenterPosition(). We can't reset the anchorPoint inside of resetToCenterPosition() (as far as I'm aware) because that screws up the animation. So I tried putting it in layoutSubviews(), this worked for the most part, except that it is causing this behaviour (you can test when it's getting called by putting a print statement inside of layoutSubviews).

So I need to find a way to reset the anchorPoint after calling resetToCenterPosition() and before the user starts scrolling. I'm just not sure where to put it as of now.

edit: After some further testing it looks like the issue is not related to the anchorPoint being reset, looking into it further to find the cause.

More

As always, any help is always appreciated, if you found a fix or have a solution before I do, feel free to create a Pull Request or respond to this issue.

IndexPath.row "3" Issues

Hello, thanks for sharing this library. Exactly what I was looking for. I found one problem which I can't explain its behaviour and where is it coming from. I need to use the index of the visible cell to save it as a progress, so next time the user loads the collection view with the specific theme, it can scroll to index where it was left last time.

It's straight forward implementation, but the issue is, for whatever reason, the count always ignores index "3" and it goes like this: 1, 2, 2, 4, 5, .... even swiping backwards ...5, 4, 2, 2, 1

Home.swift:

func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
        let visibleIndexPath = collectionView.indexPathsForVisibleItems
        let lastCardIndex = visibleIndexPath[0].row + 1
        print("visible index: \(lastCardIndex)")
    }

Where do I look within the code to tackle this?

Also, the very last card has an offset on Y axe. I couldn't figure out where to disable it. I'd like to animate the last card the same way and keep it in centre of the view as the other cards. The idea is to:

  • display "Done" statement
  • assign same BG colour as a view, so it looks it disappeared into it after the scroll animation finishes
  • disable user interaction with bool

Thank you for your suggestions

Kind regards

A.

Delegate issue?

Hey,
After following the how to use section, I'm running into an error:
"Type 'XYViewController' does not conform to protocol 'VerticalCardSwiperDatasource'" and wants to add the "cardForItemAt" function, however, its implemented as it was described:

func cardForItemAt(verticalCardSwiperView: VerticalCardSwiperView, cardForItemAt index: Int) -> CardCell {
        let cardCell = verticalCardSwiperView.dequeueReusableCell(withReuseIdentifier: "ExampleCell", for: index) as! ExampleCardCel
        return cardCell
    }

This function has a warning btw: "Cast from 'UICollectionViewCell' to unrelated type 'ExampleCardCell' always fails"

The only difference in my code is that i dont use storyboard, so this is how the viewDidLoad looks like:

    override func viewDidLoad() {
        super.viewDidLoad()        
        cardSwiper = VerticalCardSwiper(frame: self.view.bounds)
        cardSwiper.datasource = self
        cardSwiper.register(ExampleCardCell.self, forCellWithReuseIdentifier: "ExampleCell")
    }

I'm experience this in xCode 10 and Swift 4.2

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.