diff --git a/submodules/SlotMachineAnimationNode/Sources/SlotMachineAnimationNode.swift b/submodules/SlotMachineAnimationNode/Sources/SlotMachineAnimationNode.swift index 48a7bdc427..701f19c9eb 100644 --- a/submodules/SlotMachineAnimationNode/Sources/SlotMachineAnimationNode.swift +++ b/submodules/SlotMachineAnimationNode/Sources/SlotMachineAnimationNode.swift @@ -154,9 +154,12 @@ public final class SlotMachineAnimationNode: ASDisplayNode { private var diceState: ManagedSlotMachineAnimationState? = nil private let disposables = DisposableSet() - private let animationSize = CGSize(width: 184.0, height: 184.0) + private let animationSize: CGSize - public override init() { + public var success: ((Bool) -> Void)? + + public init(size: CGSize = CGSize(width: 184.0, height: 184.0)) { + self.animationSize = size self.backNode = ManagedAnimationNode(size: self.animationSize) self.leftReelNode = ManagedAnimationNode(size: self.animationSize) self.centerReelNode = ManagedAnimationNode(size: self.animationSize) @@ -197,8 +200,9 @@ public final class SlotMachineAnimationNode: ASDisplayNode { case let .value(value, _): let slotValue = SlotMachineValue(rawValue: value) if slotValue.isThreeOfSame { - Queue.mainQueue().after(1.5) { + Queue.mainQueue().after(1.2) { self.backNode.trackTo(item: ManagedAnimationItem(source: .local("Slot_Back_Win"), loop: false)) + self.success?(!slotValue.is777) } } else { self.backNode.trackTo(item: ManagedAnimationItem(source: .local("Slot_Back_Win"), frames: .still(.start), loop: false)) diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 5dc393360d..85053269ca 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -2159,7 +2159,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G self?.displayPsa(type: type, sourceNode: sourceNode, isAutomatic: false) }, displayDiceTooltip: { [weak self] dice in self?.displayDiceTooltip(dice: dice) - }, animateDiceSuccess: { [weak self] in + }, animateDiceSuccess: { [weak self] onlyHaptic in guard let strongSelf = self else { return } @@ -2167,7 +2167,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G strongSelf.selectPollOptionFeedback = HapticFeedback() } strongSelf.selectPollOptionFeedback?.success() - strongSelf.chatDisplayNode.animateQuizCorrectOptionSelected() + if !onlyHaptic { + strongSelf.chatDisplayNode.animateQuizCorrectOptionSelected() + } }, greetingStickerNode: { [weak self] in return self?.chatDisplayNode.greetingStickerNode }, openPeerContextMenu: { [weak self] peer, node, rect, gesture in diff --git a/submodules/TelegramUI/Sources/ChatControllerInteraction.swift b/submodules/TelegramUI/Sources/ChatControllerInteraction.swift index 0d8a24af56..d6b1b7ea43 100644 --- a/submodules/TelegramUI/Sources/ChatControllerInteraction.swift +++ b/submodules/TelegramUI/Sources/ChatControllerInteraction.swift @@ -110,7 +110,7 @@ public final class ChatControllerInteraction { let displayPollSolution: (TelegramMediaPollResults.Solution, ASDisplayNode) -> Void let displayPsa: (String, ASDisplayNode) -> Void let displayDiceTooltip: (TelegramMediaDice) -> Void - let animateDiceSuccess: () -> Void + let animateDiceSuccess: (Bool) -> Void let greetingStickerNode: () -> (ASDisplayNode, ASDisplayNode, ASDisplayNode, () -> Void)? let openPeerContextMenu: (Peer, ASDisplayNode, CGRect, ContextGesture?) -> Void let openMessageReplies: (MessageId, Bool, Bool) -> Void @@ -197,7 +197,7 @@ public final class ChatControllerInteraction { displayPollSolution: @escaping (TelegramMediaPollResults.Solution, ASDisplayNode) -> Void, displayPsa: @escaping (String, ASDisplayNode) -> Void, displayDiceTooltip: @escaping (TelegramMediaDice) -> Void, - animateDiceSuccess: @escaping () -> Void, + animateDiceSuccess: @escaping (Bool) -> Void, greetingStickerNode: @escaping () -> (ASDisplayNode, ASDisplayNode, ASDisplayNode, () -> Void)?, openPeerContextMenu: @escaping (Peer, ASDisplayNode, CGRect, ContextGesture?) -> Void, openMessageReplies: @escaping (MessageId, Bool, Bool) -> Void, @@ -321,7 +321,7 @@ public final class ChatControllerInteraction { }, displayPollSolution: { _, _ in }, displayPsa: { _, _ in }, displayDiceTooltip: { _ in - }, animateDiceSuccess: { + }, animateDiceSuccess: { _ in }, greetingStickerNode: { return nil }, openPeerContextMenu: { _, _, _, _ in diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index cd7ee8e3c3..1b2c7ae280 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -584,15 +584,14 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { self.addSubnode(self.backgroundNode) self.addSubnode(self.historyNodeContainer) + self.addSubnode(self.navigateButtons) self.addSubnode(self.titleAccessoryPanelContainer) self.addSubnode(self.inputPanelBackgroundNode) self.addSubnode(self.inputPanelBackgroundSeparatorNode) self.addSubnode(self.inputContextPanelContainer) - - self.addSubnode(self.navigateButtons) - + self.addSubnode(self.navigationBarBackroundNode) self.addSubnode(self.navigationBarSeparatorNode) if !self.context.sharedContext.immediateExperimentalUISettings.playerEmbedding { diff --git a/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift index 7572f1bb00..d7a87fd8da 100644 --- a/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift @@ -334,13 +334,20 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView { if let telegramDice = self.telegramDice { if telegramDice.emoji == "🎰" { let animationNode = SlotMachineAnimationNode() + if !item.message.effectivelyIncoming(item.context.account.peerId) { + animationNode.success = { [weak self] onlyHaptic in + if let strongSelf = self, let item = strongSelf.item { + item.controllerInteraction.animateDiceSuccess(onlyHaptic) + } + } + } self.animationNode = animationNode } else { let animationNode = ManagedDiceAnimationNode(context: item.context, emoji: telegramDice.emoji.strippedEmoji) if !item.message.effectivelyIncoming(item.context.account.peerId) { animationNode.success = { [weak self] in if let strongSelf = self, let item = strongSelf.item { - item.controllerInteraction.animateDiceSuccess() + item.controllerInteraction.animateDiceSuccess(false) } } } diff --git a/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift b/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift index 9e49f7c1e1..eae9201b4a 100644 --- a/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift @@ -448,7 +448,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { }, displayPollSolution: { _, _ in }, displayPsa: { _, _ in }, displayDiceTooltip: { _ in - }, animateDiceSuccess: { + }, animateDiceSuccess: { _ in }, greetingStickerNode: { return nil }, openPeerContextMenu: { _, _, _, _ in diff --git a/submodules/TelegramUI/Sources/DrawingStickersScreen.swift b/submodules/TelegramUI/Sources/DrawingStickersScreen.swift index e5d957873e..110bdf9431 100644 --- a/submodules/TelegramUI/Sources/DrawingStickersScreen.swift +++ b/submodules/TelegramUI/Sources/DrawingStickersScreen.swift @@ -141,7 +141,7 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode { }, displayPollSolution: { _, _ in }, displayPsa: { _, _ in }, displayDiceTooltip: { _ in - }, animateDiceSuccess: { + }, animateDiceSuccess: { _ in }, greetingStickerNode: { return nil }, openPeerContextMenu: { _, _, _, _ in diff --git a/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift b/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift index f7fb462cf9..4bd124d7bf 100644 --- a/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift +++ b/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift @@ -131,7 +131,7 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, UIGestu }, displayPollSolution: { _, _ in }, displayPsa: { _, _ in }, displayDiceTooltip: { _ in - }, animateDiceSuccess: { + }, animateDiceSuccess: { _ in }, greetingStickerNode: { return nil }, openPeerContextMenu: { _, _, _, _ in diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index ae68b1b7a3..00376d100c 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -1959,7 +1959,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD }, displayPollSolution: { _, _ in }, displayPsa: { _, _ in }, displayDiceTooltip: { _ in - }, animateDiceSuccess: { + }, animateDiceSuccess: { _ in }, greetingStickerNode: { return nil }, openPeerContextMenu: { _, _, _, _ in diff --git a/submodules/TelegramUI/Sources/SharedAccountContext.swift b/submodules/TelegramUI/Sources/SharedAccountContext.swift index c96414f042..e8be1acdc0 100644 --- a/submodules/TelegramUI/Sources/SharedAccountContext.swift +++ b/submodules/TelegramUI/Sources/SharedAccountContext.swift @@ -1231,7 +1231,7 @@ public final class SharedAccountContextImpl: SharedAccountContext { }, displayPollSolution: { _, _ in }, displayPsa: { _, _ in }, displayDiceTooltip: { _ in - }, animateDiceSuccess: { + }, animateDiceSuccess: { _ in }, greetingStickerNode: { return nil }, openPeerContextMenu: { _, _, _, _ in diff --git a/submodules/UndoUI/Sources/UndoOverlayControllerNode.swift b/submodules/UndoUI/Sources/UndoOverlayControllerNode.swift index c35acf1101..1059abe706 100644 --- a/submodules/UndoUI/Sources/UndoOverlayControllerNode.swift +++ b/submodules/UndoUI/Sources/UndoOverlayControllerNode.swift @@ -359,11 +359,13 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode { } if dice.emoji == "🎰" { - let slotMachineNode = SlotMachineAnimationNode() + let slotMachineNode = SlotMachineAnimationNode(size: CGSize(width: 42.0, height: 42.0)) self.slotMachineNode = slotMachineNode -// slotMachineNode.setState(.rolling) -// slotMachineNode.setState(.value(value, true)) + slotMachineNode.setState(.rolling) + if let value = dice.value { + slotMachineNode.setState(.value(value, true)) + } } else { let animatedStickerNode = AnimatedStickerNode() self.animatedStickerNode = animatedStickerNode @@ -615,6 +617,8 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode { if let animatedStickerNode = self.animatedStickerNode { animatedStickerNode.updateLayout(size: iconFrame.size) transition.updateFrame(node: animatedStickerNode, frame: iconFrame) + } else if let slotMachineNode = self.slotMachineNode { + transition.updateFrame(node: slotMachineNode, frame: iconFrame) } } else if let animatedStickerNode = self.animatedStickerNode { let iconSize = CGSize(width: 32.0, height: 32.0)