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

New corner option: alwaysShowBelowStatusBar. #61

Merged
merged 3 commits into from
Apr 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,20 @@ extension PresentationController {
}

func cornerRadius(at state: DrawerState) -> CGFloat {
return maximumCornerRadius * triangularValue(at: state)
switch configuration.cornerAnimationOption {
case .maximumAtPartialY:
return maximumCornerRadius * triangularValue(at: state)
case .alwaysShowBelowStatusBar:
let drawerFullY = configuration.fullExpansionBehaviour.drawerFullY
let positionY =
GeometryEvaluator.drawerPositionY(for: state,
drawerPartialHeight: drawerPartialHeight,
containerViewHeight: containerViewHeight,
drawerFullY: drawerFullY)

return maximumCornerRadius * min(positionY, DrawerGeometry.statusBarHeight) / DrawerGeometry.statusBarHeight

}
}

func handleViewAlpha(at state: DrawerState) -> CGFloat {
Expand Down
18 changes: 18 additions & 0 deletions DrawerKit/DrawerKit/Public API/Structs/DrawerConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ public struct DrawerConfiguration {
}
}

public enum CornerAnimationOption {
/// The corners would be at its maximum radius when the drawer is
Copy link
Contributor

Choose a reason for hiding this comment

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

"The corners would be at its their maximum radius when the drawer is..."

/// partially expanded, and shrink as the drawer moves away in either
/// direction.
case maximumAtPartialY

/// The corners would be always shown below the status bar at its
Copy link
Contributor

Choose a reason for hiding this comment

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

... at their...

/// maximum radius, and shrink only as the drawer moves into the frame
/// of the status bar towards the top screen edge.
case alwaysShowBelowStatusBar
}

/// The total duration, in seconds, for the drawer to transition from its
/// collapsed state to its fully-expanded state, or vice-versa. The default
/// value is 0.4 seconds.
Expand Down Expand Up @@ -127,6 +139,10 @@ public struct DrawerConfiguration {
/// corners, from 0 to the value of this property. Setting this to 0 prevents any
/// corner animations from taking place. The default value is 15 points.
public var maximumCornerRadius: CGFloat

/// How the drawer should animate its corner radius if specified. The
/// default value is `maximumAtPartialY`.
public var cornerAnimationOption: CornerAnimationOption

/// The configuration options for the handle view, should it be shown. Set this
/// property to `nil` to hide the handle view. The default value is
Expand Down Expand Up @@ -156,6 +172,7 @@ public struct DrawerConfiguration {
upperMarkGap: CGFloat = 40,
lowerMarkGap: CGFloat = 40,
maximumCornerRadius: CGFloat = 15,
cornerAnimationOption: CornerAnimationOption = .maximumAtPartialY,
handleViewConfiguration: HandleViewConfiguration? = HandleViewConfiguration(),
drawerBorderConfiguration: DrawerBorderConfiguration? = nil,
drawerShadowConfiguration: DrawerShadowConfiguration? = nil) {
Expand All @@ -181,6 +198,7 @@ public struct DrawerConfiguration {
self.upperMarkGap = max(0, upperMarkGap)
self.lowerMarkGap = max(0, lowerMarkGap)
self.maximumCornerRadius = max(0, maximumCornerRadius)
self.cornerAnimationOption = cornerAnimationOption
self.handleViewConfiguration = handleViewConfiguration
self.drawerBorderConfiguration = drawerBorderConfiguration
self.drawerShadowConfiguration = drawerShadowConfiguration
Expand Down