Skip to content
Open
Changes from all commits
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
20 changes: 18 additions & 2 deletions DrawerView/DrawerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ let dateFormatter: DateFormatter = {
case closed = 0
case collapsed = 1
case partiallyOpen = 2
case open = 3
case pushedUp = 3
case open = 4
}

extension DrawerPosition: CustomStringConvertible {
Expand All @@ -34,6 +35,7 @@ extension DrawerPosition: CustomStringConvertible {
case .closed: return "closed"
case .collapsed: return "collapsed"
case .partiallyOpen: return "partiallyOpen"
case .pushedUp: return "pushedUp"
case .open: return "open"
}
}
Expand All @@ -42,7 +44,7 @@ extension DrawerPosition: CustomStringConvertible {
fileprivate extension DrawerPosition {

static var allPositions: [DrawerPosition] {
return [.closed, .collapsed, .partiallyOpen, .open]
return [.closed, .collapsed, .partiallyOpen, .pushedUp, .open]
}

static let activePositions: [DrawerPosition] = allPositions
Expand Down Expand Up @@ -372,6 +374,13 @@ private struct ChildScrollViewInfo {
self.updateSnapPosition(animated: false)
}
}

/// The amount the drawer is pushed up from partially open when selected.
public var pushUp: CGFloat = 50 {
didSet {
self.updateSnapPosition(animated: false)
}
}

/// The current position of the drawer.
public var position: DrawerPosition {
Expand Down Expand Up @@ -995,6 +1004,9 @@ private struct ChildScrollViewInfo {
} else {
return self.topMargin
}

case .pushedUp:
return superview.bounds.height - bottomInset - (self.pushUp + self.partiallyOpenHeight)
case .partiallyOpen:
return superview.bounds.height - bottomInset - self.partiallyOpenHeight
case .collapsed:
Expand All @@ -1016,6 +1028,8 @@ private struct ChildScrollViewInfo {
return (position.rawValue >= topmost) ? 1 : 0
case (.open, .whenOpen):
fallthrough
case (.pushedUp, .whenOpen):
return 1
case (.partiallyOpen, .whenOpen):
return 1
case (.collapsed, _):
Expand All @@ -1033,6 +1047,8 @@ private struct ChildScrollViewInfo {
switch position {
case .open:
return self.shadowOpacity
case .pushedUp:
return self.shadowOpacity
case .partiallyOpen:
return self.shadowOpacity
case .collapsed:
Expand Down