Skip to content

Commit

Permalink
Merge pull request #401 from 52inc/xcode12
Browse files Browse the repository at this point in the history
Xcode12 Fixes to issue #400
  • Loading branch information
ulmentflam committed Oct 8, 2020
2 parents 780fc8e + 82d023d commit 780234b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Pulley.podspec
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'Pulley'
s.version = ENV['LIB_VERSION'] || '2.8.4'
s.version = ENV['LIB_VERSION'] || '2.8.5'
s.summary = 'A library to imitate the iOS 10 Maps UI.'

# This description is used to generate tags and improve search results.
Expand Down
Expand Up @@ -62,7 +62,7 @@
<CommandLineArguments>
<CommandLineArgument
argument = "-UIViewLayoutFeedbackLoopDebuggingThreshold 100"
isEnabled = "YES">
isEnabled = "NO">
</CommandLineArgument>
</CommandLineArguments>
</LaunchAction>
Expand Down
3 changes: 3 additions & 0 deletions Pulley/PrimaryContentViewController.swift
Expand Up @@ -70,6 +70,9 @@ extension PrimaryContentViewController: PulleyPrimaryContentControllerDelegate {

func drawerChangedDistanceFromBottom(drawer: PulleyViewController, distance: CGFloat, bottomSafeArea: CGFloat)
{
// As of iOS 14, setting the constant on the constraint causes viewDidLayoutSubviews() to be call
// on the PulleyViewController. This was causing issues with the drawer scroll view in 2.8.2+, see fix
// for issue #400 and update 2.8.5
guard drawer.currentDisplayMode == .drawer else {

temperatureLabelBottomConstraint.constant = temperatureLabelBottomDistance
Expand Down
36 changes: 34 additions & 2 deletions PulleyLib/PulleyViewController.swift
Expand Up @@ -131,14 +131,29 @@ public typealias PulleyAnimationCompletionBlock = ((_ finished: Bool) -> Void)
return .collapsed
}
}

public override func isEqual(_ object: Any?) -> Bool {
guard let position = object as? PulleyPosition else {
return false
}

return self.rawValue == position.rawValue
}

public override var description: String {
switch rawValue {
case 0:
return "collapsed"
case 1:
return "partiallyrevealed"
case 2:
return "open"
case 3:
return "closed"
default:
return "collapsed"
}
}
}

/// Represents the current display mode for Pulley
Expand Down Expand Up @@ -630,6 +645,8 @@ open class PulleyViewController: UIViewController, PulleyDrawerViewControllerDel

fileprivate var isAnimatingDrawerPosition: Bool = false

fileprivate var isChangingDrawerPosition: Bool = false

/// The height of the open position for the drawer
private var heightOfOpenDrawer: CGFloat {

Expand Down Expand Up @@ -955,7 +972,14 @@ open class PulleyViewController: UIViewController, PulleyDrawerViewControllerDel

maskDrawerVisualEffectView()
maskBackgroundDimmingView()
setDrawerPosition(position: drawerPosition, animated: false)

// Do not need to set the the drawer position in layoutSubview if the position of the drawer is changing
// and the view is being layed out. If the drawer position is changing and the view is layed out (i.e.
// a value or constraints are bing updated) the drawer is always set to the last position,
// and no longer scrolls properly.
if self.isChangingDrawerPosition == false {
setDrawerPosition(position: drawerPosition, animated: false)
}
}

// MARK: Private State Updates
Expand Down Expand Up @@ -1527,6 +1551,7 @@ extension PulleyViewController: UIScrollViewDelegate {

public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {


if scrollView == drawerScrollView
{
// Find the closest anchor point and snap there.
Expand Down Expand Up @@ -1650,6 +1675,12 @@ extension PulleyViewController: UIScrollViewDelegate {
}
}

public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
if scrollView == drawerScrollView {
self.isChangingDrawerPosition = true
}
}

public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {

prepareFeedbackGenerator()
Expand All @@ -1660,6 +1691,7 @@ extension PulleyViewController: UIScrollViewDelegate {

// Halt intertia
targetContentOffset.pointee = scrollView.contentOffset
self.isChangingDrawerPosition = false
}
}

Expand Down

0 comments on commit 780234b

Please sign in to comment.