forked from shadowfacts/Tusker
parent
f1facea929
commit
edd1e55cbb
|
@ -0,0 +1,7 @@
|
||||||
|
# Haptic Feedback
|
||||||
|
|
||||||
|
## Selection changed
|
||||||
|
`UISelectionFeedbackGenerator`
|
||||||
|
|
||||||
|
## Actions
|
||||||
|
On success, `UIImpactFeedbackGenerator` with the `.light` style. On error, `UINotificationFeedbackGenerator` with the `.error` type.
|
|
@ -62,7 +62,7 @@ public class DuckableContainerViewController: UIViewController, DuckableViewCont
|
||||||
guard case .idle = state else {
|
guard case .idle = state else {
|
||||||
if animated,
|
if animated,
|
||||||
case .ducked(_, placeholder: let placeholder) = state {
|
case .ducked(_, placeholder: let placeholder) = state {
|
||||||
UIImpactFeedbackGenerator(style: .soft).impactOccurred()
|
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
||||||
let origConstant = placeholder.topConstraint.constant
|
let origConstant = placeholder.topConstraint.constant
|
||||||
UIView.animateKeyframes(withDuration: 0.4, delay: 0) {
|
UIView.animateKeyframes(withDuration: 0.4, delay: 0) {
|
||||||
UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 0.5) {
|
UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 0.5) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ class FastAccountSwitcherViewController: UIViewController {
|
||||||
|
|
||||||
private(set) var accountViews: [FastSwitchingAccountView] = []
|
private(set) var accountViews: [FastSwitchingAccountView] = []
|
||||||
private var lastSelectedAccountViewIndex: Int?
|
private var lastSelectedAccountViewIndex: Int?
|
||||||
private var selectionChangedFeedbackGenerator: UIImpactFeedbackGenerator?
|
private var selectionChangedFeedbackGenerator: UISelectionFeedbackGenerator?
|
||||||
private var touchBeganFeedbackWorkItem: DispatchWorkItem?
|
private var touchBeganFeedbackWorkItem: DispatchWorkItem?
|
||||||
|
|
||||||
var itemOrientation: ItemOrientation = .iconsTrailing
|
var itemOrientation: ItemOrientation = .iconsTrailing
|
||||||
|
@ -148,7 +148,7 @@ class FastAccountSwitcherViewController: UIViewController {
|
||||||
private func switchAccount(newIndex: Int, hapticFeedback: Bool = true) {
|
private func switchAccount(newIndex: Int, hapticFeedback: Bool = true) {
|
||||||
if newIndex == 0 { // add account placeholder
|
if newIndex == 0 { // add account placeholder
|
||||||
if hapticFeedback {
|
if hapticFeedback {
|
||||||
selectionChangedFeedbackGenerator?.impactOccurred()
|
selectionChangedFeedbackGenerator?.selectionChanged()
|
||||||
}
|
}
|
||||||
selectionChangedFeedbackGenerator = nil
|
selectionChangedFeedbackGenerator = nil
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ class FastAccountSwitcherViewController: UIViewController {
|
||||||
|
|
||||||
if account.id != LocalData.shared.mostRecentAccountID {
|
if account.id != LocalData.shared.mostRecentAccountID {
|
||||||
if hapticFeedback {
|
if hapticFeedback {
|
||||||
selectionChangedFeedbackGenerator?.impactOccurred()
|
selectionChangedFeedbackGenerator?.selectionChanged()
|
||||||
}
|
}
|
||||||
selectionChangedFeedbackGenerator = nil
|
selectionChangedFeedbackGenerator = nil
|
||||||
|
|
||||||
|
@ -178,8 +178,8 @@ class FastAccountSwitcherViewController: UIViewController {
|
||||||
@objc private func handleLongPress(_ recognizer: UIGestureRecognizer) {
|
@objc private func handleLongPress(_ recognizer: UIGestureRecognizer) {
|
||||||
switch recognizer.state {
|
switch recognizer.state {
|
||||||
case .began:
|
case .began:
|
||||||
selectionChangedFeedbackGenerator = UIImpactFeedbackGenerator(style: .medium)
|
UIImpactFeedbackGenerator(style: .heavy).impactOccurred()
|
||||||
selectionChangedFeedbackGenerator?.impactOccurred()
|
selectionChangedFeedbackGenerator = UISelectionFeedbackGenerator()
|
||||||
selectionChangedFeedbackGenerator?.prepare()
|
selectionChangedFeedbackGenerator?.prepare()
|
||||||
|
|
||||||
show()
|
show()
|
||||||
|
@ -231,7 +231,7 @@ class FastAccountSwitcherViewController: UIViewController {
|
||||||
lastSelectedAccountViewIndex = selectedAccountViewIndex
|
lastSelectedAccountViewIndex = selectedAccountViewIndex
|
||||||
|
|
||||||
if hapticFeedback {
|
if hapticFeedback {
|
||||||
selectionChangedFeedbackGenerator?.impactOccurred(intensity: 0.5)
|
selectionChangedFeedbackGenerator?.selectionChanged()
|
||||||
selectionChangedFeedbackGenerator?.prepare()
|
selectionChangedFeedbackGenerator?.prepare()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ class FastAccountSwitcherViewController: UIViewController {
|
||||||
// if the user is merely tapping, not initiating a pan, we don't want to trigger a double-impact
|
// if the user is merely tapping, not initiating a pan, we don't want to trigger a double-impact
|
||||||
// if the tap ends very quickly, this will be cancelled
|
// if the tap ends very quickly, this will be cancelled
|
||||||
touchBeganFeedbackWorkItem = DispatchWorkItem {
|
touchBeganFeedbackWorkItem = DispatchWorkItem {
|
||||||
self.selectionChangedFeedbackGenerator?.impactOccurred(intensity: 0.5)
|
self.selectionChangedFeedbackGenerator?.selectionChanged()
|
||||||
self.selectionChangedFeedbackGenerator?.prepare()
|
self.selectionChangedFeedbackGenerator?.prepare()
|
||||||
self.touchBeganFeedbackWorkItem = nil
|
self.touchBeganFeedbackWorkItem = nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ class FollowRequestNotificationTableViewCell: UITableViewCell {
|
||||||
do {
|
do {
|
||||||
_ = try await mastodonController.run(request)
|
_ = try await mastodonController.run(request)
|
||||||
|
|
||||||
UINotificationFeedbackGenerator().notificationOccurred(.success)
|
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
||||||
self.actionButtonsStackView.isHidden = true
|
self.actionButtonsStackView.isHidden = true
|
||||||
self.addLabel(NSLocalizedString("Rejected", comment: "rejected follow request label"))
|
self.addLabel(NSLocalizedString("Rejected", comment: "rejected follow request label"))
|
||||||
} catch let error as Client.Error {
|
} catch let error as Client.Error {
|
||||||
|
@ -172,7 +172,7 @@ class FollowRequestNotificationTableViewCell: UITableViewCell {
|
||||||
do {
|
do {
|
||||||
_ = try await mastodonController.run(request)
|
_ = try await mastodonController.run(request)
|
||||||
|
|
||||||
UINotificationFeedbackGenerator().notificationOccurred(.success)
|
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
||||||
self.actionButtonsStackView.isHidden = true
|
self.actionButtonsStackView.isHidden = true
|
||||||
self.addLabel(NSLocalizedString("Accepted", comment: "accepted follow request label"))
|
self.addLabel(NSLocalizedString("Accepted", comment: "accepted follow request label"))
|
||||||
} catch let error as Client.Error {
|
} catch let error as Client.Error {
|
||||||
|
|
|
@ -26,7 +26,7 @@ class PollOptionsView: UIControl {
|
||||||
private let animationDuration: TimeInterval = 0.1
|
private let animationDuration: TimeInterval = 0.1
|
||||||
private let scaledTransform = CGAffineTransform(scaleX: 0.95, y: 0.95)
|
private let scaledTransform = CGAffineTransform(scaleX: 0.95, y: 0.95)
|
||||||
|
|
||||||
private let generator = UIImpactFeedbackGenerator(style: .soft)
|
private let generator = UISelectionFeedbackGenerator()
|
||||||
|
|
||||||
override var isEnabled: Bool {
|
override var isEnabled: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
|
@ -110,7 +110,7 @@ class PollOptionsView: UIControl {
|
||||||
}
|
}
|
||||||
animator.startAnimation()
|
animator.startAnimation()
|
||||||
|
|
||||||
generator.impactOccurred()
|
generator.selectionChanged()
|
||||||
generator.prepare()
|
generator.prepare()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -139,7 +139,7 @@ class PollOptionsView: UIControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
if newIndex != nil {
|
if newIndex != nil {
|
||||||
generator.impactOccurred()
|
generator.selectionChanged()
|
||||||
generator.prepare()
|
generator.prepare()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ class StatusPollView: UIView {
|
||||||
voteButton.isEnabled = false
|
voteButton.isEnabled = false
|
||||||
voteButton.disabledTitle = "Voted"
|
voteButton.disabledTitle = "Voted"
|
||||||
|
|
||||||
UIImpactFeedbackGenerator(style: .medium).impactOccurred()
|
UIImpactFeedbackGenerator(style: .light).impactOccurred()
|
||||||
|
|
||||||
let request = Poll.vote(poll!.id, choices: optionsView.checkedOptionIndices)
|
let request = Poll.vote(poll!.id, choices: optionsView.checkedOptionIndices)
|
||||||
mastodonController.run(request) { (response) in
|
mastodonController.run(request) { (response) in
|
||||||
|
|
Loading…
Reference in New Issue