-
-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move all UI*FeedbackGenerators to FeedbackGenerator and disable them …
…for now (IOS-247) (#1267) * Move all UI*FeedbackGenerators to FeedbackGenerator and disable them for now (IOS-247) * Fix copyright header * Remove empty private constructor
- Loading branch information
Showing
16 changed files
with
81 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright © 2024 Mastodon gGmbH. All rights reserved. | ||
|
||
import UIKit | ||
|
||
public class FeedbackGenerator { | ||
|
||
private let lightImpactFeedbackGenerator = UIImpactFeedbackGenerator(style: .light) | ||
private let mediumImpactFeedbackGenerator = UIImpactFeedbackGenerator(style: .medium) | ||
private let notificationFeedbackGenerator = UINotificationFeedbackGenerator() | ||
private let selectionFeedbackGenerator = UISelectionFeedbackGenerator() | ||
|
||
public enum Impact { | ||
case light, medium | ||
} | ||
|
||
public enum Feedback { | ||
case impact(Impact) | ||
case notification(UINotificationFeedbackGenerator.FeedbackType) | ||
case selectionChanged | ||
} | ||
|
||
public static let shared = FeedbackGenerator() | ||
public var isEnabled = true | ||
|
||
public func generate(_ feedback: Feedback) { | ||
guard isEnabled else { return } | ||
DispatchQueue.main.async { [self] in | ||
switch feedback { | ||
case .impact(.light): | ||
lightImpactFeedbackGenerator.impactOccurred() | ||
case .impact(.medium): | ||
mediumImpactFeedbackGenerator.impactOccurred() | ||
case let .notification(type): | ||
notificationFeedbackGenerator.notificationOccurred(type) | ||
case .selectionChanged: | ||
selectionFeedbackGenerator.selectionChanged() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters