Skip to content

Commit fe8541c

Browse files
committed
Merge branch 'long-press-ended-callback'
2 parents bd5ecff + 5b2dade commit fe8541c

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

KWStepper.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "KWStepper"
3-
s.version = "2.3.0"
3+
s.version = "2.4.0"
44
s.summary = "A stepper control with flexible UI and tailored UX."
55
s.homepage = "https://github.com/kyleweiner/KWStepper"
66
s.license = { :type => "MIT", :file => "LICENSE" }

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ Adopting `KWStepperDelegate` provides the following optional delegate methods fo
114114
* `optional func KWStepperDidIncrement()`
115115
* `optional func KWStepperMaxValueClamped()`
116116
* `optional func KWStepperMinValueClamped()`
117+
* `optional func KWStepperDidEndLongPress()`
117118

118119
### Callbacks
119120

@@ -124,6 +125,7 @@ KWStepper provides the following callbacks:
124125
* `incrementCallback`
125126
* `maxValueClampedCallback`
126127
* `minValueClampedCallback`
128+
* `longPressEndedCallback`
127129

128130
Method chaining is supported for callbacks too:
129131

@@ -134,6 +136,7 @@ stepper
134136
.didIncrement { _ in }
135137
.maxValueClamped { _ in }
136138
.minValueClamped { _ in }
139+
.longPressEnded { _ in }
137140

138141
// `maxValueClampedCallback` and `minValueClampedCallback` may be set simultaneously.
139142
stepper.valueClamped { stepper in

Source/KWStepper+Chaining.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ extension KWStepper {
129129
return self
130130
}
131131

132+
/// Sets the stepper's `longPressEndedCallback`.
133+
@discardableResult
134+
public func longPressEnded(_ callback: KWStepperCallback?) -> Self {
135+
longPressEndedCallback = callback
136+
137+
return self
138+
}
139+
132140
// MARK: - Convenience Methods
133141

134142
/// Sets the stepper's `decrementStepValue` and `incrementStepValue`.

Source/KWStepper.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ import UIKit
2020

2121
/// Called when `value` is clamped to `minimumValue` via `decrementValue()`.
2222
@objc optional func KWStepperMinValueClamped()
23+
24+
/// Called when a long press gesture ends.
25+
@objc optional func KWStepperDidEndLongPress()
2326
}
2427

2528
/// A stepper control with flexible UI and tailored UX.
@@ -130,6 +133,9 @@ public class KWStepper: UIControl {
130133
/// Executed when `value` is clamped to `minimumValue` via `decrementValue()`.
131134
public var minValueClampedCallback: KWStepperCallback?
132135

136+
/// Executed when a long press gesture ends.
137+
public var longPressEndedCallback: KWStepperCallback?
138+
133139
// MARK: - Private Variables
134140

135141
fileprivate var longPressTimer: Timer?
@@ -251,6 +257,9 @@ extension KWStepper {
251257

252258
timer.invalidate()
253259
longPressTimer = nil
260+
261+
delegate?.KWStepperDidEndLongPress?()
262+
longPressEndedCallback?(self)
254263
}
255264
}
256265

0 commit comments

Comments
 (0)