mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 14:02:48 +00:00
Merge commit
This commit is contained in:
parent
d8e0567de8
commit
61a20bbbfc
@ -247,11 +247,15 @@ final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
mediaAndFlags = (webpage.image ?? file, [.preferMediaBeforeText])
|
mediaAndFlags = (webpage.image ?? file, [.preferMediaBeforeText])
|
||||||
}
|
}
|
||||||
} else if webpage.type == "telegram_background" {
|
} else if webpage.type == "telegram_background" {
|
||||||
var patternColor: UIColor?
|
var topColor: UIColor?
|
||||||
if let wallpaper = parseWallpaperUrl(webpage.url), case let .slug(_, _, color, intensity) = wallpaper {
|
var bottomColor: UIColor?
|
||||||
patternColor = color?.withAlphaComponent(CGFloat(intensity ?? 50) / 100.0)
|
var rotation: Int32?
|
||||||
|
if let wallpaper = parseWallpaperUrl(webpage.url), case let .slug(_, _, firstColor, secondColor, intensity, rotationValue) = wallpaper {
|
||||||
|
topColor = firstColor?.withAlphaComponent(CGFloat(intensity ?? 50) / 100.0)
|
||||||
|
bottomColor = secondColor?.withAlphaComponent(CGFloat(intensity ?? 50) / 100.0)
|
||||||
|
rotation = rotationValue
|
||||||
}
|
}
|
||||||
let media = WallpaperPreviewMedia(content: .file(file, patternColor, nil, 0, false, false))
|
let media = WallpaperPreviewMedia(content: .file(file, topColor, bottomColor, rotation, false, false))
|
||||||
mediaAndFlags = (media, [.preferMediaAspectFilled])
|
mediaAndFlags = (media, [.preferMediaAspectFilled])
|
||||||
if let fileSize = file.size {
|
if let fileSize = file.size {
|
||||||
badge = dataSizeString(fileSize, decimalSeparator: item.presentationData.dateTimeFormat.decimalSeparator)
|
badge = dataSizeString(fileSize, decimalSeparator: item.presentationData.dateTimeFormat.decimalSeparator)
|
||||||
@ -279,23 +283,31 @@ final class ChatMessageWebpageBubbleContentNode: ChatMessageBubbleContentNode {
|
|||||||
}
|
}
|
||||||
} else if let type = webpage.type {
|
} else if let type = webpage.type {
|
||||||
if type == "telegram_background" {
|
if type == "telegram_background" {
|
||||||
if let text = webpage.text {
|
var topColor: UIColor?
|
||||||
let colorCodeRange = text.range(of: "#")
|
var bottomColor: UIColor?
|
||||||
if colorCodeRange != nil {
|
var rotation: Int32?
|
||||||
let components = text.replacingOccurrences(of: "#", with: "").components(separatedBy: "-")
|
if let wallpaper = parseWallpaperUrl(webpage.url) {
|
||||||
if components.count == 2, let topColorCode = components.first, let bottomColorCode = components.last {
|
if case let .color(color) = wallpaper {
|
||||||
if let topColor = UIColor(hexString: topColorCode), let bottomColor = UIColor(hexString: bottomColorCode) {
|
topColor = color
|
||||||
let media = WallpaperPreviewMedia(content: .gradient(topColor, bottomColor, 0))
|
} else if case let .gradient(topColorValue, bottomColorValue, rotationValue) = wallpaper {
|
||||||
mediaAndFlags = (media, ChatMessageAttachedContentNodeMediaFlags())
|
topColor = topColorValue
|
||||||
}
|
bottomColor = bottomColorValue
|
||||||
} else if components.count == 1, let colorCode = components.first {
|
rotation = rotationValue
|
||||||
if let color = UIColor(hexString: colorCode) {
|
|
||||||
let media = WallpaperPreviewMedia(content: .color(color))
|
|
||||||
mediaAndFlags = (media, ChatMessageAttachedContentNodeMediaFlags())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var content: WallpaperPreviewMediaContent?
|
||||||
|
if let topColor = topColor {
|
||||||
|
if let bottomColor = bottomColor {
|
||||||
|
content = .gradient(topColor, bottomColor, rotation)
|
||||||
|
} else {
|
||||||
|
content = .color(topColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let content = content {
|
||||||
|
let media = WallpaperPreviewMedia(content: content)
|
||||||
|
mediaAndFlags = (media, [])
|
||||||
|
}
|
||||||
} else if type == "telegram_theme" {
|
} else if type == "telegram_theme" {
|
||||||
var file: TelegramMediaFile?
|
var file: TelegramMediaFile?
|
||||||
var isSupported = false
|
var isSupported = false
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user