Update theme colors

This commit is contained in:
Ali 2021-06-22 19:35:34 +04:00
parent 9131d607f7
commit 7a4ea093e5
9 changed files with 341 additions and 72 deletions

View File

@ -470,7 +470,7 @@ final class ThemeAccentColorController: ViewController {
} else if let customWallpaper = settings.themeSpecificChatWallpapers[themeReference.index] {
wallpaper = customWallpaper
} else {
let theme = makePresentationTheme(mediaBox: strongSelf.context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: themeSpecificAccentColor?.color, wallpaper: themeSpecificAccentColor?.wallpaper, wallpaperGradientColors: themeSpecificAccentColor?.baseColor.wallpaperGradientColors) ?? defaultPresentationTheme
let theme = makePresentationTheme(mediaBox: strongSelf.context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: themeSpecificAccentColor?.color, wallpaper: themeSpecificAccentColor?.wallpaper, baseColor: themeSpecificAccentColor?.baseColor) ?? defaultPresentationTheme
referenceTheme = theme
wallpaper = theme.chat.defaultWallpaper
}

View File

@ -4,31 +4,31 @@ import SyncCore
import TelegramUIPreferences
import TelegramPresentationData
private func patternWallpaper(colors: [UInt32], intensity: Int32?, rotation: Int32?) -> TelegramWallpaper {
return defaultBuiltinWallpaper(colors: colors, intensity: intensity ?? 50, rotation: rotation)
private func patternWallpaper(data: BuiltinWallpaperData, colors: [UInt32], intensity: Int32?, rotation: Int32?) -> TelegramWallpaper {
return defaultBuiltinWallpaper(data: data, colors: colors, intensity: intensity ?? 50, rotation: rotation)
}
var dayClassicColorPresets: [PresentationThemeAccentColor] = [
// Pink with Blue
PresentationThemeAccentColor(index: 106, baseColor: .preset, accentColor: 0xfff55783, bubbleColors: (0xffd6f5ff, 0xffc9fdfe), wallpaper: patternWallpaper(colors: [0x8dc0eb, 0xb9d1ea, 0xc6b1ef, 0xebd7ef], intensity: 50, rotation: nil)),
PresentationThemeAccentColor(index: 106, baseColor: .preset, accentColor: 0xfff55783, bubbleColors: (0xffd6f5ff, 0xffc9fdfe), wallpaper: patternWallpaper(data: .default, colors: [0x8dc0eb, 0xb9d1ea, 0xc6b1ef, 0xebd7ef], intensity: 50, rotation: nil)),
// Pink with Gold
PresentationThemeAccentColor(index: 102, baseColor: .preset, accentColor: 0xFFFF5FA9, bubbleColors: (0xFFFFF4D7, nil), wallpaper: patternWallpaper(colors: [0xeaa36e, 0xf0e486, 0xf29ebf, 0xe8c06e], intensity: 50, rotation: nil)),
PresentationThemeAccentColor(index: 102, baseColor: .preset, accentColor: 0xFFFF5FA9, bubbleColors: (0xFFFFF4D7, nil), wallpaper: patternWallpaper(data: .variant12, colors: [0xeaa36e, 0xf0e486, 0xf29ebf, 0xe8c06e], intensity: 50, rotation: nil)),
// Green
PresentationThemeAccentColor(index: 104, baseColor: .preset, accentColor: 0xFF5A9E29, bubbleColors: (0xffFFF8DF, nil), wallpaper: patternWallpaper(colors: [0x7fc289, 0xe4d573, 0xafd677, 0xf0c07a], intensity: 50, rotation: nil)),
PresentationThemeAccentColor(index: 104, baseColor: .preset, accentColor: 0xFF5A9E29, bubbleColors: (0xffFFF8DF, nil), wallpaper: patternWallpaper(data: .variant13, colors: [0x7fc289, 0xe4d573, 0xafd677, 0xf0c07a], intensity: 50, rotation: nil)),
// Purple
PresentationThemeAccentColor(index: 101, baseColor: .preset, accentColor: 0xFF7E5FE5, bubbleColors: (0xFFF5e2FF, nil), wallpaper: patternWallpaper(colors: [0xe4b2ea, 0x8376c2, 0xeab9d9, 0xb493e6], intensity: 50, rotation: nil)),
PresentationThemeAccentColor(index: 101, baseColor: .preset, accentColor: 0xFF7E5FE5, bubbleColors: (0xFFF5e2FF, nil), wallpaper: patternWallpaper(data: .variant14, colors: [0xe4b2ea, 0x8376c2, 0xeab9d9, 0xb493e6], intensity: 50, rotation: nil)),
// Light Blue
PresentationThemeAccentColor(index: 107, baseColor: .preset, accentColor: 0xFF2CB9ED, bubbleColors: (0xFFADF7B5, 0xFFFCFF8B), wallpaper: patternWallpaper(colors: [0x1a2e1a, 0x47623c, 0x222e24, 0x314429], intensity: 50, rotation: nil)),
PresentationThemeAccentColor(index: 107, baseColor: .preset, accentColor: 0xFF2CB9ED, bubbleColors: (0xFFADF7B5, 0xFFFCFF8B), wallpaper: patternWallpaper(data: .variant3, colors: [0x1a2e1a, 0x47623c, 0x222e24, 0x314429], intensity: 50, rotation: nil)),
// Mint
PresentationThemeAccentColor(index: 103, baseColor: .preset, accentColor: 0xFF199972, bubbleColors: (0xFFFFFEC7, nil), wallpaper: patternWallpaper(colors: [0xdceb92, 0x8fe1d6, 0x67a3f2, 0x85d685], intensity: 50, rotation: nil)),
PresentationThemeAccentColor(index: 103, baseColor: .preset, accentColor: 0xFF199972, bubbleColors: (0xFFFFFEC7, nil), wallpaper: patternWallpaper(data: .variant3, colors: [0xdceb92, 0x8fe1d6, 0x67a3f2, 0x85d685], intensity: 50, rotation: nil)),
// Pink with Green
PresentationThemeAccentColor(index: 105, baseColor: .preset, accentColor: 0xFFDA90D9, bubbleColors: (0xFF94FFF9, 0xFFCCFFC7), wallpaper: patternWallpaper(colors: [0xffc3b2, 0xe2c0ff, 0xffe7b2], intensity: 50, rotation: nil))
PresentationThemeAccentColor(index: 105, baseColor: .preset, accentColor: 0xFFDA90D9, bubbleColors: (0xFF94FFF9, 0xFFCCFFC7), wallpaper: patternWallpaper(data: .variant9, colors: [0xffc3b2, 0xe2c0ff, 0xffe7b2], intensity: 50, rotation: nil))
]
var dayColorPresets: [PresentationThemeAccentColor] = [
@ -38,9 +38,11 @@ var dayColorPresets: [PresentationThemeAccentColor] = [
PresentationThemeAccentColor(index: 104, baseColor: .preset, accentColor: 0xea8ced, bubbleColors: (0xea8ced, 0x00c2ed), wallpaper: nil)
]
//CJNyxPMgSVAEAAAAvW9sMwc51cw?bg_color=7fa381~fff5c5~336f55~fbe37d&intensity=-20
var nightColorPresets: [PresentationThemeAccentColor] = [
PresentationThemeAccentColor(index: 101, baseColor: .preset, accentColor: 0x007aff, bubbleColors: (0x007aff, 0xff53f4), wallpaper: nil),
PresentationThemeAccentColor(index: 102, baseColor: .preset, accentColor: 0x00b09b, bubbleColors: (0xaee946, 0x00b09b), wallpaper: nil),
PresentationThemeAccentColor(index: 102, baseColor: .preset, accentColor: 0x00b09b, bubbleColors: (0xaee946, 0x00b09b), wallpaper: patternWallpaper(data: .variant9, colors: [0xe4b2ea, 0x8376c2, 0xeab9d9, 0xb493e6], intensity: -35, rotation: nil)),
PresentationThemeAccentColor(index: 103, baseColor: .preset, accentColor: 0xd33213, bubbleColors: (0xf9db00, 0xd33213), wallpaper: nil),
PresentationThemeAccentColor(index: 104, baseColor: .preset, accentColor: 0xea8ced, bubbleColors: (0xea8ced, 0x00c2ed), wallpaper: nil)
]

View File

@ -549,6 +549,10 @@ private final class ThemeSettingsControllerImpl: ItemListController, ThemeSettin
}
public func themeSettingsController(context: AccountContext, focusOnItemTag: ThemeSettingsEntryTag? = nil) -> ViewController {
#if DEBUG
BuiltinWallpaperData.generate(account: context.account)
#endif
var pushControllerImpl: ((ViewController) -> Void)?
var presentControllerImpl: ((ViewController, Any?) -> Void)?
var updateControllersImpl: ((([UIViewController]) -> [UIViewController]) -> Void)?
@ -844,14 +848,14 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
if let accentColor = accentColor, case let .theme(themeReference) = accentColor {
theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: themeReference)
} else {
var wallpaperGradientColors: [UInt32]?
var baseColor: PresentationThemeBaseColor?
switch accentColor {
case let .accentColor(value):
wallpaperGradientColors = value.baseColor.wallpaperGradientColors
baseColor = value.baseColor
default:
break
}
theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: generalThemeReference, accentColor: accentColor?.accentColor, bubbleColors: accentColor?.customBubbleColors, wallpaper: accentColor?.wallpaper, wallpaperGradientColors: wallpaperGradientColors)
theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: generalThemeReference, accentColor: accentColor?.accentColor, bubbleColors: accentColor?.customBubbleColors, wallpaper: accentColor?.wallpaper, baseColor: baseColor)
}
effectiveWallpaper = theme?.chat.defaultWallpaper ?? .builtin(WallpaperSettings())
}
@ -1301,7 +1305,7 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
updatedTheme = generalThemeReference
}
guard let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: generalThemeReference, accentColor: accentColor?.color, wallpaper: presetWallpaper, wallpaperGradientColors: accentColor?.baseColor.wallpaperGradientColors) else {
guard let theme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: generalThemeReference, accentColor: accentColor?.color, wallpaper: presetWallpaper, baseColor: accentColor?.baseColor) else {
return current
}

View File

@ -5,9 +5,56 @@ import SyncCore
import TelegramUIPreferences
public let defaultDarkPresentationTheme = makeDefaultDarkPresentationTheme(preview: false)
public let defaultDarkColorPresentationTheme = customizeDefaultDarkPresentationTheme(theme: defaultDarkPresentationTheme, editing: false, title: nil, accentColor: UIColor(rgb: 0x007aff), backgroundColors: [], bubbleColors: nil, wallpaper: nil)
public let defaultDarkColorPresentationTheme = customizeDefaultDarkPresentationTheme(theme: defaultDarkPresentationTheme, editing: false, title: nil, accentColor: UIColor(rgb: 0x007aff), backgroundColors: [], bubbleColors: nil, wallpaper: nil, baseColor: nil)
public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, editing: Bool, title: String?, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: (UIColor, UIColor?)?, wallpaper forcedWallpaper: TelegramWallpaper? = nil) -> PresentationTheme {
private extension PresentationThemeBaseColor {
/*
Оранжевая с красным
https://t.me/bg/9LW_RcoOSVACAAAAFTk3DTyXN-M?bg_color=fec496~dd6cb9~962fbf~4f5bd5&intensity=-40
Голубая с розовым
https://t.me/bg/9iklpvIPQVABAAAAORQXKur_Eyc?bg_color=8adbf2~888dec~e39fea~679ced&intensity=-30
Мятная
https://t.me/bg/CJNyxPMgSVAEAAAAvW9sMwc51cw?bg_color=7fa381~fff5c5~336f55~fbe37d&intensity=-20
Синяя с розовым
https://t.me/bg/9LW_RcoOSVACAAAAFTk3DTyXN-M?bg_color=fec496~dd6cb9~962fbf~4f5bd5&intensity=-40
*/
var colorWallpaper: (BuiltinWallpaperData, Int32, [UInt32])? {
switch self {
case .blue:
return nil
case .cyan:
return (.variant5, -30, [0xa4dbff, 0x009fdd, 0x527bdd])
case .green:
return (.variant3, -20, [0x7fa381, 0xfff5c5, 0x336f55, 0xfbe37d])
case .pink:
return (.variant9, -35, [0xe4b2ea, 0x8376c2, 0xeab9d9, 0xb493e6])
case .orange:
return (.variant2, -40, [0xfec496, 0xdd6cb9, 0x962fbf, 0x4f5bd5])
case .purple:
return (.variant6, -30, [0x8adbf2, 0x888dec, 0xe39fea, 0x679ced])
case .red:
return (.variant4, -35, [0xe4b2ea, 0x8376c2, 0xeab9d9, 0xb493e6])
case .yellow:
return (.variant1, -30, [0xeaa36e, 0xf0e486, 0xf29ebf, 0xe8c06e])
case .gray:
return nil
case .black:
return nil
case .white:
return nil
case .custom, .preset, .theme:
return nil
}
}
}
public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, editing: Bool, title: String?, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: (UIColor, UIColor?)?, wallpaper forcedWallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil) -> PresentationTheme {
if (theme.referenceTheme != .night) {
return theme
}
@ -82,6 +129,8 @@ public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, edit
var defaultWallpaper: TelegramWallpaper?
if let forcedWallpaper = forcedWallpaper {
defaultWallpaper = forcedWallpaper
} else if let baseColor = baseColor, let (variant, intensity, colors) = baseColor.colorWallpaper, !colors.isEmpty {
defaultWallpaper = defaultBuiltinWallpaper(data: variant, colors: colors, intensity: intensity)
} else if !backgroundColors.isEmpty {
if backgroundColors.count >= 2 {
defaultWallpaper = .gradient(nil, backgroundColors, WallpaperSettings())

View File

@ -8,7 +8,38 @@ import Postbox
private let defaultDarkTintedAccentColor = UIColor(rgb: 0x2ea6ff)
public let defaultDarkTintedPresentationTheme = makeDefaultDarkTintedPresentationTheme(preview: false)
public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme, editing: Bool, title: String?, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: (UIColor, UIColor?)?, wallpaper forcedWallpaper: TelegramWallpaper? = nil, wallpaperGradientColors: [UInt32]? = nil) -> PresentationTheme {
private extension PresentationThemeBaseColor {
var colorWallpaper: (BuiltinWallpaperData, Int32, [UInt32])? {
switch self {
case .blue:
return (.variant7, 40, [0x1e3557, 0x182036, 0x1c4352, 0x16263a])
case .cyan:
return (.variant3, 40, [0x1e3557, 0x151a36, 0x1c4352, 0x2a4541])
case .green:
return (.variant3, 40, [0x2d4836, 0x172b19, 0x364331, 0x103231])
case .pink:
return (.variant9, 40, [0x2c0b22, 0x290020, 0x160a22, 0x3b1834])
case .orange:
return (.variant10, 40, [0x2c211b, 0x442917, 0x22191f, 0x3b2714])
case .purple:
return (.variant11, 40, [0x3a1c3a, 0x24193c, 0x392e3e, 0x1a1632])
case .red:
return (.variant4, 40, [0x2c211b, 0x44332a, 0x22191f, 0x3b2d36])
case .yellow:
return (.variant2, 40, [0x2c2512, 0x45360b, 0x221d08, 0x3b2f13])
case .gray:
return (.variant6, 40, [0x1c2731, 0x1a1c25, 0x27303b, 0x1b1b21])
case .black:
return nil
case .white:
return nil
case .custom, .preset, .theme:
return nil
}
}
}
public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme, editing: Bool, title: String?, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: (UIColor, UIColor?)?, wallpaper forcedWallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil) -> PresentationTheme {
if (theme.referenceTheme != .nightAccent) {
return theme
}
@ -47,8 +78,8 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme
var bubbleColors = bubbleColors
if bubbleColors == nil, editing {
if let accentColor = accentColor {
if let wallpaperGradientColors = wallpaperGradientColors, !wallpaperGradientColors.isEmpty {
suggestedWallpaper = defaultBuiltinWallpaper(colors: wallpaperGradientColors)
if let baseColor = baseColor, let (variant, intensity, colors) = baseColor.colorWallpaper, !colors.isEmpty {
suggestedWallpaper = defaultBuiltinWallpaper(data: variant, colors: colors, intensity: intensity)
} else {
let color = accentColor.withMultiplied(hue: 1.024, saturation: 0.573, brightness: 0.18)
suggestedWallpaper = .color(color.argb)
@ -757,7 +788,7 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
)
let chat = PresentationThemeChat(
defaultWallpaper: defaultBuiltinWallpaper(colors: [0x1b2836, 0x121a22, 0x1b2836, 0x121a22]),
defaultWallpaper: defaultBuiltinWallpaper(data: .default, colors: [0x1b2836, 0x121a22, 0x1b2836, 0x121a22]),
message: message,
serviceMessage: serviceMessage,
inputPanel: inputPanel,

View File

@ -4,6 +4,7 @@ import TelegramCore
import SyncCore
import TelegramUIPreferences
import Postbox
import SwiftSignalKit
public func selectDateFillStaticColor(theme: PresentationTheme, wallpaper: TelegramWallpaper) -> UIColor {
if case .color(0xffffff) = wallpaper {
@ -738,7 +739,7 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
badgeTextColor: UIColor(rgb: 0xffffff)
)
let defaultPatternWallpaper: TelegramWallpaper = defaultBuiltinWallpaper(colors: defaultBuiltinWallpaperGradientColors.map(\.rgb))
let defaultPatternWallpaper: TelegramWallpaper = defaultBuiltinWallpaper(data: .default, colors: defaultBuiltinWallpaperGradientColors.map(\.rgb))
let chat = PresentationThemeChat(
defaultWallpaper: day ? .color(0xffffff) : defaultPatternWallpaper,
@ -842,23 +843,235 @@ public let defaultBuiltinWallpaperGradientColors: [UIColor] = [
UIColor(rgb: 0x88b884)
]
public func defaultBuiltinWallpaper(colors: [UInt32], intensity: Int32 = 50, rotation: Int32? = nil) -> TelegramWallpaper {
public struct BuiltinWallpaperData {
var wallpaperId: Int64
var wallpaperAccessHash: Int64
var slug: String
var fileId: Int64
var fileAccessHash: Int64
var datacenterId: Int
var fileSize: Int
}
public extension BuiltinWallpaperData {
static let `default` = BuiltinWallpaperData(
wallpaperId: 5951821522514477057,
wallpaperAccessHash: 542913527008942388,
slug: "fqv01SQemVIBAAAApND8LDRUhRU",
fileId: 5789658100176783156,
fileAccessHash: 2106033778341319685,
datacenterId: 4,
fileSize: 183832
)
static let variant1 = BuiltinWallpaperData(
wallpaperId: 5784984711902265347,
wallpaperAccessHash: -7073897034484875424,
slug: "RlZs2PJkSFADAAAAElGaGwgJBgU",
fileId: 5924571028763183790,
fileAccessHash: 8131740629580593134,
datacenterId: 4,
fileSize: 175995
)
static let variant2 = BuiltinWallpaperData(
wallpaperId: 5785171457080295426,
wallpaperAccessHash: 7299737721761177260,
slug: "9LW_RcoOSVACAAAAFTk3DTyXN-M",
fileId: 5927041584146156278,
fileAccessHash: -5921024951834087382,
datacenterId: 4,
fileSize: 134539
)
static let variant3 = BuiltinWallpaperData(
wallpaperId: 5785191424383254532,
wallpaperAccessHash: 6428855567842967483,
slug: "CJNyxPMgSVAEAAAAvW9sMwc51cw",
fileId: 5785343895722264360,
fileAccessHash: 3407562549390786397,
datacenterId: 4,
fileSize: 312605
)
static let variant4 = BuiltinWallpaperData(
wallpaperId: 5785123761468473345,
wallpaperAccessHash: -6430405714673464374,
slug: "BQqgrGnjSFABAAAA8mQDBXQcARE",
fileId: 5924847998319201207,
fileAccessHash: 6746675725325490532,
datacenterId: 4,
fileSize: 55699
)
static let variant5 = BuiltinWallpaperData(
wallpaperId: 5785021373743104005,
wallpaperAccessHash: -1374597781576365315,
slug: "MIo6r0qGSFAFAAAAtL8TsDzNX60",
fileId: 5782630687571969871,
fileAccessHash: 8944679612701303524,
datacenterId: 4,
fileSize: 100992
)
static let variant6 = BuiltinWallpaperData(
wallpaperId: 5782920928576929793,
wallpaperAccessHash: -2397741670740938317,
slug: "9iklpvIPQVABAAAAORQXKur_Eyc",
fileId: 5924714386181589959,
fileAccessHash: -316419094644368953,
datacenterId: 4,
fileSize: 106249
)
static let variant7 = BuiltinWallpaperData(
wallpaperId: 5931406765567508492,
wallpaperAccessHash: 7991333610111953175,
slug: "H6rz6geXUFIMAAAAuUs7m6cXbcc",
fileId: 5931433527508732666,
fileAccessHash: -8637914243010610774,
datacenterId: 4,
fileSize: 76332
)
static let variant8 = BuiltinWallpaperData(
wallpaperId: 5785007509588672513,
wallpaperAccessHash: 8437532349638900210,
slug: "kO4jyq55SFABAAAA0WEpcLfahXk",
fileId: 5925009274341165314,
fileAccessHash: 5091210796362176800,
datacenterId: 4,
fileSize: 78338
)
static let variant9 = BuiltinWallpaperData(
wallpaperId: 5785068300555780101,
wallpaperAccessHash: -4335874468273472323,
slug: "mP3FG_iwSFAFAAAA2AklJO978pA",
fileId: 5924664689115007842,
fileAccessHash: -4490072684673383370,
datacenterId: 4,
fileSize: 51705
)
static let variant10 = BuiltinWallpaperData(
wallpaperId: 5785165465600917506,
wallpaperAccessHash: 4563443115749434444,
slug: "Ujx2TFcJSVACAAAARJ4vLa50MkM",
fileId: 5924792752154872619,
fileAccessHash: -2210879717040856036,
datacenterId: 4,
fileSize: 114694
)
static let variant11 = BuiltinWallpaperData(
wallpaperId: 5785225431934304257,
wallpaperAccessHash: 3814946612408881045,
slug: "RepJ5uE_SVABAAAAr4d0YhgB850",
fileId: 5927262354055105101,
fileAccessHash: -435932841948252811,
datacenterId: 4,
fileSize: 66465
)
static let variant12 = BuiltinWallpaperData(
wallpaperId: 5785328386595356675,
wallpaperAccessHash: -5900784223259948847,
slug: "9GcNVISdSVADAAAAUcw5BYjELW4",
fileId: 5926924928539429325,
fileAccessHash: -5306472339097647861,
datacenterId: 4,
fileSize: 57262
)
static let variant13 = BuiltinWallpaperData(
wallpaperId: 6041986402319597570,
wallpaperAccessHash: -8909137552203056986,
slug: "-Xc-np9y2VMCAAAARKr0yNNPYW0",
fileId: 5789856918507882132,
fileAccessHash: 2327344847690632249,
datacenterId: 4,
fileSize: 104932
)
static let variant14 = BuiltinWallpaperData(
wallpaperId: 5784981280223395841,
wallpaperAccessHash: 8334701614156015552,
slug: "JrNEYdNhSFABAAAA9WtRdJkPRbY",
fileId: 5924784243824658746,
fileAccessHash: -2563505106174626287,
datacenterId: 4,
fileSize: 122246
)
static func generate(account: Account) {
let slugToName: [(String, String)] = [
("fqv01SQemVIBAAAApND8LDRUhRU", "`default`"),
("RlZs2PJkSFADAAAAElGaGwgJBgU", "variant1"),
("9LW_RcoOSVACAAAAFTk3DTyXN-M", "variant2"),
("CJNyxPMgSVAEAAAAvW9sMwc51cw", "variant3"),
("BQqgrGnjSFABAAAA8mQDBXQcARE", "variant4"),
("MIo6r0qGSFAFAAAAtL8TsDzNX60", "variant5"),
("9iklpvIPQVABAAAAORQXKur_Eyc", "variant6"),
("H6rz6geXUFIMAAAAuUs7m6cXbcc", "variant7"),
("kO4jyq55SFABAAAA0WEpcLfahXk", "variant8"),
("mP3FG_iwSFAFAAAA2AklJO978pA", "variant9"),
("Ujx2TFcJSVACAAAARJ4vLa50MkM", "variant10"),
("RepJ5uE_SVABAAAAr4d0YhgB850", "variant11"),
("9GcNVISdSVADAAAAUcw5BYjELW4", "variant12"),
("-Xc-np9y2VMCAAAARKr0yNNPYW0", "variant13"),
("JrNEYdNhSFABAAAA9WtRdJkPRbY", "variant14"),
]
var signals: [Signal<String?, GetWallpaperError>] = []
for (slug, name) in slugToName {
signals.append(getWallpaper(network: account.network, slug: slug)
|> map { wallpaper -> String? in
switch wallpaper {
case let .file(id, accessHash, _, _, _, _, _, file, _):
guard let resource = file.resource as? CloudDocumentMediaResource else {
return nil
}
guard let size = file.size else {
return nil
}
return """
static let \(name) = BuiltinWallpaperData(
wallpaperId: \(id),
wallpaperAccessHash: \(accessHash),
slug: "\(slug)",
fileId: \(file.fileId.id),
fileAccessHash: \(resource.accessHash),
datacenterId: \(resource.datacenterId),
fileSize: \(size)
)
"""
default:
return nil
}
})
}
let _ = (combineLatest(signals)
|> map { strings -> String in
var result = ""
for case let string? in strings {
if !result.isEmpty {
result.append("\n")
}
result.append(string)
}
return result
}
|> deliverOnMainQueue).start(next: { result in
print("\(result)")
})
}
}
public func defaultBuiltinWallpaper(data: BuiltinWallpaperData, colors: [UInt32], intensity: Int32 = 50, rotation: Int32? = nil) -> TelegramWallpaper {
return .file(
id: 5933856211186221059,
accessHash: 7039846297018949116,
id: data.wallpaperId,
accessHash: data.wallpaperAccessHash,
isCreator: false,
isDefault: false,
isPattern: true,
isDark: false,
slug: "fqv01SQemVIBAAAApND8LDRUhRU",
slug: data.slug,
file: TelegramMediaFile(
fileId: MediaId(namespace: Namespaces.Media.CloudFile, id: 5789658100176783156),
fileId: MediaId(namespace: Namespaces.Media.CloudFile, id: data.fileId),
partialReference: nil,
resource: CloudDocumentMediaResource(
datacenterId: 1,
fileId: 5789658100176783156,
accessHash: 5949005087206403318,
size: 183832,
datacenterId: data.datacenterId,
fileId: data.fileId,
accessHash: data.fileAccessHash,
size: data.fileSize,
fileReference: Data(),
fileName: "pattern.tgv"
),
@ -867,8 +1080,8 @@ public func defaultBuiltinWallpaper(colors: [UInt32], intensity: Int32 = 50, rot
dimensions: PixelDimensions(width: 155, height: 320),
resource: CloudDocumentSizeMediaResource(
datacenterId: 1,
documentId: 5789658100176783156,
accessHash: 5949005087206403318,
documentId: data.fileId,
accessHash: data.fileAccessHash,
sizeSpec: "m",
fileReference: Data()
),
@ -879,7 +1092,7 @@ public func defaultBuiltinWallpaper(colors: [UInt32], intensity: Int32 = 50, rot
videoThumbnails: [],
immediateThumbnailData: nil,
mimeType: "application/x-tgwallpattern",
size: 183832,
size: data.fileSize,
attributes: [
.ImageSize(size: PixelDimensions(width: 1440, height: 2960)),
.FileName(fileName: "pattern.tgv")

View File

@ -19,7 +19,7 @@ public func makeDefaultPresentationTheme(reference: PresentationBuiltinThemeRefe
return theme
}
public func customizePresentationTheme(_ theme: PresentationTheme, editing: Bool, title: String? = nil, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: (UIColor, UIColor?)?, wallpaper: TelegramWallpaper? = nil, wallpaperGradientColors: [UInt32]? = nil) -> PresentationTheme {
public func customizePresentationTheme(_ theme: PresentationTheme, editing: Bool, title: String? = nil, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: (UIColor, UIColor?)?, wallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil) -> PresentationTheme {
if accentColor == nil && bubbleColors == nil && backgroundColors.isEmpty && wallpaper == nil {
return theme
}
@ -27,9 +27,9 @@ public func customizePresentationTheme(_ theme: PresentationTheme, editing: Bool
case .day, .dayClassic:
return customizeDefaultDayTheme(theme: theme, editing: editing, title: title, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper, serviceBackgroundColor: nil)
case .night:
return customizeDefaultDarkPresentationTheme(theme: theme, editing: editing, title: title, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper)
return customizeDefaultDarkPresentationTheme(theme: theme, editing: editing, title: title, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper, baseColor: baseColor)
case .nightAccent:
return customizeDefaultDarkTintedPresentationTheme(theme: theme, editing: editing, title: title, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper, wallpaperGradientColors: wallpaperGradientColors)
return customizeDefaultDarkTintedPresentationTheme(theme: theme, editing: editing, title: title, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper, baseColor: baseColor)
}
}
@ -38,12 +38,12 @@ public func makePresentationTheme(settings: TelegramThemeSettings, title: String
return customizePresentationTheme(defaultTheme, editing: true, title: title, accentColor: UIColor(argb: settings.accentColor), backgroundColors: [], bubbleColors: settings.messageColors.flatMap { (UIColor(argb: $0.top), UIColor(argb: $0.bottom)) }, wallpaper: settings.wallpaper)
}
public func makePresentationTheme(mediaBox: MediaBox, themeReference: PresentationThemeReference, extendingThemeReference: PresentationThemeReference? = nil, accentColor: UIColor? = nil, backgroundColors: [UInt32] = [], bubbleColors: (UIColor, UIColor?)? = nil, wallpaper: TelegramWallpaper? = nil, wallpaperGradientColors: [UInt32]? = nil, serviceBackgroundColor: UIColor? = nil, preview: Bool = false) -> PresentationTheme? {
public func makePresentationTheme(mediaBox: MediaBox, themeReference: PresentationThemeReference, extendingThemeReference: PresentationThemeReference? = nil, accentColor: UIColor? = nil, backgroundColors: [UInt32] = [], bubbleColors: (UIColor, UIColor?)? = nil, wallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil, serviceBackgroundColor: UIColor? = nil, preview: Bool = false) -> PresentationTheme? {
let theme: PresentationTheme
switch themeReference {
case let .builtin(reference):
let defaultTheme = makeDefaultPresentationTheme(reference: reference, extendingThemeReference: extendingThemeReference, serviceBackgroundColor: serviceBackgroundColor, preview: preview)
theme = customizePresentationTheme(defaultTheme, editing: true, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper, wallpaperGradientColors: wallpaperGradientColors)
theme = customizePresentationTheme(defaultTheme, editing: true, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper, baseColor: baseColor)
case let .local(info):
if let path = mediaBox.completedResourcePath(info.resource), let data = try? Data(contentsOf: URL(fileURLWithPath: path), options: .mappedRead), let loadedTheme = makePresentationTheme(data: data, themeReference: themeReference, resolvedWallpaper: info.resolvedWallpaper) {
theme = customizePresentationTheme(loadedTheme, editing: false, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper)

View File

@ -292,7 +292,7 @@ public func currentPresentationDataAndSettings(accountManager: AccountManager, s
}
let effectiveColors = themeSettings.themeSpecificAccentColors[effectiveTheme.index]
let theme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: effectiveTheme, accentColor: effectiveColors?.color, bubbleColors: effectiveColors?.customBubbleColors, wallpaperGradientColors: effectiveColors?.baseColor.wallpaperGradientColors) ?? defaultPresentationTheme
let theme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: effectiveTheme, accentColor: effectiveColors?.color, bubbleColors: effectiveColors?.customBubbleColors, baseColor: effectiveColors?.baseColor) ?? defaultPresentationTheme
let effectiveChatWallpaper: TelegramWallpaper = (themeSettings.themeSpecificChatWallpapers[coloredThemeIndex(reference: effectiveTheme, accentColor: effectiveColors)] ?? themeSettings.themeSpecificChatWallpapers[effectiveTheme.index]) ?? theme.chat.defaultWallpaper
@ -583,7 +583,7 @@ public func updatedPresentationData(accountManager: AccountManager, applicationI
if let themeSpecificWallpaper = themeSpecificWallpaper {
currentWallpaper = themeSpecificWallpaper
} else {
let theme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: themeSettings.theme, accentColor: currentColors?.color, bubbleColors: currentColors?.customBubbleColors, wallpaper: currentColors?.wallpaper, wallpaperGradientColors: currentColors?.baseColor.wallpaperGradientColors) ?? defaultPresentationTheme
let theme = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: themeSettings.theme, accentColor: currentColors?.color, bubbleColors: currentColors?.customBubbleColors, wallpaper: currentColors?.wallpaper, baseColor: currentColors?.baseColor) ?? defaultPresentationTheme
currentWallpaper = theme.chat.defaultWallpaper
}
@ -619,7 +619,7 @@ public func updatedPresentationData(accountManager: AccountManager, applicationI
effectiveColors = nil
}
let themeValue = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: effectiveTheme, accentColor: effectiveColors?.color, bubbleColors: effectiveColors?.customBubbleColors, wallpaper: effectiveColors?.wallpaper, wallpaperGradientColors: effectiveColors?.baseColor.wallpaperGradientColors, serviceBackgroundColor: serviceBackgroundColor) ?? defaultPresentationTheme
let themeValue = makePresentationTheme(mediaBox: accountManager.mediaBox, themeReference: effectiveTheme, accentColor: effectiveColors?.color, bubbleColors: effectiveColors?.customBubbleColors, wallpaper: effectiveColors?.wallpaper, baseColor: effectiveColors?.baseColor, serviceBackgroundColor: serviceBackgroundColor) ?? defaultPresentationTheme
if autoNightModeTriggered && !switchedToNightModeWallpaper {
switch effectiveChatWallpaper {

View File

@ -404,36 +404,6 @@ public enum PresentationThemeBaseColor: Int32, CaseIterable {
}
return UIColor(rgb: value)
}
public var wallpaperGradientColors: [UInt32]? {
switch self {
case .blue:
return [0x1b2836, 0x121a22, 0x1b2836, 0x121a22]
case .cyan:
return [0x152b32, 0x0c181c, 0x152b32, 0x0c181c]
case .green:
return [0x142615, 0x0b160c, 0x142615, 0x0b160c]
case .pink:
return [0x2d1f23, 0x22171a, 0x2d1f23, 0x22171a]
case .orange:
return [0x2e2213, 0x221b0f, 0x2e2213, 0x221b0f]
case .purple:
return [0x25212e, 0x1b1822, 0x25212e, 0x1b1822]
case .red:
return [0x281613, 0x1e110e, 0x281613, 0x1e110e]
case .yellow:
return [0x2d2813, 0x221d0e, 0x2d2813, 0x221d0e]
case .gray:
return [0x1b1d21, 0x111315, 0x1b1d21, 0x111315]
case .black:
return nil
case .white:
return nil
case .custom, .preset, .theme:
return nil
}
}
}
public struct PresentationThemeAccentColor: PostboxCoding, Equatable {