rename haptic classes, no change in functionality

This commit is contained in:
Michael Kirk 2019-03-19 10:27:31 -07:00
parent 7d72244315
commit 6ccd73837c
2 changed files with 20 additions and 23 deletions

View File

@ -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()
}
}

View File

@ -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)