Skip to content

Commit

Permalink
Added new property - useful when is added to a view controller that i…
Browse files Browse the repository at this point in the history
…s presented modally on iOS 13 where the default presentation style supports a dismiss gesture.
  • Loading branch information
benpackard committed Oct 1, 2019
1 parent fbe74ee commit 2d0356d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cosmos/CosmosDefaultSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,7 @@ struct CosmosDefaultSettings {

/// When `true` the star fill level is updated when user touches the cosmos view. When `false` the Cosmos view only shows the rating and does not act as the input control.
static let updateOnTouch = true

/// Set to `true` if you want to ignore pan gestures (can be useful when presented modally with a `presentationStyle` of `pageSheet` to avoid competing with the dismiss gesture)
static let disablePanGestures = false
}
3 changes: 3 additions & 0 deletions Cosmos/CosmosSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public struct CosmosSettings {

/// When `true` the star fill level is updated when user touches the cosmos view. When `false` the Cosmos view only shows the rating and does not act as the input control.
public var updateOnTouch = CosmosDefaultSettings.updateOnTouch

/// Set to `true` if you want to ignore pan gestures (can be useful when presented modally with a `presentationStyle` of `pageSheet` to avoid competing with the dismiss gesture)
public var disablePanGestures = CosmosDefaultSettings.disablePanGestures
}


8 changes: 8 additions & 0 deletions Cosmos/CosmosView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ Shows: ★★★★☆ (123)
didFinishTouchingCosmos?(rating)
}

/// Deciding whether to recognize a gesture.
open override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
if settings.disablePanGestures {
return !(gestureRecognizer is UIPanGestureRecognizer)
}
return true
}

/**

Detecting event when the touches are cancelled (can happen in a scroll view).
Expand Down
14 changes: 14 additions & 0 deletions Distrib/CosmosDistrib.swift
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ struct CosmosDefaultSettings {

/// When `true` the star fill level is updated when user touches the cosmos view. When `false` the Cosmos view only shows the rating and does not act as the input control.
static let updateOnTouch = true

/// Set to `true` if you want to ignore pan gestures (can be useful when presented modally with a `presentationStyle` of `pageSheet` to avoid competing with the dismiss gesture)
static let disablePanGestures = false
}


Expand Down Expand Up @@ -1093,6 +1096,9 @@ public struct CosmosSettings {

/// When `true` the star fill level is updated when user touches the cosmos view. When `false` the Cosmos view only shows the rating and does not act as the input control.
public var updateOnTouch = CosmosDefaultSettings.updateOnTouch

/// Set to `true` if you want to ignore pan gestures (can be useful when presented modally with a `presentationStyle` of `pageSheet` to avoid competing with the dismiss gesture)
public var disablePanGestures = CosmosDefaultSettings.disablePanGestures
}


Expand Down Expand Up @@ -1443,6 +1449,14 @@ Shows: ★★★★☆ (123)
didFinishTouchingCosmos?(rating)
}

/// Deciding whether to recognize a gesture.
open override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
if settings.disablePanGestures {
return !(gestureRecognizer is UIPanGestureRecognizer)
}
return true
}

/**

Detecting event when the touches are cancelled (can happen in a scroll view).
Expand Down

0 comments on commit 2d0356d

Please sign in to comment.