Merge pull request #2 from TouchInstinct/block_minimum_reached
Added block call when minimum is reached
This commit is contained in:
commit
d7c8bb83b0
|
|
@ -111,7 +111,10 @@ import UIKit
|
||||||
|
|
||||||
/// Label tap closure
|
/// Label tap closure
|
||||||
@objc public var didTouchLabel: ((Double) -> Void)?
|
@objc public var didTouchLabel: ((Double) -> Void)?
|
||||||
|
|
||||||
|
/// Block is called when the minimum is exceeded
|
||||||
|
@objc public var minimumExceeded: (() -> Void)?
|
||||||
|
|
||||||
/// Text color of the middle label. Defaults to white.
|
/// Text color of the middle label. Defaults to white.
|
||||||
@objc @IBInspectable public var labelTextColor: UIColor = UIColor.white {
|
@objc @IBInspectable public var labelTextColor: UIColor = UIColor.white {
|
||||||
didSet {
|
didSet {
|
||||||
|
|
@ -439,6 +442,7 @@ extension GMStepper {
|
||||||
|
|
||||||
if value == minimumValue {
|
if value == minimumValue {
|
||||||
animateLimitHitIfNeeded()
|
animateLimitHitIfNeeded()
|
||||||
|
minimumExceeded?()
|
||||||
} else {
|
} else {
|
||||||
stepperState = .ShouldDecrease
|
stepperState = .ShouldDecrease
|
||||||
animateSlideLeft()
|
animateSlideLeft()
|
||||||
|
|
@ -529,12 +533,11 @@ private extension GMStepper {
|
||||||
func handleIsLimitReached() {
|
func handleIsLimitReached() {
|
||||||
let isLimitReached = value == minimumValue
|
let isLimitReached = value == minimumValue
|
||||||
leftButton.alpha = isLimitReached ? leftButtonLimitOpacity : 1
|
leftButton.alpha = isLimitReached ? leftButtonLimitOpacity : 1
|
||||||
leftButton.isUserInteractionEnabled = !isLimitReached
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Decimal {
|
extension Decimal {
|
||||||
|
|
||||||
var significantFractionalDecimalDigits: Int {
|
var significantFractionalDecimalDigits: Int {
|
||||||
return max(-exponent, 0)
|
return max(-exponent, 0)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue