Swiftgram/submodules/TelegramCallsUI/Sources/VideoChatNotifications.swift
2025-09-27 01:27:56 +04:00

24 lines
794 B
Swift

import Foundation
import SwiftSignalKit
import TelegramCore
enum VideoChatNotificationIcon {
case peer(EnginePeer)
case icon(String)
}
extension VideoChatScreenComponent.View {
func displayNotification(icon: VideoChatNotificationIcon, text: String, duration: Int32) {
let id = Int64.random(in: 0 ..< .max)
let expiresOn = Int32(CFAbsoluteTimeGetCurrent()) + duration
self.messageNotifications.append((id: id, icon: icon, text: text, expiresOn: expiresOn))
self.state?.updated(transition: .spring(duration: 0.4))
Queue.mainQueue().after(Double(duration)) {
self.messageNotifications.removeAll(where: { $0.id == id })
self.state?.updated(transition: .spring(duration: 0.4))
}
}
}