From 2c9abf7a1b70a0ecd41e83e8493605e699431842 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Fri, 27 Dec 2019 04:07:18 +0300 Subject: [PATCH] Fix wallpaper preview --- .../ThemeAccentColorControllerNode.swift | 1 - .../Themes/WallpaperGalleryController.swift | 98 +------------ .../Sources/Themes/WallpaperGalleryItem.swift | 132 ++++++++++++++++-- .../Themes/WallpaperPatternPanelNode.swift | 2 +- .../Sources/PresentationTheme.swift | 4 + 5 files changed, 132 insertions(+), 105 deletions(-) diff --git a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift index 2e6b7ac083..51f5bb1193 100644 --- a/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift +++ b/submodules/SettingsUI/Sources/Themes/ThemeAccentColorControllerNode.swift @@ -847,7 +847,6 @@ final class ThemeAccentColorControllerNode: ASDisplayNode, UIScrollViewDelegate let message8 = Message(stableId: 8, stableVersion: 0, id: MessageId(peerId: otherPeerId, namespace: 0, id: 8), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, timestamp: 66007, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[otherPeerId], text: self.presentationData.strings.Appearance_ThemePreview_Chat_3_Text, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: []) sampleMessages.append(message8) - items = sampleMessages.reversed().map { message in let item = self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, message: message, theme: self.theme, strings: self.presentationData.strings, wallpaper: self.wallpaper, fontSize: self.presentationData.fontSize, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: !message.media.isEmpty ? FileMediaResourceStatus(mediaStatus: .playbackStatus(.paused), fetchStatus: .Local) : nil, tapMessage: { [weak self] message in if message.flags.contains(.Incoming) { diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift index cdb1b63984..9eb5fcf49b 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryController.swift @@ -159,7 +159,6 @@ public class WallpaperGalleryController: ViewController { private var validLayout: (ContainerViewLayout, CGFloat)? private var overlayNode: WallpaperGalleryOverlayNode? - private var messageNodes: [ListViewItemNode]? private var toolbarNode: WallpaperGalleryToolbarNode? private var patternPanelNode: WallpaperPatternPanelNode? @@ -295,7 +294,7 @@ public class WallpaperGalleryController: ViewController { var i: Int = 0 var updateItems: [GalleryPagerUpdateItem] = [] for entry in entries { - let item = GalleryPagerUpdateItem(index: i, previousIndex: i, item: WallpaperGalleryItem(context: self.context, entry: entry, arguments: arguments)) + let item = GalleryPagerUpdateItem(index: i, previousIndex: i, item: WallpaperGalleryItem(context: self.context, entry: entry, arguments: arguments, source: self.source)) updateItems.append(item) i += 1 } @@ -536,10 +535,6 @@ public class WallpaperGalleryController: ViewController { strongSelf.containerLayoutUpdated(layout, transition: .animated(duration: 0.3, curve: .spring)) } } - - if let (layout, bottomInset) = self.validLayout { - self.updateMessagesLayout(layout: layout, bottomInset: bottomInset, transition: .immediate) - } } } @@ -595,92 +590,7 @@ public class WallpaperGalleryController: ViewController { self.galleryNode.pager.transaction(self.updateTransaction(entries: updatedEntries, arguments: WallpaperGalleryItemArguments(colorPreview: preview, isColorsList: true, patternEnabled: self.patternPanelEnabled))) } - private func updateMessagesLayout(layout: ContainerViewLayout, bottomInset: CGFloat, transition: ContainedViewLayoutTransition) { - var items: [ListViewItem] = [] - let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 1) - let otherPeerId = self.context.account.peerId - var peers = SimpleDictionary() - let messages = SimpleDictionary() - peers[peerId] = TelegramUser(id: peerId, accessHash: nil, firstName: self.presentationData.strings.Appearance_PreviewReplyAuthor, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - peers[otherPeerId] = TelegramUser(id: otherPeerId, accessHash: nil, firstName: self.presentationData.strings.Appearance_PreviewReplyAuthor, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) - - var currentWallpaper: TelegramWallpaper = self.presentationData.chatWallpaper - if let entry = self.currentEntry(), case let .wallpaper(wallpaper, _) = entry { - currentWallpaper = wallpaper - } - - var topMessageText: String - var bottomMessageText: String - switch self.source { - case .wallpaper, .slug: - topMessageText = presentationData.strings.WallpaperPreview_PreviewTopText - bottomMessageText = presentationData.strings.WallpaperPreview_PreviewBottomText - case let .list(_, _, type): - switch type { - case .wallpapers: - topMessageText = presentationData.strings.WallpaperPreview_SwipeTopText - bottomMessageText = presentationData.strings.WallpaperPreview_SwipeBottomText - case .colors: - topMessageText = presentationData.strings.WallpaperPreview_SwipeColorsTopText - bottomMessageText = presentationData.strings.WallpaperPreview_SwipeColorsBottomText - } - case .asset, .contextResult: - topMessageText = presentationData.strings.WallpaperPreview_CropTopText - bottomMessageText = presentationData.strings.WallpaperPreview_CropBottomText - case .customColor: - topMessageText = presentationData.strings.WallpaperPreview_CustomColorTopText - bottomMessageText = presentationData.strings.WallpaperPreview_CustomColorBottomText - } - - let message1 = Message(stableId: 2, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 2), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, timestamp: 66001, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[otherPeerId], text: bottomMessageText, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: []) - items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, message: message1, theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: currentWallpaper, fontSize: self.presentationData.fontSize, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil)) - - let message2 = Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[peerId], text: topMessageText, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: []) - - items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, message: message2, theme: self.presentationData.theme, strings: self.presentationData.strings, wallpaper: currentWallpaper, fontSize: self.presentationData.fontSize, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil)) - - let params = ListViewItemLayoutParams(width: layout.size.width, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, availableHeight: layout.size.height) - if let messageNodes = self.messageNodes { - for i in 0 ..< items.count { - let itemNode = messageNodes[i] - 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 - let nodeFrame = CGRect(origin: itemNode.frame.origin, size: CGSize(width: layout.size.width, height: layout.size.height)) - - itemNode.contentSize = layout.contentSize - itemNode.insets = layout.insets - itemNode.frame = nodeFrame - itemNode.isUserInteractionEnabled = false - - apply(ListViewItemApply(isOnScreen: true)) - }) - } - } else { - var messageNodes: [ListViewItemNode] = [] - for i in 0 ..< items.count { - var itemNode: ListViewItemNode? - items[i].nodeConfiguredForParams(async: { $0() }, params: params, synchronousLoads: false, previousItem: i == 0 ? nil : items[i - 1], nextItem: i == (items.count - 1) ? nil : items[i + 1], completion: { node, apply in - itemNode = node - apply().1(ListViewItemApply(isOnScreen: true)) - }) - itemNode!.subnodeTransform = CATransform3DMakeRotation(CGFloat.pi, 0.0, 0.0, 1.0) - itemNode!.isUserInteractionEnabled = false - messageNodes.append(itemNode!) - self.overlayNode?.addSubnode(itemNode!) - } - self.messageNodes = messageNodes - } - - if let messageNodes = self.messageNodes { - var bottomOffset: CGFloat = layout.size.height - bottomInset - 9.0 - for itemNode in messageNodes { - transition.updateFrame(node: itemNode, frame: CGRect(origin: CGPoint(x: 0.0, y: bottomOffset - itemNode.frame.height), size: itemNode.frame.size)) - bottomOffset -= itemNode.frame.height - itemNode.updateFrame(itemNode.frame, within: layout.size) - } - } - } + override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { let hadLayout = self.validLayout != nil @@ -725,8 +635,6 @@ public class WallpaperGalleryController: ViewController { transition.updateFrame(node: currentPatternPanelNode, frame: patternPanelFrame) currentPatternPanelNode.updateLayout(size: patternPanelFrame.size, transition: transition) - self.updateMessagesLayout(layout: layout, bottomInset: bottomInset, transition: transition) - self.validLayout = (layout, bottomInset) if !hadLayout { var colors = false @@ -734,7 +642,7 @@ public class WallpaperGalleryController: ViewController { colors = true } - self.galleryNode.pager.replaceItems(self.entries.map({ WallpaperGalleryItem(context: self.context, entry: $0, arguments: WallpaperGalleryItemArguments(isColorsList: colors)) }), centralItemIndex: self.centralEntryIndex) + self.galleryNode.pager.replaceItems(self.entries.map({ WallpaperGalleryItem(context: self.context, entry: $0, arguments: WallpaperGalleryItemArguments(isColorsList: colors), source: self.source) }), centralItemIndex: self.centralEntryIndex) if let initialOptions = self.initialOptions, let itemNode = self.galleryNode.pager.centralItemNode() as? WallpaperGalleryItemNode { itemNode.options = initialOptions diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift index 7fe2436807..f8df1530c5 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperGalleryItem.swift @@ -35,22 +35,24 @@ class WallpaperGalleryItem: GalleryItem { let context: AccountContext let entry: WallpaperGalleryEntry let arguments: WallpaperGalleryItemArguments + let source: WallpaperListSource - init(context: AccountContext, entry: WallpaperGalleryEntry, arguments: WallpaperGalleryItemArguments) { + init(context: AccountContext, entry: WallpaperGalleryEntry, arguments: WallpaperGalleryItemArguments, source: WallpaperListSource) { self.context = context self.entry = entry self.arguments = arguments + self.source = source } func node() -> GalleryItemNode { let node = WallpaperGalleryItemNode(context: self.context) - node.setEntry(self.entry, arguments: self.arguments) + node.setEntry(self.entry, arguments: self.arguments, source: self.source) return node } func updateNode(node: GalleryItemNode) { if let node = node as? WallpaperGalleryItemNode { - node.setEntry(self.entry, arguments: self.arguments) + node.setEntry(self.entry, arguments: self.arguments, source: self.source) } } @@ -71,7 +73,10 @@ private func reference(for resource: MediaResource, media: Media, message: Messa final class WallpaperGalleryItemNode: GalleryItemNode { private let context: AccountContext + private let presentationData: PresentationData + var entry: WallpaperGalleryEntry? + var source: WallpaperListSource? private var colorPreview: Bool = false private var contentSize: CGSize? private var arguments = WallpaperGalleryItemArguments() @@ -86,6 +91,9 @@ final class WallpaperGalleryItemNode: GalleryItemNode { private var motionButtonNode: WallpaperOptionButtonNode private var patternButtonNode: WallpaperOptionButtonNode + private let messagesContainerNode: ASDisplayNode + private var messageNodes: [ListViewItemNode]? + fileprivate let _ready = Promise() private let fetchDisposable = MetaDisposable() private let statusDisposable = MetaDisposable() @@ -102,6 +110,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode { init(context: AccountContext) { self.context = context + self.presentationData = context.sharedContext.currentPresentationData.with { $0 } self.wrapperNode = ASDisplayNode() self.imageNode = TransformImageNode() @@ -113,12 +122,14 @@ final class WallpaperGalleryItemNode: GalleryItemNode { self.blurredNode = BlurredImageNode() - let presentationData = context.sharedContext.currentPresentationData.with { $0 } - self.blurButtonNode = WallpaperOptionButtonNode(title: presentationData.strings.WallpaperPreview_Blurred, value: .check(false)) + self.messagesContainerNode = ASDisplayNode() + self.messagesContainerNode.transform = CATransform3DMakeScale(1.0, -1.0, 1.0) + + self.blurButtonNode = WallpaperOptionButtonNode(title: self.presentationData.strings.WallpaperPreview_Blurred, value: .check(false)) self.blurButtonNode.setEnabled(false) - self.motionButtonNode = WallpaperOptionButtonNode(title: presentationData.strings.WallpaperPreview_Motion, value: .check(false)) + self.motionButtonNode = WallpaperOptionButtonNode(title: self.presentationData.strings.WallpaperPreview_Motion, value: .check(false)) self.motionButtonNode.setEnabled(false) - self.patternButtonNode = WallpaperOptionButtonNode(title: presentationData.strings.WallpaperPreview_Pattern, value: .check(false)) + self.patternButtonNode = WallpaperOptionButtonNode(title: self.presentationData.strings.WallpaperPreview_Pattern, value: .check(false)) self.patternButtonNode.setEnabled(false) super.init() @@ -135,6 +146,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode { self.addSubnode(self.wrapperNode) self.addSubnode(self.statusNode) + self.addSubnode(self.messagesContainerNode) self.addSubnode(self.blurButtonNode) self.addSubnode(self.motionButtonNode) @@ -171,9 +183,10 @@ final class WallpaperGalleryItemNode: GalleryItemNode { self.action?() } - func setEntry(_ entry: WallpaperGalleryEntry, arguments: WallpaperGalleryItemArguments) { + func setEntry(_ entry: WallpaperGalleryEntry, arguments: WallpaperGalleryItemArguments, source: WallpaperListSource) { let previousArguments = self.arguments self.arguments = arguments + self.source = source if self.arguments.colorPreview != previousArguments.colorPreview { if self.arguments.colorPreview { @@ -511,6 +524,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode { if let layout = self.validLayout { self.updateButtonsLayout(layout: layout, offset: CGPoint(), transition: .immediate) + self.updateMessagesLayout(layout: layout, offset: CGPoint(), transition: .immediate) } } } @@ -524,12 +538,14 @@ final class WallpaperGalleryItemNode: GalleryItemNode { if let layout = self.validLayout { self.updateWrapperLayout(layout: layout, offset: offset, transition: .immediate) self.updateButtonsLayout(layout: layout, offset: CGPoint(x: offset, y: 0.0), transition: .immediate) + self.updateMessagesLayout(layout: layout, offset: CGPoint(x: offset, y: 0.0), transition:.immediate) } } func updateDismissTransition(_ value: CGFloat) { if let layout = self.validLayout { self.updateButtonsLayout(layout: layout, offset: CGPoint(x: 0.0, y: value), transition: .immediate) + self.updateMessagesLayout(layout: layout, offset: CGPoint(x: 0.0, y: value), transition: .immediate) } } @@ -764,6 +780,104 @@ final class WallpaperGalleryItemNode: GalleryItemNode { transition.updateAlpha(node: self.motionButtonNode, alpha: motionAlpha * alpha) } + private func updateMessagesLayout(layout: ContainerViewLayout, offset: CGPoint, transition: ContainedViewLayoutTransition) { + var bottomInset: CGFloat = 115.0 + if self.patternButtonNode.isSelected { + bottomInset = 350.0 + } + + var items: [ListViewItem] = [] + let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 1) + let otherPeerId = self.context.account.peerId + var peers = SimpleDictionary() + let messages = SimpleDictionary() + peers[peerId] = TelegramUser(id: peerId, accessHash: nil, firstName: self.presentationData.strings.Appearance_PreviewReplyAuthor, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + peers[otherPeerId] = TelegramUser(id: otherPeerId, accessHash: nil, firstName: self.presentationData.strings.Appearance_PreviewReplyAuthor, lastName: "", username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: []) + + var topMessageText = "" + var bottomMessageText = "" + var currentWallpaper: TelegramWallpaper = self.presentationData.chatWallpaper + if let entry = self.entry, case let .wallpaper(wallpaper, _) = entry { + currentWallpaper = wallpaper + } + + if let source = self.source { + switch source { + case .wallpaper, .slug: + topMessageText = presentationData.strings.WallpaperPreview_PreviewTopText + bottomMessageText = presentationData.strings.WallpaperPreview_PreviewBottomText + case let .list(_, _, type): + switch type { + case .wallpapers: + topMessageText = presentationData.strings.WallpaperPreview_SwipeTopText + bottomMessageText = presentationData.strings.WallpaperPreview_SwipeBottomText + case .colors: + topMessageText = presentationData.strings.WallpaperPreview_SwipeColorsTopText + bottomMessageText = presentationData.strings.WallpaperPreview_SwipeColorsBottomText + } + case .asset, .contextResult: + topMessageText = presentationData.strings.WallpaperPreview_CropTopText + bottomMessageText = presentationData.strings.WallpaperPreview_CropBottomText + case .customColor: + topMessageText = presentationData.strings.WallpaperPreview_CustomColorTopText + bottomMessageText = presentationData.strings.WallpaperPreview_CustomColorBottomText + } + } + + let theme = self.presentationData.theme.withUpdated(preview: true) + + let message1 = Message(stableId: 2, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 2), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, timestamp: 66001, flags: [], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[otherPeerId], text: bottomMessageText, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: []) + items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, message: message1, theme: theme, strings: self.presentationData.strings, wallpaper: currentWallpaper, fontSize: self.presentationData.fontSize, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil)) + + let message2 = Message(stableId: 1, stableVersion: 0, id: MessageId(peerId: peerId, namespace: 0, id: 1), globallyUniqueId: nil, groupingKey: nil, groupInfo: nil, timestamp: 66000, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: peers[peerId], text: topMessageText, attributes: [], media: [], peers: peers, associatedMessages: messages, associatedMessageIds: []) + items.append(self.context.sharedContext.makeChatMessagePreviewItem(context: self.context, message: message2, theme: theme, strings: self.presentationData.strings, wallpaper: currentWallpaper, fontSize: self.presentationData.fontSize, dateTimeFormat: self.presentationData.dateTimeFormat, nameOrder: self.presentationData.nameDisplayOrder, forcedResourceStatus: nil, tapMessage: nil, clickThroughMessage: nil)) + + let params = ListViewItemLayoutParams(width: layout.size.width, leftInset: layout.safeInsets.left, rightInset: layout.safeInsets.right, availableHeight: layout.size.height) + if let messageNodes = self.messageNodes { +// for i in 0 ..< items.count { +// let itemNode = messageNodes[i] +// 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 +// let nodeFrame = CGRect(origin: itemNode.frame.origin, size: CGSize(width: layout.size.width, height: layout.size.height)) +// +// itemNode.contentSize = layout.contentSize +// itemNode.insets = layout.insets +// itemNode.frame = nodeFrame +// itemNode.isUserInteractionEnabled = false +// +// apply(ListViewItemApply(isOnScreen: true)) +// }) +// } + } else { + var messageNodes: [ListViewItemNode] = [] + for i in 0 ..< items.count { + var itemNode: ListViewItemNode? + items[i].nodeConfiguredForParams(async: { $0() }, params: params, synchronousLoads: false, previousItem: i == 0 ? nil : items[i - 1], nextItem: i == (items.count - 1) ? nil : items[i + 1], completion: { node, apply in + itemNode = node + apply().1(ListViewItemApply(isOnScreen: true)) + }) + itemNode!.subnodeTransform = CATransform3DMakeScale(-1.0, 1.0, 1.0) + itemNode!.isUserInteractionEnabled = false + messageNodes.append(itemNode!) + self.messagesContainerNode.addSubnode(itemNode!) + } + self.messageNodes = messageNodes + } + + let alpha = 1.0 - min(1.0, max(0.0, abs(offset.y) / 50.0)) + + if let messageNodes = self.messageNodes { + var bottomOffset: CGFloat = 9.0 + bottomInset + for itemNode in messageNodes { + transition.updateFrame(node: itemNode, frame: CGRect(origin: CGPoint(x: offset.x, y: bottomOffset - offset.y), size: itemNode.frame.size)) + bottomOffset += itemNode.frame.height + itemNode.updateFrame(itemNode.frame, within: layout.size) + transition.updateAlpha(node: itemNode, alpha: alpha) + } + } + } + override func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) { super.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: transition) @@ -774,6 +888,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode { self.wrapperNode.bounds = CGRect(origin: CGPoint(), size: layout.size) self.updateWrapperLayout(layout: layout, offset: offset, transition: transition) + self.messagesContainerNode.frame = CGRect(origin: CGPoint(), size: layout.size) if self.cropNode.supernode == nil { self.imageNode.frame = self.wrapperNode.bounds @@ -798,6 +913,7 @@ final class WallpaperGalleryItemNode: GalleryItemNode { self.statusNode.frame = CGRect(x: layout.safeInsets.left + floorToScreenPixels((layout.size.width - layout.safeInsets.left - layout.safeInsets.right - progressDiameter) / 2.0), y: floorToScreenPixels((layout.size.height + additionalYOffset - progressDiameter) / 2.0), width: progressDiameter, height: progressDiameter) self.updateButtonsLayout(layout: layout, offset: CGPoint(x: offset, y: 0.0), transition: transition) + self.updateMessagesLayout(layout: layout, offset: CGPoint(x: offset, y: 0.0), transition: transition) self.validLayout = layout } diff --git a/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift b/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift index 93b581e63f..54d00f91de 100644 --- a/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift +++ b/submodules/SettingsUI/Sources/Themes/WallpaperPatternPanelNode.swift @@ -220,7 +220,7 @@ final class WallpaperPatternPanelNode: ASDisplayNode { } self.currentWallpaper = wallpaper - self.sliderView?.value = CGFloat(intensity ?? 40) + self.sliderView?.value = CGFloat(intensity ?? 50) self.scrollNode.view.contentOffset = CGPoint() diff --git a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift index 43342ae28c..66a2ba6ba1 100644 --- a/submodules/TelegramPresentationData/Sources/PresentationTheme.swift +++ b/submodules/TelegramPresentationData/Sources/PresentationTheme.swift @@ -1190,4 +1190,8 @@ public final class PresentationTheme: Equatable { } return PresentationTheme(name: name.flatMap(PresentationThemeName.custom) ?? .custom(self.name.string), index: self.index, referenceTheme: self.referenceTheme, overallDarkAppearance: self.overallDarkAppearance, intro: self.intro, passcode: self.passcode, rootController: self.rootController, list: self.list, chatList: self.chatList, chat: self.chat.withUpdated(defaultWallpaper: defaultWallpaper), actionSheet: self.actionSheet, contextMenu: self.contextMenu, inAppNotification: self.inAppNotification) } + + public func withUpdated(preview: Bool) -> PresentationTheme { + return PresentationTheme(name: self.name, index: self.index, referenceTheme: self.referenceTheme, overallDarkAppearance: self.overallDarkAppearance, intro: self.intro, passcode: self.passcode, rootController: self.rootController, list: self.list, chatList: self.chatList, chat: self.chat, actionSheet: self.actionSheet, contextMenu: self.contextMenu, inAppNotification: self.inAppNotification, preview: preview) + } }