GithubHelp home page GithubHelp logo

babylonhealth / drawerkit Goto Github PK

View Code? Open in Web Editor NEW
778.0 62.0 44.0 12.45 MB

DrawerKit lets an UIViewController modally present another UIViewController in a manner similar to the way Apple's Maps app works.

Home Page: https://github.com/Babylonpartners

License: MIT License

Ruby 0.72% Objective-C 0.27% Swift 99.01%
uikit transition animator viewcontroller-transition ios-swift ios

drawerkit's People

Contributors

andersio avatar dmcrodrigues avatar halleygen avatar ilyapuchka avatar kelvin2468 avatar mluisbrown avatar wltrup 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  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

drawerkit's Issues

CustomGap doesn't affect the final size of presented view

I'm trying to place UI component depending of the size of the presented view, for instance having a button at the bottom of the drawer.

When testing it, it seems that the size of the presented view is never matching the size left from the custom gap. For instance, if I set a .leavesCustomGap(gap: 100), the view presented frame won't get shorter of 100. Therefore any elements at the bottom might not be visible.

I guess what I would expect is that if the drawer can have a maximum size of 500, its presented view and contained one would reflect the same size. That's not the case at the moment. Is it something available with DrawerKit?

To replicate it, inspect the view frame in a presented view controller (in viewDidAppear for instance), it will be the size of the screen regardless the maximum size available of the drawer.

Drawer top corner always set to 0 even when .fullExpansionBehaviour set to leavesCustomGap(gap:)

I set drawer not cover the whole screen when full expansion. However, top corner mask disappeared. But I really want the corner exist when drawer not modal fully.

configuration.fullExpansionBehaviour to .leavesCustomGap(gap: 135)
configuration.cornerAnimationOption = .alwaysShowBelowStatusBar

I have skimmed the Internal API. This may be caused cornerRadius set to 0 in animator's completionHandler.

// PresentationController+Animation.swift
let shouldSetCornerRadiusToZero =
    (isEndingStateCollapsedOrFullyExpanded && endingPosition == .end) ||
    (isStartingStateCollapsedOrFullyExpanded && endingPosition == .start)
self.currentDrawerCornerRadius = 0

Not sure this behavior indeed we want. And I temporary change that to get AppleMusic.app likely behavior. Please let me know If another configuration option could get the same behavior I want. ๐Ÿ˜ƒ

// PresentationController+Animation.swift
if case DrawerConfiguration.FullExpansionBehaviour.leavesCustomGap(gap: _) = self.configuration.fullExpansionBehaviour {
    self.currentDrawerCornerRadius = maxCornerRadius
} else if maxCornerRadius != 0 && shouldSetCornerRadiusToZero {
    self.currentDrawerCornerRadius = 0
}

Drawer doesn't dismiss when clicking outside the drawer.

The drawer doesn't dismiss when clicking outside the drawer, regardless of the configuration of isDismissableByOutsideDrawerTaps.

drawerclickbug

I'm using the following DrawerConfiguration:

DrawerConfiguration(
        fullExpansionBehaviour: .leavesCustomGap(gap: 300),
        cornerAnimationOption: .none,
        handleViewConfiguration: HandleViewConfiguration(autoAnimatesDimming: false)
 )

And my DrawerPresentable implementation has just the following:

var heightOfPartiallyExpandedDrawer = CGFloat(200)

Changing state after previously changing it to dismissed results in drawer "jumping" before it is being dismissed

Drawer state change animation is implemented in a way that does not forbid changing to a different state while previous transition animation is still in progress (related to #86). Because of that when dismissing drawer (by calling setDrawerState(.dismissed)) and then changing state to something else, i.e. partially expanded, you can see that it is animating to this new state even though the intention is for it to be dismissed.

20190320184605

Presented view controller captures gestures

Using DrawerKit to present a UICollectionView or UITableView controller means that the presented controller captures touches and prevents being able to pull the draw up/down. In the Apple Maps example, touches are ignored by the table view until the draw is 100%.

CornerRadius only affecting border, not drawer itself

I'm playing with the demo app and the corner radius doesn't seem to be affecting the actual VC itself. This is how it looks in the simulator on 11.3 Xcode 9.3.1. Border is there, but it wont affect the drawer itself. Am I missing something?
image

Support insufficiently tall content

When the presented view controller's content is not tall enough to fill the entire screen, it doesn't make sense to expand the drawer all the way to the top of the screen. Rather, we should only expand it as far as there is content to show. This essentially boils down to not identifying the fully-expanded state with the full-screen height.

Display above Tab Bar

Got root view with container view/
Inside that container i'm presenting drawer.
Got tab bar in root view.
image
Is there any way to use view's insets for drawer and present drawer above my tab bar??
There i've got drawer over my tab bar:
screen shot 2018-11-05 at 17 53 01

Method to Disable Collapsed / Dismissed Presented View Controller

TL;DR: How can I make the collapse presented view controller persist on screen, and not dismiss / fly off the screen for good?

Fork: https://github.com/mattbarker016/DrawerKit

Description: I replaced or changed nearly all instances of DrawerState.collapsed to act like .partiallyExpanded. This makes the the drawer toggle between two states, keeping a persistent view no matter what (I also had to use configuration.lowerMarkGap = 100000000 . Ideally, I'd like to be able to adjust the .collapsed presented view controller so I can get some of the cool transition and partiallyExpanded physics and functionality, but I haven't found a way yet. Please let me know how I could do this, or if this is a feature to be added!

Code Changed: https://github.com/mattbarker016/DrawerKit/commit/53ef319dc54cd25083d5e262be4876767eccce19

DrawerKit with RxCocoa, UITableView `didSelectRow` not called

I use DrawerKit to display a UIViewController with an UITableView. I use RxSwift / RxCocoa to handle UITableView data / events.

I've noticed that DrawerKit PullToDismissManager can't forward event to RxTableViewDelegateProxy as it does with UITableViewDelegate:

  • If I don't implement scrollViewForPullToDismiss, tableView.rx.itemSelected works as usual.
  • If I implement scrollViewForPullToDismiss with a classic UITableViewDelegate approach, implementation of didSelectRowAt:index works as usual.
  • If I implement scrollViewForPullToDismiss, tableView.rx.itemSelected doesn't work.

I'm not sure if it's more a question to address in RxCocoa side or DrawerKit. I wonder if you had this issue before and have a hint to proceed except reimplementing UITableViewDelegate for that specific view.

Thanks

Views presented by the drawer do not always deallocate upon dismissal

To reproduce:

  1. Open the provided sample project and add the following to PresentedView:
    deinit {
        print("Did deinit presentedView")
    }
  1. Run app
  2. Open the drawer
  3. Dismiss the drawer by swiping the drawer down or by tapping the close button.
  4. Observe the console.

"Did deinit presentedView" is not always printed. on dismissal. Most of the time, the line is printed when the drawer is re-opened. The view is always deallocated correctly if the user taps somewhere on the screen outside of the drawer.

drawerkit dealloc

Blur background, Question

Hey,
Thanks for the library! Great job!

I was wondering what's the best way to modify to add blur background when the view not fully presented, to cover upper part?

Thanks!

Content size awareness

Similarly to the issues described in #101 there seems to be no good way to consider content size of the view presented in the drawer for it's partially expanded state (as well as for fully expanded).
I've tried to solve that by adopting DrawerPresentable and return the content size from its heightOfPartiallyExpandedDrawer like this:

extension DrawerMapPlaceDetailsViewController: DrawerPresentable, DrawerAnimationParticipant {
    public var heightOfPartiallyExpandedDrawer: CGFloat {
        return self.tableView.contentSize.height + (view.window?.safeAreaInsets.bottom ?? 0)
    }
}

This seems to work visually without issues but internally the state of the drawer changes and it is not in the partially expanded state because during transition the value returned by this method changes from 0 to final value (for some reason it changes one more time adding 4 pixels, but that's probably for reasons unrelated to DrawerKit) and as a result drawer is in the transitioning state, which breaks interactions with background view a they are only considering "final" states (collapsed, partially expanded and fully expanded).
One fix for that might be to consider transition state while detecting touches, but that does not seem like a solution of underlying problem.

Way to change the width of the drawer (iPad apple maps)

We're dealing with a map related product and would like to mimic iOS maps.

DrawerKit satisfies our needs on an iPhone, but anything in the size class of iPads, the drawer is too big.

Is there a way to limit the size of the container view controller?

I'm looking in to DrawerGeometry but it doesn't look like I can get at it, or provide it to my presentation handler or anything

Drawer corners are not shown on initial presentation.

On initial presentation, the drawer corners are not displayed. They only appear (and then remain) after moving the drawer:

drawercorners

I'm using the following DrawerConfiguration:

DrawerConfiguration(
        fullExpansionBehaviour: .leavesCustomGap(gap: 300),
        cornerAnimationOption: .none,
        handleViewConfiguration: HandleViewConfiguration(autoAnimatesDimming: false)
 )

And my DrawerPresentable implementation has just the following:

var heightOfPartiallyExpandedDrawer = CGFloat(200)

Lines behind controller

Where are the 3 lines behind the controller (seen in the demo gifs) created? I'm trying to find out how to remove them

Partially expanded drawer does not dismiss on background click

  • If you have partially expanded drawer it does not dismiss if I click outside the drawer. (currently you can interact with the visible content)
  • In addition if drawer is fully expanded with leavesCustomGap clicking on the gap does not dismiss the drawer.

Is this a bug on iOS 14 or intended behaviour? How can I accomplish dismissing drawer in both cases?

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.