mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Reaction effect in own stories
This commit is contained in:
parent
8130d9e937
commit
d5c1f37878
@ -3308,97 +3308,100 @@ final class StoryItemSetContainerSendMessage {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if component.slice.peer.id != component.context.account.peerId {
|
let animateWithReactionItem: (ReactionItem) -> Void = { [weak self, weak view] reactionItem in
|
||||||
let animateWithReactionItem: (ReactionItem) -> Void = { [weak self, weak view] reactionItem in
|
guard let self, let view else {
|
||||||
guard let self, let view else {
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
self.performWithPossibleStealthModeConfirmation(view: view, action: { [weak view] in
|
||||||
|
guard let view, let component = view.component else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if component.slice.peer.id != component.context.account.peerId {
|
||||||
|
} else if case .channel = component.slice.peer {
|
||||||
|
} else {
|
||||||
|
let _ = component.context.engine.messages.setStoryReaction(peerId: component.slice.peer.id, id: component.slice.item.storyItem.id, reaction: reaction).start()
|
||||||
|
}
|
||||||
|
|
||||||
self.performWithPossibleStealthModeConfirmation(view: view, action: { [weak view] in
|
let targetFrame = reactionView.convert(reactionView.bounds, to: view)
|
||||||
guard let view, let component = view.component else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if case .channel = component.slice.peer {
|
|
||||||
} else {
|
|
||||||
let _ = component.context.engine.messages.setStoryReaction(peerId: component.slice.peer.id, id: component.slice.item.storyItem.id, reaction: reaction).start()
|
|
||||||
}
|
|
||||||
|
|
||||||
let targetFrame = reactionView.convert(reactionView.bounds, to: view)
|
let targetView = UIView(frame: targetFrame)
|
||||||
|
targetView.isUserInteractionEnabled = false
|
||||||
|
view.addSubview(targetView)
|
||||||
|
|
||||||
let targetView = UIView(frame: targetFrame)
|
let standaloneReactionAnimation = StandaloneReactionAnimation(genericReactionEffect: nil, useDirectRendering: false)
|
||||||
targetView.isUserInteractionEnabled = false
|
view.componentContainerView.addSubview(standaloneReactionAnimation.view)
|
||||||
view.addSubview(targetView)
|
|
||||||
|
|
||||||
let standaloneReactionAnimation = StandaloneReactionAnimation(genericReactionEffect: nil, useDirectRendering: false)
|
if let standaloneReactionAnimation = view.standaloneReactionAnimation {
|
||||||
view.componentContainerView.addSubview(standaloneReactionAnimation.view)
|
view.standaloneReactionAnimation = nil
|
||||||
|
|
||||||
if let standaloneReactionAnimation = view.standaloneReactionAnimation {
|
let standaloneReactionAnimationView = standaloneReactionAnimation.view
|
||||||
view.standaloneReactionAnimation = nil
|
standaloneReactionAnimation.view.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.1, removeOnCompletion: false, completion: { [weak standaloneReactionAnimationView] _ in
|
||||||
standaloneReactionAnimation.view.removeFromSuperview()
|
standaloneReactionAnimationView?.removeFromSuperview()
|
||||||
}
|
})
|
||||||
view.standaloneReactionAnimation = standaloneReactionAnimation
|
}
|
||||||
|
view.standaloneReactionAnimation = standaloneReactionAnimation
|
||||||
|
|
||||||
standaloneReactionAnimation.frame = view.bounds
|
standaloneReactionAnimation.frame = view.bounds
|
||||||
standaloneReactionAnimation.animateReactionSelection(
|
standaloneReactionAnimation.animateReactionSelection(
|
||||||
context: component.context,
|
context: component.context,
|
||||||
theme: component.theme,
|
theme: component.theme,
|
||||||
animationCache: component.context.animationCache,
|
animationCache: component.context.animationCache,
|
||||||
reaction: reactionItem,
|
reaction: reactionItem,
|
||||||
avatarPeers: [],
|
avatarPeers: [],
|
||||||
playHaptic: true,
|
playHaptic: true,
|
||||||
isLarge: false,
|
isLarge: false,
|
||||||
hideCenterAnimation: true,
|
hideCenterAnimation: true,
|
||||||
targetView: targetView,
|
targetView: targetView,
|
||||||
addStandaloneReactionAnimation: { [weak view] standaloneReactionAnimation in
|
addStandaloneReactionAnimation: { [weak view] standaloneReactionAnimation in
|
||||||
guard let view else {
|
guard let view else {
|
||||||
return
|
return
|
||||||
}
|
|
||||||
|
|
||||||
if let standaloneReactionAnimation = view.standaloneReactionAnimation {
|
|
||||||
view.standaloneReactionAnimation = nil
|
|
||||||
standaloneReactionAnimation.view.removeFromSuperview()
|
|
||||||
}
|
|
||||||
view.standaloneReactionAnimation = standaloneReactionAnimation
|
|
||||||
|
|
||||||
standaloneReactionAnimation.frame = view.bounds
|
|
||||||
view.componentContainerView.addSubview(standaloneReactionAnimation.view)
|
|
||||||
},
|
|
||||||
completion: { [weak targetView, weak standaloneReactionAnimation] in
|
|
||||||
targetView?.removeFromSuperview()
|
|
||||||
standaloneReactionAnimation?.view.removeFromSuperview()
|
|
||||||
}
|
}
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
switch reaction {
|
if let standaloneReactionAnimation = view.standaloneReactionAnimation {
|
||||||
case .builtin:
|
view.standaloneReactionAnimation = nil
|
||||||
if let availableReactions = component.availableReactions {
|
standaloneReactionAnimation.view.removeFromSuperview()
|
||||||
for reactionItem in availableReactions.reactionItems {
|
|
||||||
if reactionItem.reaction.rawValue == reaction {
|
|
||||||
animateWithReactionItem(reactionItem)
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
view.standaloneReactionAnimation = standaloneReactionAnimation
|
||||||
|
|
||||||
|
standaloneReactionAnimation.frame = view.bounds
|
||||||
|
view.componentContainerView.addSubview(standaloneReactionAnimation.view)
|
||||||
|
},
|
||||||
|
completion: { [weak targetView, weak standaloneReactionAnimation] in
|
||||||
|
targetView?.removeFromSuperview()
|
||||||
|
standaloneReactionAnimation?.view.removeFromSuperview()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
switch reaction {
|
||||||
|
case .builtin:
|
||||||
|
if let availableReactions = component.availableReactions {
|
||||||
|
for reactionItem in availableReactions.reactionItems {
|
||||||
|
if reactionItem.reaction.rawValue == reaction {
|
||||||
|
animateWithReactionItem(reactionItem)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case let .custom(fileId):
|
|
||||||
let _ = (component.context.engine.stickers.resolveInlineStickers(fileIds: [fileId])
|
|
||||||
|> deliverOnMainQueue).start(next: { files in
|
|
||||||
if let itemFile = files[fileId] {
|
|
||||||
let reactionItem = ReactionItem(
|
|
||||||
reaction: ReactionItem.Reaction(rawValue: .custom(itemFile.fileId.id)),
|
|
||||||
appearAnimation: itemFile,
|
|
||||||
stillAnimation: itemFile,
|
|
||||||
listAnimation: itemFile,
|
|
||||||
largeListAnimation: itemFile,
|
|
||||||
applicationAnimation: nil,
|
|
||||||
largeApplicationAnimation: nil,
|
|
||||||
isCustom: true
|
|
||||||
)
|
|
||||||
animateWithReactionItem(reactionItem)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
case let .custom(fileId):
|
||||||
|
let _ = (component.context.engine.stickers.resolveInlineStickers(fileIds: [fileId])
|
||||||
|
|> deliverOnMainQueue).start(next: { files in
|
||||||
|
if let itemFile = files[fileId] {
|
||||||
|
let reactionItem = ReactionItem(
|
||||||
|
reaction: ReactionItem.Reaction(rawValue: .custom(itemFile.fileId.id)),
|
||||||
|
appearAnimation: itemFile,
|
||||||
|
stillAnimation: itemFile,
|
||||||
|
listAnimation: itemFile,
|
||||||
|
largeListAnimation: itemFile,
|
||||||
|
applicationAnimation: nil,
|
||||||
|
largeApplicationAnimation: nil,
|
||||||
|
isCustom: true
|
||||||
|
)
|
||||||
|
animateWithReactionItem(reactionItem)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user