Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Card Visibility #14

Closed
wants to merge 19 commits into from
Closed

Card Visibility #14

wants to merge 19 commits into from

Conversation

dtumer
Copy link
Contributor

@dtumer dtumer commented May 23, 2018

Adds a listener in CardPartsViewController that allows for custom CardPartsViewControllers to be notified of the visibility of the card within a custom CardsViewController implementation.

Every time scrollViewDidScroll() is called in the CardsViewController the corresponding "cardVisibility(percentVisible: CGFloat)" function is called if the card in question is visible within the bounds of the scroll view. The card is then notified of the percentage of itself that is visible.

Tumer, Deniz and others added 11 commits May 23, 2018 09:15
Adds delegate for card visibility. Also adds scroll view delegate implementation. Cards can now override this functionality to get notified about when the cards scroll view is getting changed and how much of each card is visible on the screen at any time. Adds readme changes to let developers know how to use this functionality. Also adds unit testing to the utility functions.
@croossin
Copy link
Contributor

@dtumer Could you squish all these commits? They are muddying the water since I believe you were testing out git users?

Copy link
Contributor

@croossin croossin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of comments. Also, did we not want to expose the scroll delegates as well? Possibly for the CardControllers?

*
* @param percentVisible - percentage of the card that is visible in the list of cards
*/
@objc optional func cardVisibility(percentVisible: CGFloat)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include a boolean isVisible as well? I could imagine users would want a quick check if it is visible or not and then some might care about the percent visible. Instead of having to check if percentVisible == 0.0 What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing was that this function doesn't get called unless the card is visible so I thought it was unnecessary. But maybe we could include in the documentation that this method will only be called when the card is actually visible in some way

import Foundation
import CardParts

class DummyCardController: CardPartsViewController {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this still? Or was this just for testing performance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was just testing performance I can remove it if we don't need it anymore

import XCTest
@testable import CardParts

class CardUtilsTests: XCTestCase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid tests... great job 👍


// Notifies your card parts view controller of the percentage of the card that is visible.
// This function is called every time 'scrollViewDidScroll' is called in your CardsViewController.
override func cardVisibility(percentVisible: CGFloat) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we decide to add the isVisible Bool, lets make sure we update the docs.

@croossin croossin mentioned this pull request May 23, 2018
@bharathmurs
Copy link
Contributor

You could send cardVisibility only if percent changes. If during successive scroll, if the percent is same as previous scroll, then there is no point in sending the callbacks again.

dtumer added 7 commits May 24, 2018 07:50
commit 1f1f0bb
Author: Tumer, Deniz <e.tumer.deniz@gmail.com>
Date:   Wed May 23 16:02:29 2018 -0700

    removed scrollViewDidScroll method since it isn't necessary

commit bc3b4dc
Author: Tumer, Deniz <e.tumer.deniz@gmail.com>
Date:   Wed May 23 15:58:09 2018 -0700

    Card visibility

    Adds delegate for card visibility. Also adds scroll view delegate implementation. Cards can now override this functionality to get notified about when the cards scroll view is getting changed and how much of each card is visible on the screen at any time. Adds readme changes to let developers know how to use this functionality. Also adds unit testing to the utility functions.

commit c8e0009
Author: Tumer, Deniz <e.tumer.deniz@gmail.com>
Date:   Wed May 23 09:49:19 2018 -0700

    testing

commit a5ae870
Author: Tumer, Deniz <>
Date:   Wed May 23 09:46:08 2018 -0700

    test

commit 9bbf3ce
Author: Tumer, Deniz <>
Date:   Wed May 23 09:44:47 2018 -0700

    tst

commit cbfeed9
Author: Tumer, Deniz <>
Date:   Wed May 23 09:40:10 2018 -0700

    another test

commit 38fa7ce
Author: Tumer, Deniz <>
Date:   Wed May 23 09:28:44 2018 -0700

    Another test

commit 3f9b966
Author: Tumer, Deniz <e.tumer.deniz@gmail.com>
Date:   Wed May 23 09:27:58 2018 -0700

    Another test

commit 9cfb76a
Author: Tumer, Deniz <Deniz_Tumer@intuit.com>
Date:   Wed May 23 09:25:43 2018 -0700

    testing

commit 38697cb
Author: Tumer, Deniz <Deniz_Tumer@intuit.com>
Date:   Wed May 23 09:19:41 2018 -0700

    commit

commit da6b380
Author: Tumer, Deniz <Deniz_Tumer@intuit.com>
Date:   Wed May 23 09:17:47 2018 -0700

    test

Squashed commits
@dtumer
Copy link
Contributor Author

dtumer commented May 24, 2018

#15

@dtumer dtumer closed this May 24, 2018
@croossin croossin deleted the feature/card-visibility branch June 20, 2018 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants