mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Play haptic feedback when receiving emoji interaction
This commit is contained in:
parent
34590f0836
commit
e3206fc855
@ -7435,15 +7435,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
strongSelf.chatDisplayNode.historyNode.forEachVisibleItemNode({ itemNode in
|
||||
if !found, let itemNode = itemNode as? ChatMessageAnimatedStickerItemNode, let item = itemNode.item {
|
||||
if item.message.id == messageId {
|
||||
for animation in interaction.animations {
|
||||
if animation.timeOffset > 0.0 {
|
||||
Queue.mainQueue().after(Double(animation.timeOffset)) {
|
||||
itemNode.playAdditionalAnimation(index: animation.index)
|
||||
}
|
||||
} else {
|
||||
itemNode.playAdditionalAnimation(index: animation.index)
|
||||
}
|
||||
}
|
||||
itemNode.playEmojiInteraction(interaction)
|
||||
found = true
|
||||
}
|
||||
}
|
||||
|
@ -204,6 +204,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
||||
|
||||
private var forceStopAnimations = false
|
||||
|
||||
private var hapticFeedback: HapticFeedback?
|
||||
private var haptic: EmojiHaptic?
|
||||
private var mediaPlayer: MediaPlayer?
|
||||
private let mediaStatusDisposable = MetaDisposable()
|
||||
@ -1352,6 +1353,38 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
||||
item.context.account.updateLocalInputActivity(peerId: PeerActivitySpace(peerId: item.message.id.peerId, category: .global), activity: .interactingWithEmoji(emoticon: textEmoji, messageId: item.message.id, interaction: EmojiInteraction(animations: animations)), isPresent: true)
|
||||
}
|
||||
|
||||
func playEmojiInteraction(_ interaction: EmojiInteraction) {
|
||||
var hapticFeedback: HapticFeedback
|
||||
if let current = self.hapticFeedback {
|
||||
hapticFeedback = current
|
||||
} else {
|
||||
hapticFeedback = HapticFeedback()
|
||||
self.hapticFeedback = hapticFeedback
|
||||
}
|
||||
|
||||
var playHaptic = true
|
||||
if let existingHaptic = self.haptic, existingHaptic.active {
|
||||
playHaptic = false
|
||||
}
|
||||
hapticFeedback.prepareTap()
|
||||
|
||||
for animation in interaction.animations {
|
||||
if animation.timeOffset > 0.0 {
|
||||
Queue.mainQueue().after(Double(animation.timeOffset)) {
|
||||
self.playAdditionalAnimation(index: animation.index)
|
||||
if playHaptic {
|
||||
hapticFeedback.tap()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.playAdditionalAnimation(index: animation.index)
|
||||
if playHaptic {
|
||||
hapticFeedback.tap()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func playAdditionalAnimation(index: Int) {
|
||||
guard let item = self.item else {
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user