mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-08 19:10:53 +00:00
Add outgoing accent color customization
This commit is contained in:
parent
cb93fdbc08
commit
767a30038b
@ -14,8 +14,8 @@ import MediaResources
|
||||
private let randomBackgroundColors: [Int32] = [0x007aff, 0x00c2ed, 0x29b327, 0xeb6ca4, 0xf08200, 0x9472ee, 0xd33213, 0xedb400, 0x6d839e]
|
||||
|
||||
extension TelegramThemeSettings {
|
||||
convenience init(baseTheme: TelegramBaseTheme, accentColor: UIColor, messageColors: [UInt32], animateMessageColors: Bool, wallpaper: TelegramWallpaper?) {
|
||||
self.init(baseTheme: baseTheme, accentColor: accentColor.argb, messageColors: messageColors, animateMessageColors: animateMessageColors, wallpaper: wallpaper)
|
||||
convenience init(baseTheme: TelegramBaseTheme, accentColor: UIColor, outgoingAccentColor: UIColor?, messageColors: [UInt32], animateMessageColors: Bool, wallpaper: TelegramWallpaper?) {
|
||||
self.init(baseTheme: baseTheme, accentColor: accentColor.argb, outgoingAccentColor: outgoingAccentColor?.argb, messageColors: messageColors, animateMessageColors: animateMessageColors, wallpaper: wallpaper)
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,13 +201,13 @@ final class ThemeAccentColorController: ViewController {
|
||||
}
|
||||
|
||||
if let themeReference = generalThemeReference {
|
||||
updatedTheme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: state.accentColor.color, backgroundColors: state.backgroundColors.map { $0.rgb }, bubbleColors: state.messagesColors.map { $0.rgb }, animateBubbleColors: state.animateMessageColors, wallpaper: coloredWallpaper ?? state.initialWallpaper, serviceBackgroundColor: serviceBackgroundColor) ?? defaultPresentationTheme
|
||||
updatedTheme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: state.accentColor.color, outgoingAccentColor: state.outgoingAccentColor?.color, backgroundColors: state.backgroundColors.map { $0.rgb }, bubbleColors: state.messagesColors.map { $0.rgb }, animateBubbleColors: state.animateMessageColors, wallpaper: coloredWallpaper ?? state.initialWallpaper, serviceBackgroundColor: serviceBackgroundColor) ?? defaultPresentationTheme
|
||||
} else {
|
||||
updatedTheme = customizePresentationTheme(theme, editing: false, accentColor: state.accentColor.color, backgroundColors: state.backgroundColors.map { $0.rgb }, bubbleColors: state.messagesColors.map { $0.rgb }, animateBubbleColors: state.animateMessageColors, wallpaper: state.initialWallpaper ?? coloredWallpaper)
|
||||
updatedTheme = customizePresentationTheme(theme, editing: false, accentColor: state.accentColor.color, outgoingAccentColor: state.outgoingAccentColor?.color, backgroundColors: state.backgroundColors.map { $0.rgb }, bubbleColors: state.messagesColors.map { $0.rgb }, animateBubbleColors: state.animateMessageColors, wallpaper: state.initialWallpaper ?? coloredWallpaper)
|
||||
}
|
||||
|
||||
if hasSettings, let baseTheme = baseTheme {
|
||||
settings = TelegramThemeSettings(baseTheme: baseTheme, accentColor: state.accentColor.color, messageColors: state.messagesColors.map { $0.rgb }, animateMessageColors: state.animateMessageColors, wallpaper: coloredWallpaper)
|
||||
settings = TelegramThemeSettings(baseTheme: baseTheme, accentColor: state.accentColor.color, outgoingAccentColor: state.outgoingAccentColor?.color, messageColors: state.messagesColors.map { $0.rgb }, animateMessageColors: state.animateMessageColors, wallpaper: coloredWallpaper)
|
||||
}
|
||||
|
||||
completion(updatedTheme, settings)
|
||||
@ -226,7 +226,7 @@ final class ThemeAccentColorController: ViewController {
|
||||
|
||||
let wallpaper = coloredWallpaper ?? state.initialWallpaper
|
||||
|
||||
let settings = TelegramThemeSettings(baseTheme: baseTheme, accentColor: state.accentColor.rgb, messageColors: state.messagesColors.map { $0.rgb }, animateMessageColors: state.animateMessageColors, wallpaper: wallpaper)
|
||||
let settings = TelegramThemeSettings(baseTheme: baseTheme, accentColor: state.accentColor.rgb, outgoingAccentColor: state.outgoingAccentColor?.rgb, messageColors: state.messagesColors.map { $0.rgb }, animateMessageColors: state.animateMessageColors, wallpaper: wallpaper)
|
||||
let baseThemeReference = PresentationThemeReference.builtin(PresentationBuiltinThemeReference(baseTheme: baseTheme))
|
||||
|
||||
let apply: Signal<Void, CreateThemeError>
|
||||
@ -371,6 +371,7 @@ final class ThemeAccentColorController: ViewController {
|
||||
let settings = (sharedData.entries[ApplicationSpecificSharedDataKeys.presentationThemeSettings] as? PresentationThemeSettings) ?? PresentationThemeSettings.defaultSettings
|
||||
|
||||
let accentColor: UIColor
|
||||
let outgoingAccentColor: UIColor?
|
||||
var initialWallpaper: TelegramWallpaper?
|
||||
var backgroundColors: [UInt32] = []
|
||||
var patternWallpaper: TelegramWallpaper?
|
||||
@ -446,10 +447,13 @@ final class ThemeAccentColorController: ViewController {
|
||||
|
||||
if case let .cloud(cloudTheme) = initialThemeReference, let settings = cloudTheme.theme.settings {
|
||||
animateMessageColors = settings.animateMessageColors
|
||||
outgoingAccentColor = settings.outgoingAccentColor.flatMap { UIColor(rgb: $0) }
|
||||
} else if let referenceTheme = referenceTheme {
|
||||
animateMessageColors = referenceTheme.chat.animateMessageColors
|
||||
outgoingAccentColor = nil
|
||||
} else {
|
||||
animateMessageColors = false
|
||||
outgoingAccentColor = nil
|
||||
}
|
||||
|
||||
extractBuiltinWallpaper(wallpaper)
|
||||
@ -497,6 +501,7 @@ final class ThemeAccentColorController: ViewController {
|
||||
}
|
||||
|
||||
animateMessageColors = themeSettings.animateMessageColors
|
||||
outgoingAccentColor = themeSettings.outgoingAccentColor.flatMap { UIColor(rgb: $0) }
|
||||
} else if case .builtin = themeReference {
|
||||
let themeSpecificAccentColor = settings.themeSpecificAccentColors[themeReference.index]
|
||||
accentColor = themeSpecificAccentColor?.color ?? defaultDayAccentColor
|
||||
@ -533,10 +538,12 @@ final class ThemeAccentColorController: ViewController {
|
||||
}
|
||||
|
||||
animateMessageColors = false
|
||||
outgoingAccentColor = nil
|
||||
} else {
|
||||
let theme = makePresentationTheme(mediaBox: strongSelf.context.sharedContext.accountManager.mediaBox, themeReference: themeReference)!
|
||||
|
||||
accentColor = theme.rootController.navigationBar.accentTextColor
|
||||
outgoingAccentColor = nil
|
||||
|
||||
let wallpaper = theme.chat.defaultWallpaper
|
||||
extractWallpaperParameters(wallpaper)
|
||||
@ -552,6 +559,7 @@ final class ThemeAccentColorController: ViewController {
|
||||
}
|
||||
} else if case let .edit(theme, wallpaper, _, _, _, _) = strongSelf.mode {
|
||||
accentColor = theme.rootController.navigationBar.accentTextColor
|
||||
outgoingAccentColor = nil
|
||||
|
||||
let wallpaper = wallpaper ?? theme.chat.defaultWallpaper
|
||||
extractWallpaperParameters(wallpaper)
|
||||
@ -565,13 +573,14 @@ final class ThemeAccentColorController: ViewController {
|
||||
animateMessageColors = theme.chat.animateMessageColors
|
||||
} else {
|
||||
accentColor = defaultDayAccentColor
|
||||
outgoingAccentColor = nil
|
||||
backgroundColors = []
|
||||
messageColors = []
|
||||
|
||||
animateMessageColors = false
|
||||
}
|
||||
|
||||
let initialState = ThemeColorState(section: strongSelf.section, accentColor: HSBColor(color: accentColor), initialWallpaper: initialWallpaper, backgroundColors: backgroundColors.map { HSBColor(rgb: $0) }, patternWallpaper: patternWallpaper, patternIntensity: patternIntensity, animateMessageColors: animateMessageColors, defaultMessagesColor: defaultMessagesColor.flatMap { HSBColor(color: $0) }, messagesColors: messageColors.map { HSBColor(rgb: $0) }, selectedColor: 0, rotation: rotation)
|
||||
let initialState = ThemeColorState(section: strongSelf.section, accentColor: HSBColor(color: accentColor), outgoingAccentColor: outgoingAccentColor.flatMap { HSBColor(color: $0) }, initialWallpaper: initialWallpaper, backgroundColors: backgroundColors.map { HSBColor(rgb: $0) }, patternWallpaper: patternWallpaper, patternIntensity: patternIntensity, animateMessageColors: animateMessageColors, defaultMessagesColor: defaultMessagesColor.flatMap { HSBColor(color: $0) }, messagesColors: messageColors.map { HSBColor(rgb: $0) }, selectedColor: 0, rotation: rotation)
|
||||
|
||||
strongSelf.controllerNode.updateState({ _ in
|
||||
return initialState
|
||||
|
@ -40,6 +40,7 @@ struct ThemeColorState {
|
||||
fileprivate var displayPatternPanel: Bool
|
||||
|
||||
var accentColor: HSBColor
|
||||
var outgoingAccentColor: HSBColor?
|
||||
var initialWallpaper: TelegramWallpaper?
|
||||
var backgroundColors: [HSBColor]
|
||||
|
||||
@ -61,6 +62,7 @@ struct ThemeColorState {
|
||||
self.colorPanelCollapsed = false
|
||||
self.displayPatternPanel = false
|
||||
self.accentColor = HSBColor(hue: 0.0, saturation: 0.0, brightness: 1.0)
|
||||
self.outgoingAccentColor = nil
|
||||
self.initialWallpaper = nil
|
||||
self.backgroundColors = []
|
||||
self.preview = false
|
||||
@ -74,11 +76,12 @@ struct ThemeColorState {
|
||||
self.rotation = 0
|
||||
}
|
||||
|
||||
init(section: ThemeColorSection, accentColor: HSBColor, initialWallpaper: TelegramWallpaper?, backgroundColors: [HSBColor], patternWallpaper: TelegramWallpaper?, patternIntensity: Int32, animateMessageColors: Bool, defaultMessagesColor: HSBColor?, messagesColors: [HSBColor], selectedColor: Int = 0, rotation: Int32 = 0) {
|
||||
init(section: ThemeColorSection, accentColor: HSBColor, outgoingAccentColor: HSBColor?, initialWallpaper: TelegramWallpaper?, backgroundColors: [HSBColor], patternWallpaper: TelegramWallpaper?, patternIntensity: Int32, animateMessageColors: Bool, defaultMessagesColor: HSBColor?, messagesColors: [HSBColor], selectedColor: Int = 0, rotation: Int32 = 0) {
|
||||
self.section = section
|
||||
self.colorPanelCollapsed = false
|
||||
self.displayPatternPanel = false
|
||||
self.accentColor = accentColor
|
||||
self.outgoingAccentColor = outgoingAccentColor
|
||||
self.initialWallpaper = initialWallpaper
|
||||
self.backgroundColors = backgroundColors
|
||||
self.preview = false
|
||||
@ -96,6 +99,9 @@ struct ThemeColorState {
|
||||
if self.accentColor != otherState.accentColor {
|
||||
return false
|
||||
}
|
||||
if self.outgoingAccentColor != otherState.outgoingAccentColor {
|
||||
return false
|
||||
}
|
||||
if self.preview != otherState.preview {
|
||||
return false
|
||||
}
|
||||
@ -345,6 +351,11 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
||||
if let firstColor = colors.first {
|
||||
updated.accentColor = firstColor
|
||||
}
|
||||
if colors.count == 2, let secondColor = colors.last {
|
||||
updated.outgoingAccentColor = secondColor
|
||||
} else {
|
||||
updated.outgoingAccentColor = nil
|
||||
}
|
||||
case .background:
|
||||
updated.backgroundColors = colors
|
||||
case .messages:
|
||||
@ -434,6 +445,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
||||
}
|
||||
|> map { state -> (PresentationTheme?, TelegramWallpaper, UIColor, [HSBColor], Int32, PatternWallpaperArguments, Bool) in
|
||||
let accentColor = state.accentColor
|
||||
let outgoingAccentColor = state.outgoingAccentColor
|
||||
var backgroundColors = state.backgroundColors
|
||||
let messagesColors = state.messagesColors
|
||||
|
||||
@ -484,9 +496,9 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
||||
|
||||
if !updateOnlyWallpaper {
|
||||
if let themeReference = mode.themeReference {
|
||||
updatedTheme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: accentColor.color, backgroundColors: backgroundColors.map { $0.rgb }, bubbleColors: messagesColors.map { $0.rgb }, animateBubbleColors: state.animateMessageColors, serviceBackgroundColor: serviceBackgroundColor, preview: true) ?? defaultPresentationTheme
|
||||
updatedTheme = makePresentationTheme(mediaBox: context.sharedContext.accountManager.mediaBox, themeReference: themeReference, accentColor: accentColor.color, outgoingAccentColor: outgoingAccentColor?.color, backgroundColors: backgroundColors.map { $0.rgb }, bubbleColors: messagesColors.map { $0.rgb }, animateBubbleColors: state.animateMessageColors, serviceBackgroundColor: serviceBackgroundColor, preview: true) ?? defaultPresentationTheme
|
||||
} else if case let .edit(theme, _, _, _, _, _) = mode {
|
||||
updatedTheme = customizePresentationTheme(theme, editing: false, accentColor: accentColor.color, backgroundColors: backgroundColors.map { $0.rgb }, bubbleColors: messagesColors.map { $0.rgb }, animateBubbleColors: state.animateMessageColors)
|
||||
updatedTheme = customizePresentationTheme(theme, editing: false, accentColor: accentColor.color, outgoingAccentColor: outgoingAccentColor?.color, backgroundColors: backgroundColors.map { $0.rgb }, bubbleColors: messagesColors.map { $0.rgb }, animateBubbleColors: state.animateMessageColors)
|
||||
} else {
|
||||
updatedTheme = theme
|
||||
}
|
||||
@ -644,9 +656,14 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
||||
|
||||
var colors: [HSBColor]
|
||||
var defaultColor: HSBColor?
|
||||
var suggestedNewColor: HSBColor?
|
||||
switch section {
|
||||
case .accent:
|
||||
colors = [self.state.accentColor]
|
||||
if let outgoingAccentColor = self.state.outgoingAccentColor {
|
||||
colors.append(outgoingAccentColor)
|
||||
}
|
||||
suggestedNewColor = HSBColor(color: self.theme.chat.message.outgoing.accentTextColor)
|
||||
case .background:
|
||||
if let themeReference = self.mode.themeReference, case let .builtin(theme) = themeReference {
|
||||
switch theme {
|
||||
@ -682,10 +699,11 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
||||
colors = [defaultColor]
|
||||
}
|
||||
|
||||
|
||||
let maximumNumberOfColors: Int
|
||||
switch self.state.section {
|
||||
case .accent:
|
||||
maximumNumberOfColors = 1
|
||||
maximumNumberOfColors = 2
|
||||
case .background:
|
||||
maximumNumberOfColors = 4
|
||||
case .messages:
|
||||
@ -702,7 +720,8 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
||||
rotateAvailable: self.state.section == .background,
|
||||
rotation: self.state.rotation,
|
||||
preview: false,
|
||||
simpleGradientGeneration: self.state.section == .messages
|
||||
simpleGradientGeneration: self.state.section == .messages,
|
||||
suggestedNewColor: suggestedNewColor
|
||||
)
|
||||
}, animated: animated)
|
||||
|
||||
@ -903,9 +922,10 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
|
||||
sampleMessages.append(message3)
|
||||
|
||||
let message4 = Message(stableId: 4, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 4), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66003, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_7_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [])
|
||||
messages[message4.id] = message4
|
||||
sampleMessages.append(message4)
|
||||
|
||||
let message5 = Message(stableId: 5, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 5), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66004, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [])
|
||||
let message5 = Message(stableId: 5, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 5), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66004, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [ReplyMessageAttribute(messageId: message4.id, threadMessageId: nil)], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [])
|
||||
messages[message5.id] = message5
|
||||
sampleMessages.append(message5)
|
||||
|
||||
|
@ -471,9 +471,10 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
sampleMessages.append(message3)
|
||||
|
||||
let message4 = Message(stableId: 4, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 4), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66003, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[peerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_7_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [])
|
||||
messages[message4.id] = message4
|
||||
sampleMessages.append(message4)
|
||||
|
||||
let message5 = Message(stableId: 5, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 5), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66004, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [])
|
||||
let message5 = Message(stableId: 5, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 5), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: 66004, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_1_Text, attributes: [ReplyMessageAttribute(messageId: message4.id, threadMessageId: nil)], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: [])
|
||||
messages[message5.id] = message5
|
||||
sampleMessages.append(message5)
|
||||
|
||||
|
@ -318,6 +318,7 @@ struct WallpaperColorPanelNodeState: Equatable {
|
||||
var rotation: Int32
|
||||
var preview: Bool
|
||||
var simpleGradientGeneration: Bool
|
||||
var suggestedNewColor: HSBColor?
|
||||
}
|
||||
|
||||
private final class ColorSampleItemNode: ASImageNode {
|
||||
@ -707,6 +708,8 @@ final class WallpaperColorPanelNode: ASDisplayNode {
|
||||
hsb.0 += 0.05
|
||||
}
|
||||
current.colors.append(HSBColor(values: hsb))
|
||||
} else if let suggestedNewColor = current.suggestedNewColor {
|
||||
current.colors.append(suggestedNewColor)
|
||||
} else {
|
||||
current.colors.append(current.colors[current.colors.count - 1])
|
||||
}
|
||||
|
@ -710,7 +710,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-433014407] = { return Api.InputWallPaper.parse_inputWallPaper($0) }
|
||||
dict[1913199744] = { return Api.InputWallPaper.parse_inputWallPaperSlug($0) }
|
||||
dict[-1770371538] = { return Api.InputWallPaper.parse_inputWallPaperNoFile($0) }
|
||||
dict[-13043438] = { return Api.InputThemeSettings.parse_inputThemeSettings($0) }
|
||||
dict[-1881255857] = { return Api.InputThemeSettings.parse_inputThemeSettings($0) }
|
||||
dict[1251549527] = { return Api.InputStickeredMedia.parse_inputStickeredMediaPhoto($0) }
|
||||
dict[70813275] = { return Api.InputStickeredMedia.parse_inputStickeredMediaDocument($0) }
|
||||
dict[1421174295] = { return Api.WebPageAttribute.parse_webPageAttributeTheme($0) }
|
||||
@ -865,7 +865,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-402474788] = { return Api.Theme.parse_theme($0) }
|
||||
dict[-1290580579] = { return Api.contacts.Found.parse_found($0) }
|
||||
dict[-368018716] = { return Api.ChannelAdminLogEventsFilter.parse_channelAdminLogEventsFilter($0) }
|
||||
dict[-1917524116] = { return Api.ThemeSettings.parse_themeSettings($0) }
|
||||
dict[-94849324] = { return Api.ThemeSettings.parse_themeSettings($0) }
|
||||
dict[-1353671392] = { return Api.PeerNotifySettings.parse_peerNotifySettings($0) }
|
||||
dict[-1995686519] = { return Api.InputBotInlineMessageID.parse_inputBotInlineMessageID($0) }
|
||||
dict[-1227287081] = { return Api.InputBotInlineMessageID.parse_inputBotInlineMessageID64($0) }
|
||||
|
@ -18446,17 +18446,18 @@ public extension Api {
|
||||
|
||||
}
|
||||
public enum InputThemeSettings: TypeConstructorDescription {
|
||||
case inputThemeSettings(flags: Int32, baseTheme: Api.BaseTheme, accentColor: Int32, messageColors: [Int32]?, wallpaper: Api.InputWallPaper?, wallpaperSettings: Api.WallPaperSettings?)
|
||||
case inputThemeSettings(flags: Int32, baseTheme: Api.BaseTheme, accentColor: Int32, outboxAccentColor: Int32?, messageColors: [Int32]?, wallpaper: Api.InputWallPaper?, wallpaperSettings: Api.WallPaperSettings?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .inputThemeSettings(let flags, let baseTheme, let accentColor, let messageColors, let wallpaper, let wallpaperSettings):
|
||||
case .inputThemeSettings(let flags, let baseTheme, let accentColor, let outboxAccentColor, let messageColors, let wallpaper, let wallpaperSettings):
|
||||
if boxed {
|
||||
buffer.appendInt32(-13043438)
|
||||
buffer.appendInt32(-1881255857)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
baseTheme.serialize(buffer, true)
|
||||
serializeInt32(accentColor, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 3) != 0 {serializeInt32(outboxAccentColor!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 0) != 0 {buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(messageColors!.count))
|
||||
for item in messageColors! {
|
||||
@ -18470,8 +18471,8 @@ public extension Api {
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .inputThemeSettings(let flags, let baseTheme, let accentColor, let messageColors, let wallpaper, let wallpaperSettings):
|
||||
return ("inputThemeSettings", [("flags", flags), ("baseTheme", baseTheme), ("accentColor", accentColor), ("messageColors", messageColors), ("wallpaper", wallpaper), ("wallpaperSettings", wallpaperSettings)])
|
||||
case .inputThemeSettings(let flags, let baseTheme, let accentColor, let outboxAccentColor, let messageColors, let wallpaper, let wallpaperSettings):
|
||||
return ("inputThemeSettings", [("flags", flags), ("baseTheme", baseTheme), ("accentColor", accentColor), ("outboxAccentColor", outboxAccentColor), ("messageColors", messageColors), ("wallpaper", wallpaper), ("wallpaperSettings", wallpaperSettings)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -18484,26 +18485,29 @@ public extension Api {
|
||||
}
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
var _4: [Int32]?
|
||||
var _4: Int32?
|
||||
if Int(_1!) & Int(1 << 3) != 0 {_4 = reader.readInt32() }
|
||||
var _5: [Int32]?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {if let _ = reader.readInt32() {
|
||||
_4 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self)
|
||||
_5 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self)
|
||||
} }
|
||||
var _5: Api.InputWallPaper?
|
||||
var _6: Api.InputWallPaper?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
|
||||
_5 = Api.parse(reader, signature: signature) as? Api.InputWallPaper
|
||||
_6 = Api.parse(reader, signature: signature) as? Api.InputWallPaper
|
||||
} }
|
||||
var _6: Api.WallPaperSettings?
|
||||
var _7: Api.WallPaperSettings?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
|
||||
_6 = Api.parse(reader, signature: signature) as? Api.WallPaperSettings
|
||||
_7 = Api.parse(reader, signature: signature) as? Api.WallPaperSettings
|
||||
} }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
|
||||
let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil
|
||||
let _c4 = (Int(_1!) & Int(1 << 3) == 0) || _4 != nil
|
||||
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil
|
||||
let _c6 = (Int(_1!) & Int(1 << 1) == 0) || _6 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||
return Api.InputThemeSettings.inputThemeSettings(flags: _1!, baseTheme: _2!, accentColor: _3!, messageColors: _4, wallpaper: _5, wallpaperSettings: _6)
|
||||
let _c7 = (Int(_1!) & Int(1 << 1) == 0) || _7 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
|
||||
return Api.InputThemeSettings.inputThemeSettings(flags: _1!, baseTheme: _2!, accentColor: _3!, outboxAccentColor: _4, messageColors: _5, wallpaper: _6, wallpaperSettings: _7)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
@ -22118,17 +22122,18 @@ public extension Api {
|
||||
|
||||
}
|
||||
public enum ThemeSettings: TypeConstructorDescription {
|
||||
case themeSettings(flags: Int32, baseTheme: Api.BaseTheme, accentColor: Int32, messageColors: [Int32]?, wallpaper: Api.WallPaper?)
|
||||
case themeSettings(flags: Int32, baseTheme: Api.BaseTheme, accentColor: Int32, outboxAccentColor: Int32?, messageColors: [Int32]?, wallpaper: Api.WallPaper?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .themeSettings(let flags, let baseTheme, let accentColor, let messageColors, let wallpaper):
|
||||
case .themeSettings(let flags, let baseTheme, let accentColor, let outboxAccentColor, let messageColors, let wallpaper):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1917524116)
|
||||
buffer.appendInt32(-94849324)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
baseTheme.serialize(buffer, true)
|
||||
serializeInt32(accentColor, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 3) != 0 {serializeInt32(outboxAccentColor!, buffer: buffer, boxed: false)}
|
||||
if Int(flags) & Int(1 << 0) != 0 {buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(messageColors!.count))
|
||||
for item in messageColors! {
|
||||
@ -22141,8 +22146,8 @@ public extension Api {
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .themeSettings(let flags, let baseTheme, let accentColor, let messageColors, let wallpaper):
|
||||
return ("themeSettings", [("flags", flags), ("baseTheme", baseTheme), ("accentColor", accentColor), ("messageColors", messageColors), ("wallpaper", wallpaper)])
|
||||
case .themeSettings(let flags, let baseTheme, let accentColor, let outboxAccentColor, let messageColors, let wallpaper):
|
||||
return ("themeSettings", [("flags", flags), ("baseTheme", baseTheme), ("accentColor", accentColor), ("outboxAccentColor", outboxAccentColor), ("messageColors", messageColors), ("wallpaper", wallpaper)])
|
||||
}
|
||||
}
|
||||
|
||||
@ -22155,21 +22160,24 @@ public extension Api {
|
||||
}
|
||||
var _3: Int32?
|
||||
_3 = reader.readInt32()
|
||||
var _4: [Int32]?
|
||||
var _4: Int32?
|
||||
if Int(_1!) & Int(1 << 3) != 0 {_4 = reader.readInt32() }
|
||||
var _5: [Int32]?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {if let _ = reader.readInt32() {
|
||||
_4 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self)
|
||||
_5 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self)
|
||||
} }
|
||||
var _5: Api.WallPaper?
|
||||
var _6: Api.WallPaper?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
|
||||
_5 = Api.parse(reader, signature: signature) as? Api.WallPaper
|
||||
_6 = Api.parse(reader, signature: signature) as? Api.WallPaper
|
||||
} }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
|
||||
let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 {
|
||||
return Api.ThemeSettings.themeSettings(flags: _1!, baseTheme: _2!, accentColor: _3!, messageColors: _4, wallpaper: _5)
|
||||
let _c4 = (Int(_1!) & Int(1 << 3) == 0) || _4 != nil
|
||||
let _c5 = (Int(_1!) & Int(1 << 0) == 0) || _5 != nil
|
||||
let _c6 = (Int(_1!) & Int(1 << 1) == 0) || _6 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||
return Api.ThemeSettings.themeSettings(flags: _1!, baseTheme: _2!, accentColor: _3!, outboxAccentColor: _4, messageColors: _5, wallpaper: _6)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
@ -46,8 +46,8 @@ extension TelegramBaseTheme {
|
||||
extension TelegramThemeSettings {
|
||||
convenience init?(apiThemeSettings: Api.ThemeSettings) {
|
||||
switch apiThemeSettings {
|
||||
case let .themeSettings(flags, baseTheme, accentColor, messageColors, wallpaper):
|
||||
self.init(baseTheme: TelegramBaseTheme(apiBaseTheme: baseTheme), accentColor: UInt32(bitPattern: accentColor), messageColors: messageColors?.map(UInt32.init(bitPattern:)) ?? [], animateMessageColors: (flags & 1 << 2) != 0, wallpaper: wallpaper.flatMap(TelegramWallpaper.init(apiWallpaper:)))
|
||||
case let .themeSettings(flags, baseTheme, accentColor, outboxAccentColor, messageColors, wallpaper):
|
||||
self.init(baseTheme: TelegramBaseTheme(apiBaseTheme: baseTheme), accentColor: UInt32(bitPattern: accentColor), outgoingAccentColor: outboxAccentColor.flatMap { UInt32(bitPattern: $0) }, messageColors: messageColors?.map(UInt32.init(bitPattern:)) ?? [], animateMessageColors: (flags & 1 << 2) != 0, wallpaper: wallpaper.flatMap(TelegramWallpaper.init(apiWallpaper:)))
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,6 +61,10 @@ extension TelegramThemeSettings {
|
||||
flags |= 1 << 2
|
||||
}
|
||||
|
||||
if let _ = self.outgoingAccentColor {
|
||||
flags |= 1 << 3
|
||||
}
|
||||
|
||||
var inputWallpaper: Api.InputWallPaper?
|
||||
var inputWallpaperSettings: Api.WallPaperSettings?
|
||||
if let wallpaper = self.wallpaper, let inputWallpaperAndSettings = wallpaper.apiInputWallpaperAndSettings {
|
||||
@ -69,6 +73,6 @@ extension TelegramThemeSettings {
|
||||
flags |= 1 << 1
|
||||
}
|
||||
|
||||
return .inputThemeSettings(flags: flags, baseTheme: self.baseTheme.apiBaseTheme, accentColor: Int32(bitPattern: self.accentColor), messageColors: self.messageColors.isEmpty ? nil : self.messageColors.map(Int32.init(bitPattern:)), wallpaper: inputWallpaper, wallpaperSettings: inputWallpaperSettings)
|
||||
return .inputThemeSettings(flags: flags, baseTheme: self.baseTheme.apiBaseTheme, accentColor: Int32(bitPattern: self.accentColor), outboxAccentColor: self.outgoingAccentColor.flatMap { Int32(bitPattern: $0) }, messageColors: self.messageColors.isEmpty ? nil : self.messageColors.map(Int32.init(bitPattern:)), wallpaper: inputWallpaper, wallpaperSettings: inputWallpaperSettings)
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,9 @@ public final class TelegramThemeSettings: PostboxCoding, Equatable {
|
||||
if lhs.accentColor != rhs.accentColor {
|
||||
return false
|
||||
}
|
||||
if lhs.outgoingAccentColor != rhs.outgoingAccentColor {
|
||||
return false
|
||||
}
|
||||
if lhs.messageColors != rhs.messageColors {
|
||||
return false
|
||||
}
|
||||
@ -35,13 +38,15 @@ public final class TelegramThemeSettings: PostboxCoding, Equatable {
|
||||
|
||||
public let baseTheme: TelegramBaseTheme
|
||||
public let accentColor: UInt32
|
||||
public let outgoingAccentColor: UInt32?
|
||||
public let messageColors: [UInt32]
|
||||
public let animateMessageColors: Bool
|
||||
public let wallpaper: TelegramWallpaper?
|
||||
|
||||
public init(baseTheme: TelegramBaseTheme, accentColor: UInt32, messageColors: [UInt32], animateMessageColors: Bool, wallpaper: TelegramWallpaper?) {
|
||||
public init(baseTheme: TelegramBaseTheme, accentColor: UInt32, outgoingAccentColor: UInt32?, messageColors: [UInt32], animateMessageColors: Bool, wallpaper: TelegramWallpaper?) {
|
||||
self.baseTheme = baseTheme
|
||||
self.accentColor = accentColor
|
||||
self.outgoingAccentColor = outgoingAccentColor
|
||||
self.messageColors = messageColors
|
||||
self.animateMessageColors = animateMessageColors
|
||||
self.wallpaper = wallpaper
|
||||
@ -50,6 +55,7 @@ public final class TelegramThemeSettings: PostboxCoding, Equatable {
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.baseTheme = TelegramBaseTheme(rawValue: decoder.decodeInt32ForKey("baseTheme", orElse: 0)) ?? .classic
|
||||
self.accentColor = UInt32(bitPattern: decoder.decodeInt32ForKey("accent", orElse: 0))
|
||||
self.outgoingAccentColor = decoder.decodeOptionalInt32ForKey("outgoingAccent").flatMap { UInt32(bitPattern: $0) }
|
||||
let messageColors = decoder.decodeInt32ArrayForKey("messageColors")
|
||||
if !messageColors.isEmpty {
|
||||
self.messageColors = messageColors.map(UInt32.init(bitPattern:))
|
||||
@ -67,6 +73,11 @@ public final class TelegramThemeSettings: PostboxCoding, Equatable {
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeInt32(self.baseTheme.rawValue, forKey: "baseTheme")
|
||||
encoder.encodeInt32(Int32(bitPattern: self.accentColor), forKey: "accent")
|
||||
if let outgoingAccentColor = self.outgoingAccentColor {
|
||||
encoder.encodeInt32(Int32(bitPattern: outgoingAccentColor), forKey: "outgoingAccent")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "outgoingAccent")
|
||||
}
|
||||
encoder.encodeInt32Array(self.messageColors.map(Int32.init(bitPattern:)), forKey: "messageColors")
|
||||
encoder.encodeInt32(self.animateMessageColors ? 1 : 0, forKey: "animateMessageColors")
|
||||
if let wallpaper = self.wallpaper {
|
||||
|
@ -35,7 +35,7 @@ public let defaultServiceBackgroundColor = UIColor(rgb: 0x000000, alpha: 0.2)
|
||||
public let defaultPresentationTheme = makeDefaultDayPresentationTheme(serviceBackgroundColor: defaultServiceBackgroundColor, day: false, preview: false)
|
||||
public let defaultDayAccentColor = UIColor(rgb: 0x007ee5)
|
||||
|
||||
public func customizeDefaultDayTheme(theme: PresentationTheme, specialMode: Bool = false, editing: Bool, title: String?, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: [UInt32], animateBubbleColors: Bool?, wallpaper forcedWallpaper: TelegramWallpaper? = nil, serviceBackgroundColor: UIColor?) -> PresentationTheme {
|
||||
public func customizeDefaultDayTheme(theme: PresentationTheme, specialMode: Bool = false, editing: Bool, title: String?, accentColor: UIColor?, outgoingAccentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: [UInt32], animateBubbleColors: Bool?, wallpaper forcedWallpaper: TelegramWallpaper? = nil, serviceBackgroundColor: UIColor?) -> PresentationTheme {
|
||||
if (theme.referenceTheme != .day && theme.referenceTheme != .dayClassic) {
|
||||
return theme
|
||||
}
|
||||
@ -52,7 +52,7 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, specialMode: Bool
|
||||
var suggestedWallpaper: TelegramWallpaper?
|
||||
|
||||
var bubbleColors = bubbleColors
|
||||
if specialMode, bubbleColors.count < 3, let color = bubbleColors.first.flatMap({ UIColor(rgb: $0) }) {
|
||||
if specialMode, outgoingAccentColor == nil, bubbleColors.count < 3, let color = bubbleColors.first.flatMap({ UIColor(rgb: $0) }) {
|
||||
let colorHSB = color.hsb
|
||||
if colorHSB.b > 0.9 {
|
||||
let bubbleColor = color.withMultiplied(hue: 0.9, saturation: 1.3, brightness: 1.0)
|
||||
@ -105,22 +105,30 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, specialMode: Bool
|
||||
if day {
|
||||
let accentColor = accentColor ?? defaultDayAccentColor
|
||||
bubbleColors = [accentColor.withMultiplied(hue: 0.966, saturation: 0.61, brightness: 0.98).rgb, accentColor.rgb]
|
||||
outgoingAccent = outgoingAccentColor
|
||||
} else {
|
||||
if let accentColor = accentColor, !accentColor.alpha.isZero {
|
||||
let hsb = accentColor.hsb
|
||||
bubbleColors = [UIColor(hue: hsb.0, saturation: (hsb.1 > 0.0 && hsb.2 > 0.0) ? 0.14 : 0.0, brightness: 0.79 + hsb.2 * 0.21, alpha: 1.0).rgb]
|
||||
if accentColor.lightness > 0.705 {
|
||||
outgoingAccent = UIColor(hue: hsb.0, saturation: min(1.0, hsb.1 * 1.1), brightness: min(hsb.2, 0.6), alpha: 1.0)
|
||||
if let outgoingAccentColor = outgoingAccentColor {
|
||||
outgoingAccent = outgoingAccentColor
|
||||
} else {
|
||||
outgoingAccent = accentColor
|
||||
if accentColor.lightness > 0.705 {
|
||||
outgoingAccent = UIColor(hue: hsb.0, saturation: min(1.0, hsb.1 * 1.1), brightness: min(hsb.2, 0.6), alpha: 1.0)
|
||||
} else {
|
||||
outgoingAccent = accentColor
|
||||
}
|
||||
}
|
||||
|
||||
suggestedWallpaper = .gradient(TelegramWallpaper.Gradient(id: nil, colors: defaultBuiltinWallpaperGradientColors.map(\.rgb), settings: WallpaperSettings()))
|
||||
} else {
|
||||
bubbleColors = [UIColor(rgb: 0xe1ffc7).rgb]
|
||||
suggestedWallpaper = .gradient(TelegramWallpaper.Gradient(id: nil, colors: defaultBuiltinWallpaperGradientColors.map(\.rgb), settings: WallpaperSettings()))
|
||||
outgoingAccent = outgoingAccentColor
|
||||
}
|
||||
}
|
||||
} else {
|
||||
outgoingAccent = outgoingAccentColor
|
||||
}
|
||||
}
|
||||
|
||||
@ -217,10 +225,10 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, specialMode: Bool
|
||||
outgoingAccentTextColor = outgoingAccent
|
||||
outgoingLinkTextColor = outgoingAccent
|
||||
outgoingScamColor = UIColor(rgb: 0xff3b30)
|
||||
outgoingControlColor = outgoingAccent
|
||||
outgoingControlColor = outgoingAccent.withMultiplied(hue: 0.983, saturation: 0.7, brightness: 1.169)
|
||||
outgoingInactiveControlColor = outgoingAccent
|
||||
outgoingFileTitleColor = outgoingAccent
|
||||
outgoingPollsProgressColor = accentColor
|
||||
outgoingPollsProgressColor = outgoingControlColor
|
||||
outgoingSelectionColor = outgoingAccent.withMultiplied(hue: 1.0, saturation: 1.292, brightness: 0.871)
|
||||
outgoingSelectionBaseColor = outgoingControlColor
|
||||
outgoingCheckColor = outgoingAccent
|
||||
|
@ -19,13 +19,13 @@ public func makeDefaultPresentationTheme(reference: PresentationBuiltinThemeRefe
|
||||
return theme
|
||||
}
|
||||
|
||||
public func customizePresentationTheme(_ theme: PresentationTheme, specialMode: Bool = false, editing: Bool, title: String? = nil, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: [UInt32], animateBubbleColors: Bool?, wallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil) -> PresentationTheme {
|
||||
public func customizePresentationTheme(_ theme: PresentationTheme, specialMode: Bool = false, editing: Bool, title: String? = nil, accentColor: UIColor?, outgoingAccentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: [UInt32], animateBubbleColors: Bool?, wallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil) -> PresentationTheme {
|
||||
if accentColor == nil && bubbleColors.isEmpty && backgroundColors.isEmpty && wallpaper == nil {
|
||||
return theme
|
||||
}
|
||||
switch theme.referenceTheme {
|
||||
case .day, .dayClassic:
|
||||
return customizeDefaultDayTheme(theme: theme, specialMode: specialMode, editing: editing, title: title, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, animateBubbleColors: animateBubbleColors ?? false, wallpaper: wallpaper, serviceBackgroundColor: nil)
|
||||
return customizeDefaultDayTheme(theme: theme, specialMode: specialMode, editing: editing, title: title, accentColor: accentColor, outgoingAccentColor: outgoingAccentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, animateBubbleColors: animateBubbleColors ?? false, wallpaper: wallpaper, serviceBackgroundColor: nil)
|
||||
case .night:
|
||||
return customizeDefaultDarkPresentationTheme(theme: theme, editing: editing, title: title, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, animateBubbleColors: animateBubbleColors ?? false, wallpaper: wallpaper, baseColor: baseColor)
|
||||
case .nightAccent:
|
||||
@ -45,30 +45,30 @@ public func makePresentationTheme(settings: TelegramThemeSettings, specialMode:
|
||||
}
|
||||
}
|
||||
let defaultTheme = makeDefaultPresentationTheme(reference: PresentationBuiltinThemeReference(baseTheme: baseTheme), extendingThemeReference: nil, serviceBackgroundColor: serviceBackgroundColor, preview: false)
|
||||
return customizePresentationTheme(defaultTheme, specialMode: specialMode, editing: true, title: title, accentColor: UIColor(argb: settings.accentColor), backgroundColors: [], bubbleColors: settings.messageColors, animateBubbleColors: settings.animateMessageColors, wallpaper: chatWallpaper)
|
||||
return customizePresentationTheme(defaultTheme, specialMode: specialMode, editing: true, title: title, accentColor: UIColor(argb: settings.accentColor), outgoingAccentColor: settings.outgoingAccentColor.flatMap { UIColor(argb: $0) }, backgroundColors: [], bubbleColors: settings.messageColors, animateBubbleColors: settings.animateMessageColors, wallpaper: chatWallpaper)
|
||||
}
|
||||
|
||||
public func makePresentationTheme(mediaBox: MediaBox, themeReference: PresentationThemeReference, extendingThemeReference: PresentationThemeReference? = nil, accentColor: UIColor? = nil, backgroundColors: [UInt32] = [], bubbleColors: [UInt32] = [], animateBubbleColors: Bool? = nil, wallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil, serviceBackgroundColor: UIColor? = nil, specialMode: Bool = false, preview: Bool = false) -> PresentationTheme? {
|
||||
public func makePresentationTheme(mediaBox: MediaBox, themeReference: PresentationThemeReference, extendingThemeReference: PresentationThemeReference? = nil, accentColor: UIColor? = nil, outgoingAccentColor: UIColor? = nil, backgroundColors: [UInt32] = [], bubbleColors: [UInt32] = [], animateBubbleColors: Bool? = nil, wallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil, serviceBackgroundColor: UIColor? = nil, specialMode: Bool = false, 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, specialMode: specialMode, editing: true, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, animateBubbleColors: animateBubbleColors, wallpaper: wallpaper, baseColor: baseColor)
|
||||
theme = customizePresentationTheme(defaultTheme, specialMode: specialMode, editing: true, accentColor: accentColor, outgoingAccentColor: outgoingAccentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, animateBubbleColors: animateBubbleColors, 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, animateBubbleColors: animateBubbleColors, wallpaper: wallpaper)
|
||||
theme = customizePresentationTheme(loadedTheme, editing: false, accentColor: accentColor, outgoingAccentColor: outgoingAccentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, animateBubbleColors: animateBubbleColors, wallpaper: wallpaper)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
case let .cloud(info):
|
||||
if let settings = info.theme.settings {
|
||||
if let loadedTheme = makePresentationTheme(mediaBox: mediaBox, themeReference: .builtin(PresentationBuiltinThemeReference(baseTheme: settings.baseTheme)), extendingThemeReference: themeReference, accentColor: accentColor ?? UIColor(argb: settings.accentColor), backgroundColors: [], bubbleColors: bubbleColors.isEmpty ? settings.messageColors : bubbleColors, animateBubbleColors: animateBubbleColors ?? settings.animateMessageColors, wallpaper: wallpaper ?? settings.wallpaper, serviceBackgroundColor: serviceBackgroundColor, preview: preview) {
|
||||
if let loadedTheme = makePresentationTheme(mediaBox: mediaBox, themeReference: .builtin(PresentationBuiltinThemeReference(baseTheme: settings.baseTheme)), extendingThemeReference: themeReference, accentColor: accentColor ?? UIColor(argb: settings.accentColor), outgoingAccentColor: outgoingAccentColor ?? settings.outgoingAccentColor.flatMap { UIColor(argb: $0) }, backgroundColors: [], bubbleColors: bubbleColors.isEmpty ? settings.messageColors : bubbleColors, animateBubbleColors: animateBubbleColors ?? settings.animateMessageColors, wallpaper: wallpaper ?? settings.wallpaper, serviceBackgroundColor: serviceBackgroundColor, preview: preview) {
|
||||
theme = loadedTheme
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
} else if let file = info.theme.file, let path = mediaBox.completedResourcePath(file.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, animateBubbleColors: animateBubbleColors, wallpaper: wallpaper)
|
||||
theme = customizePresentationTheme(loadedTheme, editing: false, accentColor: accentColor, outgoingAccentColor: outgoingAccentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, animateBubbleColors: animateBubbleColors, wallpaper: wallpaper)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user