|
|
|
@ -24,7 +24,7 @@ class FastAccountSwitcherViewController: UIViewController {
|
|
|
|
|
|
|
|
|
|
private(set) var accountViews: [FastSwitchingAccountView] = []
|
|
|
|
|
private var lastSelectedAccountViewIndex: Int?
|
|
|
|
|
private var selectionChangedFeedbackGenerator: UIImpactFeedbackGenerator?
|
|
|
|
|
private var selectionChangedFeedbackGenerator: UISelectionFeedbackGenerator?
|
|
|
|
|
private var touchBeganFeedbackWorkItem: DispatchWorkItem?
|
|
|
|
|
|
|
|
|
|
var itemOrientation: ItemOrientation = .iconsTrailing
|
|
|
|
@ -148,7 +148,7 @@ class FastAccountSwitcherViewController: UIViewController {
|
|
|
|
|
private func switchAccount(newIndex: Int, hapticFeedback: Bool = true) {
|
|
|
|
|
if newIndex == 0 { // add account placeholder
|
|
|
|
|
if hapticFeedback {
|
|
|
|
|
selectionChangedFeedbackGenerator?.impactOccurred()
|
|
|
|
|
selectionChangedFeedbackGenerator?.selectionChanged()
|
|
|
|
|
}
|
|
|
|
|
selectionChangedFeedbackGenerator = nil
|
|
|
|
|
|
|
|
|
@ -160,7 +160,7 @@ class FastAccountSwitcherViewController: UIViewController {
|
|
|
|
|
|
|
|
|
|
if account.id != LocalData.shared.mostRecentAccountID {
|
|
|
|
|
if hapticFeedback {
|
|
|
|
|
selectionChangedFeedbackGenerator?.impactOccurred()
|
|
|
|
|
selectionChangedFeedbackGenerator?.selectionChanged()
|
|
|
|
|
}
|
|
|
|
|
selectionChangedFeedbackGenerator = nil
|
|
|
|
|
|
|
|
|
@ -178,8 +178,8 @@ class FastAccountSwitcherViewController: UIViewController {
|
|
|
|
|
@objc private func handleLongPress(_ recognizer: UIGestureRecognizer) {
|
|
|
|
|
switch recognizer.state {
|
|
|
|
|
case .began:
|
|
|
|
|
selectionChangedFeedbackGenerator = UIImpactFeedbackGenerator(style: .medium)
|
|
|
|
|
selectionChangedFeedbackGenerator?.impactOccurred()
|
|
|
|
|
UIImpactFeedbackGenerator(style: .heavy).impactOccurred()
|
|
|
|
|
selectionChangedFeedbackGenerator = UISelectionFeedbackGenerator()
|
|
|
|
|
selectionChangedFeedbackGenerator?.prepare()
|
|
|
|
|
|
|
|
|
|
show()
|
|
|
|
@ -231,7 +231,7 @@ class FastAccountSwitcherViewController: UIViewController {
|
|
|
|
|
lastSelectedAccountViewIndex = selectedAccountViewIndex
|
|
|
|
|
|
|
|
|
|
if hapticFeedback {
|
|
|
|
|
selectionChangedFeedbackGenerator?.impactOccurred(intensity: 0.5)
|
|
|
|
|
selectionChangedFeedbackGenerator?.selectionChanged()
|
|
|
|
|
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 tap ends very quickly, this will be cancelled
|
|
|
|
|
touchBeganFeedbackWorkItem = DispatchWorkItem {
|
|
|
|
|
self.selectionChangedFeedbackGenerator?.impactOccurred(intensity: 0.5)
|
|
|
|
|
self.selectionChangedFeedbackGenerator?.selectionChanged()
|
|
|
|
|
self.selectionChangedFeedbackGenerator?.prepare()
|
|
|
|
|
self.touchBeganFeedbackWorkItem = nil
|
|
|
|
|
}
|
|
|
|
|