Various theme editing imrpovements

This commit is contained in:
Ilya Laktyushin 2021-08-18 00:46:30 +04:00
parent 46917eaaf3
commit ce97e49ed7
15 changed files with 251 additions and 141 deletions

View File

@ -6608,3 +6608,41 @@ Sorry for the inconvenience.";
"Conversation.ForwardOptions.Messages_0" = "%@ messages";
"Conversation.ForwardOptions.You" = "You (senders' names hidden)";
"Activity.ChoosingSticker" = "choosing sticker";
"WallpaperPreview.Animate" = "Animate";
"WallpaperPreview.AnimateDescription" = "Colors will move when you send messages";
"Appstore.Cloud" = "**Cloud-based**\nUnlimited storage for chats,\nmedia and documents.";
"Appstore.Cloud.Profile" = "**Jennifer**\n23 y.o. designer from San Francisco.";
"Appstore.Creative" = "**Creative**\nColor themes, stickers, GIFs,\nvideo messages and more.";
"Appstore.Creative.Chat" = "**You**\nSend a dice emoji to roll a die!\n**You**\nAdvance to Illinois Ave. If you pass Go, collect coffee\n**Gabriella**\nPassed!\n**You**\nOkay\nWait for me there.";
"Appstore.Creative.Chat.Name" = "**Gabriella**";
"Appstore.Fast" = "**Fast**\nSimple, reliable and synced\nacross all your devices.";
"Appstore.Fast.Chat1" = "**Alicia Torreaux**\nBob says hi.";
"Appstore.Fast.Chat2" = "**Roberto**\nSay hello to Alice.";
"Appstore.Fast.Chat3" = "**Digital Nomads**\nJennie\nWe just reached 2,500 members! WOO!";
"Appstore.Fast.Chat4" = "**Veronica**\nTable for four, 2 PM. Be there.";
"Appstore.Fast.Chat5" = "**Animal Videos**\nVote now! Moar cat videos in this channel?";
"Appstore.Fast.Chat6" = "**Little Sister**\nDon't tell mom yet, but I got the job! I'm going to ROME!";
"Appstore.Fast.Chat7" = "**James**\nCheck these out";
"Appstore.Fast.Chat8" = "**Study Group**\nEmma\nSticker";
"Appstore.Fast.Chat9" = "**Digital Nomads**";
"Appstore.Free.Chat" = "**Jessica**\nPaper airplane is lyfted by...\nWings\nPropeller\n**You**\nIs this from Mondays test?\n**Harry**\nOnlinePartyPlan.ppd\nLet's get back to planning!\n**You**\n550 MB keynote file??\n**Helene**\nHe added fireworks videos";
"Appstore.Free.Chat.Name" = "**Study Group**";
"Appstore.Open" = "**Open**\nNo ads, no fees. Open source\ncode free for everyone.";
"Appstore.Powerful" = "**Powerful**\nNo limits on the size of\ngroups and broadcasts.";
"Appstore.Powerful.Chat" = "**James**\nGood morning!\n\nDwayne joined the group\n\n**You**\nDo you have any idea what time it is?\n**Roxanne**\nIs it still morning?\nSure!\nNot sure\n**Emma**\nVoice";
"Appstore.Private" = "**Private**\nYour data is never disclosed.\nOnly you are in control.";
"Appstore.Private.Chat" = "**You**\nNo limits on the size of your cats.";
"Appstore.Private.Chat.Name" = "**Beatrice**";
"Appstore.Public" = "**Public**\nPublic channels, open groups,\nbots for integrations.";
"Appstore.Public.Chat1" = "**Financial Times**\nTruth is like the sun. You can shut it out for a time, but it aint goin away.";
"Appstore.Public.Chat2" = "**Bloomberg**\nWe'll be sending you a few big stories daily, which you can expect to start...";
"Appstore.Public.Chat3" = "**Health and Safety**\nIf you're looking for official news about the Novel Coronavirus and COVID-19";
"Appstore.Public.IV" = "We now have enough data to measure the relative effectiveness of major climate solutions. This simulator lets you see which ones would work best.\n\nBloomberg\n\nThe Best Way to Slow Global Warming? You Decide in This Climate Simulator\nIt was on Earth Day 2016 when more than 170 nations signed the Paris Agreement calling for limiting global warming \"to well below 2°C\".";
"Appstore.Secure" = "**Secure**\nAll chats are protected\nwith strong encryption.";
"Appstore.Secure.Chat" = "**Little Sister**\nAny gift ideas for mom?\n**You**A dog!\n**You**I'm serious. Let's get her a puppy. \n**You**\nI saw this!\n**Little Sister**\nI needed proof this was your idea!";
"Appstore.Secure.Chat.Name" = "**Little Sister**";

View File

@ -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], wallpaper: TelegramWallpaper?) {
self.init(baseTheme: baseTheme, accentColor: accentColor.argb, messageColors: messageColors, wallpaper: wallpaper)
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)
}
}
@ -203,11 +203,11 @@ 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 }, 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 }, wallpaper: state.initialWallpaper ?? coloredWallpaper)
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)
}
if hasSettings, let baseTheme = baseTheme {
settings = TelegramThemeSettings(baseTheme: baseTheme, accentColor: state.accentColor.color, messageColors: state.messagesColors.map { $0.rgb }, wallpaper: coloredWallpaper)
settings = TelegramThemeSettings(baseTheme: baseTheme, accentColor: state.accentColor.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 }, wallpaper: wallpaper)
let settings = TelegramThemeSettings(baseTheme: baseTheme, accentColor: state.accentColor.rgb, messageColors: state.messagesColors.map { $0.rgb }, animateMessageColors: state.animateMessageColors, wallpaper: wallpaper)
let baseThemeReference = PresentationThemeReference.builtin(PresentationBuiltinThemeReference(baseTheme: baseTheme))
let apply: Signal<Void, CreateThemeError>
@ -552,7 +552,7 @@ final class ThemeAccentColorController: ViewController {
messageColors = []
}
let initialState = ThemeColorState(section: strongSelf.section, accentColor: HSBColor(color: accentColor), initialWallpaper: initialWallpaper, backgroundColors: backgroundColors.map { HSBColor(rgb: $0) }, patternWallpaper: patternWallpaper, patternIntensity: patternIntensity, defaultMessagesColor: defaultMessagesColor.flatMap { HSBColor(color: $0) }, messagesColors: messageColors.map { HSBColor(rgb: $0) }, rotation: rotation)
let initialState = ThemeColorState(section: strongSelf.section, accentColor: HSBColor(color: accentColor), initialWallpaper: initialWallpaper, backgroundColors: backgroundColors.map { HSBColor(rgb: $0) }, patternWallpaper: patternWallpaper, patternIntensity: patternIntensity, animateMessageColors: false, defaultMessagesColor: defaultMessagesColor.flatMap { HSBColor(color: $0) }, messagesColors: messageColors.map { HSBColor(rgb: $0) }, selectedColor: 0, rotation: rotation)
strongSelf.controllerNode.updateState({ _ in
return initialState

View File

@ -48,9 +48,12 @@ struct ThemeColorState {
var patternWallpaper: TelegramWallpaper?
var patternIntensity: Int32
var animateMessageColors: Bool
var defaultMessagesColor: HSBColor?
var messagesColors: [HSBColor]
var selectedColor: Int
var rotation: Int32
init() {
@ -64,12 +67,14 @@ struct ThemeColorState {
self.previousPatternWallpaper = nil
self.patternWallpaper = nil
self.patternIntensity = 50
self.animateMessageColors = false
self.defaultMessagesColor = nil
self.messagesColors = []
self.selectedColor = 0
self.rotation = 0
}
init(section: ThemeColorSection, accentColor: HSBColor, initialWallpaper: TelegramWallpaper?, backgroundColors: [HSBColor], patternWallpaper: TelegramWallpaper?, patternIntensity: Int32, defaultMessagesColor: HSBColor?, messagesColors: [HSBColor], rotation: Int32 = 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) {
self.section = section
self.colorPanelCollapsed = false
self.displayPatternPanel = false
@ -80,8 +85,10 @@ struct ThemeColorState {
self.previousPatternWallpaper = nil
self.patternWallpaper = patternWallpaper
self.patternIntensity = patternIntensity
self.animateMessageColors = animateMessageColors
self.defaultMessagesColor = defaultMessagesColor
self.messagesColors = messagesColors
self.selectedColor = selectedColor
self.rotation = rotation
}
@ -98,17 +105,21 @@ struct ThemeColorState {
if self.patternIntensity != otherState.patternIntensity {
return false
}
if self.rotation != otherState.rotation {
if self.animateMessageColors != otherState.animateMessageColors {
return false
}
if self.backgroundColors != otherState.backgroundColors {
return false
}
if self.messagesColors != otherState.messagesColors {
return false
}
if self.selectedColor != otherState.selectedColor {
return false
}
if self.rotation != otherState.rotation {
return false
}
return true
}
}
@ -324,7 +335,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
self.colorsButtonNode.addTarget(self, action: #selector(self.toggleColors), forControlEvents: .touchUpInside)
self.playButtonNode.addTarget(self, action: #selector(self.playPressed), forControlEvents: .touchUpInside)
self.colorPanelNode.colorsChanged = { [weak self] colors, ended in
self.colorPanelNode.colorsChanged = { [weak self] colors, selectedColor, ended in
if let strongSelf = self, let section = strongSelf.state.section {
strongSelf.updateState({ current in
var updated = current
@ -339,8 +350,9 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
case .messages:
updated.messagesColors = colors
}
updated.selectedColor = selectedColor
return updated
})
}, animated: true)
}
}
@ -472,9 +484,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 }, serviceBackgroundColor: serviceBackgroundColor, preview: true) ?? defaultPresentationTheme
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
} 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 })
updatedTheme = customizePresentationTheme(theme, editing: false, accentColor: accentColor.color, backgroundColors: backgroundColors.map { $0.rgb }, bubbleColors: messagesColors.map { $0.rgb }, animateBubbleColors: state.animateMessageColors)
} else {
updatedTheme = theme
}
@ -516,8 +528,6 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
strongSelf.wallpaper = wallpaper
strongSelf.patternArguments = patternArguments
strongSelf.colorsButtonNode.colors = backgroundColors.map { $0.color }
if !preview {
if !backgroundColors.isEmpty {
strongSelf.currentBackgroundColors = (backgroundColors, strongSelf.state.rotation, strongSelf.state.patternIntensity)
@ -592,6 +602,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
}
}
private var crossfadeBubbles = false
func updateState(_ f: (ThemeColorState) -> ThemeColorState, animated: Bool = false) {
let previousState = self.state
self.state = f(self.state)
@ -613,14 +624,24 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
}
}
if (previousState.patternWallpaper != nil) != (self.state.patternWallpaper != nil) {
let sectionChanged = previousState.section != self.state.section
if self.state.section == .background {
if (previousState.patternWallpaper != nil) != (self.state.patternWallpaper != nil) || sectionChanged {
self.patternButtonNode.setSelected(self.state.patternWallpaper != nil, animated: animated)
}
} else if self.state.section == .messages {
if previousState.animateMessageColors != self.state.animateMessageColors || sectionChanged {
self.crossfadeBubbles = true
self.patternButtonNode.setSelected(self.state.animateMessageColors, animated: animated)
}
}
let sectionChanged = previousState.section != self.state.section
if sectionChanged, let section = self.state.section {
self.view.endEditing(true)
self.patternButtonNode.title = section == .messages ? self.presentationData.strings.WallpaperPreview_Animate : self.presentationData.strings.WallpaperPreview_Pattern
var colors: [HSBColor]
var defaultColor: HSBColor?
switch section {
@ -688,6 +709,8 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
needsLayout = true
}
self.colorsButtonNode.colors = state.section == .messages ? state.messagesColors.map { $0.color } : state.backgroundColors.map { $0.color }
if previousState.colorPanelCollapsed != self.state.colorPanelCollapsed {
animationCurve = .spring
animationDuration = 0.45
@ -731,6 +754,17 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
needsLayout = true
}
if previousState.messagesColors.count != self.state.messagesColors.count {
needsLayout = true
}
if previousState.selectedColor != self.state.selectedColor {
needsLayout = true
}
if let section = self.state.section {
switch section {
case .background:
if previousState.backgroundColors.count != self.state.backgroundColors.count {
if self.state.backgroundColors.count <= 2 {
self.playButtonNode.setImage(self.playButtonRotateImage, for: [])
@ -738,6 +772,12 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
self.playButtonNode.setImage(self.playButtonPlayImage, for: [])
}
}
case .accent:
break
case .messages:
self.playButtonNode.setImage(self.playButtonPlayImage, for: [])
}
}
self.colorsButtonNode.isSelected = !self.state.colorPanelCollapsed
@ -755,6 +795,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
updated.section = section
updated.displayPatternPanel = false
updated.colorPanelCollapsed = false
updated.selectedColor = 0
return updated
}, animated: true)
}
@ -884,22 +925,11 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
}
strongSelf.updateState({ state in
var state = state
//if state.section == .background {
state.colorPanelCollapsed = true
state.displayPatternPanel = false
//}
return state
}, animated: true)
/*if message.flags.contains(.Incoming) {
self?.updateSection(.accent)
self?.requestSectionUpdate?(.accent)
} else {
self?.updateSection(.messages)
self?.requestSectionUpdate?(.messages)
}*/
}, clickThroughMessage: { [weak self] in
self?.updateSection(.background)
self?.requestSectionUpdate?(.background)
}, clickThroughMessage: {
}, backgroundNode: self.backgroundNode)
return item
}
@ -908,6 +938,18 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
if let messageNodes = self.messageNodes {
for i in 0 ..< items.count {
let itemNode = messageNodes[i]
if self.crossfadeBubbles {
if let snapshot = itemNode.view.snapshotView(afterScreenUpdates: false) {
snapshot.frame = itemNode.bounds
itemNode.view.addSubview(snapshot)
snapshot.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, completion: { [weak snapshot] _ in
snapshot?.removeFromSuperview()
})
}
}
items[i].updateNode(async: { $0() }, node: {
return itemNode
}, params: params, previousItem: i == 0 ? nil : items[i - 1], nextItem: i == (items.count - 1) ? nil : items[i + 1], animation: .None, completion: { (layout, apply) in
@ -920,6 +962,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
apply(ListViewItemApply(isOnScreen: true))
})
}
self.crossfadeBubbles = false
} else {
var messageNodes: [ListViewItemNode] = []
for i in 0 ..< items.count {
@ -928,22 +971,30 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
itemNode = node
apply().1(ListViewItemApply(isOnScreen: true))
})
//itemNode!.subnodeTransform = CATransform3DMakeScale(-1.0, 1.0, 1.0)
messageNodes.append(itemNode!)
self.messagesContainerNode.addSubnode(itemNode!)
}
self.messageNodes = messageNodes
}
let toolbarHeight = 49.0 + layout.intrinsicInsets.bottom
var relativeOffset: CGFloat = 0.0
if !self.state.colorPanelCollapsed {
relativeOffset = (CGFloat(self.state.selectedColor) / CGFloat(max(1, self.state.messagesColors.count))) * (self.colorPanelNode.frame.height + toolbarHeight + 144.0) * -1.0
}
let containerSize = CGSize(width: layout.size.width, height: layout.size.height - toolbarHeight - 44.0)
var bottomOffset: CGFloat = 9.0 + bottomInset
if let messageNodes = self.messageNodes {
for itemNode in messageNodes {
let previousFrame = itemNode.frame
transition.updateFrame(node: itemNode, frame: CGRect(origin: CGPoint(x: 0.0, y: bottomOffset), size: itemNode.frame.size))
bottomOffset += itemNode.frame.height
itemNode.updateFrame(itemNode.frame, within: layout.size)
let relativeFrame = itemNode.frame.offsetBy(dx: 0.0, dy: relativeOffset)
itemNode.updateAbsoluteRect(relativeFrame, within: containerSize)
if case let .animated(duration, curve) = transition {
itemNode.applyAbsoluteOffset(value: CGPoint(x: 0.0, y: -itemNode.frame.minY + previousFrame.minY), animationCurve: curve, duration: duration)
itemNode.applyAbsoluteOffset(value: CGPoint(x: 0.0, y: -relativeFrame.minY + previousFrame.minY), animationCurve: curve, duration: duration)
}
}
}
@ -954,7 +1005,6 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
headerItem.updateNode(dateHeaderNode, previous: nil, next: headerItem)
} else {
dateHeaderNode = headerItem.node(synchronousLoad: true)
//dateHeaderNode.subnodeTransform = CATransform3DMakeScale(-1.0, 1.0, 1.0)
self.messagesContainerNode.addSubnode(dateHeaderNode)
self.dateHeaderNode = dateHeaderNode
}
@ -1026,9 +1076,9 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
transition.updateBounds(node: self.backgroundWrapperNode, bounds: CGRect(origin: CGPoint(), size: layout.size))
let displayOptionButtons = self.state.section == .background
var messagesBottomInset: CGFloat = bottomInset
let displayOptionButtons = self.state.section == .background || self.state.section == .messages
var messagesBottomInset: CGFloat = bottomInset
if displayOptionButtons {
messagesBottomInset += 56.0
} else if chatListPreviewAvailable {
@ -1054,7 +1104,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
let maxButtonWidth = max(patternButtonSize.width, colorsButtonSize.width)
let buttonSize = CGSize(width: maxButtonWidth, height: 30.0)
let patternAlpha: CGFloat = displayOptionButtons ? 1.0 : 0.0
var patternAlpha: CGFloat = displayOptionButtons ? 1.0 : 0.0
let colorsAlpha: CGFloat = displayOptionButtons ? 1.0 : 0.0
let patternFrame: CGRect
@ -1067,15 +1117,30 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
let playFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - playButtonSize.width) / 2.0), y: layout.size.height - bottomInset - 44.0 - buttonsVerticalOffset + floor((buttonSize.height - playButtonSize.height) / 2.0)), size: playButtonSize)
let playAlpha: CGFloat
var centerButtons = false
if self.state.section == .background {
if self.state.backgroundColors.count >= 2 {
playAlpha = displayOptionButtons ? 1.0 : 0.0
centerDistance += playButtonSize.width
} else {
playAlpha = 0.0
}
} else if self.state.section == .messages {
if self.state.messagesColors.count >= 3 {
patternAlpha = 1.0
playAlpha = displayOptionButtons ? 1.0 : 0.0
centerDistance += playButtonSize.width
} else {
patternAlpha = 0.0
playAlpha = 0.0
centerButtons = true
}
} else {
playAlpha = 0.0
}
patternFrame = CGRect(origin: CGPoint(x: floor((layout.size.width - buttonSize.width * 2.0 - centerDistance) / 2.0), y: layout.size.height - bottomInset - 44.0 - buttonsVerticalOffset), size: buttonSize)
colorsFrame = CGRect(origin: CGPoint(x: patternFrame.maxX + centerDistance, y: layout.size.height - bottomInset - 44.0 - buttonsVerticalOffset), size: buttonSize)
patternFrame = CGRect(origin: CGPoint(x: centerButtons ? floor((layout.size.width - buttonSize.width) / 2.0) : floor((layout.size.width - buttonSize.width * 2.0 - centerDistance) / 2.0), y: layout.size.height - bottomInset - 44.0 - buttonsVerticalOffset), size: buttonSize)
colorsFrame = CGRect(origin: CGPoint(x: centerButtons ? floor((layout.size.width - buttonSize.width) / 2.0) : patternFrame.maxX + centerDistance, y: layout.size.height - bottomInset - 44.0 - buttonsVerticalOffset), size: buttonSize)
transition.updateFrame(node: self.patternButtonNode, frame: patternFrame)
transition.updateAlpha(node: self.patternButtonNode, alpha: patternAlpha)
@ -1089,6 +1154,13 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
}
@objc private func togglePattern() {
if self.state.section == .messages {
self.updateState({ current in
var updated = current
updated.animateMessageColors = !current.animateMessageColors
return updated
}, animated: true)
} else {
self.view.endEditing(true)
let wallpaper = self.state.previousPatternWallpaper ?? self.patternPanelNode.wallpapers.first
@ -1140,6 +1212,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
self.patternPanelNode.didAppear(initialWallpaper: wallpaper, intensity: self.state.patternIntensity)
}
}
}
@objc private func toggleColors() {
self.updateState({ current in
@ -1165,7 +1238,7 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate
} else {
self.updateState({ state in
var state = state
state.rotation = (state.rotation + 90) % 360
state.rotation = (state.rotation + 45) % 360
return state
}, animated: true)
}

View File

@ -390,7 +390,7 @@ final class WallpaperColorPanelNode: ASDisplayNode {
private var sampleItemNodes: [ColorSampleItemNode] = []
private let multiColorFieldNode: ColorInputFieldNode
var colorsChanged: (([HSBColor], Bool) -> Void)?
var colorsChanged: (([HSBColor], Int, Bool) -> Void)?
var colorSelected: (() -> Void)?
var rotate: (() -> Void)?
@ -518,6 +518,7 @@ final class WallpaperColorPanelNode: ASDisplayNode {
var updateLayout = updateLayout
let previousColors = self.state.colors
let previousPreview = self.state.preview
let previousSelection = self.state.selection
self.state = f(self.state)
let colorWasRemovable = self.multiColorFieldNode.isRemovable
@ -548,8 +549,8 @@ final class WallpaperColorPanelNode: ASDisplayNode {
}
}
if self.state.colors != previousColors || self.state.preview != previousPreview {
self.colorsChanged?(self.state.colors, !self.state.preview)
if self.state.colors != previousColors || self.state.preview != previousPreview || self.state.selection != previousSelection {
self.colorsChanged?(self.state.colors, self.state.selection ?? 0, !self.state.preview)
}
}
@ -576,42 +577,12 @@ final class WallpaperColorPanelNode: ASDisplayNode {
}
let buttonSize = CGSize(width: 26.0, height: 26.0)
//let middleButtonFrame = CGRect(origin: CGPoint(x: self.state.secondColor != nil ? floor((size.width - 26.0) / 2.0) : (self.state.secondColorAvailable ? size.width - rightInsetWithButton + floor((rightInsetWithButton - buttonSize.width) / 2.0) : size.width + buttonOffset), y: floor((topPanelHeight - buttonSize.height) / 2.0)), size: buttonSize)
//transition.updateFrame(node: self.rotateButton, frame: middleButtonFrame)
//transition.updateFrame(node: self.swapButton, frame: middleButtonFrame)
let canAddColors = self.state.colors.count < self.state.maximumNumberOfColors
transition.updateFrame(node: self.addButton, frame: CGRect(origin: CGPoint(x: size.width - rightInset - buttonSize.width, y: floor((topPanelHeight - buttonSize.height) / 2.0)), size: buttonSize))
transition.updateAlpha(node: self.addButton, alpha: canAddColors ? 1.0 : 0.0)
transition.updateSublayerTransformScale(node: self.addButton, scale: canAddColors ? 1.0 : 0.1)
/*let rotateButtonAlpha: CGFloat
let swapButtonAlpha: CGFloat
let addButtonAlpha: CGFloat
if let _ = self.state.secondColor {
if self.state.rotateAvailable {
rotateButtonAlpha = 1.0
swapButtonAlpha = 0.0
} else {
rotateButtonAlpha = 0.0
swapButtonAlpha = 1.0
}
addButtonAlpha = 0.0
} else {
swapButtonAlpha = 0.0
rotateButtonAlpha = 0.0
if self.state.secondColorAvailable {
addButtonAlpha = 1.0
} else {
addButtonAlpha = 0.0
}
}
transition.updateAlpha(node: self.rotateButton, alpha: rotateButtonAlpha)
transition.updateAlpha(node: self.swapButton, alpha: swapButtonAlpha)
transition.updateAlpha(node: self.addButton, alpha: addButtonAlpha)*/
func degreesToRadians(_ degrees: CGFloat) -> CGFloat {
var degrees = degrees
if degrees >= 270.0 {

View File

@ -880,7 +880,7 @@ public class WallpaperGalleryController: ViewController {
currentColorsPanelNode = colorsPanelNode
self.overlayNode?.insertSubnode(colorsPanelNode, belowSubnode: self.toolbarNode!)
colorsPanelNode.colorsChanged = { [weak self] colors, _ in
colorsPanelNode.colorsChanged = { [weak self] colors, _, _ in
guard let strongSelf = self else {
return
}

View File

@ -63,8 +63,15 @@ final class WallpaperOptionButtonNode: HighlightTrackingButtonNode {
}
}
var title: String {
didSet {
self.textNode.attributedText = NSAttributedString(string: title, font: Font.medium(13), textColor: .white)
}
}
init(title: String, value: WallpaperOptionButtonValue) {
self._value = value
self.title = title
self.backgroundNode = NavigationBackgroundNode(color: UIColor(rgb: 0x000000, alpha: 0.3))
self.backgroundNode.cornerRadius = 14.0

View File

@ -46,8 +46,8 @@ extension TelegramBaseTheme {
extension TelegramThemeSettings {
convenience init?(apiThemeSettings: Api.ThemeSettings) {
switch apiThemeSettings {
case let .themeSettings(_, baseTheme, accentColor, messageColors, wallpaper):
self.init(baseTheme: TelegramBaseTheme(apiBaseTheme: baseTheme), accentColor: UInt32(bitPattern: accentColor), messageColors: messageColors?.map(UInt32.init(bitPattern:)) ?? [], wallpaper: wallpaper.flatMap(TelegramWallpaper.init(apiWallpaper:)))
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:)))
}
}
@ -57,6 +57,10 @@ extension TelegramThemeSettings {
flags |= 1 << 0
}
if self.animateMessageColors {
flags |= 1 << 2
}
var inputWallpaper: Api.InputWallPaper?
var inputWallpaperSettings: Api.WallPaperSettings?
if let wallpaper = self.wallpaper, let inputWallpaperAndSettings = wallpaper.apiInputWallpaperAndSettings {

View File

@ -24,6 +24,9 @@ public final class TelegramThemeSettings: PostboxCoding, Equatable {
if lhs.messageColors != rhs.messageColors {
return false
}
if lhs.animateMessageColors != rhs.animateMessageColors {
return false
}
if lhs.wallpaper != rhs.wallpaper {
return false
}
@ -33,12 +36,14 @@ public final class TelegramThemeSettings: PostboxCoding, Equatable {
public let baseTheme: TelegramBaseTheme
public let accentColor: UInt32
public let messageColors: [UInt32]
public let animateMessageColors: Bool
public let wallpaper: TelegramWallpaper?
public init(baseTheme: TelegramBaseTheme, accentColor: UInt32, messageColors: [UInt32], wallpaper: TelegramWallpaper?) {
public init(baseTheme: TelegramBaseTheme, accentColor: UInt32, messageColors: [UInt32], animateMessageColors: Bool, wallpaper: TelegramWallpaper?) {
self.baseTheme = baseTheme
self.accentColor = accentColor
self.messageColors = messageColors
self.animateMessageColors = animateMessageColors
self.wallpaper = wallpaper
}
@ -55,6 +60,7 @@ public final class TelegramThemeSettings: PostboxCoding, Equatable {
self.messageColors = []
}
}
self.animateMessageColors = decoder.decodeInt32ForKey("animateMessageColors", orElse: 0) != 0
self.wallpaper = decoder.decodeObjectForKey("wallpaper", decoder: { TelegramWallpaper(decoder: $0) }) as? TelegramWallpaper
}
@ -62,6 +68,7 @@ public final class TelegramThemeSettings: PostboxCoding, Equatable {
encoder.encodeInt32(self.baseTheme.rawValue, forKey: "baseTheme")
encoder.encodeInt32(Int32(bitPattern: self.accentColor), forKey: "accent")
encoder.encodeInt32Array(self.messageColors.map(Int32.init(bitPattern:)), forKey: "messageColors")
encoder.encodeInt32(self.animateMessageColors ? 1 : 0, forKey: "animateMessageColors")
if let wallpaper = self.wallpaper {
encoder.encodeObject(wallpaper, forKey: "wallpaper")
} else {

View File

@ -4,7 +4,7 @@ import TelegramCore
import TelegramUIPreferences
public let defaultDarkPresentationTheme = makeDefaultDarkPresentationTheme(preview: false)
public let defaultDarkColorPresentationTheme = customizeDefaultDarkPresentationTheme(theme: defaultDarkPresentationTheme, editing: false, title: nil, accentColor: UIColor(rgb: 0x007aff), backgroundColors: [], bubbleColors: [], wallpaper: nil, baseColor: nil)
public let defaultDarkColorPresentationTheme = customizeDefaultDarkPresentationTheme(theme: defaultDarkPresentationTheme, editing: false, title: nil, accentColor: UIColor(rgb: 0x007aff), backgroundColors: [], bubbleColors: [], animateBubbleColors: false, wallpaper: nil, baseColor: nil)
private extension PresentationThemeBaseColor {
var colorWallpaper: (BuiltinWallpaperData, Int32, [UInt32])? {
@ -37,7 +37,7 @@ private extension PresentationThemeBaseColor {
}
}
public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, editing: Bool, title: String?, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: [UInt32], wallpaper forcedWallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil) -> PresentationTheme {
public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, editing: Bool, title: String?, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: [UInt32], animateBubbleColors: Bool?, wallpaper forcedWallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil) -> PresentationTheme {
if (theme.referenceTheme != .night) {
return theme
}
@ -165,6 +165,7 @@ public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, edit
chat = chat.withUpdated(
defaultWallpaper: defaultWallpaper,
animateMessageColors: animateBubbleColors,
message: chat.message.withUpdated(
incoming: chat.message.incoming.withUpdated(
linkTextColor: accentColor,
@ -523,6 +524,7 @@ public func makeDefaultDarkPresentationTheme(extendingThemeReference: Presentati
let chat = PresentationThemeChat(
defaultWallpaper: .color(0x000000),
animateMessageColors: false,
message: message,
serviceMessage: serviceMessage,
inputPanel: inputPanel,

View File

@ -38,7 +38,7 @@ private extension PresentationThemeBaseColor {
}
}
public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme, editing: Bool, title: String?, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: [UInt32], wallpaper forcedWallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil) -> PresentationTheme {
public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme, editing: Bool, title: String?, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: [UInt32], animateBubbleColors: Bool?, wallpaper forcedWallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil) -> PresentationTheme {
if (theme.referenceTheme != .nightAccent) {
return theme
}
@ -303,6 +303,7 @@ public func customizeDefaultDarkTintedPresentationTheme(theme: PresentationTheme
chat = chat.withUpdated(
defaultWallpaper: defaultWallpaper,
animateMessageColors: animateBubbleColors,
message: chat.message.withUpdated(
incoming: chat.message.incoming.withUpdated(
bubble: chat.message.incoming.bubble.withUpdated(
@ -784,6 +785,7 @@ public func makeDefaultDarkTintedPresentationTheme(extendingThemeReference: Pres
let chat = PresentationThemeChat(
defaultWallpaper: defaultBuiltinWallpaper(data: .default, colors: [0x1b2836, 0x121a22, 0x1b2836, 0x121a22]),
animateMessageColors: false,
message: message,
serviceMessage: serviceMessage,
inputPanel: inputPanel,

View File

@ -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, editing: Bool, title: String?, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: [UInt32], wallpaper forcedWallpaper: TelegramWallpaper? = nil, serviceBackgroundColor: UIColor?) -> PresentationTheme {
public func customizeDefaultDayTheme(theme: PresentationTheme, editing: Bool, title: String?, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: [UInt32], animateBubbleColors: Bool?, wallpaper forcedWallpaper: TelegramWallpaper? = nil, serviceBackgroundColor: UIColor?) -> PresentationTheme {
if (theme.referenceTheme != .day && theme.referenceTheme != .dayClassic) {
return theme
}
@ -236,6 +236,7 @@ public func customizeDefaultDayTheme(theme: PresentationTheme, editing: Bool, ti
chat = chat.withUpdated(
defaultWallpaper: defaultWallpaper,
animateMessageColors: animateBubbleColors,
message: chat.message.withUpdated(
incoming: chat.message.incoming.withUpdated(
bubble: chat.message.incoming.bubble.withUpdated(
@ -738,6 +739,7 @@ public func makeDefaultDayPresentationTheme(extendingThemeReference: Presentatio
let chat = PresentationThemeChat(
defaultWallpaper: day ? .color(0xffffff) : defaultPatternWallpaper,
animateMessageColors: false,
message: day ? messageDay : message,
serviceMessage: day ? serviceMessageDay : serviceMessage,
inputPanel: inputPanel,

View File

@ -19,46 +19,46 @@ public func makeDefaultPresentationTheme(reference: PresentationBuiltinThemeRefe
return theme
}
public func customizePresentationTheme(_ theme: PresentationTheme, editing: Bool, title: String? = nil, accentColor: UIColor?, backgroundColors: [UInt32], bubbleColors: [UInt32], wallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil) -> PresentationTheme {
public func customizePresentationTheme(_ theme: PresentationTheme, editing: Bool, title: String? = nil, accentColor: 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, editing: editing, title: title, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper, serviceBackgroundColor: nil)
return customizeDefaultDayTheme(theme: theme, editing: editing, title: title, accentColor: accentColor, 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, wallpaper: wallpaper, baseColor: baseColor)
return customizeDefaultDarkPresentationTheme(theme: theme, editing: editing, title: title, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, animateBubbleColors: animateBubbleColors ?? false, wallpaper: wallpaper, baseColor: baseColor)
case .nightAccent:
return customizeDefaultDarkTintedPresentationTheme(theme: theme, editing: editing, title: title, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, wallpaper: wallpaper, baseColor: baseColor)
return customizeDefaultDarkTintedPresentationTheme(theme: theme, editing: editing, title: title, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, animateBubbleColors: animateBubbleColors ?? false, wallpaper: wallpaper, baseColor: baseColor)
}
}
public func makePresentationTheme(settings: TelegramThemeSettings, title: String? = nil, serviceBackgroundColor: UIColor? = nil) -> PresentationTheme? {
let defaultTheme = makeDefaultPresentationTheme(reference: PresentationBuiltinThemeReference(baseTheme: settings.baseTheme), extendingThemeReference: nil, serviceBackgroundColor: serviceBackgroundColor, preview: false)
return customizePresentationTheme(defaultTheme, editing: true, title: title, accentColor: UIColor(argb: settings.accentColor), backgroundColors: [], bubbleColors: settings.messageColors, wallpaper: settings.wallpaper)
return customizePresentationTheme(defaultTheme, editing: true, title: title, accentColor: UIColor(argb: settings.accentColor), backgroundColors: [], bubbleColors: settings.messageColors, animateBubbleColors: settings.animateMessageColors, wallpaper: settings.wallpaper)
}
public func makePresentationTheme(mediaBox: MediaBox, themeReference: PresentationThemeReference, extendingThemeReference: PresentationThemeReference? = nil, accentColor: UIColor? = nil, backgroundColors: [UInt32] = [], bubbleColors: [UInt32] = [], wallpaper: TelegramWallpaper? = nil, baseColor: PresentationThemeBaseColor? = nil, serviceBackgroundColor: UIColor? = nil, preview: Bool = false) -> PresentationTheme? {
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, 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, baseColor: baseColor)
theme = customizePresentationTheme(defaultTheme, editing: true, accentColor: accentColor, 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, wallpaper: wallpaper)
theme = customizePresentationTheme(loadedTheme, editing: false, accentColor: accentColor, 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, 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), 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, wallpaper: wallpaper)
theme = customizePresentationTheme(loadedTheme, editing: false, accentColor: accentColor, backgroundColors: backgroundColors, bubbleColors: bubbleColors, animateBubbleColors: animateBubbleColors, wallpaper: wallpaper)
} else {
return nil
}

View File

@ -1066,6 +1066,7 @@ public final class PresentationThemeChatHistoryNavigation {
public final class PresentationThemeChat {
public let defaultWallpaper: TelegramWallpaper
public let animateMessageColors: Bool
public let message: PresentationThemeChatMessage
public let serviceMessage: PresentationThemeServiceMessage
public let inputPanel: PresentationThemeChatInputPanel
@ -1073,8 +1074,9 @@ public final class PresentationThemeChat {
public let inputButtonPanel: PresentationThemeInputButtonPanel
public let historyNavigation: PresentationThemeChatHistoryNavigation
public init(defaultWallpaper: TelegramWallpaper, message: PresentationThemeChatMessage, serviceMessage: PresentationThemeServiceMessage, inputPanel: PresentationThemeChatInputPanel, inputMediaPanel: PresentationThemeInputMediaPanel, inputButtonPanel: PresentationThemeInputButtonPanel, historyNavigation: PresentationThemeChatHistoryNavigation) {
public init(defaultWallpaper: TelegramWallpaper, animateMessageColors: Bool, message: PresentationThemeChatMessage, serviceMessage: PresentationThemeServiceMessage, inputPanel: PresentationThemeChatInputPanel, inputMediaPanel: PresentationThemeInputMediaPanel, inputButtonPanel: PresentationThemeInputButtonPanel, historyNavigation: PresentationThemeChatHistoryNavigation) {
self.defaultWallpaper = defaultWallpaper
self.animateMessageColors = animateMessageColors
self.message = message
self.serviceMessage = serviceMessage
self.inputPanel = inputPanel
@ -1083,8 +1085,8 @@ public final class PresentationThemeChat {
self.historyNavigation = historyNavigation
}
public func withUpdated(defaultWallpaper: TelegramWallpaper? = nil, message: PresentationThemeChatMessage? = nil, serviceMessage: PresentationThemeServiceMessage? = nil, inputPanel: PresentationThemeChatInputPanel? = nil, inputMediaPanel: PresentationThemeInputMediaPanel? = nil, inputButtonPanel: PresentationThemeInputButtonPanel? = nil, historyNavigation: PresentationThemeChatHistoryNavigation? = nil) -> PresentationThemeChat {
return PresentationThemeChat(defaultWallpaper: defaultWallpaper ?? self.defaultWallpaper, message: message ?? self.message, serviceMessage: serviceMessage ?? self.serviceMessage, inputPanel: inputPanel ?? self.inputPanel, inputMediaPanel: inputMediaPanel ?? self.inputMediaPanel, inputButtonPanel: inputButtonPanel ?? self.inputButtonPanel, historyNavigation: historyNavigation ?? self.historyNavigation)
public func withUpdated(defaultWallpaper: TelegramWallpaper? = nil, animateMessageColors: Bool? = nil, message: PresentationThemeChatMessage? = nil, serviceMessage: PresentationThemeServiceMessage? = nil, inputPanel: PresentationThemeChatInputPanel? = nil, inputMediaPanel: PresentationThemeInputMediaPanel? = nil, inputButtonPanel: PresentationThemeInputButtonPanel? = nil, historyNavigation: PresentationThemeChatHistoryNavigation? = nil) -> PresentationThemeChat {
return PresentationThemeChat(defaultWallpaper: defaultWallpaper ?? self.defaultWallpaper, animateMessageColors: animateMessageColors ?? self.animateMessageColors, message: message ?? self.message, serviceMessage: serviceMessage ?? self.serviceMessage, inputPanel: inputPanel ?? self.inputPanel, inputMediaPanel: inputMediaPanel ?? self.inputMediaPanel, inputButtonPanel: inputButtonPanel ?? self.inputButtonPanel, historyNavigation: historyNavigation ?? self.historyNavigation)
}
}

View File

@ -1659,6 +1659,7 @@ extension PresentationThemeChat: Codable {
enum CodingKeys: String, CodingKey {
case defaultWallpaper
case message
case animateMessageColors
case serviceMessage
case inputPanel
case inputMediaPanel
@ -1677,6 +1678,7 @@ extension PresentationThemeChat: Codable {
}
self.init(defaultWallpaper: wallpaper,
animateMessageColors: (try? values.decode(Bool.self, forKey: .animateMessageColors)) ?? false,
message: try values.decode(PresentationThemeChatMessage.self, forKey: .message),
serviceMessage: try values.decode(PresentationThemeServiceMessage.self, forKey: .serviceMessage),
inputPanel: try values.decode(PresentationThemeChatInputPanel.self, forKey: .inputPanel),

View File

@ -773,7 +773,7 @@ public final class WallpaperBackgroundNode: ASDisplayNode {
self.bubbleTheme = bubbleTheme
self.bubbleCorners = bubbleCorners
if bubbleTheme.chat.message.outgoing.bubble.withoutWallpaper.fill.count >= 3 && self.context.sharedContext.immediateExperimentalUISettings.enableDebugDataDisplay {
if bubbleTheme.chat.message.outgoing.bubble.withoutWallpaper.fill.count >= 3 && bubbleTheme.chat.animateMessageColors {
if self.outgoingBubbleGradientBackgroundNode == nil {
let outgoingBubbleGradientBackgroundNode = GradientBackgroundNode()
if let size = self.validLayout {