mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-17 11:50:56 +00:00
Fix theme decoding
This commit is contained in:
parent
c91f1e05b7
commit
ee883c9ac6
@ -68,8 +68,7 @@ extension TelegramWallpaper: Codable {
|
|||||||
self = .gradient([topColor.argb, bottomColor.argb], WallpaperSettings(blur: blur, motion: motion, rotation: rotation))
|
self = .gradient([topColor.argb, bottomColor.argb], WallpaperSettings(blur: blur, motion: motion, rotation: rotation))
|
||||||
} else {
|
} else {
|
||||||
var slug: String?
|
var slug: String?
|
||||||
var color: UInt32?
|
var colors: [UInt32] = []
|
||||||
var bottomColor: UInt32?
|
|
||||||
var intensity: Int32?
|
var intensity: Int32?
|
||||||
var rotation: Int32?
|
var rotation: Int32?
|
||||||
|
|
||||||
@ -83,11 +82,7 @@ extension TelegramWallpaper: Codable {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if [6, 8].contains(component.count), let value = UIColor(hexString: component) {
|
if [6, 8].contains(component.count), let value = UIColor(hexString: component) {
|
||||||
if color == nil {
|
colors.append(value.rgb)
|
||||||
color = value.argb
|
|
||||||
} else if bottomColor == nil {
|
|
||||||
bottomColor = value.argb
|
|
||||||
}
|
|
||||||
} else if component.count <= 3, let value = Int32(component) {
|
} else if component.count <= 3, let value = Int32(component) {
|
||||||
if intensity == nil {
|
if intensity == nil {
|
||||||
if value >= 0 && value <= 100 {
|
if value >= 0 && value <= 100 {
|
||||||
@ -104,14 +99,7 @@ extension TelegramWallpaper: Codable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let slug = slug {
|
if let slug = slug {
|
||||||
var colors: [UInt32] = []
|
self = .file(id: 0, accessHash: 0, isCreator: false, isDefault: false, isPattern: !colors.isEmpty, isDark: false, slug: slug, file: TelegramMediaFile(fileId: MediaId(namespace: 0, id: 0), partialReference: nil, resource: WallpaperDataResource(slug: slug), previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "", size: nil, attributes: []), settings: WallpaperSettings(blur: blur, motion: motion, colors: colors, intensity: intensity, rotation: rotation))
|
||||||
if let color = color {
|
|
||||||
colors.append(color)
|
|
||||||
}
|
|
||||||
if let bottomColor = bottomColor {
|
|
||||||
colors.append(bottomColor)
|
|
||||||
}
|
|
||||||
self = .file(id: 0, accessHash: 0, isCreator: false, isDefault: false, isPattern: color != nil, isDark: false, slug: slug, file: TelegramMediaFile(fileId: MediaId(namespace: 0, id: 0), partialReference: nil, resource: WallpaperDataResource(slug: slug), previewRepresentations: [], videoThumbnails: [], immediateThumbnailData: nil, mimeType: "", size: nil, attributes: []), settings: WallpaperSettings(blur: blur, motion: motion, colors: colors, intensity: intensity, rotation: rotation))
|
|
||||||
} else {
|
} else {
|
||||||
throw PresentationThemeDecodingError.generic
|
throw PresentationThemeDecodingError.generic
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user