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

Add click through functionality for KolodaView #166

Merged
merged 10 commits into from Jun 30, 2016
Merged

Add click through functionality for KolodaView #166

merged 10 commits into from Jun 30, 2016

Conversation

ferencbeutel4711
Copy link
Contributor

  • We wanted to display a message below the lowest card of the stack of cards, therefore we needed to be able to force a click to go through it
  • Furthermore we added the ability to add/remove the View to the NotificationCenter
  • In addition to that we needed the ability to chance all of the default values to our liking, implemented the missing fields in KolodaView

//MARK: Configurations

public func subscribeForNotifications(selector: Selector) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the purpose of these methods?

@ferencbeutel4711
Copy link
Contributor Author

Hi, if I understand the Notification pattern correctly its every classes responsibility to subscribe/ unsubscribe from the notification center, especially since you dont always know when a class is deinitialized. E.g: You create a new View in a Controller and subscribe the view to a specific notification. Now you let swift handle the deinitialization since you dont want to be responsible for correctly destroying the UIView.
If you send a notification through the notification center now to an instance which is registered but destroyed already by swift bad things would happen. Thats why you should always implement the deinit method since it is always okay to unsubscribe from the notification center when deinit gets called in the lifecycle (even if you havent even subscribed).
For subscribing, I understand that the method might not be neccessary since you could add the instance to the notification center from the initializing controller for example. In my understanding it is bad practice though, since subscribing/ unsubscribing is logic which the view itself should include (think of the views state which gets effected). So you ask the View to subscribe itself in the controller and now the view does what it has to do to update its state correctly (think syncing over multiple instances; logging; etc.).
When I look at the subscription I see that there should be more parameters though, that is my bad. The notification center and Notification itself should be parameters too, I will change the PR soon.

@lukas2 Anythnig to add?

@lukas2
Copy link
Contributor

lukas2 commented Jun 15, 2016

Hm. I think you are not calling subscribeForNotifications anywhere and it can probably be deleted.
You are right that if we subscribed to notifications (which we don't) then we would need to unsubscribe at deinit (or earlier).

Also I think UIOrientationDidChangeNotification may be outdated.

Better to use viewWillTransitionToSize(:withTransitionCoordinator:) or willTransitionToTraitCollection(:withTransitionCoordinator:) because the notion of Portrait / Landscape seems to be going away. (Size classes are more reliable, because the user may be holding the device in landscape-orientation, but because he is using split screen, UI is in fact vertical.)

@AEugene
Copy link
Contributor

AEugene commented Jun 15, 2016

@lukas2 You're right. I used notification centre in first versions of Koloda, when there was an issue with layoutSubviews. Now layout works fine and it's called when you change orientation. So I don't see any useful examples where we can use NotificationCentre now.

@ferencbeutel4711
Copy link
Contributor Author

ferencbeutel4711 commented Jun 15, 2016

We do indeed use the subscription, in our controller to be exact :) I added the Notification as an extra parameter so it should be fine.
EDIT: we can remove the notification subscription and handle it in our controller if you do not want to support it in your View. If you want i can remove it and update the PR

@AEugene
Copy link
Contributor

AEugene commented Jun 15, 2016

@ferencbeutel I think you should remove it.

private let backgroundCardsScalePercent: CGFloat = 0.95
private let backgroundCardsLeftMargin: CGFloat = 8.0
private let backgroundCardFrameAnimationDuration: NSTimeInterval = 0.2
private let defaultBackgroundCardsTopMargin: CGFloat = 4.0
Copy link
Contributor

Choose a reason for hiding this comment

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

This constants are used in frameForCardAtIndex as default implementation. So it wasn't meant to be adjustable, because user of Koloda can apply totally different pattern for frames calculation and we'll end up with 4 extra variables.

@ferencbeutel4711
Copy link
Contributor Author

Hi,
sorry it took me so long to respond, university got in the way.
I have removed the notification center subscription/ unsubscription. We do need a way to modify the margin/scaling of the background cards though in order to apply a proper styling. What would be your desired way of achieving that? If you just dont want 4 additional variables maybe it would be a better option to optionally supply a Config object which contains the configuration of all of the variables which would lead to just one additional variable. But I dont really think that that would be a better way tbh.

@AEugene
Copy link
Contributor

AEugene commented Jun 28, 2016

Hi @ferencbeutel . I'll include configuration in next version for Swift 3, but for now could you please remove these variables and achieve desired behaviour through subclassing?

@ferencbeutel4711
Copy link
Contributor Author

ferencbeutel4711 commented Jun 29, 2016

Hey @AEugene, that are some good news! I have removed the variables and implemented the desired behavior in our code. Anything more you want me to change?

@AEugene
Copy link
Contributor

AEugene commented Jun 30, 2016

hi @ferencbeutel . Everything is good. Thank you for contribution. I'll update pod version in a few days.

@AEugene AEugene merged commit 5130739 into Yalantis:master Jun 30, 2016
felix-dumit added a commit to felix-dumit/Koloda that referenced this pull request Jun 30, 2016
commit 5130739
Merge: 8dd0d52 3e5c8f5
Author: AEugene <barakuda1933@gmail.com>
Date:   Thu Jun 30 09:08:49 2016 +0300

    Merge pull request Yalantis#166 from ferencbeutel/master

    Add click through functionality for KolodaView

commit 8dd0d52
Merge: 2b2e7b5 4867bb0
Author: AEugene <barakuda1933@gmail.com>
Date:   Thu Jun 30 09:06:30 2016 +0300

    Merge pull request Yalantis#171 from Yalantis/feature/wrong_frame_on_suspending

    Fixed top card frame issue on suspending of application.

commit 4867bb0
Author: Eugene Andreyev <justandjack@hotmail.com>
Date:   Thu Jun 30 09:05:11 2016 +0300

    Fixed top card frame issue on suspending of application.

commit 3e5c8f5
Author: Ferenc Beutel <ferenc.beutel@otto.de>
Date:   Tue Jun 28 15:45:03 2016 +0200

    Remove configuration variables from KolodaView

commit 714258c
Author: Ferenc Beutel <ferenc.beutel@otto.de>
Date:   Mon Jun 27 11:10:42 2016 +0200

    Remove notification center (un)subscription

commit 6ba0e67
Author: 13668 <ferenc.beutel@nordakademie.de>
Date:   Wed Jun 15 09:42:03 2016 +0200

    Add parameters to subscribeForNotifications

commit 8a08ed8
Author: Ferenc Beutel <ferenc.beutel@otto.de>
Date:   Tue Jun 14 15:36:52 2016 +0200

    Format code

commit 3bf4e00
Author: Ferenc Beutel <ferenc.beutel@otto.de>
Date:   Tue Jun 14 15:25:57 2016 +0200

    Make all default Values of KolodaView overwritable

commit 8827a77
Author: Ferenc Beutel <ferenc.beutel@otto.de>
Date:   Tue Jun 14 14:49:20 2016 +0200

    Integrate 3f9b393

commit b46df74
Author: Ferenc Beutel <ferenc.beutel@otto.de>
Date:   Tue Jun 14 14:33:10 2016 +0200

    Make fork changes non breaking for older versions of Koloda

commit e663736
Author: Ferenc Beutel <ferenc.beutel@otto.de>
Date:   Tue Jun 14 12:08:23 2016 +0200

    Merge fork into Koloda upstream

commit 5c30829
Author: Lukas Zielinski <lukas.zielinski@otto.de>
Date:   Thu May 26 17:12:23 2016 +0200

    Added option to pass through taps when no cards are visible.

commit c07f107
Author: Lukas Zielinski <lukas.zielinski@otto.de>
Date:   Tue Apr 26 16:26:15 2016 +0200

    For background cards change top margin to 0 and scale percent to 1.

commit 2b2e7b5
Merge: 8ac3d8e 3f9b393
Author: AEugene <barakuda1933@gmail.com>
Date:   Mon Jun 13 18:17:49 2016 +0300

    Merge pull request Yalantis#162 from maximeloizeau/master

    Fix index out of range when removing all cards

commit 3f9b393
Author: Maxime <maximeloizeau@gmail.com>
Date:   Thu Jun 9 21:20:44 2016 +0100

    Fix index out of range when removing all cards

commit 8ac3d8e
Merge: 4e6f05c 03d0c32
Author: AEugene <barakuda1933@gmail.com>
Date:   Tue Jun 7 13:51:16 2016 +0300

    Merge pull request Yalantis#160 from lbatteau/master

    Fixed index out of bounds error

commit 4e6f05c
Merge: 1b29ffa 5f7e0a9
Author: AEugene <barakuda1933@gmail.com>
Date:   Tue Jun 7 12:58:16 2016 +0300

    Merge pull request Yalantis#157 from petalvlad/master

    Disallow canceling touches in subviews

commit 1b29ffa
Author: Ed Baev <edbaev@gmail.com>
Date:   Tue Jun 7 12:00:49 2016 +0300

    Update README.md

commit 548b98d
Author: Ed Baev <edbaev@gmail.com>
Date:   Tue Jun 7 12:00:16 2016 +0300

    Update README.md

commit 03d0c32
Author: Lukas Batteau <l.batteau@indieit.nl>
Date:   Wed Jun 1 10:40:12 2016 +0200

    Fixed index out of bounds error

commit 5f7e0a9
Author: Alexander Petropavlovsky <petalvlad@gmail.com>
Date:   Fri May 27 09:57:06 2016 -0700

    Disallow canceling touches in subviews

commit 1646272
Merge: 8370da9 112b45f
Author: AEugene <barakuda1933@gmail.com>
Date:   Wed May 25 17:16:25 2016 +0300

    Merge pull request Yalantis#155 from Yalantis/feature/add_tutorial

    [Add] Added 'Usage' part to Readme.md

commit 112b45f
Author: AndrewiOS <andrew.petrov@yalantis.com>
Date:   Wed May 25 17:06:18 2016 +0300

    [Fix] Fixed Radme.md

commit 61d921f
Author: AndrewiOS <andrew.petrov@yalantis.com>
Date:   Wed May 25 15:04:21 2016 +0300

    [Add] Added "Apps using KolodaView" section

commit dd6f6ec
Author: AndrewiOS <andrew.petrov@yalantis.com>
Date:   Wed May 25 13:06:18 2016 +0300

    [Add] Added 'Usage' part to Readme.md

commit 8370da9
Author: Eugene Andreyev <justandjack@hotmail.com>
Date:   Mon May 23 18:53:21 2016 +0300

    Made overlayStrength unavailable.

commit 53d9c6f
Merge: ca27bcd 3b4fa2f
Author: AEugene <barakuda1933@gmail.com>
Date:   Mon May 23 17:21:16 2016 +0300

    Merge pull request Yalantis#152 from Yalantis/feature/148

    [Refactor] Refactored the code.  deprecated overlayStrength and intro…

commit 3b4fa2f
Author: AndrewiOS <andrew.petrov@yalantis.com>
Date:   Mon May 23 17:09:31 2016 +0300

    [Refactor] Refactored the code.  deprecated overlayStrength and introduced updateWithProgress

commit ca27bcd
Author: Eugene Andreyev <justandjack@hotmail.com>
Date:   Tue May 10 20:59:35 2016 +0300

    Added CoreGraphics dependency to SwipeResultDirection.
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.

None yet

4 participants