The syntax convention for the feedback generator was re-implemented to follow TCA and secant wallet principles.
This commit is contained in:
Lukas Korba 2022-02-23 18:39:39 +01:00
parent c8e54550fc
commit b7fccb3c28
2 changed files with 11 additions and 15 deletions

View File

@ -7,20 +7,16 @@
import UIKit import UIKit
protocol FeedbackGenerator { struct FeedbackGenerator {
func generateFeedback() let generateFeedback: () -> Void
} }
/// use in case of testing or when real haptic feedback is not appropriate extension FeedbackGenerator {
class SilentFeedbackGenerator: FeedbackGenerator { static let haptic = FeedbackGenerator(
func generateFeedback() { } generateFeedback: { UINotificationFeedbackGenerator().notificationOccurred(.error) }
} )
/// haptic feedback for the failures (when we want to amplify importance of the failure)
class ImpactFeedbackGenerator: FeedbackGenerator {
let generator = UINotificationFeedbackGenerator()
func generateFeedback() { static let silent = FeedbackGenerator(
generator.notificationOccurred(.error) generateFeedback: { }
} )
} }

View File

@ -53,14 +53,14 @@ extension BackupPhraseEnvironment {
mainQueue: DispatchQueue.main.eraseToAnyScheduler(), mainQueue: DispatchQueue.main.eraseToAnyScheduler(),
newPhrase: { Effect(value: .init(words: RecoveryPhrase.placeholder.words)) }, newPhrase: { Effect(value: .init(words: RecoveryPhrase.placeholder.words)) },
pasteboard: .test, pasteboard: .test,
feedbackGenerator: SilentFeedbackGenerator() feedbackGenerator: .silent
) )
static let live = Self( static let live = Self(
mainQueue: DispatchQueue.main.eraseToAnyScheduler(), mainQueue: DispatchQueue.main.eraseToAnyScheduler(),
newPhrase: { Effect(value: .init(words: RecoveryPhrase.placeholder.words)) }, newPhrase: { Effect(value: .init(words: RecoveryPhrase.placeholder.words)) },
pasteboard: .live, pasteboard: .live,
feedbackGenerator: ImpactFeedbackGenerator() feedbackGenerator: .haptic
) )
} }