From 0d93bf0b71f08ec2eb2f354bb8348bf7156affd5 Mon Sep 17 00:00:00 2001 From: Peter <> Date: Sat, 27 Jul 2019 20:07:08 +0100 Subject: [PATCH 1/2] Proof of concept --- .../Display/Display/GenerateImage.swift | 2 +- submodules/Display/Display/ListView.swift | 47 ++++++-------- .../Display/Display/ListViewItemNode.swift | 8 +++ .../ChatControllerBackgroundNode.swift | 2 + .../ChatMessageBubbleBackdrop.swift | 56 +++++++++++++++++ .../TelegramUI/ChatMessageBubbleImages.swift | 61 +++++++++++++------ .../ChatMessageBubbleItemNode.swift | 35 +++++++---- .../PresentationThemeEssentialGraphics.swift | 48 +++++++-------- .../project.pbxproj | 4 ++ 9 files changed, 182 insertions(+), 81 deletions(-) create mode 100644 submodules/TelegramUI/TelegramUI/ChatMessageBubbleBackdrop.swift diff --git a/submodules/Display/Display/GenerateImage.swift b/submodules/Display/Display/GenerateImage.swift index ae6baba564..99eb870956 100644 --- a/submodules/Display/Display/GenerateImage.swift +++ b/submodules/Display/Display/GenerateImage.swift @@ -1,7 +1,7 @@ import Foundation import UIKit -private let deviceColorSpace: CGColorSpace = { +public let deviceColorSpace: CGColorSpace = { if #available(iOSApplicationExtension 9.3, *) { if let colorSpace = CGColorSpace(name: CGColorSpace.displayP3) { return colorSpace diff --git a/submodules/Display/Display/ListView.swift b/submodules/Display/Display/ListView.swift index 3fa834e803..d94cd83817 100644 --- a/submodules/Display/Display/ListView.swift +++ b/submodules/Display/Display/ListView.swift @@ -677,8 +677,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture } for itemNode in self.itemNodes { - let position = itemNode.position - itemNode.position = CGPoint(x: position.x, y: position.y - deltaY) + itemNode.updateFrame(itemNode.frame.offsetBy(dx: 0.0, dy: -deltaY), within: self.visibleSize) if self.dynamicBounceEnabled && itemNode.wantsScrollDynamics { useScrollDynamics = true @@ -908,7 +907,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture for itemNode in self.itemNodes { var frame = itemNode.frame frame.origin.y += offset - itemNode.frame = frame + itemNode.updateFrame(frame, within: self.visibleSize) if let accessoryItemNode = itemNode.accessoryItemNode { itemNode.layoutAccessoryItemNode(accessoryItemNode, leftInset: self.insets.left, rightInset: self.insets.right) } @@ -1890,7 +1889,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture node.contentSize = layout.contentSize node.insets = layout.insets node.apparentHeight = animated ? 0.0 : layout.size.height - node.frame = nodeFrame + node.updateFrame(nodeFrame, within: self.visibleSize) if let accessoryItemNode = node.accessoryItemNode { node.layoutAccessoryItemNode(accessoryItemNode, leftInset: listInsets.left, rightInset: listInsets.right) } @@ -1905,14 +1904,13 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture if nextNode.index == nil && nextNode.subnodes == nil || nextNode.subnodes!.isEmpty { let nextHeight = nextNode.apparentHeight if abs(nextHeight - previousApparentHeight) < CGFloat.ulpOfOne { - if let animation = nextNode.animationForKey("apparentHeight") { + if let _ = nextNode.animationForKey("apparentHeight") { node.apparentHeight = previousApparentHeight offsetHeight = 0.0 - var offsetPosition = nextNode.position - offsetPosition.y += nextHeight - nextNode.position = offsetPosition + nextNode.updateFrame(nextNode.frame.offsetBy(dx: 0.0, dy: nextHeight), within: self.visibleSize) + nextNode.apparentHeight = 0.0 nextNode.removeApparentHeightAnimation() @@ -2015,7 +2013,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture while i >= 0 { var frame = self.itemNodes[i].frame frame.origin.y -= offsetHeight - self.itemNodes[i].frame = frame + self.itemNodes[i].updateFrame(frame, within: self.visibleSize) if let accessoryItemNode = self.itemNodes[i].accessoryItemNode { self.itemNodes[i].layoutAccessoryItemNode(accessoryItemNode, leftInset: listInsets.left, rightInset: listInsets.right) } @@ -2026,7 +2024,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture while i < self.itemNodes.count { var frame = self.itemNodes[i].frame frame.origin.y += offsetHeight - self.itemNodes[i].frame = frame + self.itemNodes[i].updateFrame(frame, within: self.visibleSize) if let accessoryItemNode = self.itemNodes[i].accessoryItemNode { self.itemNodes[i].layoutAccessoryItemNode(accessoryItemNode, leftInset: listInsets.left, rightInset: listInsets.right) } @@ -2253,7 +2251,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture for i in index + 1 ..< self.itemNodes.count { var frame = self.itemNodes[i].frame frame.origin.y -= height - self.itemNodes[i].frame = frame + self.itemNodes[i].updateFrame(frame, within: self.visibleSize) if let accessoryItemNode = self.itemNodes[i].accessoryItemNode { self.itemNodes[i].layoutAccessoryItemNode(accessoryItemNode, leftInset: listInsets.left, rightInset: listInsets.right) } @@ -2264,7 +2262,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture for i in (0 ..< index).reversed() { var frame = self.itemNodes[i].frame frame.origin.y += height - self.itemNodes[i].frame = frame + self.itemNodes[i].updateFrame(frame, within: self.visibleSize) if let accessoryItemNode = self.itemNodes[i].accessoryItemNode { self.itemNodes[i].layoutAccessoryItemNode(accessoryItemNode, leftInset: listInsets.left, rightInset: listInsets.right) } @@ -2350,7 +2348,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture if offset != 0.0 { var frame = itemNode.frame frame.origin.y += offset - itemNode.frame = frame + itemNode.updateFrame(frame, within: self.visibleSize) } index += 1 @@ -2419,7 +2417,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture for itemNode in self.itemNodes { var frame = itemNode.frame frame.origin.y += offset - itemNode.frame = frame + itemNode.updateFrame(frame, within: self.visibleSize) if let accessoryItemNode = itemNode.accessoryItemNode { itemNode.layoutAccessoryItemNode(accessoryItemNode, leftInset: listInsets.left, rightInset: listInsets.right) } @@ -2439,7 +2437,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture for itemNode in self.itemNodes { var frame = itemNode.frame frame.origin.y += offset - itemNode.frame = frame + itemNode.updateFrame(frame, within: self.visibleSize) if let accessoryItemNode = itemNode.accessoryItemNode { itemNode.layoutAccessoryItemNode(accessoryItemNode, leftInset: listInsets.left, rightInset: listInsets.right) } @@ -2487,8 +2485,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture self.visibleSize = updateSizeAndInsets.size for itemNode in self.itemNodes { - let position = itemNode.position - itemNode.position = CGPoint(x: position.x, y: position.y + offsetFix) + itemNode.updateFrame(itemNode.frame.offsetBy(dx: 0.0, dy: offsetFix), within: self.visibleSize) } let (snappedTopInset, snapToBoundsOffset) = self.snapToBounds(snapTopItem: scrollToItem != nil, stackFromBottom: self.stackFromBottom, updateSizeAndInsets: updateSizeAndInsets, isExperimentalSnapToScrollToItem: isExperimentalSnapToScrollToItem) @@ -2497,8 +2494,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture offsetFix += snappedTopInset for itemNode in self.itemNodes { - let position = itemNode.position - itemNode.position = CGPoint(x: position.x, y: position.y + snappedTopInset) + itemNode.updateFrame(itemNode.frame.offsetBy(dx: 0.0, dy: snappedTopInset), within: self.visibleSize) } } @@ -2608,8 +2604,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture if !snappedTopInset.isZero && previousApparentFrames.isEmpty { for itemNode in self.itemNodes { - let position = itemNode.position - itemNode.position = CGPoint(x: position.x, y: position.y + snappedTopInset) + itemNode.updateFrame(itemNode.frame.offsetBy(dx: 0.0, dy: snappedTopInset), within: self.visibleSize) } } @@ -2653,7 +2648,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture for (previousNode, previousFrame) in previousApparentFrames { if previousNode.supernode == nil { temporaryPreviousNodes.append(previousNode) - previousNode.frame = previousFrame + previousNode.updateFrame(previousFrame, within: self.visibleSize) if previousUpperBound == nil || previousUpperBound! > previousFrame.minY { previousUpperBound = previousFrame.minY } @@ -2671,7 +2666,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture for (previousNode, previousFrame) in previousApparentFrames { if previousNode.supernode == nil { temporaryPreviousNodes.append(previousNode) - previousNode.frame = previousFrame + previousNode.updateFrame(previousFrame, within: self.visibleSize) if previousUpperBound == nil || previousUpperBound! > previousFrame.minY { previousUpperBound = previousFrame.minY } @@ -2719,7 +2714,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture if let offset = offset, !offset.isZero { let lowestNodeToInsertBelow = self.lowestNodeToInsertBelow() for itemNode in temporaryPreviousNodes { - itemNode.frame = itemNode.frame.offsetBy(dx: 0.0, dy: offset) + itemNode.updateFrame(itemNode.frame.offsetBy(dx: 0.0, dy: offset), within: self.visibleSize) if let lowestNodeToInsertBelow = lowestNodeToInsertBelow { self.insertSubnode(itemNode, belowSubnode: lowestNodeToInsertBelow) } else if let verticalScrollIndicator = self.verticalScrollIndicator { @@ -3547,9 +3542,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture for itemNode in self.itemNodes { let offset = offsetRanges.offsetForIndex(index) if offset != 0.0 { - var position = itemNode.position - position.y += offset - itemNode.position = position + itemNode.updateFrame(itemNode.frame.offsetBy(dx: 0.0, dy: offset), within: self.visibleSize) } index += 1 diff --git a/submodules/Display/Display/ListViewItemNode.swift b/submodules/Display/Display/ListViewItemNode.swift index 898047167a..c12a81168f 100644 --- a/submodules/Display/Display/ListViewItemNode.swift +++ b/submodules/Display/Display/ListViewItemNode.swift @@ -549,4 +549,12 @@ open class ListViewItemNode: ASDisplayNode { override open func accessibilityElementDidBecomeFocused() { (self.supernode as? ListView)?.ensureItemNodeVisible(self, animated: false, overflow: 22.0) } + + func updateFrame(_ frame: CGRect, within containerSize: CGSize) { + self.frame = frame + self.updateAbsoluteRect(frame, within: containerSize) + } + + open func updateAbsoluteRect(_ rect: CGRect, within containerSize: CGSize) { + } } diff --git a/submodules/TelegramUI/TelegramUI/ChatControllerBackgroundNode.swift b/submodules/TelegramUI/TelegramUI/ChatControllerBackgroundNode.swift index a177fafcac..aea76c3698 100644 --- a/submodules/TelegramUI/TelegramUI/ChatControllerBackgroundNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatControllerBackgroundNode.swift @@ -53,12 +53,14 @@ func chatControllerBackgroundImage(wallpaper: TelegramWallpaper, mediaBox: Media var image: UIImage? let _ = mediaBox.cachedResourceRepresentation(file.file.resource, representation: CachedBlurredWallpaperRepresentation(), complete: true, fetch: true, attemptSynchronously: true).start(next: { data in if data.complete { + print("background image: \(data.path)") image = UIImage(contentsOfFile: data.path)?.precomposed() } }) backgroundImage = image } if backgroundImage == nil, let path = mediaBox.completedResourcePath(file.file.resource) { + print("background image: \(path)") backgroundImage = UIImage(contentsOfFile: path)?.precomposed() } } diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageBubbleBackdrop.swift b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleBackdrop.swift new file mode 100644 index 0000000000..69e07fe8d2 --- /dev/null +++ b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleBackdrop.swift @@ -0,0 +1,56 @@ +import Foundation +import AsyncDisplayKit +import Display +import Postbox + +private let backgroundContentImage = generateImage(CGSize(width: 1.0, height: 1000.0), rotatedContext: { size, context in + var locations: [CGFloat] = [0.0, 1.0] + let colors = [UIColor(rgb: 0x018CFE).cgColor, UIColor(rgb: 0x0A51A1).cgColor] as NSArray + + let colorSpace = deviceColorSpace + let gradient = CGGradient(colorsSpace: colorSpace, colors: colors, locations: &locations)! + + context.drawLinearGradient(gradient, start: CGPoint(), end: CGPoint(x: 0.0, y: size.height), options: CGGradientDrawingOptions()) +}) + +private let backgroundContentIncomingImage = generateImage(CGSize(width: 1.0, height: 1000.0), rotatedContext: { size, context in + var locations: [CGFloat] = [0.0, 1.0] + let colors = [UIColor(rgb: 0x39393C).cgColor, UIColor(rgb: 0x222224).cgColor] as NSArray + + let colorSpace = deviceColorSpace + let gradient = CGGradient(colorsSpace: colorSpace, colors: colors, locations: &locations)! + + context.drawLinearGradient(gradient, start: CGPoint(), end: CGPoint(x: 0.0, y: size.height), options: CGGradientDrawingOptions()) +}) + +private let blurredImage = UIImage(contentsOfFile: "/Users/peter/Library/Developer/CoreSimulator/Devices/5D789082-637B-493D-8CD3-32E59577B64D/data/Containers/Shared/AppGroup/AA2C1D1D-BD42-4662-8003-A4DDC118839F/telegram-data/account-8200745692227124259/postbox/media/telegram-cloud-document-1-5033031402610753634")?.precomposed() + +final class ChatMessageBubbleBackdrop: ASDisplayNode { + private let backgroundContent: ASDisplayNode + + private var currentType: Bool? + + override init() { + self.backgroundContent = ASDisplayNode() + + super.init() + + self.clipsToBounds = true + + self.addSubnode(self.backgroundContent) + } + + func setType(incoming: Bool, theme: ChatPresentationThemeData, mediaBox: MediaBox) { + if self.currentType != incoming { + self.currentType = incoming + + //self.backgroundContent.contents = blurredImage?.cgImage + + self.backgroundContent.contents = incoming ? backgroundContentIncomingImage?.cgImage : backgroundContentImage?.cgImage + } + } + + func update(rect: CGRect, within containerSize: CGSize) { + self.backgroundContent.frame = CGRect(origin: CGPoint(x: -rect.minX, y: -rect.minY), size: containerSize) + } +} diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageBubbleImages.swift b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleImages.swift index dc128a9fba..2f04369ec2 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageBubbleImages.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleImages.swift @@ -1,6 +1,8 @@ import Foundation import UIKit import Display +import TelegramPresentationData +import TelegramCore enum MessageBubbleImageNeighbors { case none @@ -24,11 +26,19 @@ func messageSingleBubbleLikeImage(fillColor: UIColor, strokeColor: UIColor) -> U })!.stretchableImage(withLeftCapWidth: Int(diameter / 2.0), topCapHeight: Int(diameter / 2.0)) } -func messageBubbleImage(incoming: Bool, fillColor: UIColor, strokeColor: UIColor, neighbors: MessageBubbleImageNeighbors) -> UIImage { +func messageBubbleImage(incoming: Bool, fillColor: UIColor, strokeColor: UIColor, neighbors: MessageBubbleImageNeighbors, theme: PresentationThemeChat, wallpaper: TelegramWallpaper) -> UIImage { let diameter: CGFloat = 36.0 let corner: CGFloat = 7.0 return generateImage(CGSize(width: 42.0, height: diameter), contextGenerator: { size, context in - context.clear(CGRect(origin: CGPoint(), size: size)) + var drawWithClearColor = false + + if case let .color(color) = wallpaper { + drawWithClearColor = true + context.setFillColor(UIColor(rgb: UInt32(color)).cgColor) + context.fill(CGRect(origin: CGPoint(), size: size)) + } else { + context.clear(CGRect(origin: CGPoint(), size: size)) + } let additionalOffset: CGFloat switch neighbors { @@ -44,40 +54,57 @@ func messageBubbleImage(incoming: Bool, fillColor: UIColor, strokeColor: UIColor let lineWidth: CGFloat = 1.0 - context.setFillColor(fillColor.cgColor) - context.setLineWidth(lineWidth) - context.setStrokeColor(strokeColor.cgColor) + if drawWithClearColor { + context.setBlendMode(.copy) + context.setFillColor(UIColor.clear.cgColor) + } else { + context.setFillColor(fillColor.cgColor) + context.setLineWidth(lineWidth) + context.setStrokeColor(strokeColor.cgColor) + } switch neighbors { case .none: - let _ = try? drawSvgPath(context, path: "M6,17.5 C6,7.83289181 13.8350169,0 23.5,0 C33.1671082,0 41,7.83501688 41,17.5 C41,27.1671082 33.1649831,35 23.5,35 C19.2941198,35 15.4354328,33.5169337 12.4179496,31.0453367 C9.05531719,34.9894816 -2.41102995e-08,35 0,35 C5.972003,31.5499861 6,26.8616169 6,26.8616169 L6,17.5 L6,17.5 ") - context.strokePath() + if !drawWithClearColor { + let _ = try? drawSvgPath(context, path: "M6,17.5 C6,7.83289181 13.8350169,0 23.5,0 C33.1671082,0 41,7.83501688 41,17.5 C41,27.1671082 33.1649831,35 23.5,35 C19.2941198,35 15.4354328,33.5169337 12.4179496,31.0453367 C9.05531719,34.9894816 -2.41102995e-08,35 0,35 C5.972003,31.5499861 6,26.8616169 6,26.8616169 L6,17.5 L6,17.5 ") + context.strokePath() + } let _ = try? drawSvgPath(context, path: "M6,17.5 C6,7.83289181 13.8350169,0 23.5,0 C33.1671082,0 41,7.83501688 41,17.5 C41,27.1671082 33.1649831,35 23.5,35 C19.2941198,35 15.4354328,33.5169337 12.4179496,31.0453367 C9.05531719,34.9894816 -2.41102995e-08,35 0,35 C5.972003,31.5499861 6,26.8616169 6,26.8616169 L6,17.5 L6,17.5 ") context.fillPath() case .side: - context.strokeEllipse(in: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: 35.0, height: 35.0))) - context.strokePath() + if !drawWithClearColor { + context.strokeEllipse(in: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: 35.0, height: 35.0))) + context.strokePath() + } context.fillEllipse(in: CGRect(origin: CGPoint(x: 0.0, y: 0.0), size: CGSize(width: 35.0, height: 35.0))) case let .top(side): if side { - let _ = try? drawSvgPath(context, path: "M17.5,0 L17.5,0 C27.1649831,-1.7754286e-15 35,7.83501688 35,17.5 L35,29 C35,32.3137085 32.3137085,35 29,35 L6,35 C2.6862915,35 4.05812251e-16,32.3137085 0,29 L0,17.5 C-1.18361906e-15,7.83501688 7.83501688,1.7754286e-15 17.5,0 ") - context.strokePath() + if !drawWithClearColor { + let _ = try? drawSvgPath(context, path: "M17.5,0 L17.5,0 C27.1649831,-1.7754286e-15 35,7.83501688 35,17.5 L35,29 C35,32.3137085 32.3137085,35 29,35 L6,35 C2.6862915,35 4.05812251e-16,32.3137085 0,29 L0,17.5 C-1.18361906e-15,7.83501688 7.83501688,1.7754286e-15 17.5,0 ") + context.strokePath() + } let _ = try? drawSvgPath(context, path: "M17.5,0 L17.5,0 C27.1649831,-1.7754286e-15 35,7.83501688 35,17.5 L35,29 C35,32.3137085 32.3137085,35 29,35 L6,35 C2.6862915,35 4.05812251e-16,32.3137085 0,29 L0,17.5 C-1.18361906e-15,7.83501688 7.83501688,1.7754286e-15 17.5,0 ") context.fillPath() } else { - let _ = try? drawSvgPath(context, path: "M35,17.5 C35,7.83501688 27.1671082,0 17.5,0 L17.5,0 C7.83501688,0 0,7.83289181 0,17.5 L0,29.0031815 C0,32.3151329 2.6882755,35 5.99681848,35 L17.5,35 C27.1649831,35 35,27.1671082 35,17.5 L35,17.5 L35,17.5 ") - context.strokePath() + if !drawWithClearColor { + let _ = try? drawSvgPath(context, path: "M35,17.5 C35,7.83501688 27.1671082,0 17.5,0 L17.5,0 C7.83501688,0 0,7.83289181 0,17.5 L0,29.0031815 C0,32.3151329 2.6882755,35 5.99681848,35 L17.5,35 C27.1649831,35 35,27.1671082 35,17.5 L35,17.5 L35,17.5 ") + context.strokePath() + } let _ = try? drawSvgPath(context, path: "M35,17.5 C35,7.83501688 27.1671082,0 17.5,0 L17.5,0 C7.83501688,0 0,7.83289181 0,17.5 L0,29.0031815 C0,32.3151329 2.6882755,35 5.99681848,35 L17.5,35 C27.1649831,35 35,27.1671082 35,17.5 L35,17.5 L35,17.5 ") context.fillPath() } case .bottom: - let _ = try? drawSvgPath(context, path: "M6,17.5 L6,5.99681848 C6,2.6882755 8.68486709,0 11.9968185,0 L23.5,0 C33.1671082,0 41,7.83501688 41,17.5 C41,27.1671082 33.1649831,35 23.5,35 C19.2941198,35 15.4354328,33.5169337 12.4179496,31.0453367 C9.05531719,34.9894816 -2.41103066e-08,35 0,35 C5.972003,31.5499861 6,26.8616169 6,26.8616169 L6,17.5 L6,17.5 ") - context.strokePath() + if !drawWithClearColor { + let _ = try? drawSvgPath(context, path: "M6,17.5 L6,5.99681848 C6,2.6882755 8.68486709,0 11.9968185,0 L23.5,0 C33.1671082,0 41,7.83501688 41,17.5 C41,27.1671082 33.1649831,35 23.5,35 C19.2941198,35 15.4354328,33.5169337 12.4179496,31.0453367 C9.05531719,34.9894816 -2.41103066e-08,35 0,35 C5.972003,31.5499861 6,26.8616169 6,26.8616169 L6,17.5 L6,17.5 ") + context.strokePath() + } let _ = try? drawSvgPath(context, path: "M6,17.5 L6,5.99681848 C6,2.6882755 8.68486709,0 11.9968185,0 L23.5,0 C33.1671082,0 41,7.83501688 41,17.5 C41,27.1671082 33.1649831,35 23.5,35 C19.2941198,35 15.4354328,33.5169337 12.4179496,31.0453367 C9.05531719,34.9894816 -2.41103066e-08,35 0,35 C5.972003,31.5499861 6,26.8616169 6,26.8616169 L6,17.5 L6,17.5 ") context.fillPath() case .both: - let _ = try? drawSvgPath(context, path: "M35,17.5 C35,7.83501688 27.1671082,0 17.5,0 L5.99681848,0 C2.68486709,0 0,2.6882755 0,5.99681848 L0,29.0031815 C0,32.3151329 2.6882755,35 5.99681848,35 L17.5,35 C27.1649831,35 35,27.1671082 35,17.5 L35,17.5 L35,17.5 ") - context.strokePath() + if !drawWithClearColor { + let _ = try? drawSvgPath(context, path: "M35,17.5 C35,7.83501688 27.1671082,0 17.5,0 L5.99681848,0 C2.68486709,0 0,2.6882755 0,5.99681848 L0,29.0031815 C0,32.3151329 2.6882755,35 5.99681848,35 L17.5,35 C27.1649831,35 35,27.1671082 35,17.5 L35,17.5 L35,17.5 ") + context.strokePath() + } let _ = try? drawSvgPath(context, path: "M35,17.5 C35,7.83501688 27.1671082,0 17.5,0 L5.99681848,0 C2.68486709,0 0,2.6882755 0,5.99681848 L0,29.0031815 C0,32.3151329 2.6882755,35 5.99681848,35 L17.5,35 C27.1649831,35 35,27.1671082 35,17.5 L35,17.5 L35,17.5 ") context.fillPath() } diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift index fe9fabddb0..b0a2b94344 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift @@ -128,6 +128,7 @@ private enum ContentNodeOperation { } class ChatMessageBubbleItemNode: ChatMessageItemView { + private let backgroundWallpaperNode: ChatMessageBubbleBackdrop private let backgroundNode: ChatMessageBackground private var transitionClippingNode: ASDisplayNode? @@ -171,11 +172,14 @@ class ChatMessageBubbleItemNode: ChatMessageItemView { } required init() { + self.backgroundWallpaperNode = ChatMessageBubbleBackdrop() + self.backgroundNode = ChatMessageBackground() self.messageAccessibilityArea = AccessibilityAreaNode() super.init(layerBacked: false) + self.addSubnode(self.backgroundWallpaperNode) self.addSubnode(self.backgroundNode) self.addSubnode(self.messageAccessibilityArea) @@ -215,17 +219,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView { override func animateAdded(_ currentTimestamp: Double, duration: Double) { super.animateAdded(currentTimestamp, duration: duration) - self.backgroundNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) - - self.nameNode?.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) - self.adminBadgeNode?.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) - self.credibilityIconNode?.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) - self.forwardInfoNode?.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) - self.replyInfoNode?.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) - - for contentNode in self.contentNodes { - contentNode.animateAdded(currentTimestamp, duration: duration) - } + self.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) } override func didLoad() { @@ -1370,6 +1364,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView { backgroundType = .incoming(mergeType) } strongSelf.backgroundNode.setType(type: backgroundType, highlighted: strongSelf.highlightedState, graphics: graphics, transition: transition) + strongSelf.backgroundWallpaperNode.setType(incoming: incoming, theme: item.presentationData.theme, mediaBox: item.context.account.postbox.mediaBox) strongSelf.backgroundType = backgroundType @@ -1628,6 +1623,10 @@ class ChatMessageBubbleItemNode: ChatMessageItemView { strongSelf.backgroundFrameTransition = nil } strongSelf.backgroundNode.frame = backgroundFrame + strongSelf.backgroundWallpaperNode.frame = backgroundFrame + if let (rect, size) = strongSelf.absoluteRect { + strongSelf.updateAbsoluteRect(rect, within: size) + } strongSelf.messageAccessibilityArea.frame = backgroundFrame if let shareButtonNode = strongSelf.shareButtonNode { shareButtonNode.frame = CGRect(origin: CGPoint(x: backgroundFrame.maxX + 8.0, y: backgroundFrame.maxY - 30.0), size: CGSize(width: 29.0, height: 29.0)) @@ -1774,6 +1773,10 @@ class ChatMessageBubbleItemNode: ChatMessageItemView { if let backgroundFrameTransition = self.backgroundFrameTransition { let backgroundFrame = CGRect.interpolator()(backgroundFrameTransition.0, backgroundFrameTransition.1, progress) as! CGRect self.backgroundNode.frame = backgroundFrame + self.backgroundWallpaperNode.frame = backgroundFrame + if let (rect, size) = self.absoluteRect { + self.updateAbsoluteRect(rect, within: size) + } self.messageAccessibilityArea.frame = backgroundFrame if let shareButtonNode = self.shareButtonNode { @@ -2115,7 +2118,6 @@ class ChatMessageBubbleItemNode: ChatMessageItemView { if !self.backgroundNode.frame.contains(point) { if self.actionButtonsNode == nil || !self.actionButtonsNode!.frame.contains(point) { - //return nil } } @@ -2189,6 +2191,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView { } self.backgroundNode.isHidden = hasHiddenBackground + self.backgroundWallpaperNode.isHidden = hasHiddenBackground } override func updateAutomaticMediaDownloadSettings() { @@ -2437,4 +2440,12 @@ class ChatMessageBubbleItemNode: ChatMessageItemView { break } } + + private var absoluteRect: (CGRect, CGSize)? + + override func updateAbsoluteRect(_ rect: CGRect, within containerSize: CGSize) { + self.absoluteRect = (rect, containerSize) + let mappedRect = CGRect(origin: CGPoint(x: rect.minX + self.backgroundWallpaperNode.frame.minX, y: containerSize.height - rect.maxY + self.backgroundWallpaperNode.frame.minY), size: rect.size) + self.backgroundWallpaperNode.update(rect: mappedRect, within: containerSize) + } } diff --git a/submodules/TelegramUI/TelegramUI/PresentationThemeEssentialGraphics.swift b/submodules/TelegramUI/TelegramUI/PresentationThemeEssentialGraphics.swift index ea5bd20001..d38be39677 100644 --- a/submodules/TelegramUI/TelegramUI/PresentationThemeEssentialGraphics.swift +++ b/submodules/TelegramUI/TelegramUI/PresentationThemeEssentialGraphics.swift @@ -131,32 +131,32 @@ public final class PrincipalThemeEssentialGraphics { let incoming: PresentationThemeBubbleColorComponents = wallpaper.isEmpty ? theme.message.incoming.bubble.withoutWallpaper : theme.message.incoming.bubble.withWallpaper let outgoing: PresentationThemeBubbleColorComponents = wallpaper.isEmpty ? theme.message.outgoing.bubble.withoutWallpaper : theme.message.outgoing.bubble.withWallpaper - self.chatMessageBackgroundIncomingImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .none) - self.chatMessageBackgroundIncomingHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .none) - self.chatMessageBackgroundIncomingMergedTopImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .top(side: false)) - self.chatMessageBackgroundIncomingMergedTopHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .top(side: false)) - self.chatMessageBackgroundIncomingMergedTopSideImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .top(side: true)) - self.chatMessageBackgroundIncomingMergedTopSideHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .top(side: true)) - self.chatMessageBackgroundIncomingMergedBottomImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .bottom) - self.chatMessageBackgroundIncomingMergedBottomHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .bottom) - self.chatMessageBackgroundIncomingMergedBothImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .both) - self.chatMessageBackgroundIncomingMergedBothHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .both) + self.chatMessageBackgroundIncomingImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundIncomingHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundIncomingMergedTopImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .top(side: false), theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundIncomingMergedTopHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .top(side: false), theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundIncomingMergedTopSideImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .top(side: true), theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundIncomingMergedTopSideHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .top(side: true), theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundIncomingMergedBottomImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundIncomingMergedBottomHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundIncomingMergedBothImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .both, theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundIncomingMergedBothHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .both, theme: theme, wallpaper: wallpaper) - self.chatMessageBackgroundOutgoingImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .none) - self.chatMessageBackgroundOutgoingHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .none) - self.chatMessageBackgroundOutgoingMergedTopImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .top(side: false)) - self.chatMessageBackgroundOutgoingMergedTopHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .top(side: false)) - self.chatMessageBackgroundOutgoingMergedTopSideImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .top(side: true)) - self.chatMessageBackgroundOutgoingMergedTopSideHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .top(side: true)) - self.chatMessageBackgroundOutgoingMergedBottomImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .bottom) - self.chatMessageBackgroundOutgoingMergedBottomHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .bottom) - self.chatMessageBackgroundOutgoingMergedBothImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .both) - self.chatMessageBackgroundOutgoingMergedBothHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .both) + self.chatMessageBackgroundOutgoingImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundOutgoingHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .none, theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundOutgoingMergedTopImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .top(side: false), theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundOutgoingMergedTopHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .top(side: false), theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundOutgoingMergedTopSideImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .top(side: true), theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundOutgoingMergedTopSideHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .top(side: true), theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundOutgoingMergedBottomImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundOutgoingMergedBottomHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .bottom, theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundOutgoingMergedBothImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .both, theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundOutgoingMergedBothHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .both, theme: theme, wallpaper: wallpaper) - self.chatMessageBackgroundIncomingMergedSideImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .side) - self.chatMessageBackgroundOutgoingMergedSideImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .side) - self.chatMessageBackgroundIncomingMergedSideHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .side) - self.chatMessageBackgroundOutgoingMergedSideHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .side) + self.chatMessageBackgroundIncomingMergedSideImage = messageBubbleImage(incoming: true, fillColor: incoming.fill, strokeColor: incoming.stroke, neighbors: .side, theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundOutgoingMergedSideImage = messageBubbleImage(incoming: false, fillColor: outgoing.fill, strokeColor: outgoing.stroke, neighbors: .side, theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundIncomingMergedSideHighlightedImage = messageBubbleImage(incoming: true, fillColor: incoming.highlightedFill, strokeColor: incoming.stroke, neighbors: .side, theme: theme, wallpaper: wallpaper) + self.chatMessageBackgroundOutgoingMergedSideHighlightedImage = messageBubbleImage(incoming: false, fillColor: outgoing.highlightedFill, strokeColor: outgoing.stroke, neighbors: .side, theme: theme, wallpaper: wallpaper) self.checkBubbleFullImage = generateCheckImage(partial: false, color: theme.message.outgoingCheckColor)! self.checkBubblePartialImage = generateCheckImage(partial: true, color: theme.message.outgoingCheckColor)! diff --git a/submodules/TelegramUI/TelegramUI_Xcode.xcodeproj/project.pbxproj b/submodules/TelegramUI/TelegramUI_Xcode.xcodeproj/project.pbxproj index 8a4c511a03..d306ee29c2 100644 --- a/submodules/TelegramUI/TelegramUI_Xcode.xcodeproj/project.pbxproj +++ b/submodules/TelegramUI/TelegramUI_Xcode.xcodeproj/project.pbxproj @@ -1225,6 +1225,7 @@ D0FA08C020483F9600DD23FC /* ExtractVideoData.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0FA08BF20483F9600DD23FC /* ExtractVideoData.swift */; }; D0FA08C8204982DC00DD23FC /* ChatTextInputActionButtonsNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0FA08C7204982DC00DD23FC /* ChatTextInputActionButtonsNode.swift */; }; D0FA08CA2049BEAC00DD23FC /* ChatEmptyNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0FA08C92049BEAC00DD23FC /* ChatEmptyNode.swift */; }; + D0FAB13E22EBC25300D8BED2 /* ChatMessageBubbleBackdrop.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0FAB13D22EBC25300D8BED2 /* ChatMessageBubbleBackdrop.swift */; }; D0FB87B21F7C4C19004DE005 /* FetchMediaUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0FB87B11F7C4C19004DE005 /* FetchMediaUtils.swift */; }; D0FBE84F2273395C00B33B52 /* ChatListArchiveInfoItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0FBE84E2273395C00B33B52 /* ChatListArchiveInfoItem.swift */; }; D0FC194D201F82A000FEDBB2 /* OpenResolvedUrl.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0FC194C201F82A000FEDBB2 /* OpenResolvedUrl.swift */; }; @@ -2488,6 +2489,7 @@ D0FA0AC41E77431A005BB9B7 /* InstalledStickerPacksController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InstalledStickerPacksController.swift; sourceTree = ""; }; D0FA34FE1EA5834C00E56FFA /* ItemListControllerSegmentedTitleView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemListControllerSegmentedTitleView.swift; sourceTree = ""; }; D0FA35001EA6127000E56FFA /* StorageUsageController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StorageUsageController.swift; sourceTree = ""; }; + D0FAB13D22EBC25300D8BED2 /* ChatMessageBubbleBackdrop.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatMessageBubbleBackdrop.swift; sourceTree = ""; }; D0FB87B11F7C4C19004DE005 /* FetchMediaUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FetchMediaUtils.swift; sourceTree = ""; }; D0FBE84E2273395C00B33B52 /* ChatListArchiveInfoItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatListArchiveInfoItem.swift; sourceTree = ""; }; D0FC194C201F82A000FEDBB2 /* OpenResolvedUrl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OpenResolvedUrl.swift; sourceTree = ""; }; @@ -4782,6 +4784,7 @@ D0AB262821C307D7008F6685 /* ChatMessagePollBubbleContentNode.swift */, 099529AF21D2123E00805E13 /* ChatMessageUnsupportedBubbleContentNode.swift */, D0439B5A228EC4A00067E026 /* ChatMessagePhoneNumberRequestContentNode.swift */, + D0FAB13D22EBC25300D8BED2 /* ChatMessageBubbleBackdrop.swift */, ); name = Items; sourceTree = ""; @@ -6333,6 +6336,7 @@ D0EC6E741EB9F58900EBF1C3 /* ThemeGridController.swift in Sources */, D0EC6E751EB9F58900EBF1C3 /* ThemeGridControllerNode.swift in Sources */, D0EC6E761EB9F58900EBF1C3 /* SettingsController.swift in Sources */, + D0FAB13E22EBC25300D8BED2 /* ChatMessageBubbleBackdrop.swift in Sources */, D0EC6E771EB9F58900EBF1C3 /* NotificationsAndSounds.swift in Sources */, D0EC6E781EB9F58900EBF1C3 /* NotificationSoundSelection.swift in Sources */, D056CD741FF2996B00880D28 /* ExternalMusicAlbumArtResources.swift in Sources */, From 6602671913d80a3447cedd4e3d3d3a5a20aff8b8 Mon Sep 17 00:00:00 2001 From: Peter <> Date: Fri, 2 Aug 2019 20:54:33 +0300 Subject: [PATCH 2/2] Fix build --- .../project.pbxproj | 2 - .../project.pbxproj | 4 + .../CachedResourceRepresentations.swift | 154 +++++++++--------- .../ChatControllerBackgroundNode.swift | 1 + .../project.pbxproj | 4 + .../TelegramUI/ChatHistoryListNode.swift | 1 + .../ChatMessageBubbleBackdrop.swift | 1 + .../ChatMessageBubbleItemNode.swift | 4 +- .../ChatMessageDateAndStatusNode.swift | 4 +- .../TelegramUI/ChatMessageDateHeader.swift | 10 +- ...SendMessageActionSheetControllerNode.swift | 2 +- .../TelegramUI/ChatUnreadItem.swift | 2 +- .../TelegramUI/ContactListNode.swift | 2 + .../TelegramUI/CustomWallpaperPicker.swift | 1 + .../TelegramUI/EmojiResources.swift | 1 + .../FetchCachedRepresentations.swift | 1 + .../LegacyInstantVideoController.swift | 2 +- .../TelegramUI/NotificationsAndSounds.swift | 1 + .../TelegramUI/TelegramUI/Permission.swift | 1 + .../TelegramUI/PhotoResources.swift | 1 + .../TelegramUI/SettingsController.swift | 1 + .../TelegramUI/StickerResources.swift | 1 + .../TelegramUI/UpgradedAccounts.swift | 1 + .../WallpaperGalleryController.swift | 1 + .../TelegramUI/WallpaperGalleryItem.swift | 1 + .../TelegramUI/WallpaperResources.swift | 1 + .../TelegramUI/WallpaperUploadManager.swift | 1 + .../project.pbxproj | 4 - 28 files changed, 118 insertions(+), 92 deletions(-) diff --git a/submodules/AccountContext/AccountContext_Xcode.xcodeproj/project.pbxproj b/submodules/AccountContext/AccountContext_Xcode.xcodeproj/project.pbxproj index 2e1f470179..e9f1cc4ae8 100644 --- a/submodules/AccountContext/AccountContext_Xcode.xcodeproj/project.pbxproj +++ b/submodules/AccountContext/AccountContext_Xcode.xcodeproj/project.pbxproj @@ -7,7 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - D06018E522F36A3900796784 /* DeviceAccess.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D06018E422F36A3900796784 /* DeviceAccess.framework */; }; D06018E722F36A3F00796784 /* TelegramPresentationData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D06018E622F36A3F00796784 /* TelegramPresentationData.framework */; }; D0D3285422F329A900D07EE2 /* AccountContext.h in Headers */ = {isa = PBXBuildFile; fileRef = D0D3285222F329A900D07EE2 /* AccountContext.h */; settings = {ATTRIBUTES = (Public, ); }; }; D0D3285F22F335B000D07EE2 /* AccountContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0D3285E22F335B000D07EE2 /* AccountContext.swift */; }; @@ -36,7 +35,6 @@ buildActionMask = 2147483647; files = ( D06018E722F36A3F00796784 /* TelegramPresentationData.framework in Frameworks */, - D06018E522F36A3900796784 /* DeviceAccess.framework in Frameworks */, D0D328A322F3462800D07EE2 /* SwiftSignalKit.framework in Frameworks */, D0D328A122F3462400D07EE2 /* Postbox.framework in Frameworks */, D0D3289F22F3462000D07EE2 /* TelegramCore.framework in Frameworks */, diff --git a/submodules/DeviceAccess/DeviceAccess_Xcode.xcodeproj/project.pbxproj b/submodules/DeviceAccess/DeviceAccess_Xcode.xcodeproj/project.pbxproj index a801764776..16d0d369ee 100644 --- a/submodules/DeviceAccess/DeviceAccess_Xcode.xcodeproj/project.pbxproj +++ b/submodules/DeviceAccess/DeviceAccess_Xcode.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + D068EE9222F4ABB60064E921 /* AccountContext.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D068EE9122F4ABB60064E921 /* AccountContext.framework */; }; D0AE31FE22B281300058D3BC /* DeviceAccess.h in Headers */ = {isa = PBXBuildFile; fileRef = D0AE31FC22B281300058D3BC /* DeviceAccess.h */; settings = {ATTRIBUTES = (Public, ); }; }; D0AE320522B2818D0058D3BC /* DeviceAccess.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0AE320422B2818D0058D3BC /* DeviceAccess.swift */; }; D0AE320A22B281CA0058D3BC /* Display.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D0AE320922B281CA0058D3BC /* Display.framework */; }; @@ -17,6 +18,7 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + D068EE9122F4ABB60064E921 /* AccountContext.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = AccountContext.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D0AE31F922B281300058D3BC /* DeviceAccess.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = DeviceAccess.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D0AE31FC22B281300058D3BC /* DeviceAccess.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DeviceAccess.h; sourceTree = ""; }; D0AE31FD22B281300058D3BC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -33,6 +35,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D068EE9222F4ABB60064E921 /* AccountContext.framework in Frameworks */, D0AE321222B2821B0058D3BC /* TelegramPresentationData.framework in Frameworks */, D0AE321022B281E50058D3BC /* LegacyComponents.framework in Frameworks */, D0AE320E22B281D30058D3BC /* SwiftSignalKit.framework in Frameworks */, @@ -74,6 +77,7 @@ D0AE320822B281CA0058D3BC /* Frameworks */ = { isa = PBXGroup; children = ( + D068EE9122F4ABB60064E921 /* AccountContext.framework */, D0AE321122B2821B0058D3BC /* TelegramPresentationData.framework */, D0AE320F22B281E50058D3BC /* LegacyComponents.framework */, D0AE320D22B281D30058D3BC /* SwiftSignalKit.framework */, diff --git a/submodules/MediaResources/Sources/CachedResourceRepresentations.swift b/submodules/MediaResources/Sources/CachedResourceRepresentations.swift index e962023208..550dc45c74 100644 --- a/submodules/MediaResources/Sources/CachedResourceRepresentations.swift +++ b/submodules/MediaResources/Sources/CachedResourceRepresentations.swift @@ -3,11 +3,11 @@ import UIKit import Postbox import SwiftSignalKit -final class CachedStickerAJpegRepresentation: CachedMediaResourceRepresentation { - let size: CGSize? - let keepDuration: CachedMediaRepresentationKeepDuration = .general +public final class CachedStickerAJpegRepresentation: CachedMediaResourceRepresentation { + public let size: CGSize? + public let keepDuration: CachedMediaRepresentationKeepDuration = .general - var uniqueId: String { + public var uniqueId: String { if let size = self.size { return "sticker-ajpeg-\(Int(size.width))x\(Int(size.height))" } else { @@ -15,11 +15,11 @@ final class CachedStickerAJpegRepresentation: CachedMediaResourceRepresentation } } - init(size: CGSize?) { + public init(size: CGSize?) { self.size = size } - func isEqual(to: CachedMediaResourceRepresentation) -> Bool { + public func isEqual(to: CachedMediaResourceRepresentation) -> Bool { if let to = to as? CachedStickerAJpegRepresentation { return self.size == to.size } else { @@ -28,27 +28,27 @@ final class CachedStickerAJpegRepresentation: CachedMediaResourceRepresentation } } -enum CachedScaledImageRepresentationMode: Int32 { +public enum CachedScaledImageRepresentationMode: Int32 { case fill = 0 case aspectFit = 1 } -final class CachedScaledImageRepresentation: CachedMediaResourceRepresentation { - let keepDuration: CachedMediaRepresentationKeepDuration = .general +public final class CachedScaledImageRepresentation: CachedMediaResourceRepresentation { + public let keepDuration: CachedMediaRepresentationKeepDuration = .general - let size: CGSize - let mode: CachedScaledImageRepresentationMode + public let size: CGSize + public let mode: CachedScaledImageRepresentationMode - var uniqueId: String { + public var uniqueId: String { return "scaled-image-\(Int(self.size.width))x\(Int(self.size.height))-\(self.mode.rawValue)" } - init(size: CGSize, mode: CachedScaledImageRepresentationMode) { + public init(size: CGSize, mode: CachedScaledImageRepresentationMode) { self.size = size self.mode = mode } - func isEqual(to: CachedMediaResourceRepresentation) -> Bool { + public func isEqual(to: CachedMediaResourceRepresentation) -> Bool { if let to = to as? CachedScaledImageRepresentation { return self.size == to.size && self.mode == to.mode } else { @@ -57,14 +57,17 @@ final class CachedScaledImageRepresentation: CachedMediaResourceRepresentation { } } -final class CachedVideoFirstFrameRepresentation: CachedMediaResourceRepresentation { - let keepDuration: CachedMediaRepresentationKeepDuration = .general +public final class CachedVideoFirstFrameRepresentation: CachedMediaResourceRepresentation { + public let keepDuration: CachedMediaRepresentationKeepDuration = .general - var uniqueId: String { + public var uniqueId: String { return "first-frame" } - func isEqual(to: CachedMediaResourceRepresentation) -> Bool { + public init() { + } + + public func isEqual(to: CachedMediaResourceRepresentation) -> Bool { if to is CachedVideoFirstFrameRepresentation { return true } else { @@ -73,20 +76,20 @@ final class CachedVideoFirstFrameRepresentation: CachedMediaResourceRepresentati } } -final class CachedScaledVideoFirstFrameRepresentation: CachedMediaResourceRepresentation { - let keepDuration: CachedMediaRepresentationKeepDuration = .general +public final class CachedScaledVideoFirstFrameRepresentation: CachedMediaResourceRepresentation { + public let keepDuration: CachedMediaRepresentationKeepDuration = .general - let size: CGSize + public let size: CGSize - var uniqueId: String { + public var uniqueId: String { return "scaled-frame-\(Int(self.size.width))x\(Int(self.size.height))" } - init(size: CGSize) { + public init(size: CGSize) { self.size = size } - func isEqual(to: CachedMediaResourceRepresentation) -> Bool { + public func isEqual(to: CachedMediaResourceRepresentation) -> Bool { if let to = to as? CachedScaledVideoFirstFrameRepresentation { return self.size == to.size } else { @@ -95,14 +98,17 @@ final class CachedScaledVideoFirstFrameRepresentation: CachedMediaResourceRepres } } -final class CachedBlurredWallpaperRepresentation: CachedMediaResourceRepresentation { - let keepDuration: CachedMediaRepresentationKeepDuration = .general +public final class CachedBlurredWallpaperRepresentation: CachedMediaResourceRepresentation { + public let keepDuration: CachedMediaRepresentationKeepDuration = .general - var uniqueId: String { + public var uniqueId: String { return "blurred-wallpaper" } - func isEqual(to: CachedMediaResourceRepresentation) -> Bool { + public init() { + } + + public func isEqual(to: CachedMediaResourceRepresentation) -> Bool { if to is CachedBlurredWallpaperRepresentation { return true } else { @@ -111,12 +117,12 @@ final class CachedBlurredWallpaperRepresentation: CachedMediaResourceRepresentat } } -final class CachedPatternWallpaperMaskRepresentation: CachedMediaResourceRepresentation { - let keepDuration: CachedMediaRepresentationKeepDuration = .general +public final class CachedPatternWallpaperMaskRepresentation: CachedMediaResourceRepresentation { + public let keepDuration: CachedMediaRepresentationKeepDuration = .general - let size: CGSize? + public let size: CGSize? - var uniqueId: String { + public var uniqueId: String { if let size = self.size { return "pattern-wallpaper-mask-\(Int(size.width))x\(Int(size.height))" } else { @@ -124,11 +130,11 @@ final class CachedPatternWallpaperMaskRepresentation: CachedMediaResourceReprese } } - init(size: CGSize?) { + public init(size: CGSize?) { self.size = size } - func isEqual(to: CachedMediaResourceRepresentation) -> Bool { + public func isEqual(to: CachedMediaResourceRepresentation) -> Bool { if let to = to as? CachedPatternWallpaperMaskRepresentation { return self.size == to.size } else { @@ -138,22 +144,22 @@ final class CachedPatternWallpaperMaskRepresentation: CachedMediaResourceReprese } -final class CachedPatternWallpaperRepresentation: CachedMediaResourceRepresentation { - let keepDuration: CachedMediaRepresentationKeepDuration = .general +public final class CachedPatternWallpaperRepresentation: CachedMediaResourceRepresentation { + public let keepDuration: CachedMediaRepresentationKeepDuration = .general - let color: Int32 - let intensity: Int32 + public let color: Int32 + public let intensity: Int32 - var uniqueId: String { + public var uniqueId: String { return "pattern-wallpaper-\(self.color)-\(self.intensity)" } - init(color: Int32, intensity: Int32) { + public init(color: Int32, intensity: Int32) { self.color = color self.intensity = intensity } - func isEqual(to: CachedMediaResourceRepresentation) -> Bool { + public func isEqual(to: CachedMediaResourceRepresentation) -> Bool { if let to = to as? CachedPatternWallpaperRepresentation { return self.color == to.color && self.intensity == intensity } else { @@ -162,12 +168,12 @@ final class CachedPatternWallpaperRepresentation: CachedMediaResourceRepresentat } } -final class CachedAlbumArtworkRepresentation: CachedMediaResourceRepresentation { - let keepDuration: CachedMediaRepresentationKeepDuration = .general +public final class CachedAlbumArtworkRepresentation: CachedMediaResourceRepresentation { + public let keepDuration: CachedMediaRepresentationKeepDuration = .general - let size: CGSize? + public let size: CGSize? - var uniqueId: String { + public var uniqueId: String { if let size = self.size { return "album-artwork-\(Int(size.width))x\(Int(size.height))" } else { @@ -175,11 +181,11 @@ final class CachedAlbumArtworkRepresentation: CachedMediaResourceRepresentation } } - init(size: CGSize) { + public init(size: CGSize) { self.size = size } - func isEqual(to: CachedMediaResourceRepresentation) -> Bool { + public func isEqual(to: CachedMediaResourceRepresentation) -> Bool { if let to = to as? CachedAlbumArtworkRepresentation { return self.size == to.size } else { @@ -188,20 +194,20 @@ final class CachedAlbumArtworkRepresentation: CachedMediaResourceRepresentation } } -final class CachedEmojiThumbnailRepresentation: CachedMediaResourceRepresentation { - let keepDuration: CachedMediaRepresentationKeepDuration = .general +public final class CachedEmojiThumbnailRepresentation: CachedMediaResourceRepresentation { + public let keepDuration: CachedMediaRepresentationKeepDuration = .general - let outline: Bool + public let outline: Bool - var uniqueId: String { + public var uniqueId: String { return "emoji-thumb-\(self.outline ? 1 : 0)" } - init(outline: Bool) { + public init(outline: Bool) { self.outline = outline } - func isEqual(to: CachedMediaResourceRepresentation) -> Bool { + public func isEqual(to: CachedMediaResourceRepresentation) -> Bool { if let to = to as? CachedEmojiThumbnailRepresentation { return self.outline == to.outline } else { @@ -210,22 +216,22 @@ final class CachedEmojiThumbnailRepresentation: CachedMediaResourceRepresentatio } } -final class CachedEmojiRepresentation: CachedMediaResourceRepresentation { - let keepDuration: CachedMediaRepresentationKeepDuration = .general +public final class CachedEmojiRepresentation: CachedMediaResourceRepresentation { + public let keepDuration: CachedMediaRepresentationKeepDuration = .general - let tile: UInt8 - let outline: Bool + public let tile: UInt8 + public let outline: Bool - var uniqueId: String { + public var uniqueId: String { return "emoji-\(Int(self.tile))-\(self.outline ? 1 : 0)" } - init(tile: UInt8, outline: Bool) { + public init(tile: UInt8, outline: Bool) { self.tile = tile self.outline = outline } - func isEqual(to: CachedMediaResourceRepresentation) -> Bool { + public func isEqual(to: CachedMediaResourceRepresentation) -> Bool { if let to = to as? CachedEmojiRepresentation { return self.tile == to.tile && self.outline == to.outline } else { @@ -234,22 +240,22 @@ final class CachedEmojiRepresentation: CachedMediaResourceRepresentation { } } -final class CachedAnimatedStickerFirstFrameRepresentation: CachedMediaResourceRepresentation { - let keepDuration: CachedMediaRepresentationKeepDuration = .general +public final class CachedAnimatedStickerFirstFrameRepresentation: CachedMediaResourceRepresentation { + public let keepDuration: CachedMediaRepresentationKeepDuration = .general - let width: Int32 - let height: Int32 + public let width: Int32 + public let height: Int32 - init(width: Int32, height: Int32) { + public init(width: Int32, height: Int32) { self.width = width self.height = height } - var uniqueId: String { + public var uniqueId: String { return "animated-sticker-first-frame-\(self.width)x\(self.height)-v1" } - func isEqual(to: CachedMediaResourceRepresentation) -> Bool { + public func isEqual(to: CachedMediaResourceRepresentation) -> Bool { if let other = to as? CachedAnimatedStickerFirstFrameRepresentation { if other.width != self.width { return false @@ -264,22 +270,22 @@ final class CachedAnimatedStickerFirstFrameRepresentation: CachedMediaResourceRe } } -final class CachedAnimatedStickerRepresentation: CachedMediaResourceRepresentation { - let keepDuration: CachedMediaRepresentationKeepDuration = .shortLived +public final class CachedAnimatedStickerRepresentation: CachedMediaResourceRepresentation { + public let keepDuration: CachedMediaRepresentationKeepDuration = .shortLived - let width: Int32 - let height: Int32 + public let width: Int32 + public let height: Int32 - var uniqueId: String { + public var uniqueId: String { return "animated-sticker-\(self.width)x\(self.height)-v7" } - init(width: Int32, height: Int32) { + public init(width: Int32, height: Int32) { self.width = width self.height = height } - func isEqual(to: CachedMediaResourceRepresentation) -> Bool { + public func isEqual(to: CachedMediaResourceRepresentation) -> Bool { if let other = to as? CachedAnimatedStickerRepresentation { if other.width != self.width { return false diff --git a/submodules/TelegramPresentationData/Sources/ChatControllerBackgroundNode.swift b/submodules/TelegramPresentationData/Sources/ChatControllerBackgroundNode.swift index 7f0e2a65d3..7177414d56 100644 --- a/submodules/TelegramPresentationData/Sources/ChatControllerBackgroundNode.swift +++ b/submodules/TelegramPresentationData/Sources/ChatControllerBackgroundNode.swift @@ -5,6 +5,7 @@ import TelegramCore import Display import SwiftSignalKit import Postbox +import MediaResources private var backgroundImageForWallpaper: (TelegramWallpaper, Bool, UIImage)? diff --git a/submodules/TelegramPresentationData/TelegramPresentationData_Xcode.xcodeproj/project.pbxproj b/submodules/TelegramPresentationData/TelegramPresentationData_Xcode.xcodeproj/project.pbxproj index 679377e805..815c2bd81c 100644 --- a/submodules/TelegramPresentationData/TelegramPresentationData_Xcode.xcodeproj/project.pbxproj +++ b/submodules/TelegramPresentationData/TelegramPresentationData_Xcode.xcodeproj/project.pbxproj @@ -22,6 +22,7 @@ D06017F522F35A4000796784 /* PresentationThemeEssentialGraphics.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06017F422F35A4000796784 /* PresentationThemeEssentialGraphics.swift */; }; D06017F722F35A9200796784 /* ChatMessageBubbleImages.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06017F622F35A9200796784 /* ChatMessageBubbleImages.swift */; }; D06017F922F35ACF00796784 /* WallpaperUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = D06017F822F35ACF00796784 /* WallpaperUtils.swift */; }; + D068EE9022F4A9B60064E921 /* MediaResources.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D068EE8F22F4A9B60064E921 /* MediaResources.framework */; }; D084F9F022F3AEFD004874CE /* ChatControllerBackgroundNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D084F9EF22F3AEFD004874CE /* ChatControllerBackgroundNode.swift */; }; D0AE31AB22B273F20058D3BC /* TelegramPresentationData.h in Headers */ = {isa = PBXBuildFile; fileRef = D0AE31A922B273F20058D3BC /* TelegramPresentationData.h */; settings = {ATTRIBUTES = (Public, ); }; }; D0AE31B422B2746B0058D3BC /* PresentationStrings.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0AE31B122B2746B0058D3BC /* PresentationStrings.swift */; }; @@ -62,6 +63,7 @@ D06017F422F35A4000796784 /* PresentationThemeEssentialGraphics.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PresentationThemeEssentialGraphics.swift; sourceTree = ""; }; D06017F622F35A9200796784 /* ChatMessageBubbleImages.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatMessageBubbleImages.swift; sourceTree = ""; }; D06017F822F35ACF00796784 /* WallpaperUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WallpaperUtils.swift; sourceTree = ""; }; + D068EE8F22F4A9B60064E921 /* MediaResources.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = MediaResources.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D084F9EF22F3AEFD004874CE /* ChatControllerBackgroundNode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChatControllerBackgroundNode.swift; sourceTree = ""; }; D084F9F122F3AFEA004874CE /* AccountContext.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = AccountContext.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D0AE31A622B273F20058D3BC /* TelegramPresentationData.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = TelegramPresentationData.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -94,6 +96,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + D068EE9022F4A9B60064E921 /* MediaResources.framework in Frameworks */, D0AE31C322B274E90058D3BC /* TelegramUIPreferences.framework in Frameworks */, D0AE31BF22B274950058D3BC /* Display.framework in Frameworks */, D0AE31BD22B274830058D3BC /* TelegramCore.framework in Frameworks */, @@ -173,6 +176,7 @@ D0AE31B722B2747A0058D3BC /* Frameworks */ = { isa = PBXGroup; children = ( + D068EE8F22F4A9B60064E921 /* MediaResources.framework */, D084F9F122F3AFEA004874CE /* AccountContext.framework */, D0AE31C222B274E90058D3BC /* TelegramUIPreferences.framework */, D0AE31BE22B274950058D3BC /* Display.framework */, diff --git a/submodules/TelegramUI/TelegramUI/ChatHistoryListNode.swift b/submodules/TelegramUI/TelegramUI/ChatHistoryListNode.swift index 376d8b32f0..f9679681d3 100644 --- a/submodules/TelegramUI/TelegramUI/ChatHistoryListNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatHistoryListNode.swift @@ -7,6 +7,7 @@ import AsyncDisplayKit import TelegramCore import TelegramPresentationData import TelegramUIPreferences +import MediaResources private let historyMessageCount: Int = 100 diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageBubbleBackdrop.swift b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleBackdrop.swift index 2fefc5c632..204c9fe4c5 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageBubbleBackdrop.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleBackdrop.swift @@ -2,6 +2,7 @@ import Foundation import AsyncDisplayKit import Display import Postbox +import TelegramPresentationData final class ChatMessageBubbleBackdrop: ASDisplayNode { private let backgroundContent: ASDisplayNode diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift index cf4909bbff..fa9438ff29 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageBubbleItemNode.swift @@ -223,7 +223,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView { self?.allowsGroupOpacity = false }) self.layer.animateScale(from: 1.0, to: 0.1, duration: 0.15, removeOnCompletion: false) - self.layer.animatePosition(from: CGPoint(), to: CGPoint(x: self.bounds.width / 2.0 - self.backgroundNode.frame.midX, y: self.backgroundNode.frame.midY), duration: 0.15, timingFunction: kCAMediaTimingFunctionEaseInEaseOut, removeOnCompletion: false, additive: true) + self.layer.animatePosition(from: CGPoint(), to: CGPoint(x: self.bounds.width / 2.0 - self.backgroundNode.frame.midX, y: self.backgroundNode.frame.midY), duration: 0.15, timingFunction: CAMediaTimingFunctionName.easeInEaseOut.rawValue, removeOnCompletion: false, additive: true) } override func animateAdded(_ currentTimestamp: Double, duration: Double) { @@ -2357,7 +2357,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView { if self.highlightedState != highlighted { self.highlightedState = highlighted if let backgroundType = self.backgroundType { - let graphics = PresentationResourcesChat.principalGraphics(context: mediaBox: item.context.account.postbox.mediaBox, knockoutWallpaper: item.context.sharedContext.immediateExperimentalUISettings.knockoutWallpaper, theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper) + let graphics = PresentationResourcesChat.principalGraphics(mediaBox: item.context.account.postbox.mediaBox, knockoutWallpaper: item.context.sharedContext.immediateExperimentalUISettings.knockoutWallpaper, theme: item.presentationData.theme.theme, wallpaper: item.presentationData.theme.wallpaper) if highlighted { self.backgroundNode.setType(type: backgroundType, highlighted: true, graphics: graphics, transition: .immediate) diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageDateAndStatusNode.swift b/submodules/TelegramUI/TelegramUI/ChatMessageDateAndStatusNode.swift index dfe58f6f65..4266ffcdc1 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageDateAndStatusNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageDateAndStatusNode.swift @@ -127,7 +127,7 @@ class ChatMessageDateAndStatusNode: ASDisplayNode { self.addSubnode(self.dateNode) } - func asyncLayout() -> (_ context: AccountContext, _ presentationData: ChatPresentationData, _ edited: Bool, _ impressionCount: Int?, _ dateText: String, _ type: ChatMessageDateAndStatusType, _ constrainedSize: CGSize) -> (CGSize, (Bool) -> Void) { + func asyncLayout() -> (_ context: AccountContextImpl, _ presentationData: ChatPresentationData, _ edited: Bool, _ impressionCount: Int?, _ dateText: String, _ type: ChatMessageDateAndStatusType, _ constrainedSize: CGSize) -> (CGSize, (Bool) -> Void) { let dateLayout = TextNode.asyncLayout(self.dateNode) var checkReadNode = self.checkReadNode @@ -506,7 +506,7 @@ class ChatMessageDateAndStatusNode: ASDisplayNode { } } - static func asyncLayout(_ node: ChatMessageDateAndStatusNode?) -> (_ context: AccountContext, _ presentationData: ChatPresentationData, _ edited: Bool, _ impressionCount: Int?, _ dateText: String, _ type: ChatMessageDateAndStatusType, _ constrainedSize: CGSize) -> (CGSize, (Bool) -> ChatMessageDateAndStatusNode) { + static func asyncLayout(_ node: ChatMessageDateAndStatusNode?) -> (_ context: AccountContextImpl, _ presentationData: ChatPresentationData, _ edited: Bool, _ impressionCount: Int?, _ dateText: String, _ type: ChatMessageDateAndStatusType, _ constrainedSize: CGSize) -> (CGSize, (Bool) -> ChatMessageDateAndStatusNode) { let currentLayout = node?.asyncLayout() return { context, presentationData, edited, impressionCount, dateText, type, constrainedSize in let resultNode: ChatMessageDateAndStatusNode diff --git a/submodules/TelegramUI/TelegramUI/ChatMessageDateHeader.swift b/submodules/TelegramUI/TelegramUI/ChatMessageDateHeader.swift index bce6478c2d..ff80ca22b1 100644 --- a/submodules/TelegramUI/TelegramUI/ChatMessageDateHeader.swift +++ b/submodules/TelegramUI/TelegramUI/ChatMessageDateHeader.swift @@ -21,10 +21,10 @@ final class ChatMessageDateHeader: ListViewItemHeader { let id: Int64 let presentationData: ChatPresentationData - let context: AccountContext + let context: AccountContextImpl let action: ((Int32) -> Void)? - init(timestamp: Int32, presentationData: ChatPresentationData, context: AccountContext, action: ((Int32) -> Void)? = nil) { + init(timestamp: Int32, presentationData: ChatPresentationData, context: AccountContextImpl, action: ((Int32) -> Void)? = nil) { self.timestamp = timestamp self.presentationData = presentationData self.context = context @@ -86,13 +86,13 @@ final class ChatMessageDateHeaderNode: ListViewItemHeaderNode { private let localTimestamp: Int32 private var presentationData: ChatPresentationData - private let context: AccountContext + private let context: AccountContextImpl private var flashingOnScrolling = false private var stickDistanceFactor: CGFloat = 0.0 private var action: ((Int32) -> Void)? = nil - init(localTimestamp: Int32, presentationData: ChatPresentationData, context: AccountContext, action: ((Int32) -> Void)? = nil) { + init(localTimestamp: Int32, presentationData: ChatPresentationData, context: AccountContextImpl, action: ((Int32) -> Void)? = nil) { self.presentationData = presentationData self.context = context @@ -161,7 +161,7 @@ final class ChatMessageDateHeaderNode: ListViewItemHeaderNode { self.view.addGestureRecognizer(ListViewTapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:)))) } - func updatePresentationData(_ presentationData: ChatPresentationData, context: AccountContext) { + func updatePresentationData(_ presentationData: ChatPresentationData, context: AccountContextImpl) { let graphics = PresentationResourcesChat.principalGraphics(mediaBox: context.account.postbox.mediaBox, knockoutWallpaper: context.sharedContext.immediateExperimentalUISettings.knockoutWallpaper, theme: presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper) self.backgroundNode.image = graphics.dateStaticBackground diff --git a/submodules/TelegramUI/TelegramUI/ChatSendMessageActionSheetControllerNode.swift b/submodules/TelegramUI/TelegramUI/ChatSendMessageActionSheetControllerNode.swift index cddc4998ed..74877cbe4f 100644 --- a/submodules/TelegramUI/TelegramUI/ChatSendMessageActionSheetControllerNode.swift +++ b/submodules/TelegramUI/TelegramUI/ChatSendMessageActionSheetControllerNode.swift @@ -100,7 +100,7 @@ private final class ActionSheetItemNode: ASDisplayNode { } final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode, UIScrollViewDelegate { - private let context: AccountContext + private let context: AccountContextImpl private var presentationData: PresentationData private let sendButtonFrame: CGRect private let textFieldFrame: CGRect diff --git a/submodules/TelegramUI/TelegramUI/ChatUnreadItem.swift b/submodules/TelegramUI/TelegramUI/ChatUnreadItem.swift index 7eab2b712f..e73f376609 100644 --- a/submodules/TelegramUI/TelegramUI/ChatUnreadItem.swift +++ b/submodules/TelegramUI/TelegramUI/ChatUnreadItem.swift @@ -13,7 +13,7 @@ class ChatUnreadItem: ListViewItem { let presentationData: ChatPresentationData let header: ChatMessageDateHeader - init(index: MessageIndex, presentationData: ChatPresentationData, context: AccountContext) { + init(index: MessageIndex, presentationData: ChatPresentationData, context: AccountContextImpl) { self.index = index self.presentationData = presentationData self.header = ChatMessageDateHeader(timestamp: index.timestamp, presentationData: presentationData, context: context) diff --git a/submodules/TelegramUI/TelegramUI/ContactListNode.swift b/submodules/TelegramUI/TelegramUI/ContactListNode.swift index 35d0bf6e31..e642a48c1e 100644 --- a/submodules/TelegramUI/TelegramUI/ContactListNode.swift +++ b/submodules/TelegramUI/TelegramUI/ContactListNode.swift @@ -10,6 +10,8 @@ import TelegramUIPreferences import DeviceAccess import MergeLists import ItemListUI +import MediaResources +import AccountContext private let dropDownIcon = { () -> UIImage in UIGraphicsBeginImageContextWithOptions(CGSize(width: 12.0, height: 12.0), false, 0.0) diff --git a/submodules/TelegramUI/TelegramUI/CustomWallpaperPicker.swift b/submodules/TelegramUI/TelegramUI/CustomWallpaperPicker.swift index 51893e342e..eeda8c94d5 100644 --- a/submodules/TelegramUI/TelegramUI/CustomWallpaperPicker.swift +++ b/submodules/TelegramUI/TelegramUI/CustomWallpaperPicker.swift @@ -6,6 +6,7 @@ import Postbox import TelegramCore import LegacyComponents import TelegramUIPreferences +import MediaResources func presentCustomWallpaperPicker(context: AccountContextImpl, present: @escaping (ViewController) -> Void) { let presentationData = context.sharedContext.currentPresentationData.with { $0 } diff --git a/submodules/TelegramUI/TelegramUI/EmojiResources.swift b/submodules/TelegramUI/TelegramUI/EmojiResources.swift index 6983e6aa7a..9c6c7ad3ac 100644 --- a/submodules/TelegramUI/TelegramUI/EmojiResources.swift +++ b/submodules/TelegramUI/TelegramUI/EmojiResources.swift @@ -9,6 +9,7 @@ import WebPImage #else import WebP #endif +import MediaResources public struct EmojiThumbnailResourceId: MediaResourceId { public let emoji: String diff --git a/submodules/TelegramUI/TelegramUI/FetchCachedRepresentations.swift b/submodules/TelegramUI/TelegramUI/FetchCachedRepresentations.swift index e7c29f278e..84ec4e6c29 100644 --- a/submodules/TelegramUI/TelegramUI/FetchCachedRepresentations.swift +++ b/submodules/TelegramUI/TelegramUI/FetchCachedRepresentations.swift @@ -14,6 +14,7 @@ import WebP #endif import Lottie import TelegramUIPrivateModule +import MediaResources public func fetchCachedResourceRepresentation(account: Account, resource: MediaResource, representation: CachedMediaResourceRepresentation) -> Signal { if let representation = representation as? CachedStickerAJpegRepresentation { diff --git a/submodules/TelegramUI/TelegramUI/LegacyInstantVideoController.swift b/submodules/TelegramUI/TelegramUI/LegacyInstantVideoController.swift index 48ad746ebf..1ae295a704 100644 --- a/submodules/TelegramUI/TelegramUI/LegacyInstantVideoController.swift +++ b/submodules/TelegramUI/TelegramUI/LegacyInstantVideoController.swift @@ -5,7 +5,7 @@ import TelegramCore import Postbox import SwiftSignalKit import TelegramPresentationData - +import MediaResources import LegacyComponents final class InstantVideoControllerRecordingStatus { diff --git a/submodules/TelegramUI/TelegramUI/NotificationsAndSounds.swift b/submodules/TelegramUI/TelegramUI/NotificationsAndSounds.swift index ad8d4d6f17..5317a0f0c3 100644 --- a/submodules/TelegramUI/TelegramUI/NotificationsAndSounds.swift +++ b/submodules/TelegramUI/TelegramUI/NotificationsAndSounds.swift @@ -8,6 +8,7 @@ import TelegramPresentationData import TelegramUIPreferences import DeviceAccess import ItemListUI +import AccountContext private final class NotificationsAndSoundsArguments { let context: AccountContextImpl diff --git a/submodules/TelegramUI/TelegramUI/Permission.swift b/submodules/TelegramUI/TelegramUI/Permission.swift index 06247d162e..1b786fef04 100644 --- a/submodules/TelegramUI/TelegramUI/Permission.swift +++ b/submodules/TelegramUI/TelegramUI/Permission.swift @@ -3,6 +3,7 @@ import SwiftSignalKit import Postbox import TelegramCore import DeviceAccess +import AccountContext public enum PermissionKind: Int32 { case contacts diff --git a/submodules/TelegramUI/TelegramUI/PhotoResources.swift b/submodules/TelegramUI/TelegramUI/PhotoResources.swift index acc3ac7fb0..2dc7eb3957 100644 --- a/submodules/TelegramUI/TelegramUI/PhotoResources.swift +++ b/submodules/TelegramUI/TelegramUI/PhotoResources.swift @@ -13,6 +13,7 @@ import WebPImage import WebP #endif import TelegramUIPreferences +import MediaResources private enum ResourceFileData { case data(Data) diff --git a/submodules/TelegramUI/TelegramUI/SettingsController.swift b/submodules/TelegramUI/TelegramUI/SettingsController.swift index 7f19bfffea..1d452e708f 100644 --- a/submodules/TelegramUI/TelegramUI/SettingsController.swift +++ b/submodules/TelegramUI/TelegramUI/SettingsController.swift @@ -15,6 +15,7 @@ import TelegramPresentationData import TelegramUIPreferences import DeviceAccess import ItemListUI +import AccountContext private let maximumNumberOfAccounts = 3 diff --git a/submodules/TelegramUI/TelegramUI/StickerResources.swift b/submodules/TelegramUI/TelegramUI/StickerResources.swift index 772a8c99a2..f8239df0b8 100644 --- a/submodules/TelegramUI/TelegramUI/StickerResources.swift +++ b/submodules/TelegramUI/TelegramUI/StickerResources.swift @@ -5,6 +5,7 @@ import SwiftSignalKit import Display import TelegramUIPrivateModule import TelegramCore +import MediaResources private func imageFromAJpeg(data: Data) -> (UIImage, UIImage)? { if let (colorData, alphaData) = data.withUnsafeBytes({ (bytes: UnsafePointer) -> (Data, Data)? in diff --git a/submodules/TelegramUI/TelegramUI/UpgradedAccounts.swift b/submodules/TelegramUI/TelegramUI/UpgradedAccounts.swift index 956a8d2920..f70b37718e 100644 --- a/submodules/TelegramUI/TelegramUI/UpgradedAccounts.swift +++ b/submodules/TelegramUI/TelegramUI/UpgradedAccounts.swift @@ -4,6 +4,7 @@ import TelegramCore import Postbox import SwiftSignalKit import TelegramUIPreferences +import MediaResources private enum LegacyPreferencesKeyValues: Int32 { case cacheStorageSettings = 1 diff --git a/submodules/TelegramUI/TelegramUI/WallpaperGalleryController.swift b/submodules/TelegramUI/TelegramUI/WallpaperGalleryController.swift index 7f9404bc2b..f0941fca9f 100644 --- a/submodules/TelegramUI/TelegramUI/WallpaperGalleryController.swift +++ b/submodules/TelegramUI/TelegramUI/WallpaperGalleryController.swift @@ -9,6 +9,7 @@ import TelegramCore import Photos import TelegramPresentationData import TelegramUIPreferences +import MediaResources enum WallpaperListType { case wallpapers(WallpaperPresentationOptions?) diff --git a/submodules/TelegramUI/TelegramUI/WallpaperGalleryItem.swift b/submodules/TelegramUI/TelegramUI/WallpaperGalleryItem.swift index 7565377a21..8232abaa2b 100644 --- a/submodules/TelegramUI/TelegramUI/WallpaperGalleryItem.swift +++ b/submodules/TelegramUI/TelegramUI/WallpaperGalleryItem.swift @@ -9,6 +9,7 @@ import LegacyComponents import TelegramPresentationData import TelegramUIPreferences import ProgressNavigationButtonNode +import MediaResources struct WallpaperGalleryItemArguments { let colorPreview: Bool diff --git a/submodules/TelegramUI/TelegramUI/WallpaperResources.swift b/submodules/TelegramUI/TelegramUI/WallpaperResources.swift index 1f530a7216..29c35e580a 100644 --- a/submodules/TelegramUI/TelegramUI/WallpaperResources.swift +++ b/submodules/TelegramUI/TelegramUI/WallpaperResources.swift @@ -5,6 +5,7 @@ import Display import Postbox import TelegramCore import TelegramUIPrivateModule +import MediaResources private func wallpaperDatas(account: Account, accountManager: AccountManager, fileReference: FileMediaReference? = nil, representations: [ImageRepresentationWithReference], alwaysShowThumbnailFirst: Bool = false, thumbnail: Bool = false, autoFetchFullSize: Bool = false, synchronousLoad: Bool = false) -> Signal<(Data?, Data?, Bool), NoError> { if let smallestRepresentation = smallestImageRepresentation(representations.map({ $0.representation })), let largestRepresentation = largestImageRepresentation(representations.map({ $0.representation })), let smallestIndex = representations.index(where: { $0.representation == smallestRepresentation }), let largestIndex = representations.index(where: { $0.representation == largestRepresentation }) { diff --git a/submodules/TelegramUI/TelegramUI/WallpaperUploadManager.swift b/submodules/TelegramUI/TelegramUI/WallpaperUploadManager.swift index 390e4badb7..f4421aeb02 100644 --- a/submodules/TelegramUI/TelegramUI/WallpaperUploadManager.swift +++ b/submodules/TelegramUI/TelegramUI/WallpaperUploadManager.swift @@ -5,6 +5,7 @@ import TelegramCore import SwiftSignalKit import TelegramPresentationData import TelegramUIPreferences +import MediaResources private extension TelegramWallpaper { var mainResource: MediaResource? { diff --git a/submodules/TelegramUI/TelegramUI_Xcode.xcodeproj/project.pbxproj b/submodules/TelegramUI/TelegramUI_Xcode.xcodeproj/project.pbxproj index 18db3b1092..b627d18e37 100644 --- a/submodules/TelegramUI/TelegramUI_Xcode.xcodeproj/project.pbxproj +++ b/submodules/TelegramUI/TelegramUI_Xcode.xcodeproj/project.pbxproj @@ -359,7 +359,6 @@ D04281F1200E4084009DDE36 /* GroupInfoSearchNavigationContentNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04281F0200E4084009DDE36 /* GroupInfoSearchNavigationContentNode.swift */; }; D04281F4200E5AB0009DDE36 /* ChatRecentActionsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04281F3200E5AB0009DDE36 /* ChatRecentActionsController.swift */; }; D04281F6200E5AC2009DDE36 /* ChatRecentActionsControllerNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04281F5200E5AC2009DDE36 /* ChatRecentActionsControllerNode.swift */; }; - D04281F8200E5C17009DDE36 /* ChatControllerBackgroundNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04281F7200E5C17009DDE36 /* ChatControllerBackgroundNode.swift */; }; D04281FA200E5CDC009DDE36 /* ChatRecentActionsControllerState.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04281F9200E5CDC009DDE36 /* ChatRecentActionsControllerState.swift */; }; D04281FC200E61BC009DDE36 /* ChatRecentActionsInteraction.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04281FB200E61BC009DDE36 /* ChatRecentActionsInteraction.swift */; }; D04281FE200E639A009DDE36 /* ChatRecentActionsTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D04281FD200E639A009DDE36 /* ChatRecentActionsTitleView.swift */; }; @@ -1642,7 +1641,6 @@ D04281F0200E4084009DDE36 /* GroupInfoSearchNavigationContentNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GroupInfoSearchNavigationContentNode.swift; sourceTree = ""; }; D04281F3200E5AB0009DDE36 /* ChatRecentActionsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatRecentActionsController.swift; sourceTree = ""; }; D04281F5200E5AC2009DDE36 /* ChatRecentActionsControllerNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatRecentActionsControllerNode.swift; sourceTree = ""; }; - D04281F7200E5C17009DDE36 /* ChatControllerBackgroundNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatControllerBackgroundNode.swift; sourceTree = ""; }; D04281F9200E5CDC009DDE36 /* ChatRecentActionsControllerState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatRecentActionsControllerState.swift; sourceTree = ""; }; D04281FB200E61BC009DDE36 /* ChatRecentActionsInteraction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatRecentActionsInteraction.swift; sourceTree = ""; }; D04281FD200E639A009DDE36 /* ChatRecentActionsTitleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatRecentActionsTitleView.swift; sourceTree = ""; }; @@ -4569,7 +4567,6 @@ D0F69E0E1D6B8ACF0046BCD6 /* ChatController.swift */, D0F69E0F1D6B8ACF0046BCD6 /* ChatControllerInteraction.swift */, D0F69E101D6B8ACF0046BCD6 /* ChatControllerNode.swift */, - D04281F7200E5C17009DDE36 /* ChatControllerBackgroundNode.swift */, D0F69E111D6B8ACF0046BCD6 /* ChatHistoryEntry.swift */, D0F69E121D6B8ACF0046BCD6 /* ChatHistoryLocation.swift */, D0D268681D78865300C422DA /* ChatAvatarNavigationNode.swift */, @@ -6130,7 +6127,6 @@ D0EC6E5C1EB9F58900EBF1C3 /* CallControllerNode.swift in Sources */, D0F4B0222110972300912B92 /* ContactInfoStrings.swift in Sources */, D0EC6E5D1EB9F58900EBF1C3 /* PrivacyAndSecurityController.swift in Sources */, - D04281F8200E5C17009DDE36 /* ChatControllerBackgroundNode.swift in Sources */, D0EC6E5E1EB9F58900EBF1C3 /* ItemListRecentSessionItem.swift in Sources */, D00ADFDD1EBB73C200873D2E /* OverlayMediaManager.swift in Sources */, D056CD7C1FF3E92C00880D28 /* DirectionalPanGestureRecognizer.swift in Sources */,