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 config to disable dismissal of collapsed drawer #65

Closed
wants to merge 4 commits into from

Conversation

georgmay
Copy link

Hello!

Here's a PR to allow users disable dismissal of a drawer view and keep some height of it always on screen.

I think i can reference this issue here.

@georgmay georgmay changed the title Add config to disable dismissal of drawer Add config to disable dismissal of collapsed drawer Apr 23, 2018
@daxfrost
Copy link

I really want this too!

Copy link
Contributor

@wltrup wltrup left a comment

Choose a reason for hiding this comment

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

Tests are failing. Please fix those and also address my comments. Thank you!

self.presentedViewController.dismiss(animated: true)
if !self.configuration.neverDismissCollapsedDrawer {
self.presentedViewController.dismiss(animated: true)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks strange. Why not add the condition directly to the local variable shouldDismiss? Also, I'd prefer not to have two negations, ie, to have something like canDismissCollapsedDrawer instead of !neverDismissCollapsedDrawer.

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense, I'll fix it.

@@ -15,7 +15,10 @@ extension PresentationController {
guard tapY < currentDrawerY else { return }
NotificationCenter.default.post(notification: DrawerNotification.drawerExteriorTapped)
tapGesture.isEnabled = false
presentedViewController.dismiss(animated: true)

if !configuration.neverDismissCollapsedDrawer {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer not to have two negations, ie, to have something like canDismissCollapsedDrawer instead of !neverDismissCollapsedDrawer.

Copy link
Author

Choose a reason for hiding this comment

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

👍

@@ -6,4 +6,8 @@ public protocol DrawerPresentable: class {
/// The height at which the drawer must be presented when it's in its
/// partially expanded state. If negative, its value is clamped to zero.
var heightOfPartiallyExpandedDrawer: CGFloat { get }

/// The height at which the drawer should be presented when it's in its
/// collapsed expanded state. If negative, its value is clamped to zero.
Copy link
Contributor

Choose a reason for hiding this comment

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

collapsed expanded state makes no sense. It should be collapsed state.

Copy link
Author

Choose a reason for hiding this comment

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

👍

@@ -82,6 +82,9 @@ public struct DrawerConfiguration {
/// When `false`, the presentation is always to full screen and there is no
/// partially expanded state. The default value is `true`.
public var supportsPartialExpansion: Bool

/// When `true`, collapsed drawer is never gets dismissed.
public var neverDismissCollapsedDrawer: Bool
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer something like canDismissCollapsedDrawer instead of neverDismissCollapsedDrawer. Also, the default value in the initialiser should then change to true.

@@ -82,6 +82,9 @@ public struct DrawerConfiguration {
/// When `false`, the presentation is always to full screen and there is no
/// partially expanded state. The default value is `true`.
public var supportsPartialExpansion: Bool

/// When `true`, collapsed drawer is never gets dismissed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Grammar needs fixing. Should be "When true, collapsed drawer is never dismissed." Also, a note about the default value is missing.

@@ -37,6 +37,7 @@ private extension PresenterViewController {
configuration.upperMarkGap = 100 // default is 40
configuration.lowerMarkGap = 80 // default is 40
configuration.maximumCornerRadius = 15
configuration.neverDismissCollapsedDrawer = true
Copy link
Contributor

Choose a reason for hiding this comment

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

If changing from neverDismissCollapsedDrawer to canDismissCollapsedDrawer, then the value here should be false.

@wltrup wltrup requested a review from andersio May 25, 2018 15:09
containerViewHeight: CGFloat,
drawerFullY: CGFloat) -> CGFloat {
switch state {
case .collapsed:
return containerViewHeight
return containerViewHeight - drawerCollapsedHeight
Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand correctly, I think the subtraction here should only happen when canDismissCollapsedDrawer is false. If it's true, then the previous behaviour (ie, no subtraction) should be the one that takes effect. In other words, I think this should be

let offset: CGFloat = canDismissCollapsedDrawer ? 0 : drawerCollapsedHeight
return containerViewHeight - offset

Please make sure to test the behaviour for both values of canDismissCollapsedDrawer and make sure that the behaviour for canDismissCollapsedDrawer == true matches the current behaviour.

@@ -82,6 +82,9 @@ public struct DrawerConfiguration {
/// When `false`, the presentation is always to full screen and there is no
/// partially expanded state. The default value is `true`.
public var supportsPartialExpansion: Bool

/// When `false`, collapsed drawer is never dismissed.
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs a comment about the default value (which is true). Something like:

/// When false, collapsed drawer is never dismissed. The default value is true.

@ilyapuchka
Copy link
Contributor

I believe this is addressed now with #75 though without a configuration to not dismiss collapsed drawer

@wltrup
Copy link
Contributor

wltrup commented Nov 5, 2018

I'm going to close this PR since the changes haven't been addressed, there are conflicts, and - as @ilyapuchka has pointed out - this is fixed by another PR.

@wltrup wltrup closed this Nov 5, 2018
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.

4 participants