Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support interactions on presented view
- Loading branch information
1 parent
6edf4eb
commit 92b5013
Showing
8 changed files
with
166 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
DrawerKit/DrawerKit/Internal API/PresentationContainerView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import UIKit | ||
|
||
public struct PassthroughOptions: OptionSet { | ||
public let rawValue: Int | ||
|
||
public init(rawValue: Int) { | ||
self.rawValue = rawValue | ||
} | ||
|
||
public static let collapsed = PassthroughOptions(rawValue: 1 << 0) | ||
public static let partiallyExpanded = PassthroughOptions(rawValue: 1 << 1) | ||
public static let fullyExpanded = PassthroughOptions(rawValue: 1 << 2) | ||
public static let all: PassthroughOptions = [.collapsed, .partiallyExpanded, .fullyExpanded] | ||
} | ||
|
||
protocol PresentationContainerViewDelegate: class { | ||
func view(_ view: PresentationContainerView, shouldPassthroughTouchAt point: CGPoint) -> Bool | ||
func view(_ view: PresentationContainerView, forTouchAt point: CGPoint) -> UIView? | ||
} | ||
|
||
class PresentationContainerView: UIView { | ||
weak var touchDelegate: PresentationContainerViewDelegate? | ||
|
||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { | ||
guard let touchDelegate = touchDelegate, | ||
touchDelegate.view(self, shouldPassthroughTouchAt: point), | ||
let viewForTouch = touchDelegate.view(self, forTouchAt: point) else { | ||
return super.hitTest(point, with: event) | ||
} | ||
|
||
let pointInView = viewForTouch.convert(point, from: self) | ||
return viewForTouch.hitTest(pointInView, with: event) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
DrawerKit/DrawerKit/Internal API/PresentationController+Setup.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.