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

Reduce API surface. #3

Closed
wants to merge 4 commits into from
Closed

Reduce API surface. #3

wants to merge 4 commits into from

Conversation

andersio
Copy link
Contributor

@andersio andersio commented Oct 16, 2017

Depends on #2.

The public DrawerKit API has been reduced to three pieces: DrawerConfiguration, DrawerController and PartiallyExpandableDrawer.

A view controller that wishes to be presented as a drawer can simply:

  1. create and retain DrawerController with its desired configuration; and
  2. set the DrawerController as its transitioning delegate.

If it wishes to support partial expansion, on top of enabling the setting in DrawerConfiguration, the drawer view controller needs to conform to also PartiallyExpandableDrawer.

How does it work?

DrawerController tracks if it has ever created any PresentationController. Since UIKit pretty much guarantees that it asks for a presentation controller before the animators, we can explore this in order to retrieve the presenting VC for the animator dynamically.

It also works when the view controller is recycled. Since UIKit would release the presentation controller upon conclusion of a presentation, this means the weak reference in DrawerController would be zeroed, and hence a new PresentationController would be created next time the drawer is presented.

Example

https://github.com/Babylonpartners/DrawerKit/pull/3/files#diff-797161087489cdf11d7916a4480c4f93R4

Basic hello world example:

drawerController = DrawerController(configuration: DrawerConfiguration())
modalPresentationStyle = .custom
transitioningDelegate = drawerController

wltrup and others added 4 commits October 16, 2017 03:48
…nd having the presented VC dictate its presentation. In addition to some warnings, the drawer presentation is lost! Somehow UIKit is ignoring the fact that the presented VC is its own transitioning delegate and, therefore, isn't asking for a custom presentation controller.
…Controller (now renamed DrawerController) be the transitioning delegate of the presented VC. Some of the same problems as with the other suggestion.
@wltrup wltrup closed this Oct 17, 2017
@andersio andersio changed the base branch from intro to develop October 17, 2017 13:40
@wltrup wltrup reopened this Oct 17, 2017
@diegopetrucci
Copy link

Why is this blocked?

@wltrup
Copy link
Contributor

wltrup commented Oct 21, 2017

I'm making some significant changes and adding some new or missing features to DrawerKit this weekend (PR forthcoming sometime today or tomorrow) and I think it would be best to wait after those are reviewed and merged before considering reducing the API surface. Besides, this branch has conflicts so they need to be resolved before any review is to happen. 😄

@wltrup wltrup closed this Nov 15, 2017
@andersio andersio deleted the anders/reduce-api-surface branch November 15, 2017 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants