rename haptic classes, no change in functionality
This commit is contained in:
parent
7d72244315
commit
6ccd73837c
|
@ -1,24 +1,37 @@
|
|||
//
|
||||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
protocol HapticAdapter {
|
||||
protocol SelectionHapticFeedbackAdapter {
|
||||
func selectionChanged()
|
||||
}
|
||||
|
||||
class LegacyHapticAdapter: NSObject, HapticAdapter {
|
||||
class SelectionHapticFeedback: SelectionHapticFeedbackAdapter {
|
||||
let adapter: SelectionHapticFeedbackAdapter
|
||||
|
||||
// MARK: HapticAdapter
|
||||
init() {
|
||||
if #available(iOS 10, *) {
|
||||
adapter = ModernSelectionHapticFeedbackAdapter()
|
||||
} else {
|
||||
adapter = LegacySelectionHapticFeedbackAdapter()
|
||||
}
|
||||
}
|
||||
|
||||
func selectionChanged() {
|
||||
adapter.selectionChanged()
|
||||
}
|
||||
}
|
||||
|
||||
class LegacySelectionHapticFeedbackAdapter: NSObject, SelectionHapticFeedbackAdapter {
|
||||
func selectionChanged() {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
@available(iOS 10, *)
|
||||
class FeedbackGeneratorHapticAdapter: NSObject, HapticAdapter {
|
||||
class ModernSelectionHapticFeedbackAdapter: NSObject, SelectionHapticFeedbackAdapter {
|
||||
let selectionFeedbackGenerator: UISelectionFeedbackGenerator
|
||||
|
||||
override init() {
|
||||
|
@ -33,19 +46,3 @@ class FeedbackGeneratorHapticAdapter: NSObject, HapticAdapter {
|
|||
selectionFeedbackGenerator.prepare()
|
||||
}
|
||||
}
|
||||
|
||||
class HapticFeedback: HapticAdapter {
|
||||
let adapter: HapticAdapter
|
||||
|
||||
init() {
|
||||
if #available(iOS 10, *) {
|
||||
adapter = FeedbackGeneratorHapticAdapter()
|
||||
} else {
|
||||
adapter = LegacyHapticAdapter()
|
||||
}
|
||||
}
|
||||
|
||||
func selectionChanged() {
|
||||
adapter.selectionChanged()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -245,7 +245,7 @@ class MenuActionSheetView: UIView, MenuActionViewDelegate {
|
|||
private let actionStackView: UIStackView
|
||||
private var actions: [MenuAction]
|
||||
private var actionViews: [MenuActionView]
|
||||
private var hapticFeedback: HapticFeedback
|
||||
private var hapticFeedback: SelectionHapticFeedback
|
||||
private var hasEverHighlightedAction = false
|
||||
|
||||
weak var delegate: MenuActionSheetDelegate?
|
||||
|
@ -268,7 +268,7 @@ class MenuActionSheetView: UIView, MenuActionViewDelegate {
|
|||
|
||||
actions = []
|
||||
actionViews = []
|
||||
hapticFeedback = HapticFeedback()
|
||||
hapticFeedback = SelectionHapticFeedback()
|
||||
|
||||
super.init(frame: frame)
|
||||
|
||||
|
|
Loading…
Reference in New Issue