mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Display a toast after sticker list changes
This commit is contained in:
@@ -2,6 +2,9 @@ import Foundation
|
||||
import UIKit
|
||||
import Display
|
||||
import TelegramPresentationData
|
||||
import SyncCore
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
|
||||
public enum UndoOverlayContent {
|
||||
case removedChat(text: String)
|
||||
@@ -12,6 +15,13 @@ public enum UndoOverlayContent {
|
||||
case emoji(path: String, text: String)
|
||||
case swipeToReply(title: String, text: String)
|
||||
case actionSucceeded(title: String, text: String, cancel: String)
|
||||
case stickersModified(title: String, text: String, undo: Bool, info: StickerPackCollectionInfo, topItem: ItemCollectionItem?, account: Account)
|
||||
}
|
||||
|
||||
public enum UndoOverlayAction {
|
||||
case info
|
||||
case undo
|
||||
case commit
|
||||
}
|
||||
|
||||
public final class UndoOverlayController: ViewController {
|
||||
@@ -19,12 +29,12 @@ public final class UndoOverlayController: ViewController {
|
||||
public let content: UndoOverlayContent
|
||||
private let elevatedLayout: Bool
|
||||
private let animateInAsReplacement: Bool
|
||||
private var action: (Bool) -> Void
|
||||
private var action: (UndoOverlayAction) -> Bool
|
||||
|
||||
private var didPlayPresentationAnimation = false
|
||||
private var dismissed = false
|
||||
|
||||
public init(presentationData: PresentationData, content: UndoOverlayContent, elevatedLayout: Bool, animateInAsReplacement: Bool = false, action: @escaping (Bool) -> Void) {
|
||||
public init(presentationData: PresentationData, content: UndoOverlayContent, elevatedLayout: Bool, animateInAsReplacement: Bool = false, action: @escaping (UndoOverlayAction) -> Bool) {
|
||||
self.presentationData = presentationData
|
||||
self.content = content
|
||||
self.elevatedLayout = elevatedLayout
|
||||
@@ -42,7 +52,7 @@ public final class UndoOverlayController: ViewController {
|
||||
|
||||
override public func loadDisplayNode() {
|
||||
self.displayNode = UndoOverlayControllerNode(presentationData: self.presentationData, content: self.content, elevatedLayout: self.elevatedLayout, action: { [weak self] value in
|
||||
self?.action(value)
|
||||
return self?.action(value) ?? false
|
||||
}, dismiss: { [weak self] in
|
||||
self?.dismiss()
|
||||
})
|
||||
@@ -50,12 +60,12 @@ public final class UndoOverlayController: ViewController {
|
||||
}
|
||||
|
||||
public func dismissWithCommitAction() {
|
||||
self.action(true)
|
||||
self.action(.commit)
|
||||
self.dismiss()
|
||||
}
|
||||
|
||||
public func dismissWithCommitActionAndReplacementAnimation() {
|
||||
self.action(true)
|
||||
self.action(.commit)
|
||||
(self.displayNode as! UndoOverlayControllerNode).animateOutWithReplacement(completion: { [weak self] in
|
||||
self?.presentingViewController?.dismiss(animated: false, completion: nil)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user