mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-06 21:22:44 +00:00
[WIP] Stickers editor
This commit is contained in:
@@ -21,12 +21,6 @@ public struct StickerPackCollectionInfoFlags: OptionSet {
|
||||
if flags.contains(StickerPackCollectionInfoFlags.isOfficial) {
|
||||
rawValue |= StickerPackCollectionInfoFlags.isOfficial.rawValue
|
||||
}
|
||||
if flags.contains(StickerPackCollectionInfoFlags.isAnimated) {
|
||||
rawValue |= StickerPackCollectionInfoFlags.isAnimated.rawValue
|
||||
}
|
||||
if flags.contains(StickerPackCollectionInfoFlags.isVideo) {
|
||||
rawValue |= StickerPackCollectionInfoFlags.isVideo.rawValue
|
||||
}
|
||||
if flags.contains(StickerPackCollectionInfoFlags.isEmoji) {
|
||||
rawValue |= StickerPackCollectionInfoFlags.isEmoji.rawValue
|
||||
}
|
||||
@@ -39,8 +33,6 @@ public struct StickerPackCollectionInfoFlags: OptionSet {
|
||||
|
||||
public static let isMasks = StickerPackCollectionInfoFlags(rawValue: 1 << 0)
|
||||
public static let isOfficial = StickerPackCollectionInfoFlags(rawValue: 1 << 1)
|
||||
public static let isAnimated = StickerPackCollectionInfoFlags(rawValue: 1 << 2)
|
||||
public static let isVideo = StickerPackCollectionInfoFlags(rawValue: 1 << 3)
|
||||
public static let isEmoji = StickerPackCollectionInfoFlags(rawValue: 1 << 4)
|
||||
public static let isAvailableAsChannelStatus = StickerPackCollectionInfoFlags(rawValue: 1 << 5)
|
||||
public static let isCustomTemplateEmoji = StickerPackCollectionInfoFlags(rawValue: 1 << 6)
|
||||
|
||||
@@ -360,20 +360,36 @@ public final class TelegramMediaImage: Media, Equatable, Codable {
|
||||
}
|
||||
|
||||
public final class TelegramMediaImageRepresentation: PostboxCoding, Equatable, CustomStringConvertible {
|
||||
public enum TypeHint: Int32 {
|
||||
case generic
|
||||
case animated
|
||||
case video
|
||||
}
|
||||
|
||||
public let dimensions: PixelDimensions
|
||||
public let resource: TelegramMediaResource
|
||||
public let progressiveSizes: [Int32]
|
||||
public let immediateThumbnailData: Data?
|
||||
public let hasVideo: Bool
|
||||
public let isPersonal: Bool
|
||||
public let typeHint: TypeHint
|
||||
|
||||
public init(dimensions: PixelDimensions, resource: TelegramMediaResource, progressiveSizes: [Int32], immediateThumbnailData: Data?, hasVideo: Bool, isPersonal: Bool) {
|
||||
public init(
|
||||
dimensions: PixelDimensions,
|
||||
resource: TelegramMediaResource,
|
||||
progressiveSizes: [Int32],
|
||||
immediateThumbnailData: Data?,
|
||||
hasVideo: Bool = false,
|
||||
isPersonal: Bool = false,
|
||||
typeHint: TypeHint = .generic
|
||||
) {
|
||||
self.dimensions = dimensions
|
||||
self.resource = resource
|
||||
self.progressiveSizes = progressiveSizes
|
||||
self.immediateThumbnailData = immediateThumbnailData
|
||||
self.hasVideo = hasVideo
|
||||
self.isPersonal = isPersonal
|
||||
self.typeHint = typeHint
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
@@ -383,6 +399,7 @@ public final class TelegramMediaImageRepresentation: PostboxCoding, Equatable, C
|
||||
self.immediateThumbnailData = decoder.decodeDataForKey("th")
|
||||
self.hasVideo = decoder.decodeBoolForKey("hv", orElse: false)
|
||||
self.isPersonal = decoder.decodeBoolForKey("ip", orElse: false)
|
||||
self.typeHint = TypeHint(rawValue: decoder.decodeInt32ForKey("th", orElse: 0)) ?? .generic
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
@@ -397,6 +414,7 @@ public final class TelegramMediaImageRepresentation: PostboxCoding, Equatable, C
|
||||
}
|
||||
encoder.encodeBool(self.hasVideo, forKey: "hv")
|
||||
encoder.encodeBool(self.isPersonal, forKey: "ip")
|
||||
encoder.encodeInt32(self.typeHint.rawValue, forKey: "th")
|
||||
}
|
||||
|
||||
public var description: String {
|
||||
@@ -422,6 +440,9 @@ public final class TelegramMediaImageRepresentation: PostboxCoding, Equatable, C
|
||||
if self.isPersonal != other.isPersonal {
|
||||
return false
|
||||
}
|
||||
if self.typeHint != other.typeHint {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user