Add haptic feedback to poll voting
This commit is contained in:
parent
e18a09f4ac
commit
9f0c1eece8
|
@ -26,6 +26,8 @@ class PollOptionsView: UIControl {
|
|||
private let animationDuration: TimeInterval = 0.1
|
||||
private let scaledTransform = CGAffineTransform(scaleX: 0.95, y: 0.95)
|
||||
|
||||
private let generator = UIImpactFeedbackGenerator(style: .soft)
|
||||
|
||||
override var isEnabled: Bool {
|
||||
didSet {
|
||||
options.forEach { $0.checkbox.readOnly = !isEnabled }
|
||||
|
@ -106,6 +108,9 @@ class PollOptionsView: UIControl {
|
|||
}
|
||||
animator.startAnimation()
|
||||
|
||||
generator.impactOccurred()
|
||||
generator.prepare()
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -130,6 +135,11 @@ class PollOptionsView: UIControl {
|
|||
view.transform = index == newIndex ? self.scaledTransform : .identity
|
||||
}
|
||||
}
|
||||
|
||||
if newIndex != nil {
|
||||
generator.impactOccurred()
|
||||
generator.prepare()
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
|
|
|
@ -136,6 +136,8 @@ class StatusPollView: UIView {
|
|||
voteButton.isEnabled = false
|
||||
voteButton.setTitle("Voted", for: .disabled)
|
||||
|
||||
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
|
||||
|
||||
let request = Poll.vote(poll.id, choices: optionsView.checkedOptionIndices)
|
||||
mastodonController.run(request) { (response) in
|
||||
switch response {
|
||||
|
|
Loading…
Reference in New Issue